]> git.ipfire.org Git - thirdparty/grsecurity-scrape.git/blob - test/grsecurity-2.9.1-3.9.4-201305251009.patch
Auto commit, 1 new patch{es}.
[thirdparty/grsecurity-scrape.git] / test / grsecurity-2.9.1-3.9.4-201305251009.patch
1 diff --git a/Documentation/dontdiff b/Documentation/dontdiff
2 index b89a739..b47493f 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,6 +75,7 @@ Image
45 Module.markers
46 Module.symvers
47 PENDING
48 +PERF*
49 SCCS
50 System.map*
51 TAGS
52 @@ -80,6 +87,7 @@ aic7*seq.h*
53 aicasm
54 aicdb.h*
55 altivec*.c
56 +ashldi3.S
57 asm-offsets.h
58 asm_offsets.h
59 autoconf.h*
60 @@ -92,19 +100,24 @@ bounds.h
61 bsetup
62 btfixupprep
63 build
64 +builtin-policy.h
65 bvmlinux
66 bzImage*
67 capability_names.h
68 capflags.c
69 classlist.h*
70 +clut_vga16.c
71 +common-cmds.h
72 comp*.log
73 compile.h*
74 conf
75 config
76 config-*
77 config_data.h*
78 +config.c
79 config.mak
80 config.mak.autogen
81 +config.tmp
82 conmakehash
83 consolemap_deftbl.c*
84 cpustr.h
85 @@ -115,9 +128,11 @@ devlist.h*
86 dnotify_test
87 docproc
88 dslm
89 +dtc-lexer.lex.c
90 elf2ecoff
91 elfconfig.h*
92 evergreen_reg_safe.h
93 +exception_policy.conf
94 fixdep
95 flask.h
96 fore200e_mkfirm
97 @@ -125,12 +140,15 @@ fore200e_pca_fw.c*
98 gconf
99 gconf.glade.h
100 gen-devlist
101 +gen-kdb_cmds.c
102 gen_crc32table
103 gen_init_cpio
104 generated
105 genheaders
106 genksyms
107 *_gray256.c
108 +hash
109 +hid-example
110 hpet_example
111 hugepage-mmap
112 hugepage-shm
113 @@ -145,14 +163,14 @@ int32.c
114 int4.c
115 int8.c
116 kallsyms
117 -kconfig
118 +kern_constants.h
119 keywords.c
120 ksym.c*
121 ksym.h*
122 kxgettext
123 lex.c
124 lex.*.c
125 -linux
126 +lib1funcs.S
127 logo_*.c
128 logo_*_clut224.c
129 logo_*_mono.c
130 @@ -162,14 +180,15 @@ mach-types.h
131 machtypes.h
132 map
133 map_hugetlb
134 -media
135 mconf
136 +mdp
137 miboot*
138 mk_elfconfig
139 mkboot
140 mkbugboot
141 mkcpustr
142 mkdep
143 +mkpiggy
144 mkprep
145 mkregtable
146 mktables
147 @@ -185,6 +204,8 @@ oui.c*
148 page-types
149 parse.c
150 parse.h
151 +parse-events*
152 +pasyms.h
153 patches*
154 pca200e.bin
155 pca200e_ecd.bin2
156 @@ -194,6 +215,7 @@ perf-archive
157 piggyback
158 piggy.gzip
159 piggy.S
160 +pmu-*
161 pnmtologo
162 ppc_defs.h*
163 pss_boot.h
164 @@ -203,7 +225,10 @@ r200_reg_safe.h
165 r300_reg_safe.h
166 r420_reg_safe.h
167 r600_reg_safe.h
168 +realmode.lds
169 +realmode.relocs
170 recordmcount
171 +regdb.c
172 relocs
173 rlim_names.h
174 rn50_reg_safe.h
175 @@ -213,8 +238,12 @@ series
176 setup
177 setup.bin
178 setup.elf
179 +signing_key*
180 +size_overflow_hash.h
181 sImage
182 +slabinfo
183 sm_tbl*
184 +sortextable
185 split-include
186 syscalltab.h
187 tables.c
188 @@ -224,6 +253,7 @@ tftpboot.img
189 timeconst.h
190 times.h*
191 trix_boot.h
192 +user_constants.h
193 utsrelease.h*
194 vdso-syms.lds
195 vdso.lds
196 @@ -235,13 +265,17 @@ vdso32.lds
197 vdso32.so.dbg
198 vdso64.lds
199 vdso64.so.dbg
200 +vdsox32.lds
201 +vdsox32-syms.lds
202 version.h*
203 vmImage
204 vmlinux
205 vmlinux-*
206 vmlinux.aout
207 vmlinux.bin.all
208 +vmlinux.bin.bz2
209 vmlinux.lds
210 +vmlinux.relocs
211 vmlinuz
212 voffset.h
213 vsyscall.lds
214 @@ -249,9 +283,12 @@ vsyscall_32.lds
215 wanxlfw.inc
216 uImage
217 unifdef
218 +utsrelease.h
219 wakeup.bin
220 wakeup.elf
221 wakeup.lds
222 +x509*
223 zImage*
224 zconf.hash.c
225 +zconf.lex.c
226 zoffset.h
227 diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
228 index 8ccbf27..afffeb4 100644
229 --- a/Documentation/kernel-parameters.txt
230 +++ b/Documentation/kernel-parameters.txt
231 @@ -948,6 +948,10 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
232 Format: <unsigned int> such that (rxsize & ~0x1fffc0) == 0.
233 Default: 1024
234
235 + grsec_proc_gid= [GRKERNSEC_PROC_USERGROUP] Chooses GID to
236 + ignore grsecurity's /proc restrictions
237 +
238 +
239 hashdist= [KNL,NUMA] Large hashes allocated during boot
240 are distributed across NUMA nodes. Defaults on
241 for 64-bit NUMA, off otherwise.
242 @@ -2147,6 +2151,18 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
243 the specified number of seconds. This is to be used if
244 your oopses keep scrolling off the screen.
245
246 + pax_nouderef [X86] disables UDEREF. Most likely needed under certain
247 + virtualization environments that don't cope well with the
248 + expand down segment used by UDEREF on X86-32 or the frequent
249 + page table updates on X86-64.
250 +
251 + pax_softmode= 0/1 to disable/enable PaX softmode on boot already.
252 +
253 + pax_extra_latent_entropy
254 + Enable a very simple form of latent entropy extraction
255 + from the first 4GB of memory as the bootmem allocator
256 + passes the memory pages to the buddy allocator.
257 +
258 pcbit= [HW,ISDN]
259
260 pcd. [PARIDE]
261 diff --git a/Makefile b/Makefile
262 index bfbfaf9..d0b1bb8 100644
263 --- a/Makefile
264 +++ b/Makefile
265 @@ -241,8 +241,9 @@ CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
266
267 HOSTCC = gcc
268 HOSTCXX = g++
269 -HOSTCFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer
270 -HOSTCXXFLAGS = -O2
271 +HOSTCFLAGS = -Wall -W -Wmissing-prototypes -Wstrict-prototypes -Wno-unused-parameter -Wno-missing-field-initializers -O2 -fomit-frame-pointer -fno-delete-null-pointer-checks
272 +HOSTCFLAGS += $(call cc-option, -Wno-empty-body)
273 +HOSTCXXFLAGS = -O2 -Wall -W -fno-delete-null-pointer-checks
274
275 # Decide whether to build built-in, modular, or both.
276 # Normally, just do built-in.
277 @@ -414,8 +415,8 @@ export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn \
278 # Rules shared between *config targets and build targets
279
280 # Basic helpers built in scripts/
281 -PHONY += scripts_basic
282 -scripts_basic:
283 +PHONY += scripts_basic gcc-plugins
284 +scripts_basic: gcc-plugins
285 $(Q)$(MAKE) $(build)=scripts/basic
286 $(Q)rm -f .tmp_quiet_recordmcount
287
288 @@ -576,6 +577,65 @@ else
289 KBUILD_CFLAGS += -O2
290 endif
291
292 +ifndef DISABLE_PAX_PLUGINS
293 +ifeq ($(call cc-ifversion, -ge, 0408, y), y)
294 +PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(HOSTCXX)" "$(HOSTCXX)" "$(CC)")
295 +else
296 +PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(HOSTCC)" "$(HOSTCXX)" "$(CC)")
297 +endif
298 +ifneq ($(PLUGINCC),)
299 +ifdef CONFIG_PAX_CONSTIFY_PLUGIN
300 +CONSTIFY_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/constify_plugin.so -DCONSTIFY_PLUGIN
301 +endif
302 +ifdef CONFIG_PAX_MEMORY_STACKLEAK
303 +STACKLEAK_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/stackleak_plugin.so -DSTACKLEAK_PLUGIN
304 +STACKLEAK_PLUGIN_CFLAGS += -fplugin-arg-stackleak_plugin-track-lowest-sp=100
305 +endif
306 +ifdef CONFIG_KALLOCSTAT_PLUGIN
307 +KALLOCSTAT_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/kallocstat_plugin.so
308 +endif
309 +ifdef CONFIG_PAX_KERNEXEC_PLUGIN
310 +KERNEXEC_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/kernexec_plugin.so
311 +KERNEXEC_PLUGIN_CFLAGS += -fplugin-arg-kernexec_plugin-method=$(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD) -DKERNEXEC_PLUGIN
312 +KERNEXEC_PLUGIN_AFLAGS := -DKERNEXEC_PLUGIN
313 +endif
314 +ifdef CONFIG_CHECKER_PLUGIN
315 +ifeq ($(call cc-ifversion, -ge, 0406, y), y)
316 +CHECKER_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/checker_plugin.so -DCHECKER_PLUGIN
317 +endif
318 +endif
319 +COLORIZE_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/colorize_plugin.so
320 +ifdef CONFIG_PAX_SIZE_OVERFLOW
321 +SIZE_OVERFLOW_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/size_overflow_plugin.so -DSIZE_OVERFLOW_PLUGIN
322 +endif
323 +ifdef CONFIG_PAX_LATENT_ENTROPY
324 +LATENT_ENTROPY_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/latent_entropy_plugin.so -DLATENT_ENTROPY_PLUGIN
325 +endif
326 +ifdef CONFIG_PAX_MEMORY_STRUCTLEAK
327 +STRUCTLEAK_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/structleak_plugin.so -DSTRUCTLEAK_PLUGIN
328 +endif
329 +GCC_PLUGINS_CFLAGS := $(CONSTIFY_PLUGIN_CFLAGS) $(STACKLEAK_PLUGIN_CFLAGS) $(KALLOCSTAT_PLUGIN_CFLAGS)
330 +GCC_PLUGINS_CFLAGS += $(KERNEXEC_PLUGIN_CFLAGS) $(CHECKER_PLUGIN_CFLAGS) $(COLORIZE_PLUGIN_CFLAGS)
331 +GCC_PLUGINS_CFLAGS += $(SIZE_OVERFLOW_PLUGIN_CFLAGS) $(LATENT_ENTROPY_PLUGIN_CFLAGS) $(STRUCTLEAK_PLUGIN_CFLAGS)
332 +GCC_PLUGINS_AFLAGS := $(KERNEXEC_PLUGIN_AFLAGS)
333 +export PLUGINCC GCC_PLUGINS_CFLAGS GCC_PLUGINS_AFLAGS CONSTIFY_PLUGIN
334 +ifeq ($(KBUILD_EXTMOD),)
335 +gcc-plugins:
336 + $(Q)$(MAKE) $(build)=tools/gcc
337 +else
338 +gcc-plugins: ;
339 +endif
340 +else
341 +gcc-plugins:
342 +ifeq ($(call cc-ifversion, -ge, 0405, y), y)
343 + $(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.))
344 +else
345 + $(Q)echo "warning, your gcc version does not support plugins, you should upgrade it to gcc 4.5 at least"
346 +endif
347 + $(Q)echo "PAX_MEMORY_STACKLEAK, constification, PAX_LATENT_ENTROPY and other features will be less secure. PAX_SIZE_OVERFLOW will not be active."
348 +endif
349 +endif
350 +
351 include $(srctree)/arch/$(SRCARCH)/Makefile
352
353 ifdef CONFIG_READABLE_ASM
354 @@ -733,7 +793,7 @@ export mod_sign_cmd
355
356
357 ifeq ($(KBUILD_EXTMOD),)
358 -core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/
359 +core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/ grsecurity/
360
361 vmlinux-dirs := $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \
362 $(core-y) $(core-m) $(drivers-y) $(drivers-m) \
363 @@ -780,6 +840,8 @@ endif
364
365 # The actual objects are generated when descending,
366 # make sure no implicit rule kicks in
367 +$(filter-out $(init-y),$(vmlinux-deps)): KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
368 +$(filter-out $(init-y),$(vmlinux-deps)): KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
369 $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
370
371 # Handle descending into subdirectories listed in $(vmlinux-dirs)
372 @@ -789,7 +851,7 @@ $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
373 # Error messages still appears in the original language
374
375 PHONY += $(vmlinux-dirs)
376 -$(vmlinux-dirs): prepare scripts
377 +$(vmlinux-dirs): gcc-plugins prepare scripts
378 $(Q)$(MAKE) $(build)=$@
379
380 # Store (new) KERNELRELASE string in include/config/kernel.release
381 @@ -833,6 +895,7 @@ prepare0: archprepare FORCE
382 $(Q)$(MAKE) $(build)=.
383
384 # All the preparing..
385 +prepare: KBUILD_CFLAGS := $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS))
386 prepare: prepare0
387
388 # Generate some files
389 @@ -940,6 +1003,8 @@ all: modules
390 # using awk while concatenating to the final file.
391
392 PHONY += modules
393 +modules: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
394 +modules: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
395 modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) modules.builtin
396 $(Q)$(AWK) '!x[$$0]++' $(vmlinux-dirs:%=$(objtree)/%/modules.order) > $(objtree)/modules.order
397 @$(kecho) ' Building modules, stage 2.';
398 @@ -955,7 +1020,7 @@ modules.builtin: $(vmlinux-dirs:%=%/modules.builtin)
399
400 # Target to prepare building external modules
401 PHONY += modules_prepare
402 -modules_prepare: prepare scripts
403 +modules_prepare: gcc-plugins prepare scripts
404
405 # Target to install modules
406 PHONY += modules_install
407 @@ -1021,7 +1086,7 @@ MRPROPER_FILES += .config .config.old .version .old_version $(version_h) \
408 Module.symvers tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS \
409 signing_key.priv signing_key.x509 x509.genkey \
410 extra_certificates signing_key.x509.keyid \
411 - signing_key.x509.signer
412 + signing_key.x509.signer tools/gcc/size_overflow_hash.h
413
414 # clean - Delete most, but leave enough to build external modules
415 #
416 @@ -1061,6 +1126,7 @@ distclean: mrproper
417 \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
418 -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \
419 -o -name '.*.rej' \
420 + -o -name '.*.rej' -o -name '*.so' \
421 -o -name '*%' -o -name '.*.cmd' -o -name 'core' \) \
422 -type f -print | xargs rm -f
423
424 @@ -1221,6 +1287,8 @@ PHONY += $(module-dirs) modules
425 $(module-dirs): crmodverdir $(objtree)/Module.symvers
426 $(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@)
427
428 +modules: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
429 +modules: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
430 modules: $(module-dirs)
431 @$(kecho) ' Building modules, stage 2.';
432 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
433 @@ -1357,17 +1425,21 @@ else
434 target-dir = $(if $(KBUILD_EXTMOD),$(dir $<),$(dir $@))
435 endif
436
437 -%.s: %.c prepare scripts FORCE
438 +%.s: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
439 +%.s: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
440 +%.s: %.c gcc-plugins prepare scripts FORCE
441 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
442 %.i: %.c prepare scripts FORCE
443 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
444 -%.o: %.c prepare scripts FORCE
445 +%.o: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
446 +%.o: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
447 +%.o: %.c gcc-plugins prepare scripts FORCE
448 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
449 %.lst: %.c prepare scripts FORCE
450 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
451 -%.s: %.S prepare scripts FORCE
452 +%.s: %.S gcc-plugins prepare scripts FORCE
453 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
454 -%.o: %.S prepare scripts FORCE
455 +%.o: %.S gcc-plugins prepare scripts FORCE
456 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
457 %.symtypes: %.c prepare scripts FORCE
458 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
459 @@ -1377,11 +1449,15 @@ endif
460 $(cmd_crmodverdir)
461 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
462 $(build)=$(build-dir)
463 -%/: prepare scripts FORCE
464 +%/: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
465 +%/: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
466 +%/: gcc-plugins prepare scripts FORCE
467 $(cmd_crmodverdir)
468 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
469 $(build)=$(build-dir)
470 -%.ko: prepare scripts FORCE
471 +%.ko: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
472 +%.ko: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
473 +%.ko: gcc-plugins prepare scripts FORCE
474 $(cmd_crmodverdir)
475 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
476 $(build)=$(build-dir) $(@:.ko=.o)
477 diff --git a/arch/alpha/include/asm/atomic.h b/arch/alpha/include/asm/atomic.h
478 index c2cbe4f..f7264b4 100644
479 --- a/arch/alpha/include/asm/atomic.h
480 +++ b/arch/alpha/include/asm/atomic.h
481 @@ -250,6 +250,16 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
482 #define atomic_dec(v) atomic_sub(1,(v))
483 #define atomic64_dec(v) atomic64_sub(1,(v))
484
485 +#define atomic64_read_unchecked(v) atomic64_read(v)
486 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
487 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
488 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
489 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
490 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
491 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
492 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
493 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
494 +
495 #define smp_mb__before_atomic_dec() smp_mb()
496 #define smp_mb__after_atomic_dec() smp_mb()
497 #define smp_mb__before_atomic_inc() smp_mb()
498 diff --git a/arch/alpha/include/asm/cache.h b/arch/alpha/include/asm/cache.h
499 index ad368a9..fbe0f25 100644
500 --- a/arch/alpha/include/asm/cache.h
501 +++ b/arch/alpha/include/asm/cache.h
502 @@ -4,19 +4,19 @@
503 #ifndef __ARCH_ALPHA_CACHE_H
504 #define __ARCH_ALPHA_CACHE_H
505
506 +#include <linux/const.h>
507
508 /* Bytes per L1 (data) cache line. */
509 #if defined(CONFIG_ALPHA_GENERIC) || defined(CONFIG_ALPHA_EV6)
510 -# define L1_CACHE_BYTES 64
511 # define L1_CACHE_SHIFT 6
512 #else
513 /* Both EV4 and EV5 are write-through, read-allocate,
514 direct-mapped, physical.
515 */
516 -# define L1_CACHE_BYTES 32
517 # define L1_CACHE_SHIFT 5
518 #endif
519
520 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
521 #define SMP_CACHE_BYTES L1_CACHE_BYTES
522
523 #endif
524 diff --git a/arch/alpha/include/asm/elf.h b/arch/alpha/include/asm/elf.h
525 index 968d999..d36b2df 100644
526 --- a/arch/alpha/include/asm/elf.h
527 +++ b/arch/alpha/include/asm/elf.h
528 @@ -91,6 +91,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
529
530 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x1000000)
531
532 +#ifdef CONFIG_PAX_ASLR
533 +#define PAX_ELF_ET_DYN_BASE (current->personality & ADDR_LIMIT_32BIT ? 0x10000 : 0x120000000UL)
534 +
535 +#define PAX_DELTA_MMAP_LEN (current->personality & ADDR_LIMIT_32BIT ? 14 : 28)
536 +#define PAX_DELTA_STACK_LEN (current->personality & ADDR_LIMIT_32BIT ? 14 : 19)
537 +#endif
538 +
539 /* $0 is set by ld.so to a pointer to a function which might be
540 registered using atexit. This provides a mean for the dynamic
541 linker to call DT_FINI functions for shared libraries that have
542 diff --git a/arch/alpha/include/asm/pgalloc.h b/arch/alpha/include/asm/pgalloc.h
543 index bc2a0da..8ad11ee 100644
544 --- a/arch/alpha/include/asm/pgalloc.h
545 +++ b/arch/alpha/include/asm/pgalloc.h
546 @@ -29,6 +29,12 @@ pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
547 pgd_set(pgd, pmd);
548 }
549
550 +static inline void
551 +pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
552 +{
553 + pgd_populate(mm, pgd, pmd);
554 +}
555 +
556 extern pgd_t *pgd_alloc(struct mm_struct *mm);
557
558 static inline void
559 diff --git a/arch/alpha/include/asm/pgtable.h b/arch/alpha/include/asm/pgtable.h
560 index 81a4342..348b927 100644
561 --- a/arch/alpha/include/asm/pgtable.h
562 +++ b/arch/alpha/include/asm/pgtable.h
563 @@ -102,6 +102,17 @@ struct vm_area_struct;
564 #define PAGE_SHARED __pgprot(_PAGE_VALID | __ACCESS_BITS)
565 #define PAGE_COPY __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW)
566 #define PAGE_READONLY __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW)
567 +
568 +#ifdef CONFIG_PAX_PAGEEXEC
569 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOE)
570 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW | _PAGE_FOE)
571 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW | _PAGE_FOE)
572 +#else
573 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
574 +# define PAGE_COPY_NOEXEC PAGE_COPY
575 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
576 +#endif
577 +
578 #define PAGE_KERNEL __pgprot(_PAGE_VALID | _PAGE_ASM | _PAGE_KRE | _PAGE_KWE)
579
580 #define _PAGE_NORMAL(x) __pgprot(_PAGE_VALID | __ACCESS_BITS | (x))
581 diff --git a/arch/alpha/kernel/module.c b/arch/alpha/kernel/module.c
582 index 2fd00b7..cfd5069 100644
583 --- a/arch/alpha/kernel/module.c
584 +++ b/arch/alpha/kernel/module.c
585 @@ -160,7 +160,7 @@ apply_relocate_add(Elf64_Shdr *sechdrs, const char *strtab,
586
587 /* The small sections were sorted to the end of the segment.
588 The following should definitely cover them. */
589 - gp = (u64)me->module_core + me->core_size - 0x8000;
590 + gp = (u64)me->module_core_rw + me->core_size_rw - 0x8000;
591 got = sechdrs[me->arch.gotsecindex].sh_addr;
592
593 for (i = 0; i < n; i++) {
594 diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c
595 index b9e37ad..44c24e7 100644
596 --- a/arch/alpha/kernel/osf_sys.c
597 +++ b/arch/alpha/kernel/osf_sys.c
598 @@ -1297,10 +1297,11 @@ SYSCALL_DEFINE1(old_adjtimex, struct timex32 __user *, txc_p)
599 generic version except that we know how to honor ADDR_LIMIT_32BIT. */
600
601 static unsigned long
602 -arch_get_unmapped_area_1(unsigned long addr, unsigned long len,
603 - unsigned long limit)
604 +arch_get_unmapped_area_1(struct file *filp, unsigned long addr, unsigned long len,
605 + unsigned long limit, unsigned long flags)
606 {
607 struct vm_unmapped_area_info info;
608 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
609
610 info.flags = 0;
611 info.length = len;
612 @@ -1308,6 +1309,7 @@ arch_get_unmapped_area_1(unsigned long addr, unsigned long len,
613 info.high_limit = limit;
614 info.align_mask = 0;
615 info.align_offset = 0;
616 + info.threadstack_offset = offset;
617 return vm_unmapped_area(&info);
618 }
619
620 @@ -1340,20 +1342,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
621 merely specific addresses, but regions of memory -- perhaps
622 this feature should be incorporated into all ports? */
623
624 +#ifdef CONFIG_PAX_RANDMMAP
625 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
626 +#endif
627 +
628 if (addr) {
629 - addr = arch_get_unmapped_area_1 (PAGE_ALIGN(addr), len, limit);
630 + addr = arch_get_unmapped_area_1 (filp, PAGE_ALIGN(addr), len, limit, flags);
631 if (addr != (unsigned long) -ENOMEM)
632 return addr;
633 }
634
635 /* Next, try allocating at TASK_UNMAPPED_BASE. */
636 - addr = arch_get_unmapped_area_1 (PAGE_ALIGN(TASK_UNMAPPED_BASE),
637 - len, limit);
638 + addr = arch_get_unmapped_area_1 (filp, PAGE_ALIGN(current->mm->mmap_base), len, limit, flags);
639 +
640 if (addr != (unsigned long) -ENOMEM)
641 return addr;
642
643 /* Finally, try allocating in low memory. */
644 - addr = arch_get_unmapped_area_1 (PAGE_SIZE, len, limit);
645 + addr = arch_get_unmapped_area_1 (filp, PAGE_SIZE, len, limit, flags);
646
647 return addr;
648 }
649 diff --git a/arch/alpha/mm/fault.c b/arch/alpha/mm/fault.c
650 index 0c4132d..88f0d53 100644
651 --- a/arch/alpha/mm/fault.c
652 +++ b/arch/alpha/mm/fault.c
653 @@ -53,6 +53,124 @@ __load_new_mm_context(struct mm_struct *next_mm)
654 __reload_thread(pcb);
655 }
656
657 +#ifdef CONFIG_PAX_PAGEEXEC
658 +/*
659 + * PaX: decide what to do with offenders (regs->pc = fault address)
660 + *
661 + * returns 1 when task should be killed
662 + * 2 when patched PLT trampoline was detected
663 + * 3 when unpatched PLT trampoline was detected
664 + */
665 +static int pax_handle_fetch_fault(struct pt_regs *regs)
666 +{
667 +
668 +#ifdef CONFIG_PAX_EMUPLT
669 + int err;
670 +
671 + do { /* PaX: patched PLT emulation #1 */
672 + unsigned int ldah, ldq, jmp;
673 +
674 + err = get_user(ldah, (unsigned int *)regs->pc);
675 + err |= get_user(ldq, (unsigned int *)(regs->pc+4));
676 + err |= get_user(jmp, (unsigned int *)(regs->pc+8));
677 +
678 + if (err)
679 + break;
680 +
681 + if ((ldah & 0xFFFF0000U) == 0x277B0000U &&
682 + (ldq & 0xFFFF0000U) == 0xA77B0000U &&
683 + jmp == 0x6BFB0000U)
684 + {
685 + unsigned long r27, addr;
686 + unsigned long addrh = (ldah | 0xFFFFFFFFFFFF0000UL) << 16;
687 + unsigned long addrl = ldq | 0xFFFFFFFFFFFF0000UL;
688 +
689 + addr = regs->r27 + ((addrh ^ 0x80000000UL) + 0x80000000UL) + ((addrl ^ 0x8000UL) + 0x8000UL);
690 + err = get_user(r27, (unsigned long *)addr);
691 + if (err)
692 + break;
693 +
694 + regs->r27 = r27;
695 + regs->pc = r27;
696 + return 2;
697 + }
698 + } while (0);
699 +
700 + do { /* PaX: patched PLT emulation #2 */
701 + unsigned int ldah, lda, br;
702 +
703 + err = get_user(ldah, (unsigned int *)regs->pc);
704 + err |= get_user(lda, (unsigned int *)(regs->pc+4));
705 + err |= get_user(br, (unsigned int *)(regs->pc+8));
706 +
707 + if (err)
708 + break;
709 +
710 + if ((ldah & 0xFFFF0000U) == 0x277B0000U &&
711 + (lda & 0xFFFF0000U) == 0xA77B0000U &&
712 + (br & 0xFFE00000U) == 0xC3E00000U)
713 + {
714 + unsigned long addr = br | 0xFFFFFFFFFFE00000UL;
715 + unsigned long addrh = (ldah | 0xFFFFFFFFFFFF0000UL) << 16;
716 + unsigned long addrl = lda | 0xFFFFFFFFFFFF0000UL;
717 +
718 + regs->r27 += ((addrh ^ 0x80000000UL) + 0x80000000UL) + ((addrl ^ 0x8000UL) + 0x8000UL);
719 + regs->pc += 12 + (((addr ^ 0x00100000UL) + 0x00100000UL) << 2);
720 + return 2;
721 + }
722 + } while (0);
723 +
724 + do { /* PaX: unpatched PLT emulation */
725 + unsigned int br;
726 +
727 + err = get_user(br, (unsigned int *)regs->pc);
728 +
729 + if (!err && (br & 0xFFE00000U) == 0xC3800000U) {
730 + unsigned int br2, ldq, nop, jmp;
731 + unsigned long addr = br | 0xFFFFFFFFFFE00000UL, resolver;
732 +
733 + addr = regs->pc + 4 + (((addr ^ 0x00100000UL) + 0x00100000UL) << 2);
734 + err = get_user(br2, (unsigned int *)addr);
735 + err |= get_user(ldq, (unsigned int *)(addr+4));
736 + err |= get_user(nop, (unsigned int *)(addr+8));
737 + err |= get_user(jmp, (unsigned int *)(addr+12));
738 + err |= get_user(resolver, (unsigned long *)(addr+16));
739 +
740 + if (err)
741 + break;
742 +
743 + if (br2 == 0xC3600000U &&
744 + ldq == 0xA77B000CU &&
745 + nop == 0x47FF041FU &&
746 + jmp == 0x6B7B0000U)
747 + {
748 + regs->r28 = regs->pc+4;
749 + regs->r27 = addr+16;
750 + regs->pc = resolver;
751 + return 3;
752 + }
753 + }
754 + } while (0);
755 +#endif
756 +
757 + return 1;
758 +}
759 +
760 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
761 +{
762 + unsigned long i;
763 +
764 + printk(KERN_ERR "PAX: bytes at PC: ");
765 + for (i = 0; i < 5; i++) {
766 + unsigned int c;
767 + if (get_user(c, (unsigned int *)pc+i))
768 + printk(KERN_CONT "???????? ");
769 + else
770 + printk(KERN_CONT "%08x ", c);
771 + }
772 + printk("\n");
773 +}
774 +#endif
775
776 /*
777 * This routine handles page faults. It determines the address,
778 @@ -133,8 +251,29 @@ retry:
779 good_area:
780 si_code = SEGV_ACCERR;
781 if (cause < 0) {
782 - if (!(vma->vm_flags & VM_EXEC))
783 + if (!(vma->vm_flags & VM_EXEC)) {
784 +
785 +#ifdef CONFIG_PAX_PAGEEXEC
786 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->pc)
787 + goto bad_area;
788 +
789 + up_read(&mm->mmap_sem);
790 + switch (pax_handle_fetch_fault(regs)) {
791 +
792 +#ifdef CONFIG_PAX_EMUPLT
793 + case 2:
794 + case 3:
795 + return;
796 +#endif
797 +
798 + }
799 + pax_report_fault(regs, (void *)regs->pc, (void *)rdusp());
800 + do_group_exit(SIGKILL);
801 +#else
802 goto bad_area;
803 +#endif
804 +
805 + }
806 } else if (!cause) {
807 /* Allow reads even for write-only mappings */
808 if (!(vma->vm_flags & (VM_READ | VM_WRITE)))
809 diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
810 index 1cacda4..2cef624 100644
811 --- a/arch/arm/Kconfig
812 +++ b/arch/arm/Kconfig
813 @@ -1850,7 +1850,7 @@ config ALIGNMENT_TRAP
814
815 config UACCESS_WITH_MEMCPY
816 bool "Use kernel mem{cpy,set}() for {copy_to,clear}_user()"
817 - depends on MMU
818 + depends on MMU && !PAX_MEMORY_UDEREF
819 default y if CPU_FEROCEON
820 help
821 Implement faster copy_to_user and clear_user methods for CPU
822 diff --git a/arch/arm/include/asm/atomic.h b/arch/arm/include/asm/atomic.h
823 index c79f61f..9ac0642 100644
824 --- a/arch/arm/include/asm/atomic.h
825 +++ b/arch/arm/include/asm/atomic.h
826 @@ -17,17 +17,35 @@
827 #include <asm/barrier.h>
828 #include <asm/cmpxchg.h>
829
830 +#ifdef CONFIG_GENERIC_ATOMIC64
831 +#include <asm-generic/atomic64.h>
832 +#endif
833 +
834 #define ATOMIC_INIT(i) { (i) }
835
836 #ifdef __KERNEL__
837
838 +#define _ASM_EXTABLE(from, to) \
839 +" .pushsection __ex_table,\"a\"\n"\
840 +" .align 3\n" \
841 +" .long " #from ", " #to"\n" \
842 +" .popsection"
843 +
844 /*
845 * On ARM, ordinary assignment (str instruction) doesn't clear the local
846 * strex/ldrex monitor on some implementations. The reason we can use it for
847 * atomic_set() is the clrex or dummy strex done on every exception return.
848 */
849 #define atomic_read(v) (*(volatile int *)&(v)->counter)
850 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
851 +{
852 + return v->counter;
853 +}
854 #define atomic_set(v,i) (((v)->counter) = (i))
855 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
856 +{
857 + v->counter = i;
858 +}
859
860 #if __LINUX_ARM_ARCH__ >= 6
861
862 @@ -42,6 +60,35 @@ static inline void atomic_add(int i, atomic_t *v)
863 int result;
864
865 __asm__ __volatile__("@ atomic_add\n"
866 +"1: ldrex %1, [%3]\n"
867 +" adds %0, %1, %4\n"
868 +
869 +#ifdef CONFIG_PAX_REFCOUNT
870 +" bvc 3f\n"
871 +"2: bkpt 0xf103\n"
872 +"3:\n"
873 +#endif
874 +
875 +" strex %1, %0, [%3]\n"
876 +" teq %1, #0\n"
877 +" bne 1b"
878 +
879 +#ifdef CONFIG_PAX_REFCOUNT
880 +"\n4:\n"
881 + _ASM_EXTABLE(2b, 4b)
882 +#endif
883 +
884 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
885 + : "r" (&v->counter), "Ir" (i)
886 + : "cc");
887 +}
888 +
889 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
890 +{
891 + unsigned long tmp;
892 + int result;
893 +
894 + __asm__ __volatile__("@ atomic_add_unchecked\n"
895 "1: ldrex %0, [%3]\n"
896 " add %0, %0, %4\n"
897 " strex %1, %0, [%3]\n"
898 @@ -60,6 +107,42 @@ static inline int atomic_add_return(int i, atomic_t *v)
899 smp_mb();
900
901 __asm__ __volatile__("@ atomic_add_return\n"
902 +"1: ldrex %1, [%3]\n"
903 +" adds %0, %1, %4\n"
904 +
905 +#ifdef CONFIG_PAX_REFCOUNT
906 +" bvc 3f\n"
907 +" mov %0, %1\n"
908 +"2: bkpt 0xf103\n"
909 +"3:\n"
910 +#endif
911 +
912 +" strex %1, %0, [%3]\n"
913 +" teq %1, #0\n"
914 +" bne 1b"
915 +
916 +#ifdef CONFIG_PAX_REFCOUNT
917 +"\n4:\n"
918 + _ASM_EXTABLE(2b, 4b)
919 +#endif
920 +
921 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
922 + : "r" (&v->counter), "Ir" (i)
923 + : "cc");
924 +
925 + smp_mb();
926 +
927 + return result;
928 +}
929 +
930 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
931 +{
932 + unsigned long tmp;
933 + int result;
934 +
935 + smp_mb();
936 +
937 + __asm__ __volatile__("@ atomic_add_return_unchecked\n"
938 "1: ldrex %0, [%3]\n"
939 " add %0, %0, %4\n"
940 " strex %1, %0, [%3]\n"
941 @@ -80,6 +163,35 @@ static inline void atomic_sub(int i, atomic_t *v)
942 int result;
943
944 __asm__ __volatile__("@ atomic_sub\n"
945 +"1: ldrex %1, [%3]\n"
946 +" subs %0, %1, %4\n"
947 +
948 +#ifdef CONFIG_PAX_REFCOUNT
949 +" bvc 3f\n"
950 +"2: bkpt 0xf103\n"
951 +"3:\n"
952 +#endif
953 +
954 +" strex %1, %0, [%3]\n"
955 +" teq %1, #0\n"
956 +" bne 1b"
957 +
958 +#ifdef CONFIG_PAX_REFCOUNT
959 +"\n4:\n"
960 + _ASM_EXTABLE(2b, 4b)
961 +#endif
962 +
963 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
964 + : "r" (&v->counter), "Ir" (i)
965 + : "cc");
966 +}
967 +
968 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
969 +{
970 + unsigned long tmp;
971 + int result;
972 +
973 + __asm__ __volatile__("@ atomic_sub_unchecked\n"
974 "1: ldrex %0, [%3]\n"
975 " sub %0, %0, %4\n"
976 " strex %1, %0, [%3]\n"
977 @@ -98,11 +210,25 @@ static inline int atomic_sub_return(int i, atomic_t *v)
978 smp_mb();
979
980 __asm__ __volatile__("@ atomic_sub_return\n"
981 -"1: ldrex %0, [%3]\n"
982 -" sub %0, %0, %4\n"
983 +"1: ldrex %1, [%3]\n"
984 +" subs %0, %1, %4\n"
985 +
986 +#ifdef CONFIG_PAX_REFCOUNT
987 +" bvc 3f\n"
988 +" mov %0, %1\n"
989 +"2: bkpt 0xf103\n"
990 +"3:\n"
991 +#endif
992 +
993 " strex %1, %0, [%3]\n"
994 " teq %1, #0\n"
995 " bne 1b"
996 +
997 +#ifdef CONFIG_PAX_REFCOUNT
998 +"\n4:\n"
999 + _ASM_EXTABLE(2b, 4b)
1000 +#endif
1001 +
1002 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1003 : "r" (&v->counter), "Ir" (i)
1004 : "cc");
1005 @@ -134,6 +260,28 @@ static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new)
1006 return oldval;
1007 }
1008
1009 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *ptr, int old, int new)
1010 +{
1011 + unsigned long oldval, res;
1012 +
1013 + smp_mb();
1014 +
1015 + do {
1016 + __asm__ __volatile__("@ atomic_cmpxchg_unchecked\n"
1017 + "ldrex %1, [%3]\n"
1018 + "mov %0, #0\n"
1019 + "teq %1, %4\n"
1020 + "strexeq %0, %5, [%3]\n"
1021 + : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1022 + : "r" (&ptr->counter), "Ir" (old), "r" (new)
1023 + : "cc");
1024 + } while (res);
1025 +
1026 + smp_mb();
1027 +
1028 + return oldval;
1029 +}
1030 +
1031 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1032 {
1033 unsigned long tmp, tmp2;
1034 @@ -167,7 +315,17 @@ static inline int atomic_add_return(int i, atomic_t *v)
1035
1036 return val;
1037 }
1038 +
1039 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
1040 +{
1041 + return atomic_add_return(i, v);
1042 +}
1043 +
1044 #define atomic_add(i, v) (void) atomic_add_return(i, v)
1045 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
1046 +{
1047 + (void) atomic_add_return(i, v);
1048 +}
1049
1050 static inline int atomic_sub_return(int i, atomic_t *v)
1051 {
1052 @@ -182,6 +340,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
1053 return val;
1054 }
1055 #define atomic_sub(i, v) (void) atomic_sub_return(i, v)
1056 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
1057 +{
1058 + (void) atomic_sub_return(i, v);
1059 +}
1060
1061 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1062 {
1063 @@ -197,6 +359,11 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1064 return ret;
1065 }
1066
1067 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
1068 +{
1069 + return atomic_cmpxchg(v, old, new);
1070 +}
1071 +
1072 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1073 {
1074 unsigned long flags;
1075 @@ -209,6 +376,10 @@ static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1076 #endif /* __LINUX_ARM_ARCH__ */
1077
1078 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
1079 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
1080 +{
1081 + return xchg(&v->counter, new);
1082 +}
1083
1084 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1085 {
1086 @@ -221,11 +392,27 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1087 }
1088
1089 #define atomic_inc(v) atomic_add(1, v)
1090 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
1091 +{
1092 + atomic_add_unchecked(1, v);
1093 +}
1094 #define atomic_dec(v) atomic_sub(1, v)
1095 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
1096 +{
1097 + atomic_sub_unchecked(1, v);
1098 +}
1099
1100 #define atomic_inc_and_test(v) (atomic_add_return(1, v) == 0)
1101 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
1102 +{
1103 + return atomic_add_return_unchecked(1, v) == 0;
1104 +}
1105 #define atomic_dec_and_test(v) (atomic_sub_return(1, v) == 0)
1106 #define atomic_inc_return(v) (atomic_add_return(1, v))
1107 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
1108 +{
1109 + return atomic_add_return_unchecked(1, v);
1110 +}
1111 #define atomic_dec_return(v) (atomic_sub_return(1, v))
1112 #define atomic_sub_and_test(i, v) (atomic_sub_return(i, v) == 0)
1113
1114 @@ -241,6 +428,14 @@ typedef struct {
1115 u64 __aligned(8) counter;
1116 } atomic64_t;
1117
1118 +#ifdef CONFIG_PAX_REFCOUNT
1119 +typedef struct {
1120 + u64 __aligned(8) counter;
1121 +} atomic64_unchecked_t;
1122 +#else
1123 +typedef atomic64_t atomic64_unchecked_t;
1124 +#endif
1125 +
1126 #define ATOMIC64_INIT(i) { (i) }
1127
1128 static inline u64 atomic64_read(const atomic64_t *v)
1129 @@ -256,6 +451,19 @@ static inline u64 atomic64_read(const atomic64_t *v)
1130 return result;
1131 }
1132
1133 +static inline u64 atomic64_read_unchecked(atomic64_unchecked_t *v)
1134 +{
1135 + u64 result;
1136 +
1137 + __asm__ __volatile__("@ atomic64_read_unchecked\n"
1138 +" ldrexd %0, %H0, [%1]"
1139 + : "=&r" (result)
1140 + : "r" (&v->counter), "Qo" (v->counter)
1141 + );
1142 +
1143 + return result;
1144 +}
1145 +
1146 static inline void atomic64_set(atomic64_t *v, u64 i)
1147 {
1148 u64 tmp;
1149 @@ -270,6 +478,20 @@ static inline void atomic64_set(atomic64_t *v, u64 i)
1150 : "cc");
1151 }
1152
1153 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, u64 i)
1154 +{
1155 + u64 tmp;
1156 +
1157 + __asm__ __volatile__("@ atomic64_set_unchecked\n"
1158 +"1: ldrexd %0, %H0, [%2]\n"
1159 +" strexd %0, %3, %H3, [%2]\n"
1160 +" teq %0, #0\n"
1161 +" bne 1b"
1162 + : "=&r" (tmp), "=Qo" (v->counter)
1163 + : "r" (&v->counter), "r" (i)
1164 + : "cc");
1165 +}
1166 +
1167 static inline void atomic64_add(u64 i, atomic64_t *v)
1168 {
1169 u64 result;
1170 @@ -278,6 +500,36 @@ static inline void atomic64_add(u64 i, atomic64_t *v)
1171 __asm__ __volatile__("@ atomic64_add\n"
1172 "1: ldrexd %0, %H0, [%3]\n"
1173 " adds %0, %0, %4\n"
1174 +" adcs %H0, %H0, %H4\n"
1175 +
1176 +#ifdef CONFIG_PAX_REFCOUNT
1177 +" bvc 3f\n"
1178 +"2: bkpt 0xf103\n"
1179 +"3:\n"
1180 +#endif
1181 +
1182 +" strexd %1, %0, %H0, [%3]\n"
1183 +" teq %1, #0\n"
1184 +" bne 1b"
1185 +
1186 +#ifdef CONFIG_PAX_REFCOUNT
1187 +"\n4:\n"
1188 + _ASM_EXTABLE(2b, 4b)
1189 +#endif
1190 +
1191 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1192 + : "r" (&v->counter), "r" (i)
1193 + : "cc");
1194 +}
1195 +
1196 +static inline void atomic64_add_unchecked(u64 i, atomic64_unchecked_t *v)
1197 +{
1198 + u64 result;
1199 + unsigned long tmp;
1200 +
1201 + __asm__ __volatile__("@ atomic64_add_unchecked\n"
1202 +"1: ldrexd %0, %H0, [%3]\n"
1203 +" adds %0, %0, %4\n"
1204 " adc %H0, %H0, %H4\n"
1205 " strexd %1, %0, %H0, [%3]\n"
1206 " teq %1, #0\n"
1207 @@ -289,12 +541,49 @@ static inline void atomic64_add(u64 i, atomic64_t *v)
1208
1209 static inline u64 atomic64_add_return(u64 i, atomic64_t *v)
1210 {
1211 - u64 result;
1212 - unsigned long tmp;
1213 + u64 result, tmp;
1214
1215 smp_mb();
1216
1217 __asm__ __volatile__("@ atomic64_add_return\n"
1218 +"1: ldrexd %1, %H1, [%3]\n"
1219 +" adds %0, %1, %4\n"
1220 +" adcs %H0, %H1, %H4\n"
1221 +
1222 +#ifdef CONFIG_PAX_REFCOUNT
1223 +" bvc 3f\n"
1224 +" mov %0, %1\n"
1225 +" mov %H0, %H1\n"
1226 +"2: bkpt 0xf103\n"
1227 +"3:\n"
1228 +#endif
1229 +
1230 +" strexd %1, %0, %H0, [%3]\n"
1231 +" teq %1, #0\n"
1232 +" bne 1b"
1233 +
1234 +#ifdef CONFIG_PAX_REFCOUNT
1235 +"\n4:\n"
1236 + _ASM_EXTABLE(2b, 4b)
1237 +#endif
1238 +
1239 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1240 + : "r" (&v->counter), "r" (i)
1241 + : "cc");
1242 +
1243 + smp_mb();
1244 +
1245 + return result;
1246 +}
1247 +
1248 +static inline u64 atomic64_add_return_unchecked(u64 i, atomic64_unchecked_t *v)
1249 +{
1250 + u64 result;
1251 + unsigned long tmp;
1252 +
1253 + smp_mb();
1254 +
1255 + __asm__ __volatile__("@ atomic64_add_return_unchecked\n"
1256 "1: ldrexd %0, %H0, [%3]\n"
1257 " adds %0, %0, %4\n"
1258 " adc %H0, %H0, %H4\n"
1259 @@ -318,6 +607,36 @@ static inline void atomic64_sub(u64 i, atomic64_t *v)
1260 __asm__ __volatile__("@ atomic64_sub\n"
1261 "1: ldrexd %0, %H0, [%3]\n"
1262 " subs %0, %0, %4\n"
1263 +" sbcs %H0, %H0, %H4\n"
1264 +
1265 +#ifdef CONFIG_PAX_REFCOUNT
1266 +" bvc 3f\n"
1267 +"2: bkpt 0xf103\n"
1268 +"3:\n"
1269 +#endif
1270 +
1271 +" strexd %1, %0, %H0, [%3]\n"
1272 +" teq %1, #0\n"
1273 +" bne 1b"
1274 +
1275 +#ifdef CONFIG_PAX_REFCOUNT
1276 +"\n4:\n"
1277 + _ASM_EXTABLE(2b, 4b)
1278 +#endif
1279 +
1280 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1281 + : "r" (&v->counter), "r" (i)
1282 + : "cc");
1283 +}
1284 +
1285 +static inline void atomic64_sub_unchecked(u64 i, atomic64_unchecked_t *v)
1286 +{
1287 + u64 result;
1288 + unsigned long tmp;
1289 +
1290 + __asm__ __volatile__("@ atomic64_sub_unchecked\n"
1291 +"1: ldrexd %0, %H0, [%3]\n"
1292 +" subs %0, %0, %4\n"
1293 " sbc %H0, %H0, %H4\n"
1294 " strexd %1, %0, %H0, [%3]\n"
1295 " teq %1, #0\n"
1296 @@ -329,18 +648,32 @@ static inline void atomic64_sub(u64 i, atomic64_t *v)
1297
1298 static inline u64 atomic64_sub_return(u64 i, atomic64_t *v)
1299 {
1300 - u64 result;
1301 - unsigned long tmp;
1302 + u64 result, tmp;
1303
1304 smp_mb();
1305
1306 __asm__ __volatile__("@ atomic64_sub_return\n"
1307 -"1: ldrexd %0, %H0, [%3]\n"
1308 -" subs %0, %0, %4\n"
1309 -" sbc %H0, %H0, %H4\n"
1310 +"1: ldrexd %1, %H1, [%3]\n"
1311 +" subs %0, %1, %4\n"
1312 +" sbcs %H0, %H1, %H4\n"
1313 +
1314 +#ifdef CONFIG_PAX_REFCOUNT
1315 +" bvc 3f\n"
1316 +" mov %0, %1\n"
1317 +" mov %H0, %H1\n"
1318 +"2: bkpt 0xf103\n"
1319 +"3:\n"
1320 +#endif
1321 +
1322 " strexd %1, %0, %H0, [%3]\n"
1323 " teq %1, #0\n"
1324 " bne 1b"
1325 +
1326 +#ifdef CONFIG_PAX_REFCOUNT
1327 +"\n4:\n"
1328 + _ASM_EXTABLE(2b, 4b)
1329 +#endif
1330 +
1331 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1332 : "r" (&v->counter), "r" (i)
1333 : "cc");
1334 @@ -374,6 +707,30 @@ static inline u64 atomic64_cmpxchg(atomic64_t *ptr, u64 old, u64 new)
1335 return oldval;
1336 }
1337
1338 +static inline u64 atomic64_cmpxchg_unchecked(atomic64_unchecked_t *ptr, u64 old, u64 new)
1339 +{
1340 + u64 oldval;
1341 + unsigned long res;
1342 +
1343 + smp_mb();
1344 +
1345 + do {
1346 + __asm__ __volatile__("@ atomic64_cmpxchg_unchecked\n"
1347 + "ldrexd %1, %H1, [%3]\n"
1348 + "mov %0, #0\n"
1349 + "teq %1, %4\n"
1350 + "teqeq %H1, %H4\n"
1351 + "strexdeq %0, %5, %H5, [%3]"
1352 + : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1353 + : "r" (&ptr->counter), "r" (old), "r" (new)
1354 + : "cc");
1355 + } while (res);
1356 +
1357 + smp_mb();
1358 +
1359 + return oldval;
1360 +}
1361 +
1362 static inline u64 atomic64_xchg(atomic64_t *ptr, u64 new)
1363 {
1364 u64 result;
1365 @@ -397,21 +754,34 @@ static inline u64 atomic64_xchg(atomic64_t *ptr, u64 new)
1366
1367 static inline u64 atomic64_dec_if_positive(atomic64_t *v)
1368 {
1369 - u64 result;
1370 - unsigned long tmp;
1371 + u64 result, tmp;
1372
1373 smp_mb();
1374
1375 __asm__ __volatile__("@ atomic64_dec_if_positive\n"
1376 -"1: ldrexd %0, %H0, [%3]\n"
1377 -" subs %0, %0, #1\n"
1378 -" sbc %H0, %H0, #0\n"
1379 +"1: ldrexd %1, %H1, [%3]\n"
1380 +" subs %0, %1, #1\n"
1381 +" sbcs %H0, %H1, #0\n"
1382 +
1383 +#ifdef CONFIG_PAX_REFCOUNT
1384 +" bvc 3f\n"
1385 +" mov %0, %1\n"
1386 +" mov %H0, %H1\n"
1387 +"2: bkpt 0xf103\n"
1388 +"3:\n"
1389 +#endif
1390 +
1391 " teq %H0, #0\n"
1392 -" bmi 2f\n"
1393 +" bmi 4f\n"
1394 " strexd %1, %0, %H0, [%3]\n"
1395 " teq %1, #0\n"
1396 " bne 1b\n"
1397 -"2:"
1398 +"4:\n"
1399 +
1400 +#ifdef CONFIG_PAX_REFCOUNT
1401 + _ASM_EXTABLE(2b, 4b)
1402 +#endif
1403 +
1404 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1405 : "r" (&v->counter)
1406 : "cc");
1407 @@ -434,13 +804,25 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
1408 " teq %0, %5\n"
1409 " teqeq %H0, %H5\n"
1410 " moveq %1, #0\n"
1411 -" beq 2f\n"
1412 +" beq 4f\n"
1413 " adds %0, %0, %6\n"
1414 -" adc %H0, %H0, %H6\n"
1415 +" adcs %H0, %H0, %H6\n"
1416 +
1417 +#ifdef CONFIG_PAX_REFCOUNT
1418 +" bvc 3f\n"
1419 +"2: bkpt 0xf103\n"
1420 +"3:\n"
1421 +#endif
1422 +
1423 " strexd %2, %0, %H0, [%4]\n"
1424 " teq %2, #0\n"
1425 " bne 1b\n"
1426 -"2:"
1427 +"4:\n"
1428 +
1429 +#ifdef CONFIG_PAX_REFCOUNT
1430 + _ASM_EXTABLE(2b, 4b)
1431 +#endif
1432 +
1433 : "=&r" (val), "+r" (ret), "=&r" (tmp), "+Qo" (v->counter)
1434 : "r" (&v->counter), "r" (u), "r" (a)
1435 : "cc");
1436 @@ -453,10 +835,13 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
1437
1438 #define atomic64_add_negative(a, v) (atomic64_add_return((a), (v)) < 0)
1439 #define atomic64_inc(v) atomic64_add(1LL, (v))
1440 +#define atomic64_inc_unchecked(v) atomic64_add_unchecked(1LL, (v))
1441 #define atomic64_inc_return(v) atomic64_add_return(1LL, (v))
1442 +#define atomic64_inc_return_unchecked(v) atomic64_add_return_unchecked(1LL, (v))
1443 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
1444 #define atomic64_sub_and_test(a, v) (atomic64_sub_return((a), (v)) == 0)
1445 #define atomic64_dec(v) atomic64_sub(1LL, (v))
1446 +#define atomic64_dec_unchecked(v) atomic64_sub_unchecked(1LL, (v))
1447 #define atomic64_dec_return(v) atomic64_sub_return(1LL, (v))
1448 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
1449 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
1450 diff --git a/arch/arm/include/asm/cache.h b/arch/arm/include/asm/cache.h
1451 index 75fe66b..ba3dee4 100644
1452 --- a/arch/arm/include/asm/cache.h
1453 +++ b/arch/arm/include/asm/cache.h
1454 @@ -4,8 +4,10 @@
1455 #ifndef __ASMARM_CACHE_H
1456 #define __ASMARM_CACHE_H
1457
1458 +#include <linux/const.h>
1459 +
1460 #define L1_CACHE_SHIFT CONFIG_ARM_L1_CACHE_SHIFT
1461 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
1462 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
1463
1464 /*
1465 * Memory returned by kmalloc() may be used for DMA, so we must make
1466 @@ -24,5 +26,6 @@
1467 #endif
1468
1469 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
1470 +#define __read_only __attribute__ ((__section__(".data..read_only")))
1471
1472 #endif
1473 diff --git a/arch/arm/include/asm/cacheflush.h b/arch/arm/include/asm/cacheflush.h
1474 index e1489c5..d418304 100644
1475 --- a/arch/arm/include/asm/cacheflush.h
1476 +++ b/arch/arm/include/asm/cacheflush.h
1477 @@ -116,7 +116,7 @@ struct cpu_cache_fns {
1478 void (*dma_unmap_area)(const void *, size_t, int);
1479
1480 void (*dma_flush_range)(const void *, const void *);
1481 -};
1482 +} __no_const;
1483
1484 /*
1485 * Select the calling method
1486 diff --git a/arch/arm/include/asm/checksum.h b/arch/arm/include/asm/checksum.h
1487 index 6dcc164..b14d917 100644
1488 --- a/arch/arm/include/asm/checksum.h
1489 +++ b/arch/arm/include/asm/checksum.h
1490 @@ -37,7 +37,19 @@ __wsum
1491 csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum);
1492
1493 __wsum
1494 -csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
1495 +__csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
1496 +
1497 +static inline __wsum
1498 +csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr)
1499 +{
1500 + __wsum ret;
1501 + pax_open_userland();
1502 + ret = __csum_partial_copy_from_user(src, dst, len, sum, err_ptr);
1503 + pax_close_userland();
1504 + return ret;
1505 +}
1506 +
1507 +
1508
1509 /*
1510 * Fold a partial checksum without adding pseudo headers
1511 diff --git a/arch/arm/include/asm/cmpxchg.h b/arch/arm/include/asm/cmpxchg.h
1512 index 4f009c1..466c59b 100644
1513 --- a/arch/arm/include/asm/cmpxchg.h
1514 +++ b/arch/arm/include/asm/cmpxchg.h
1515 @@ -102,6 +102,8 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size
1516
1517 #define xchg(ptr,x) \
1518 ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
1519 +#define xchg_unchecked(ptr,x) \
1520 + ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
1521
1522 #include <asm-generic/cmpxchg-local.h>
1523
1524 diff --git a/arch/arm/include/asm/domain.h b/arch/arm/include/asm/domain.h
1525 index 6ddbe44..b5e38b1 100644
1526 --- a/arch/arm/include/asm/domain.h
1527 +++ b/arch/arm/include/asm/domain.h
1528 @@ -48,18 +48,37 @@
1529 * Domain types
1530 */
1531 #define DOMAIN_NOACCESS 0
1532 -#define DOMAIN_CLIENT 1
1533 #ifdef CONFIG_CPU_USE_DOMAINS
1534 +#define DOMAIN_USERCLIENT 1
1535 +#define DOMAIN_KERNELCLIENT 1
1536 #define DOMAIN_MANAGER 3
1537 +#define DOMAIN_VECTORS DOMAIN_USER
1538 #else
1539 +
1540 +#ifdef CONFIG_PAX_KERNEXEC
1541 #define DOMAIN_MANAGER 1
1542 +#define DOMAIN_KERNEXEC 3
1543 +#else
1544 +#define DOMAIN_MANAGER 1
1545 +#endif
1546 +
1547 +#ifdef CONFIG_PAX_MEMORY_UDEREF
1548 +#define DOMAIN_USERCLIENT 0
1549 +#define DOMAIN_UDEREF 1
1550 +#define DOMAIN_VECTORS DOMAIN_KERNEL
1551 +#else
1552 +#define DOMAIN_USERCLIENT 1
1553 +#define DOMAIN_VECTORS DOMAIN_USER
1554 +#endif
1555 +#define DOMAIN_KERNELCLIENT 1
1556 +
1557 #endif
1558
1559 #define domain_val(dom,type) ((type) << (2*(dom)))
1560
1561 #ifndef __ASSEMBLY__
1562
1563 -#ifdef CONFIG_CPU_USE_DOMAINS
1564 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
1565 static inline void set_domain(unsigned val)
1566 {
1567 asm volatile(
1568 @@ -68,15 +87,7 @@ static inline void set_domain(unsigned val)
1569 isb();
1570 }
1571
1572 -#define modify_domain(dom,type) \
1573 - do { \
1574 - struct thread_info *thread = current_thread_info(); \
1575 - unsigned int domain = thread->cpu_domain; \
1576 - domain &= ~domain_val(dom, DOMAIN_MANAGER); \
1577 - thread->cpu_domain = domain | domain_val(dom, type); \
1578 - set_domain(thread->cpu_domain); \
1579 - } while (0)
1580 -
1581 +extern void modify_domain(unsigned int dom, unsigned int type);
1582 #else
1583 static inline void set_domain(unsigned val) { }
1584 static inline void modify_domain(unsigned dom, unsigned type) { }
1585 diff --git a/arch/arm/include/asm/elf.h b/arch/arm/include/asm/elf.h
1586 index 38050b1..9d90e8b 100644
1587 --- a/arch/arm/include/asm/elf.h
1588 +++ b/arch/arm/include/asm/elf.h
1589 @@ -116,7 +116,14 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1590 the loader. We need to make sure that it is out of the way of the program
1591 that it will "exec", and that there is sufficient room for the brk. */
1592
1593 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
1594 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
1595 +
1596 +#ifdef CONFIG_PAX_ASLR
1597 +#define PAX_ELF_ET_DYN_BASE 0x00008000UL
1598 +
1599 +#define PAX_DELTA_MMAP_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1600 +#define PAX_DELTA_STACK_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1601 +#endif
1602
1603 /* When the program starts, a1 contains a pointer to a function to be
1604 registered with atexit, as per the SVR4 ABI. A value of 0 means we
1605 @@ -126,8 +133,4 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1606 extern void elf_set_personality(const struct elf32_hdr *);
1607 #define SET_PERSONALITY(ex) elf_set_personality(&(ex))
1608
1609 -struct mm_struct;
1610 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
1611 -#define arch_randomize_brk arch_randomize_brk
1612 -
1613 #endif
1614 diff --git a/arch/arm/include/asm/fncpy.h b/arch/arm/include/asm/fncpy.h
1615 index de53547..52b9a28 100644
1616 --- a/arch/arm/include/asm/fncpy.h
1617 +++ b/arch/arm/include/asm/fncpy.h
1618 @@ -81,7 +81,9 @@
1619 BUG_ON((uintptr_t)(dest_buf) & (FNCPY_ALIGN - 1) || \
1620 (__funcp_address & ~(uintptr_t)1 & (FNCPY_ALIGN - 1))); \
1621 \
1622 + pax_open_kernel(); \
1623 memcpy(dest_buf, (void const *)(__funcp_address & ~1), size); \
1624 + pax_close_kernel(); \
1625 flush_icache_range((unsigned long)(dest_buf), \
1626 (unsigned long)(dest_buf) + (size)); \
1627 \
1628 diff --git a/arch/arm/include/asm/futex.h b/arch/arm/include/asm/futex.h
1629 index e42cf59..7b94b8f 100644
1630 --- a/arch/arm/include/asm/futex.h
1631 +++ b/arch/arm/include/asm/futex.h
1632 @@ -50,6 +50,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1633 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1634 return -EFAULT;
1635
1636 + pax_open_userland();
1637 +
1638 smp_mb();
1639 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
1640 "1: ldrex %1, [%4]\n"
1641 @@ -65,6 +67,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1642 : "cc", "memory");
1643 smp_mb();
1644
1645 + pax_close_userland();
1646 +
1647 *uval = val;
1648 return ret;
1649 }
1650 @@ -95,6 +99,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1651 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1652 return -EFAULT;
1653
1654 + pax_open_userland();
1655 +
1656 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
1657 "1: " TUSER(ldr) " %1, [%4]\n"
1658 " teq %1, %2\n"
1659 @@ -105,6 +111,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1660 : "r" (oldval), "r" (newval), "r" (uaddr), "Ir" (-EFAULT)
1661 : "cc", "memory");
1662
1663 + pax_close_userland();
1664 +
1665 *uval = val;
1666 return ret;
1667 }
1668 @@ -127,6 +135,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1669 return -EFAULT;
1670
1671 pagefault_disable(); /* implies preempt_disable() */
1672 + pax_open_userland();
1673
1674 switch (op) {
1675 case FUTEX_OP_SET:
1676 @@ -148,6 +157,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1677 ret = -ENOSYS;
1678 }
1679
1680 + pax_close_userland();
1681 pagefault_enable(); /* subsumes preempt_enable() */
1682
1683 if (!ret) {
1684 diff --git a/arch/arm/include/asm/kmap_types.h b/arch/arm/include/asm/kmap_types.h
1685 index 83eb2f7..ed77159 100644
1686 --- a/arch/arm/include/asm/kmap_types.h
1687 +++ b/arch/arm/include/asm/kmap_types.h
1688 @@ -4,6 +4,6 @@
1689 /*
1690 * This is the "bare minimum". AIO seems to require this.
1691 */
1692 -#define KM_TYPE_NR 16
1693 +#define KM_TYPE_NR 17
1694
1695 #endif
1696 diff --git a/arch/arm/include/asm/mach/dma.h b/arch/arm/include/asm/mach/dma.h
1697 index 9e614a1..3302cca 100644
1698 --- a/arch/arm/include/asm/mach/dma.h
1699 +++ b/arch/arm/include/asm/mach/dma.h
1700 @@ -22,7 +22,7 @@ struct dma_ops {
1701 int (*residue)(unsigned int, dma_t *); /* optional */
1702 int (*setspeed)(unsigned int, dma_t *, int); /* optional */
1703 const char *type;
1704 -};
1705 +} __do_const;
1706
1707 struct dma_struct {
1708 void *addr; /* single DMA address */
1709 diff --git a/arch/arm/include/asm/mach/map.h b/arch/arm/include/asm/mach/map.h
1710 index 2fe141f..192dc01 100644
1711 --- a/arch/arm/include/asm/mach/map.h
1712 +++ b/arch/arm/include/asm/mach/map.h
1713 @@ -27,13 +27,16 @@ struct map_desc {
1714 #define MT_MINICLEAN 6
1715 #define MT_LOW_VECTORS 7
1716 #define MT_HIGH_VECTORS 8
1717 -#define MT_MEMORY 9
1718 +#define MT_MEMORY_RWX 9
1719 #define MT_ROM 10
1720 -#define MT_MEMORY_NONCACHED 11
1721 +#define MT_MEMORY_NONCACHED_RX 11
1722 #define MT_MEMORY_DTCM 12
1723 #define MT_MEMORY_ITCM 13
1724 #define MT_MEMORY_SO 14
1725 #define MT_MEMORY_DMA_READY 15
1726 +#define MT_MEMORY_RW 16
1727 +#define MT_MEMORY_RX 17
1728 +#define MT_MEMORY_NONCACHED_RW 18
1729
1730 #ifdef CONFIG_MMU
1731 extern void iotable_init(struct map_desc *, int);
1732 diff --git a/arch/arm/include/asm/outercache.h b/arch/arm/include/asm/outercache.h
1733 index 12f71a1..04e063c 100644
1734 --- a/arch/arm/include/asm/outercache.h
1735 +++ b/arch/arm/include/asm/outercache.h
1736 @@ -35,7 +35,7 @@ struct outer_cache_fns {
1737 #endif
1738 void (*set_debug)(unsigned long);
1739 void (*resume)(void);
1740 -};
1741 +} __no_const;
1742
1743 #ifdef CONFIG_OUTER_CACHE
1744
1745 diff --git a/arch/arm/include/asm/page.h b/arch/arm/include/asm/page.h
1746 index 812a494..71fc0b6 100644
1747 --- a/arch/arm/include/asm/page.h
1748 +++ b/arch/arm/include/asm/page.h
1749 @@ -114,7 +114,7 @@ struct cpu_user_fns {
1750 void (*cpu_clear_user_highpage)(struct page *page, unsigned long vaddr);
1751 void (*cpu_copy_user_highpage)(struct page *to, struct page *from,
1752 unsigned long vaddr, struct vm_area_struct *vma);
1753 -};
1754 +} __no_const;
1755
1756 #ifdef MULTI_USER
1757 extern struct cpu_user_fns cpu_user;
1758 diff --git a/arch/arm/include/asm/pgalloc.h b/arch/arm/include/asm/pgalloc.h
1759 index 943504f..c37a730 100644
1760 --- a/arch/arm/include/asm/pgalloc.h
1761 +++ b/arch/arm/include/asm/pgalloc.h
1762 @@ -17,6 +17,7 @@
1763 #include <asm/processor.h>
1764 #include <asm/cacheflush.h>
1765 #include <asm/tlbflush.h>
1766 +#include <asm/system_info.h>
1767
1768 #define check_pgt_cache() do { } while (0)
1769
1770 @@ -43,6 +44,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1771 set_pud(pud, __pud(__pa(pmd) | PMD_TYPE_TABLE));
1772 }
1773
1774 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1775 +{
1776 + pud_populate(mm, pud, pmd);
1777 +}
1778 +
1779 #else /* !CONFIG_ARM_LPAE */
1780
1781 /*
1782 @@ -51,6 +57,7 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1783 #define pmd_alloc_one(mm,addr) ({ BUG(); ((pmd_t *)2); })
1784 #define pmd_free(mm, pmd) do { } while (0)
1785 #define pud_populate(mm,pmd,pte) BUG()
1786 +#define pud_populate_kernel(mm,pmd,pte) BUG()
1787
1788 #endif /* CONFIG_ARM_LPAE */
1789
1790 @@ -126,6 +133,19 @@ static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
1791 __free_page(pte);
1792 }
1793
1794 +static inline void __section_update(pmd_t *pmdp, unsigned long addr, pmdval_t prot)
1795 +{
1796 +#ifdef CONFIG_ARM_LPAE
1797 + pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1798 +#else
1799 + if (addr & SECTION_SIZE)
1800 + pmdp[1] = __pmd(pmd_val(pmdp[1]) | prot);
1801 + else
1802 + pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1803 +#endif
1804 + flush_pmd_entry(pmdp);
1805 +}
1806 +
1807 static inline void __pmd_populate(pmd_t *pmdp, phys_addr_t pte,
1808 pmdval_t prot)
1809 {
1810 @@ -155,7 +175,7 @@ pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmdp, pte_t *ptep)
1811 static inline void
1812 pmd_populate(struct mm_struct *mm, pmd_t *pmdp, pgtable_t ptep)
1813 {
1814 - __pmd_populate(pmdp, page_to_phys(ptep), _PAGE_USER_TABLE);
1815 + __pmd_populate(pmdp, page_to_phys(ptep), _PAGE_USER_TABLE | __supported_pmd_mask);
1816 }
1817 #define pmd_pgtable(pmd) pmd_page(pmd)
1818
1819 diff --git a/arch/arm/include/asm/pgtable-2level-hwdef.h b/arch/arm/include/asm/pgtable-2level-hwdef.h
1820 index 5cfba15..f415e1a 100644
1821 --- a/arch/arm/include/asm/pgtable-2level-hwdef.h
1822 +++ b/arch/arm/include/asm/pgtable-2level-hwdef.h
1823 @@ -20,12 +20,15 @@
1824 #define PMD_TYPE_FAULT (_AT(pmdval_t, 0) << 0)
1825 #define PMD_TYPE_TABLE (_AT(pmdval_t, 1) << 0)
1826 #define PMD_TYPE_SECT (_AT(pmdval_t, 2) << 0)
1827 +#define PMD_PXNTABLE (_AT(pmdval_t, 1) << 2) /* v7 */
1828 #define PMD_BIT4 (_AT(pmdval_t, 1) << 4)
1829 #define PMD_DOMAIN(x) (_AT(pmdval_t, (x)) << 5)
1830 #define PMD_PROTECTION (_AT(pmdval_t, 1) << 9) /* v5 */
1831 +
1832 /*
1833 * - section
1834 */
1835 +#define PMD_SECT_PXN (_AT(pmdval_t, 1) << 0) /* v7 */
1836 #define PMD_SECT_BUFFERABLE (_AT(pmdval_t, 1) << 2)
1837 #define PMD_SECT_CACHEABLE (_AT(pmdval_t, 1) << 3)
1838 #define PMD_SECT_XN (_AT(pmdval_t, 1) << 4) /* v6 */
1839 @@ -37,6 +40,7 @@
1840 #define PMD_SECT_nG (_AT(pmdval_t, 1) << 17) /* v6 */
1841 #define PMD_SECT_SUPER (_AT(pmdval_t, 1) << 18) /* v6 */
1842 #define PMD_SECT_AF (_AT(pmdval_t, 0))
1843 +#define PMD_SECT_RDONLY (_AT(pmdval_t, 0))
1844
1845 #define PMD_SECT_UNCACHED (_AT(pmdval_t, 0))
1846 #define PMD_SECT_BUFFERED (PMD_SECT_BUFFERABLE)
1847 @@ -66,6 +70,7 @@
1848 * - extended small page/tiny page
1849 */
1850 #define PTE_EXT_XN (_AT(pteval_t, 1) << 0) /* v6 */
1851 +#define PTE_EXT_PXN (_AT(pteval_t, 1) << 2) /* v7 */
1852 #define PTE_EXT_AP_MASK (_AT(pteval_t, 3) << 4)
1853 #define PTE_EXT_AP0 (_AT(pteval_t, 1) << 4)
1854 #define PTE_EXT_AP1 (_AT(pteval_t, 2) << 4)
1855 diff --git a/arch/arm/include/asm/pgtable-2level.h b/arch/arm/include/asm/pgtable-2level.h
1856 index f97ee02..07f1be5 100644
1857 --- a/arch/arm/include/asm/pgtable-2level.h
1858 +++ b/arch/arm/include/asm/pgtable-2level.h
1859 @@ -125,6 +125,7 @@
1860 #define L_PTE_XN (_AT(pteval_t, 1) << 9)
1861 #define L_PTE_SHARED (_AT(pteval_t, 1) << 10) /* shared(v6), coherent(xsc3) */
1862 #define L_PTE_NONE (_AT(pteval_t, 1) << 11)
1863 +#define L_PTE_PXN (_AT(pteval_t, 1) << 12) /* v7*/
1864
1865 /*
1866 * These are the memory types, defined to be compatible with
1867 diff --git a/arch/arm/include/asm/pgtable-3level-hwdef.h b/arch/arm/include/asm/pgtable-3level-hwdef.h
1868 index 18f5cef..25b8f43 100644
1869 --- a/arch/arm/include/asm/pgtable-3level-hwdef.h
1870 +++ b/arch/arm/include/asm/pgtable-3level-hwdef.h
1871 @@ -41,6 +41,7 @@
1872 */
1873 #define PMD_SECT_BUFFERABLE (_AT(pmdval_t, 1) << 2)
1874 #define PMD_SECT_CACHEABLE (_AT(pmdval_t, 1) << 3)
1875 +#define PMD_SECT_RDONLY (_AT(pmdval_t, 1) << 7)
1876 #define PMD_SECT_S (_AT(pmdval_t, 3) << 8)
1877 #define PMD_SECT_AF (_AT(pmdval_t, 1) << 10)
1878 #define PMD_SECT_nG (_AT(pmdval_t, 1) << 11)
1879 @@ -71,6 +72,7 @@
1880 #define PTE_EXT_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
1881 #define PTE_EXT_AF (_AT(pteval_t, 1) << 10) /* Access Flag */
1882 #define PTE_EXT_NG (_AT(pteval_t, 1) << 11) /* nG */
1883 +#define PTE_EXT_PXN (_AT(pteval_t, 1) << 53) /* PXN */
1884 #define PTE_EXT_XN (_AT(pteval_t, 1) << 54) /* XN */
1885
1886 /*
1887 diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h
1888 index 86b8fe3..e25f975 100644
1889 --- a/arch/arm/include/asm/pgtable-3level.h
1890 +++ b/arch/arm/include/asm/pgtable-3level.h
1891 @@ -74,6 +74,7 @@
1892 #define L_PTE_RDONLY (_AT(pteval_t, 1) << 7) /* AP[2] */
1893 #define L_PTE_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
1894 #define L_PTE_YOUNG (_AT(pteval_t, 1) << 10) /* AF */
1895 +#define L_PTE_PXN (_AT(pteval_t, 1) << 53) /* PXN */
1896 #define L_PTE_XN (_AT(pteval_t, 1) << 54) /* XN */
1897 #define L_PTE_DIRTY (_AT(pteval_t, 1) << 55) /* unused */
1898 #define L_PTE_SPECIAL (_AT(pteval_t, 1) << 56) /* unused */
1899 @@ -82,6 +83,7 @@
1900 /*
1901 * To be used in assembly code with the upper page attributes.
1902 */
1903 +#define L_PTE_PXN_HIGH (1 << (53 - 32))
1904 #define L_PTE_XN_HIGH (1 << (54 - 32))
1905 #define L_PTE_DIRTY_HIGH (1 << (55 - 32))
1906
1907 diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
1908 index 9bcd262..fba731c 100644
1909 --- a/arch/arm/include/asm/pgtable.h
1910 +++ b/arch/arm/include/asm/pgtable.h
1911 @@ -30,6 +30,9 @@
1912 #include <asm/pgtable-2level.h>
1913 #endif
1914
1915 +#define ktla_ktva(addr) (addr)
1916 +#define ktva_ktla(addr) (addr)
1917 +
1918 /*
1919 * Just any arbitrary offset to the start of the vmalloc VM area: the
1920 * current 8MB value just means that there will be a 8MB "hole" after the
1921 @@ -45,6 +48,9 @@
1922 #define LIBRARY_TEXT_START 0x0c000000
1923
1924 #ifndef __ASSEMBLY__
1925 +extern pteval_t __supported_pte_mask;
1926 +extern pmdval_t __supported_pmd_mask;
1927 +
1928 extern void __pte_error(const char *file, int line, pte_t);
1929 extern void __pmd_error(const char *file, int line, pmd_t);
1930 extern void __pgd_error(const char *file, int line, pgd_t);
1931 @@ -53,6 +59,50 @@ extern void __pgd_error(const char *file, int line, pgd_t);
1932 #define pmd_ERROR(pmd) __pmd_error(__FILE__, __LINE__, pmd)
1933 #define pgd_ERROR(pgd) __pgd_error(__FILE__, __LINE__, pgd)
1934
1935 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
1936 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
1937 +
1938 +#ifdef CONFIG_PAX_KERNEXEC
1939 +#include <asm/domain.h>
1940 +#include <linux/thread_info.h>
1941 +#include <linux/preempt.h>
1942 +#endif
1943 +
1944 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
1945 +static inline int test_domain(int domain, int domaintype)
1946 +{
1947 + return ((current_thread_info()->cpu_domain) & domain_val(domain, 3)) == domain_val(domain, domaintype);
1948 +}
1949 +#endif
1950 +
1951 +#ifdef CONFIG_PAX_KERNEXEC
1952 +static inline unsigned long pax_open_kernel(void) {
1953 +#ifdef CONFIG_ARM_LPAE
1954 + /* TODO */
1955 +#else
1956 + preempt_disable();
1957 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC));
1958 + modify_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC);
1959 +#endif
1960 + return 0;
1961 +}
1962 +
1963 +static inline unsigned long pax_close_kernel(void) {
1964 +#ifdef CONFIG_ARM_LPAE
1965 + /* TODO */
1966 +#else
1967 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_MANAGER));
1968 + /* DOMAIN_MANAGER = "client" under KERNEXEC */
1969 + modify_domain(DOMAIN_KERNEL, DOMAIN_MANAGER);
1970 + preempt_enable_no_resched();
1971 +#endif
1972 + return 0;
1973 +}
1974 +#else
1975 +static inline unsigned long pax_open_kernel(void) { return 0; }
1976 +static inline unsigned long pax_close_kernel(void) { return 0; }
1977 +#endif
1978 +
1979 /*
1980 * This is the lowest virtual address we can permit any user space
1981 * mapping to be mapped at. This is particularly important for
1982 @@ -72,8 +122,8 @@ extern void __pgd_error(const char *file, int line, pgd_t);
1983 /*
1984 * The pgprot_* and protection_map entries will be fixed up in runtime
1985 * to include the cachable and bufferable bits based on memory policy,
1986 - * as well as any architecture dependent bits like global/ASID and SMP
1987 - * shared mapping bits.
1988 + * as well as any architecture dependent bits like global/ASID, PXN,
1989 + * and SMP shared mapping bits.
1990 */
1991 #define _L_PTE_DEFAULT L_PTE_PRESENT | L_PTE_YOUNG
1992
1993 @@ -257,7 +307,7 @@ static inline pte_t pte_mkspecial(pte_t pte) { return pte; }
1994 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
1995 {
1996 const pteval_t mask = L_PTE_XN | L_PTE_RDONLY | L_PTE_USER |
1997 - L_PTE_NONE | L_PTE_VALID;
1998 + L_PTE_NONE | L_PTE_VALID | __supported_pte_mask;
1999 pte_val(pte) = (pte_val(pte) & ~mask) | (pgprot_val(newprot) & mask);
2000 return pte;
2001 }
2002 diff --git a/arch/arm/include/asm/proc-fns.h b/arch/arm/include/asm/proc-fns.h
2003 index f3628fb..a0672dd 100644
2004 --- a/arch/arm/include/asm/proc-fns.h
2005 +++ b/arch/arm/include/asm/proc-fns.h
2006 @@ -75,7 +75,7 @@ extern struct processor {
2007 unsigned int suspend_size;
2008 void (*do_suspend)(void *);
2009 void (*do_resume)(void *);
2010 -} processor;
2011 +} __do_const processor;
2012
2013 #ifndef MULTI_CPU
2014 extern void cpu_proc_init(void);
2015 diff --git a/arch/arm/include/asm/processor.h b/arch/arm/include/asm/processor.h
2016 index 06e7d50..8a8e251 100644
2017 --- a/arch/arm/include/asm/processor.h
2018 +++ b/arch/arm/include/asm/processor.h
2019 @@ -65,9 +65,8 @@ struct thread_struct {
2020 regs->ARM_cpsr |= PSR_ENDSTATE; \
2021 regs->ARM_pc = pc & ~1; /* pc */ \
2022 regs->ARM_sp = sp; /* sp */ \
2023 - regs->ARM_r2 = stack[2]; /* r2 (envp) */ \
2024 - regs->ARM_r1 = stack[1]; /* r1 (argv) */ \
2025 - regs->ARM_r0 = stack[0]; /* r0 (argc) */ \
2026 + /* r2 (envp), r1 (argv), r0 (argc) */ \
2027 + (void)copy_from_user(&regs->ARM_r0, (const char __user *)stack, 3 * sizeof(unsigned long)); \
2028 nommu_start_thread(regs); \
2029 })
2030
2031 diff --git a/arch/arm/include/asm/psci.h b/arch/arm/include/asm/psci.h
2032 index ce0dbe7..c085b6f 100644
2033 --- a/arch/arm/include/asm/psci.h
2034 +++ b/arch/arm/include/asm/psci.h
2035 @@ -29,7 +29,7 @@ struct psci_operations {
2036 int (*cpu_off)(struct psci_power_state state);
2037 int (*cpu_on)(unsigned long cpuid, unsigned long entry_point);
2038 int (*migrate)(unsigned long cpuid);
2039 -};
2040 +} __no_const;
2041
2042 extern struct psci_operations psci_ops;
2043
2044 diff --git a/arch/arm/include/asm/smp.h b/arch/arm/include/asm/smp.h
2045 index d3a22be..3a69ad5 100644
2046 --- a/arch/arm/include/asm/smp.h
2047 +++ b/arch/arm/include/asm/smp.h
2048 @@ -107,7 +107,7 @@ struct smp_operations {
2049 int (*cpu_disable)(unsigned int cpu);
2050 #endif
2051 #endif
2052 -};
2053 +} __no_const;
2054
2055 /*
2056 * set platform specific SMP operations
2057 diff --git a/arch/arm/include/asm/thread_info.h b/arch/arm/include/asm/thread_info.h
2058 index cddda1f..ff357f7 100644
2059 --- a/arch/arm/include/asm/thread_info.h
2060 +++ b/arch/arm/include/asm/thread_info.h
2061 @@ -77,9 +77,9 @@ struct thread_info {
2062 .flags = 0, \
2063 .preempt_count = INIT_PREEMPT_COUNT, \
2064 .addr_limit = KERNEL_DS, \
2065 - .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2066 - domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2067 - domain_val(DOMAIN_IO, DOMAIN_CLIENT), \
2068 + .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_USERCLIENT) | \
2069 + domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT) | \
2070 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT), \
2071 .restart_block = { \
2072 .fn = do_no_restart_syscall, \
2073 }, \
2074 @@ -152,6 +152,12 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2075 #define TIF_SYSCALL_AUDIT 9
2076 #define TIF_SYSCALL_TRACEPOINT 10
2077 #define TIF_SECCOMP 11 /* seccomp syscall filtering active */
2078 +
2079 +/* within 8 bits of TIF_SYSCALL_TRACE
2080 + * to meet flexible second operand requirements
2081 + */
2082 +#define TIF_GRSEC_SETXID 12
2083 +
2084 #define TIF_USING_IWMMXT 17
2085 #define TIF_MEMDIE 18 /* is terminating due to OOM killer */
2086 #define TIF_RESTORE_SIGMASK 20
2087 @@ -165,10 +171,11 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2088 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
2089 #define _TIF_SECCOMP (1 << TIF_SECCOMP)
2090 #define _TIF_USING_IWMMXT (1 << TIF_USING_IWMMXT)
2091 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
2092
2093 /* Checks for any syscall work in entry-common.S */
2094 #define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
2095 - _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP)
2096 + _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | _TIF_GRSEC_SETXID)
2097
2098 /*
2099 * Change these and you break ASM code in entry-common.S
2100 diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h
2101 index 7e1f760..752fcb7 100644
2102 --- a/arch/arm/include/asm/uaccess.h
2103 +++ b/arch/arm/include/asm/uaccess.h
2104 @@ -18,6 +18,7 @@
2105 #include <asm/domain.h>
2106 #include <asm/unified.h>
2107 #include <asm/compiler.h>
2108 +#include <asm/pgtable.h>
2109
2110 #define VERIFY_READ 0
2111 #define VERIFY_WRITE 1
2112 @@ -60,10 +61,34 @@ extern int __put_user_bad(void);
2113 #define USER_DS TASK_SIZE
2114 #define get_fs() (current_thread_info()->addr_limit)
2115
2116 +static inline void pax_open_userland(void)
2117 +{
2118 +
2119 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2120 + if (get_fs() == USER_DS) {
2121 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_UDEREF));
2122 + modify_domain(DOMAIN_USER, DOMAIN_UDEREF);
2123 + }
2124 +#endif
2125 +
2126 +}
2127 +
2128 +static inline void pax_close_userland(void)
2129 +{
2130 +
2131 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2132 + if (get_fs() == USER_DS) {
2133 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_NOACCESS));
2134 + modify_domain(DOMAIN_USER, DOMAIN_NOACCESS);
2135 + }
2136 +#endif
2137 +
2138 +}
2139 +
2140 static inline void set_fs(mm_segment_t fs)
2141 {
2142 current_thread_info()->addr_limit = fs;
2143 - modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_CLIENT : DOMAIN_MANAGER);
2144 + modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_KERNELCLIENT : DOMAIN_MANAGER);
2145 }
2146
2147 #define segment_eq(a,b) ((a) == (b))
2148 @@ -143,8 +168,12 @@ extern int __get_user_4(void *);
2149
2150 #define get_user(x,p) \
2151 ({ \
2152 + int __e; \
2153 might_fault(); \
2154 - __get_user_check(x,p); \
2155 + pax_open_userland(); \
2156 + __e = __get_user_check(x,p); \
2157 + pax_close_userland(); \
2158 + __e; \
2159 })
2160
2161 extern int __put_user_1(void *, unsigned int);
2162 @@ -188,8 +217,12 @@ extern int __put_user_8(void *, unsigned long long);
2163
2164 #define put_user(x,p) \
2165 ({ \
2166 + int __e; \
2167 might_fault(); \
2168 - __put_user_check(x,p); \
2169 + pax_open_userland(); \
2170 + __e = __put_user_check(x,p); \
2171 + pax_close_userland(); \
2172 + __e; \
2173 })
2174
2175 #else /* CONFIG_MMU */
2176 @@ -230,13 +263,17 @@ static inline void set_fs(mm_segment_t fs)
2177 #define __get_user(x,ptr) \
2178 ({ \
2179 long __gu_err = 0; \
2180 + pax_open_userland(); \
2181 __get_user_err((x),(ptr),__gu_err); \
2182 + pax_close_userland(); \
2183 __gu_err; \
2184 })
2185
2186 #define __get_user_error(x,ptr,err) \
2187 ({ \
2188 + pax_open_userland(); \
2189 __get_user_err((x),(ptr),err); \
2190 + pax_close_userland(); \
2191 (void) 0; \
2192 })
2193
2194 @@ -312,13 +349,17 @@ do { \
2195 #define __put_user(x,ptr) \
2196 ({ \
2197 long __pu_err = 0; \
2198 + pax_open_userland(); \
2199 __put_user_err((x),(ptr),__pu_err); \
2200 + pax_close_userland(); \
2201 __pu_err; \
2202 })
2203
2204 #define __put_user_error(x,ptr,err) \
2205 ({ \
2206 + pax_open_userland(); \
2207 __put_user_err((x),(ptr),err); \
2208 + pax_close_userland(); \
2209 (void) 0; \
2210 })
2211
2212 @@ -418,11 +459,44 @@ do { \
2213
2214
2215 #ifdef CONFIG_MMU
2216 -extern unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n);
2217 -extern unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n);
2218 +extern unsigned long __must_check ___copy_from_user(void *to, const void __user *from, unsigned long n);
2219 +extern unsigned long __must_check ___copy_to_user(void __user *to, const void *from, unsigned long n);
2220 +
2221 +static inline unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n)
2222 +{
2223 + unsigned long ret;
2224 +
2225 + check_object_size(to, n, false);
2226 + pax_open_userland();
2227 + ret = ___copy_from_user(to, from, n);
2228 + pax_close_userland();
2229 + return ret;
2230 +}
2231 +
2232 +static inline unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n)
2233 +{
2234 + unsigned long ret;
2235 +
2236 + check_object_size(from, n, true);
2237 + pax_open_userland();
2238 + ret = ___copy_to_user(to, from, n);
2239 + pax_close_userland();
2240 + return ret;
2241 +}
2242 +
2243 extern unsigned long __must_check __copy_to_user_std(void __user *to, const void *from, unsigned long n);
2244 -extern unsigned long __must_check __clear_user(void __user *addr, unsigned long n);
2245 +extern unsigned long __must_check ___clear_user(void __user *addr, unsigned long n);
2246 extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned long n);
2247 +
2248 +static inline unsigned long __must_check __clear_user(void __user *addr, unsigned long n)
2249 +{
2250 + unsigned long ret;
2251 + pax_open_userland();
2252 + ret = ___clear_user(addr, n);
2253 + pax_close_userland();
2254 + return ret;
2255 +}
2256 +
2257 #else
2258 #define __copy_from_user(to,from,n) (memcpy(to, (void __force *)from, n), 0)
2259 #define __copy_to_user(to,from,n) (memcpy((void __force *)to, from, n), 0)
2260 @@ -431,6 +505,9 @@ extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned l
2261
2262 static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
2263 {
2264 + if ((long)n < 0)
2265 + return n;
2266 +
2267 if (access_ok(VERIFY_READ, from, n))
2268 n = __copy_from_user(to, from, n);
2269 else /* security hole - plug it */
2270 @@ -440,6 +517,9 @@ static inline unsigned long __must_check copy_from_user(void *to, const void __u
2271
2272 static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
2273 {
2274 + if ((long)n < 0)
2275 + return n;
2276 +
2277 if (access_ok(VERIFY_WRITE, to, n))
2278 n = __copy_to_user(to, from, n);
2279 return n;
2280 diff --git a/arch/arm/include/uapi/asm/ptrace.h b/arch/arm/include/uapi/asm/ptrace.h
2281 index 96ee092..37f1844 100644
2282 --- a/arch/arm/include/uapi/asm/ptrace.h
2283 +++ b/arch/arm/include/uapi/asm/ptrace.h
2284 @@ -73,7 +73,7 @@
2285 * ARMv7 groups of PSR bits
2286 */
2287 #define APSR_MASK 0xf80f0000 /* N, Z, C, V, Q and GE flags */
2288 -#define PSR_ISET_MASK 0x01000010 /* ISA state (J, T) mask */
2289 +#define PSR_ISET_MASK 0x01000020 /* ISA state (J, T) mask */
2290 #define PSR_IT_MASK 0x0600fc00 /* If-Then execution state mask */
2291 #define PSR_ENDIAN_MASK 0x00000200 /* Endianness state mask */
2292
2293 diff --git a/arch/arm/kernel/armksyms.c b/arch/arm/kernel/armksyms.c
2294 index 60d3b73..d27ee09 100644
2295 --- a/arch/arm/kernel/armksyms.c
2296 +++ b/arch/arm/kernel/armksyms.c
2297 @@ -89,9 +89,9 @@ EXPORT_SYMBOL(__memzero);
2298 #ifdef CONFIG_MMU
2299 EXPORT_SYMBOL(copy_page);
2300
2301 -EXPORT_SYMBOL(__copy_from_user);
2302 -EXPORT_SYMBOL(__copy_to_user);
2303 -EXPORT_SYMBOL(__clear_user);
2304 +EXPORT_SYMBOL(___copy_from_user);
2305 +EXPORT_SYMBOL(___copy_to_user);
2306 +EXPORT_SYMBOL(___clear_user);
2307
2308 EXPORT_SYMBOL(__get_user_1);
2309 EXPORT_SYMBOL(__get_user_2);
2310 diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
2311 index 0f82098..3dbd3ee 100644
2312 --- a/arch/arm/kernel/entry-armv.S
2313 +++ b/arch/arm/kernel/entry-armv.S
2314 @@ -47,6 +47,87 @@
2315 9997:
2316 .endm
2317
2318 + .macro pax_enter_kernel
2319 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2320 + @ make aligned space for saved DACR
2321 + sub sp, sp, #8
2322 + @ save regs
2323 + stmdb sp!, {r1, r2}
2324 + @ read DACR from cpu_domain into r1
2325 + mov r2, sp
2326 + @ assume 8K pages, since we have to split the immediate in two
2327 + bic r2, r2, #(0x1fc0)
2328 + bic r2, r2, #(0x3f)
2329 + ldr r1, [r2, #TI_CPU_DOMAIN]
2330 + @ store old DACR on stack
2331 + str r1, [sp, #8]
2332 +#ifdef CONFIG_PAX_KERNEXEC
2333 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2334 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2335 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2336 +#endif
2337 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2338 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2339 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2340 +#endif
2341 + @ write r1 to current_thread_info()->cpu_domain
2342 + str r1, [r2, #TI_CPU_DOMAIN]
2343 + @ write r1 to DACR
2344 + mcr p15, 0, r1, c3, c0, 0
2345 + @ instruction sync
2346 + instr_sync
2347 + @ restore regs
2348 + ldmia sp!, {r1, r2}
2349 +#endif
2350 + .endm
2351 +
2352 + .macro pax_open_userland
2353 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2354 + @ save regs
2355 + stmdb sp!, {r0, r1}
2356 + @ read DACR from cpu_domain into r1
2357 + mov r0, sp
2358 + @ assume 8K pages, since we have to split the immediate in two
2359 + bic r0, r0, #(0x1fc0)
2360 + bic r0, r0, #(0x3f)
2361 + ldr r1, [r0, #TI_CPU_DOMAIN]
2362 + @ set current DOMAIN_USER to DOMAIN_CLIENT
2363 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2364 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2365 + @ write r1 to current_thread_info()->cpu_domain
2366 + str r1, [r0, #TI_CPU_DOMAIN]
2367 + @ write r1 to DACR
2368 + mcr p15, 0, r1, c3, c0, 0
2369 + @ instruction sync
2370 + instr_sync
2371 + @ restore regs
2372 + ldmia sp!, {r0, r1}
2373 +#endif
2374 + .endm
2375 +
2376 + .macro pax_close_userland
2377 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2378 + @ save regs
2379 + stmdb sp!, {r0, r1}
2380 + @ read DACR from cpu_domain into r1
2381 + mov r0, sp
2382 + @ assume 8K pages, since we have to split the immediate in two
2383 + bic r0, r0, #(0x1fc0)
2384 + bic r0, r0, #(0x3f)
2385 + ldr r1, [r0, #TI_CPU_DOMAIN]
2386 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2387 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2388 + @ write r1 to current_thread_info()->cpu_domain
2389 + str r1, [r0, #TI_CPU_DOMAIN]
2390 + @ write r1 to DACR
2391 + mcr p15, 0, r1, c3, c0, 0
2392 + @ instruction sync
2393 + instr_sync
2394 + @ restore regs
2395 + ldmia sp!, {r0, r1}
2396 +#endif
2397 + .endm
2398 +
2399 .macro pabt_helper
2400 @ PABORT handler takes pt_regs in r2, fault address in r4 and psr in r5
2401 #ifdef MULTI_PABORT
2402 @@ -89,11 +170,15 @@
2403 * Invalid mode handlers
2404 */
2405 .macro inv_entry, reason
2406 +
2407 + pax_enter_kernel
2408 +
2409 sub sp, sp, #S_FRAME_SIZE
2410 ARM( stmib sp, {r1 - lr} )
2411 THUMB( stmia sp, {r0 - r12} )
2412 THUMB( str sp, [sp, #S_SP] )
2413 THUMB( str lr, [sp, #S_LR] )
2414 +
2415 mov r1, #\reason
2416 .endm
2417
2418 @@ -149,7 +234,11 @@ ENDPROC(__und_invalid)
2419 .macro svc_entry, stack_hole=0
2420 UNWIND(.fnstart )
2421 UNWIND(.save {r0 - pc} )
2422 +
2423 + pax_enter_kernel
2424 +
2425 sub sp, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2426 +
2427 #ifdef CONFIG_THUMB2_KERNEL
2428 SPFIX( str r0, [sp] ) @ temporarily saved
2429 SPFIX( mov r0, sp )
2430 @@ -164,7 +253,12 @@ ENDPROC(__und_invalid)
2431 ldmia r0, {r3 - r5}
2432 add r7, sp, #S_SP - 4 @ here for interlock avoidance
2433 mov r6, #-1 @ "" "" "" ""
2434 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2435 + @ offset sp by 8 as done in pax_enter_kernel
2436 + add r2, sp, #(S_FRAME_SIZE + \stack_hole + 4)
2437 +#else
2438 add r2, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2439 +#endif
2440 SPFIX( addeq r2, r2, #4 )
2441 str r3, [sp, #-4]! @ save the "real" r0 copied
2442 @ from the exception stack
2443 @@ -359,6 +453,9 @@ ENDPROC(__pabt_svc)
2444 .macro usr_entry
2445 UNWIND(.fnstart )
2446 UNWIND(.cantunwind ) @ don't unwind the user space
2447 +
2448 + pax_enter_kernel_user
2449 +
2450 sub sp, sp, #S_FRAME_SIZE
2451 ARM( stmib sp, {r1 - r12} )
2452 THUMB( stmia sp, {r0 - r12} )
2453 @@ -456,7 +553,9 @@ __und_usr:
2454 tst r3, #PSR_T_BIT @ Thumb mode?
2455 bne __und_usr_thumb
2456 sub r4, r2, #4 @ ARM instr at LR - 4
2457 + pax_open_userland
2458 1: ldrt r0, [r4]
2459 + pax_close_userland
2460 #ifdef CONFIG_CPU_ENDIAN_BE8
2461 rev r0, r0 @ little endian instruction
2462 #endif
2463 @@ -491,10 +590,14 @@ __und_usr_thumb:
2464 */
2465 .arch armv6t2
2466 #endif
2467 + pax_open_userland
2468 2: ldrht r5, [r4]
2469 + pax_close_userland
2470 cmp r5, #0xe800 @ 32bit instruction if xx != 0
2471 blo __und_usr_fault_16 @ 16bit undefined instruction
2472 + pax_open_userland
2473 3: ldrht r0, [r2]
2474 + pax_close_userland
2475 add r2, r2, #2 @ r2 is PC + 2, make it PC + 4
2476 str r2, [sp, #S_PC] @ it's a 2x16bit instr, update
2477 orr r0, r0, r5, lsl #16
2478 @@ -733,7 +836,7 @@ ENTRY(__switch_to)
2479 THUMB( stmia ip!, {r4 - sl, fp} ) @ Store most regs on stack
2480 THUMB( str sp, [ip], #4 )
2481 THUMB( str lr, [ip], #4 )
2482 -#ifdef CONFIG_CPU_USE_DOMAINS
2483 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC)
2484 ldr r6, [r2, #TI_CPU_DOMAIN]
2485 #endif
2486 set_tls r3, r4, r5
2487 @@ -742,7 +845,7 @@ ENTRY(__switch_to)
2488 ldr r8, =__stack_chk_guard
2489 ldr r7, [r7, #TSK_STACK_CANARY]
2490 #endif
2491 -#ifdef CONFIG_CPU_USE_DOMAINS
2492 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC)
2493 mcr p15, 0, r6, c3, c0, 0 @ Set domain register
2494 #endif
2495 mov r5, r0
2496 diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
2497 index fefd7f9..e6f250e 100644
2498 --- a/arch/arm/kernel/entry-common.S
2499 +++ b/arch/arm/kernel/entry-common.S
2500 @@ -10,18 +10,46 @@
2501
2502 #include <asm/unistd.h>
2503 #include <asm/ftrace.h>
2504 +#include <asm/domain.h>
2505 #include <asm/unwind.h>
2506
2507 +#include "entry-header.S"
2508 +
2509 #ifdef CONFIG_NEED_RET_TO_USER
2510 #include <mach/entry-macro.S>
2511 #else
2512 .macro arch_ret_to_user, tmp1, tmp2
2513 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2514 + @ save regs
2515 + stmdb sp!, {r1, r2}
2516 + @ read DACR from cpu_domain into r1
2517 + mov r2, sp
2518 + @ assume 8K pages, since we have to split the immediate in two
2519 + bic r2, r2, #(0x1fc0)
2520 + bic r2, r2, #(0x3f)
2521 + ldr r1, [r2, #TI_CPU_DOMAIN]
2522 +#ifdef CONFIG_PAX_KERNEXEC
2523 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2524 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2525 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2526 +#endif
2527 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2528 + @ set current DOMAIN_USER to DOMAIN_UDEREF
2529 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2530 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2531 +#endif
2532 + @ write r1 to current_thread_info()->cpu_domain
2533 + str r1, [r2, #TI_CPU_DOMAIN]
2534 + @ write r1 to DACR
2535 + mcr p15, 0, r1, c3, c0, 0
2536 + @ instruction sync
2537 + instr_sync
2538 + @ restore regs
2539 + ldmia sp!, {r1, r2}
2540 +#endif
2541 .endm
2542 #endif
2543
2544 -#include "entry-header.S"
2545 -
2546 -
2547 .align 5
2548 /*
2549 * This is the fast syscall return path. We do as little as
2550 @@ -351,6 +379,7 @@ ENDPROC(ftrace_stub)
2551
2552 .align 5
2553 ENTRY(vector_swi)
2554 +
2555 sub sp, sp, #S_FRAME_SIZE
2556 stmia sp, {r0 - r12} @ Calling r0 - r12
2557 ARM( add r8, sp, #S_PC )
2558 @@ -400,6 +429,12 @@ ENTRY(vector_swi)
2559 ldr scno, [lr, #-4] @ get SWI instruction
2560 #endif
2561
2562 + /*
2563 + * do this here to avoid a performance hit of wrapping the code above
2564 + * that directly dereferences userland to parse the SWI instruction
2565 + */
2566 + pax_enter_kernel_user
2567 +
2568 #ifdef CONFIG_ALIGNMENT_TRAP
2569 ldr ip, __cr_alignment
2570 ldr ip, [ip]
2571 diff --git a/arch/arm/kernel/entry-header.S b/arch/arm/kernel/entry-header.S
2572 index 9a8531e..812e287 100644
2573 --- a/arch/arm/kernel/entry-header.S
2574 +++ b/arch/arm/kernel/entry-header.S
2575 @@ -73,9 +73,66 @@
2576 msr cpsr_c, \rtemp @ switch back to the SVC mode
2577 .endm
2578
2579 + .macro pax_enter_kernel_user
2580 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2581 + @ save regs
2582 + stmdb sp!, {r0, r1}
2583 + @ read DACR from cpu_domain into r1
2584 + mov r0, sp
2585 + @ assume 8K pages, since we have to split the immediate in two
2586 + bic r0, r0, #(0x1fc0)
2587 + bic r0, r0, #(0x3f)
2588 + ldr r1, [r0, #TI_CPU_DOMAIN]
2589 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2590 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2591 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2592 +#endif
2593 +#ifdef CONFIG_PAX_KERNEXEC
2594 + @ set current DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2595 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2596 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2597 +#endif
2598 + @ write r1 to current_thread_info()->cpu_domain
2599 + str r1, [r0, #TI_CPU_DOMAIN]
2600 + @ write r1 to DACR
2601 + mcr p15, 0, r1, c3, c0, 0
2602 + @ instruction sync
2603 + instr_sync
2604 + @ restore regs
2605 + ldmia sp!, {r0, r1}
2606 +#endif
2607 + .endm
2608 +
2609 + .macro pax_exit_kernel
2610 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2611 + @ save regs
2612 + stmdb sp!, {r0, r1}
2613 + @ read old DACR from stack into r1
2614 + ldr r1, [sp, #(8 + S_SP)]
2615 + sub r1, r1, #8
2616 + ldr r1, [r1]
2617 +
2618 + @ write r1 to current_thread_info()->cpu_domain
2619 + mov r0, sp
2620 + @ assume 8K pages, since we have to split the immediate in two
2621 + bic r0, r0, #(0x1fc0)
2622 + bic r0, r0, #(0x3f)
2623 + str r1, [r0, #TI_CPU_DOMAIN]
2624 + @ write r1 to DACR
2625 + mcr p15, 0, r1, c3, c0, 0
2626 + @ instruction sync
2627 + instr_sync
2628 + @ restore regs
2629 + ldmia sp!, {r0, r1}
2630 +#endif
2631 + .endm
2632 +
2633 #ifndef CONFIG_THUMB2_KERNEL
2634 .macro svc_exit, rpsr
2635 msr spsr_cxsf, \rpsr
2636 +
2637 + pax_exit_kernel
2638 +
2639 #if defined(CONFIG_CPU_V6)
2640 ldr r0, [sp]
2641 strex r1, r2, [sp] @ clear the exclusive monitor
2642 @@ -121,6 +178,9 @@
2643 .endm
2644 #else /* CONFIG_THUMB2_KERNEL */
2645 .macro svc_exit, rpsr
2646 +
2647 + pax_exit_kernel
2648 +
2649 ldr lr, [sp, #S_SP] @ top of the stack
2650 ldrd r0, r1, [sp, #S_LR] @ calling lr and pc
2651 clrex @ clear the exclusive monitor
2652 diff --git a/arch/arm/kernel/fiq.c b/arch/arm/kernel/fiq.c
2653 index 2adda11..7fbe958 100644
2654 --- a/arch/arm/kernel/fiq.c
2655 +++ b/arch/arm/kernel/fiq.c
2656 @@ -82,7 +82,9 @@ void set_fiq_handler(void *start, unsigned int length)
2657 #if defined(CONFIG_CPU_USE_DOMAINS)
2658 memcpy((void *)0xffff001c, start, length);
2659 #else
2660 + pax_open_kernel();
2661 memcpy(vectors_page + 0x1c, start, length);
2662 + pax_close_kernel();
2663 #endif
2664 flush_icache_range(0xffff001c, 0xffff001c + length);
2665 if (!vectors_high())
2666 diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
2667 index 8bac553..caee108 100644
2668 --- a/arch/arm/kernel/head.S
2669 +++ b/arch/arm/kernel/head.S
2670 @@ -52,7 +52,9 @@
2671 .equ swapper_pg_dir, KERNEL_RAM_VADDR - PG_DIR_SIZE
2672
2673 .macro pgtbl, rd, phys
2674 - add \rd, \phys, #TEXT_OFFSET - PG_DIR_SIZE
2675 + mov \rd, #TEXT_OFFSET
2676 + sub \rd, #PG_DIR_SIZE
2677 + add \rd, \rd, \phys
2678 .endm
2679
2680 /*
2681 @@ -434,7 +436,7 @@ __enable_mmu:
2682 mov r5, #(domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2683 domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2684 domain_val(DOMAIN_TABLE, DOMAIN_MANAGER) | \
2685 - domain_val(DOMAIN_IO, DOMAIN_CLIENT))
2686 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT))
2687 mcr p15, 0, r5, c3, c0, 0 @ load domain access register
2688 mcr p15, 0, r4, c2, c0, 0 @ load page table pointer
2689 #endif
2690 diff --git a/arch/arm/kernel/hw_breakpoint.c b/arch/arm/kernel/hw_breakpoint.c
2691 index 1fd749e..47adb08 100644
2692 --- a/arch/arm/kernel/hw_breakpoint.c
2693 +++ b/arch/arm/kernel/hw_breakpoint.c
2694 @@ -1029,7 +1029,7 @@ static int __cpuinit dbg_reset_notify(struct notifier_block *self,
2695 return NOTIFY_OK;
2696 }
2697
2698 -static struct notifier_block __cpuinitdata dbg_reset_nb = {
2699 +static struct notifier_block dbg_reset_nb = {
2700 .notifier_call = dbg_reset_notify,
2701 };
2702
2703 diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c
2704 index 1e9be5d..03edbc2 100644
2705 --- a/arch/arm/kernel/module.c
2706 +++ b/arch/arm/kernel/module.c
2707 @@ -37,12 +37,37 @@
2708 #endif
2709
2710 #ifdef CONFIG_MMU
2711 -void *module_alloc(unsigned long size)
2712 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
2713 {
2714 + if (!size || PAGE_ALIGN(size) > MODULES_END - MODULES_VADDR)
2715 + return NULL;
2716 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
2717 - GFP_KERNEL, PAGE_KERNEL_EXEC, -1,
2718 + GFP_KERNEL, prot, -1,
2719 __builtin_return_address(0));
2720 }
2721 +
2722 +void *module_alloc(unsigned long size)
2723 +{
2724 +
2725 +#ifdef CONFIG_PAX_KERNEXEC
2726 + return __module_alloc(size, PAGE_KERNEL);
2727 +#else
2728 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2729 +#endif
2730 +
2731 +}
2732 +
2733 +#ifdef CONFIG_PAX_KERNEXEC
2734 +void module_free_exec(struct module *mod, void *module_region)
2735 +{
2736 + module_free(mod, module_region);
2737 +}
2738 +
2739 +void *module_alloc_exec(unsigned long size)
2740 +{
2741 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2742 +}
2743 +#endif
2744 #endif
2745
2746 int
2747 diff --git a/arch/arm/kernel/patch.c b/arch/arm/kernel/patch.c
2748 index 07314af..c46655c 100644
2749 --- a/arch/arm/kernel/patch.c
2750 +++ b/arch/arm/kernel/patch.c
2751 @@ -18,6 +18,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2752 bool thumb2 = IS_ENABLED(CONFIG_THUMB2_KERNEL);
2753 int size;
2754
2755 + pax_open_kernel();
2756 if (thumb2 && __opcode_is_thumb16(insn)) {
2757 *(u16 *)addr = __opcode_to_mem_thumb16(insn);
2758 size = sizeof(u16);
2759 @@ -39,6 +40,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2760 *(u32 *)addr = insn;
2761 size = sizeof(u32);
2762 }
2763 + pax_close_kernel();
2764
2765 flush_icache_range((uintptr_t)(addr),
2766 (uintptr_t)(addr) + size);
2767 diff --git a/arch/arm/kernel/perf_event_cpu.c b/arch/arm/kernel/perf_event_cpu.c
2768 index 1f2740e..b36e225 100644
2769 --- a/arch/arm/kernel/perf_event_cpu.c
2770 +++ b/arch/arm/kernel/perf_event_cpu.c
2771 @@ -171,7 +171,7 @@ static int __cpuinit cpu_pmu_notify(struct notifier_block *b,
2772 return NOTIFY_OK;
2773 }
2774
2775 -static struct notifier_block __cpuinitdata cpu_pmu_hotplug_notifier = {
2776 +static struct notifier_block cpu_pmu_hotplug_notifier = {
2777 .notifier_call = cpu_pmu_notify,
2778 };
2779
2780 diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
2781 index 047d3e4..7e96107 100644
2782 --- a/arch/arm/kernel/process.c
2783 +++ b/arch/arm/kernel/process.c
2784 @@ -28,7 +28,6 @@
2785 #include <linux/tick.h>
2786 #include <linux/utsname.h>
2787 #include <linux/uaccess.h>
2788 -#include <linux/random.h>
2789 #include <linux/hw_breakpoint.h>
2790 #include <linux/cpuidle.h>
2791 #include <linux/leds.h>
2792 @@ -251,9 +250,10 @@ void machine_power_off(void)
2793 machine_shutdown();
2794 if (pm_power_off)
2795 pm_power_off();
2796 + BUG();
2797 }
2798
2799 -void machine_restart(char *cmd)
2800 +__noreturn void machine_restart(char *cmd)
2801 {
2802 machine_shutdown();
2803
2804 @@ -278,8 +278,8 @@ void __show_regs(struct pt_regs *regs)
2805 init_utsname()->release,
2806 (int)strcspn(init_utsname()->version, " "),
2807 init_utsname()->version);
2808 - print_symbol("PC is at %s\n", instruction_pointer(regs));
2809 - print_symbol("LR is at %s\n", regs->ARM_lr);
2810 + printk("PC is at %pA\n", instruction_pointer(regs));
2811 + printk("LR is at %pA\n", regs->ARM_lr);
2812 printk("pc : [<%08lx>] lr : [<%08lx>] psr: %08lx\n"
2813 "sp : %08lx ip : %08lx fp : %08lx\n",
2814 regs->ARM_pc, regs->ARM_lr, regs->ARM_cpsr,
2815 @@ -447,12 +447,6 @@ unsigned long get_wchan(struct task_struct *p)
2816 return 0;
2817 }
2818
2819 -unsigned long arch_randomize_brk(struct mm_struct *mm)
2820 -{
2821 - unsigned long range_end = mm->brk + 0x02000000;
2822 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
2823 -}
2824 -
2825 #ifdef CONFIG_MMU
2826 /*
2827 * The vectors page is always readable from user space for the
2828 @@ -465,9 +459,8 @@ static int __init gate_vma_init(void)
2829 {
2830 gate_vma.vm_start = 0xffff0000;
2831 gate_vma.vm_end = 0xffff0000 + PAGE_SIZE;
2832 - gate_vma.vm_page_prot = PAGE_READONLY_EXEC;
2833 - gate_vma.vm_flags = VM_READ | VM_EXEC |
2834 - VM_MAYREAD | VM_MAYEXEC;
2835 + gate_vma.vm_flags = VM_NONE;
2836 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
2837 return 0;
2838 }
2839 arch_initcall(gate_vma_init);
2840 diff --git a/arch/arm/kernel/psci.c b/arch/arm/kernel/psci.c
2841 index 3653164..d83e55d 100644
2842 --- a/arch/arm/kernel/psci.c
2843 +++ b/arch/arm/kernel/psci.c
2844 @@ -24,7 +24,7 @@
2845 #include <asm/opcodes-virt.h>
2846 #include <asm/psci.h>
2847
2848 -struct psci_operations psci_ops;
2849 +struct psci_operations psci_ops __read_only;
2850
2851 static int (*invoke_psci_fn)(u32, u32, u32, u32);
2852
2853 diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c
2854 index 03deeff..741ce88 100644
2855 --- a/arch/arm/kernel/ptrace.c
2856 +++ b/arch/arm/kernel/ptrace.c
2857 @@ -937,10 +937,19 @@ static int tracehook_report_syscall(struct pt_regs *regs,
2858 return current_thread_info()->syscall;
2859 }
2860
2861 +#ifdef CONFIG_GRKERNSEC_SETXID
2862 +extern void gr_delayed_cred_worker(void);
2863 +#endif
2864 +
2865 asmlinkage int syscall_trace_enter(struct pt_regs *regs, int scno)
2866 {
2867 current_thread_info()->syscall = scno;
2868
2869 +#ifdef CONFIG_GRKERNSEC_SETXID
2870 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
2871 + gr_delayed_cred_worker();
2872 +#endif
2873 +
2874 /* Do the secure computing check first; failures should be fast. */
2875 if (secure_computing(scno) == -1)
2876 return -1;
2877 diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
2878 index 234e339..81264a1 100644
2879 --- a/arch/arm/kernel/setup.c
2880 +++ b/arch/arm/kernel/setup.c
2881 @@ -96,21 +96,23 @@ EXPORT_SYMBOL(system_serial_high);
2882 unsigned int elf_hwcap __read_mostly;
2883 EXPORT_SYMBOL(elf_hwcap);
2884
2885 +pteval_t __supported_pte_mask __read_only;
2886 +pmdval_t __supported_pmd_mask __read_only;
2887
2888 #ifdef MULTI_CPU
2889 -struct processor processor __read_mostly;
2890 +struct processor processor;
2891 #endif
2892 #ifdef MULTI_TLB
2893 -struct cpu_tlb_fns cpu_tlb __read_mostly;
2894 +struct cpu_tlb_fns cpu_tlb __read_only;
2895 #endif
2896 #ifdef MULTI_USER
2897 -struct cpu_user_fns cpu_user __read_mostly;
2898 +struct cpu_user_fns cpu_user __read_only;
2899 #endif
2900 #ifdef MULTI_CACHE
2901 -struct cpu_cache_fns cpu_cache __read_mostly;
2902 +struct cpu_cache_fns cpu_cache __read_only;
2903 #endif
2904 #ifdef CONFIG_OUTER_CACHE
2905 -struct outer_cache_fns outer_cache __read_mostly;
2906 +struct outer_cache_fns outer_cache __read_only;
2907 EXPORT_SYMBOL(outer_cache);
2908 #endif
2909
2910 @@ -235,9 +237,13 @@ static int __get_cpu_architecture(void)
2911 asm("mrc p15, 0, %0, c0, c1, 4"
2912 : "=r" (mmfr0));
2913 if ((mmfr0 & 0x0000000f) >= 0x00000003 ||
2914 - (mmfr0 & 0x000000f0) >= 0x00000030)
2915 + (mmfr0 & 0x000000f0) >= 0x00000030) {
2916 cpu_arch = CPU_ARCH_ARMv7;
2917 - else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
2918 + if ((mmfr0 & 0x0000000f) == 0x00000005 || (mmfr0 & 0x0000000f) == 0x00000004) {
2919 + __supported_pte_mask |= L_PTE_PXN;
2920 + __supported_pmd_mask |= PMD_PXNTABLE;
2921 + }
2922 + } else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
2923 (mmfr0 & 0x000000f0) == 0x00000020)
2924 cpu_arch = CPU_ARCH_ARMv6;
2925 else
2926 @@ -478,7 +484,7 @@ static void __init setup_processor(void)
2927 __cpu_architecture = __get_cpu_architecture();
2928
2929 #ifdef MULTI_CPU
2930 - processor = *list->proc;
2931 + memcpy((void *)&processor, list->proc, sizeof processor);
2932 #endif
2933 #ifdef MULTI_TLB
2934 cpu_tlb = *list->tlb;
2935 diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
2936 index 296786b..a8d4dd5 100644
2937 --- a/arch/arm/kernel/signal.c
2938 +++ b/arch/arm/kernel/signal.c
2939 @@ -396,22 +396,14 @@ setup_return(struct pt_regs *regs, struct ksignal *ksig,
2940 __put_user(sigreturn_codes[idx+1], rc+1))
2941 return 1;
2942
2943 - if (cpsr & MODE32_BIT) {
2944 - /*
2945 - * 32-bit code can use the new high-page
2946 - * signal return code support.
2947 - */
2948 - retcode = KERN_SIGRETURN_CODE + (idx << 2) + thumb;
2949 - } else {
2950 - /*
2951 - * Ensure that the instruction cache sees
2952 - * the return code written onto the stack.
2953 - */
2954 - flush_icache_range((unsigned long)rc,
2955 - (unsigned long)(rc + 2));
2956 + /*
2957 + * Ensure that the instruction cache sees
2958 + * the return code written onto the stack.
2959 + */
2960 + flush_icache_range((unsigned long)rc,
2961 + (unsigned long)(rc + 2));
2962
2963 - retcode = ((unsigned long)rc) + thumb;
2964 - }
2965 + retcode = ((unsigned long)rc) + thumb;
2966 }
2967
2968 regs->ARM_r0 = map_sig(ksig->sig);
2969 diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
2970 index 1f2cccc..f40c02e 100644
2971 --- a/arch/arm/kernel/smp.c
2972 +++ b/arch/arm/kernel/smp.c
2973 @@ -70,7 +70,7 @@ enum ipi_msg_type {
2974
2975 static DECLARE_COMPLETION(cpu_running);
2976
2977 -static struct smp_operations smp_ops;
2978 +static struct smp_operations smp_ops __read_only;
2979
2980 void __init smp_set_ops(struct smp_operations *ops)
2981 {
2982 diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
2983 index 1c08911..264f009 100644
2984 --- a/arch/arm/kernel/traps.c
2985 +++ b/arch/arm/kernel/traps.c
2986 @@ -57,7 +57,7 @@ static void dump_mem(const char *, const char *, unsigned long, unsigned long);
2987 void dump_backtrace_entry(unsigned long where, unsigned long from, unsigned long frame)
2988 {
2989 #ifdef CONFIG_KALLSYMS
2990 - printk("[<%08lx>] (%pS) from [<%08lx>] (%pS)\n", where, (void *)where, from, (void *)from);
2991 + printk("[<%08lx>] (%pA) from [<%08lx>] (%pA)\n", where, (void *)where, from, (void *)from);
2992 #else
2993 printk("Function entered at [<%08lx>] from [<%08lx>]\n", where, from);
2994 #endif
2995 @@ -266,6 +266,8 @@ static arch_spinlock_t die_lock = __ARCH_SPIN_LOCK_UNLOCKED;
2996 static int die_owner = -1;
2997 static unsigned int die_nest_count;
2998
2999 +extern void gr_handle_kernel_exploit(void);
3000 +
3001 static unsigned long oops_begin(void)
3002 {
3003 int cpu;
3004 @@ -308,6 +310,9 @@ static void oops_end(unsigned long flags, struct pt_regs *regs, int signr)
3005 panic("Fatal exception in interrupt");
3006 if (panic_on_oops)
3007 panic("Fatal exception");
3008 +
3009 + gr_handle_kernel_exploit();
3010 +
3011 if (signr)
3012 do_exit(signr);
3013 }
3014 @@ -601,7 +606,9 @@ asmlinkage int arm_syscall(int no, struct pt_regs *regs)
3015 * The user helper at 0xffff0fe0 must be used instead.
3016 * (see entry-armv.S for details)
3017 */
3018 + pax_open_kernel();
3019 *((unsigned int *)0xffff0ff0) = regs->ARM_r0;
3020 + pax_close_kernel();
3021 }
3022 return 0;
3023
3024 @@ -841,13 +848,10 @@ void __init early_trap_init(void *vectors_base)
3025 */
3026 kuser_get_tls_init(vectors);
3027
3028 - /*
3029 - * Copy signal return handlers into the vector page, and
3030 - * set sigreturn to be a pointer to these.
3031 - */
3032 - memcpy((void *)(vectors + KERN_SIGRETURN_CODE - CONFIG_VECTORS_BASE),
3033 - sigreturn_codes, sizeof(sigreturn_codes));
3034 -
3035 flush_icache_range(vectors, vectors + PAGE_SIZE);
3036 - modify_domain(DOMAIN_USER, DOMAIN_CLIENT);
3037 +
3038 +#ifndef CONFIG_PAX_MEMORY_UDEREF
3039 + modify_domain(DOMAIN_USER, DOMAIN_USERCLIENT);
3040 +#endif
3041 +
3042 }
3043 diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
3044 index b571484..4b2fc9b 100644
3045 --- a/arch/arm/kernel/vmlinux.lds.S
3046 +++ b/arch/arm/kernel/vmlinux.lds.S
3047 @@ -8,7 +8,11 @@
3048 #include <asm/thread_info.h>
3049 #include <asm/memory.h>
3050 #include <asm/page.h>
3051 -
3052 +
3053 +#ifdef CONFIG_PAX_KERNEXEC
3054 +#include <asm/pgtable.h>
3055 +#endif
3056 +
3057 #define PROC_INFO \
3058 . = ALIGN(4); \
3059 VMLINUX_SYMBOL(__proc_info_begin) = .; \
3060 @@ -94,6 +98,11 @@ SECTIONS
3061 _text = .;
3062 HEAD_TEXT
3063 }
3064 +
3065 +#ifdef CONFIG_PAX_KERNEXEC
3066 + . = ALIGN(1<<SECTION_SHIFT);
3067 +#endif
3068 +
3069 .text : { /* Real text segment */
3070 _stext = .; /* Text and read-only data */
3071 __exception_text_start = .;
3072 @@ -116,6 +125,8 @@ SECTIONS
3073 ARM_CPU_KEEP(PROC_INFO)
3074 }
3075
3076 + _etext = .; /* End of text section */
3077 +
3078 RO_DATA(PAGE_SIZE)
3079
3080 . = ALIGN(4);
3081 @@ -146,7 +157,9 @@ SECTIONS
3082
3083 NOTES
3084
3085 - _etext = .; /* End of text and rodata section */
3086 +#ifdef CONFIG_PAX_KERNEXEC
3087 + . = ALIGN(1<<SECTION_SHIFT);
3088 +#endif
3089
3090 #ifndef CONFIG_XIP_KERNEL
3091 . = ALIGN(PAGE_SIZE);
3092 @@ -207,6 +220,11 @@ SECTIONS
3093 . = PAGE_OFFSET + TEXT_OFFSET;
3094 #else
3095 __init_end = .;
3096 +
3097 +#ifdef CONFIG_PAX_KERNEXEC
3098 + . = ALIGN(1<<SECTION_SHIFT);
3099 +#endif
3100 +
3101 . = ALIGN(THREAD_SIZE);
3102 __data_loc = .;
3103 #endif
3104 diff --git a/arch/arm/lib/clear_user.S b/arch/arm/lib/clear_user.S
3105 index 14a0d98..7771a7d 100644
3106 --- a/arch/arm/lib/clear_user.S
3107 +++ b/arch/arm/lib/clear_user.S
3108 @@ -12,14 +12,14 @@
3109
3110 .text
3111
3112 -/* Prototype: int __clear_user(void *addr, size_t sz)
3113 +/* Prototype: int ___clear_user(void *addr, size_t sz)
3114 * Purpose : clear some user memory
3115 * Params : addr - user memory address to clear
3116 * : sz - number of bytes to clear
3117 * Returns : number of bytes NOT cleared
3118 */
3119 ENTRY(__clear_user_std)
3120 -WEAK(__clear_user)
3121 +WEAK(___clear_user)
3122 stmfd sp!, {r1, lr}
3123 mov r2, #0
3124 cmp r1, #4
3125 @@ -44,7 +44,7 @@ WEAK(__clear_user)
3126 USER( strnebt r2, [r0])
3127 mov r0, #0
3128 ldmfd sp!, {r1, pc}
3129 -ENDPROC(__clear_user)
3130 +ENDPROC(___clear_user)
3131 ENDPROC(__clear_user_std)
3132
3133 .pushsection .fixup,"ax"
3134 diff --git a/arch/arm/lib/copy_from_user.S b/arch/arm/lib/copy_from_user.S
3135 index 66a477a..bee61d3 100644
3136 --- a/arch/arm/lib/copy_from_user.S
3137 +++ b/arch/arm/lib/copy_from_user.S
3138 @@ -16,7 +16,7 @@
3139 /*
3140 * Prototype:
3141 *
3142 - * size_t __copy_from_user(void *to, const void *from, size_t n)
3143 + * size_t ___copy_from_user(void *to, const void *from, size_t n)
3144 *
3145 * Purpose:
3146 *
3147 @@ -84,11 +84,11 @@
3148
3149 .text
3150
3151 -ENTRY(__copy_from_user)
3152 +ENTRY(___copy_from_user)
3153
3154 #include "copy_template.S"
3155
3156 -ENDPROC(__copy_from_user)
3157 +ENDPROC(___copy_from_user)
3158
3159 .pushsection .fixup,"ax"
3160 .align 0
3161 diff --git a/arch/arm/lib/copy_page.S b/arch/arm/lib/copy_page.S
3162 index 6ee2f67..d1cce76 100644
3163 --- a/arch/arm/lib/copy_page.S
3164 +++ b/arch/arm/lib/copy_page.S
3165 @@ -10,6 +10,7 @@
3166 * ASM optimised string functions
3167 */
3168 #include <linux/linkage.h>
3169 +#include <linux/const.h>
3170 #include <asm/assembler.h>
3171 #include <asm/asm-offsets.h>
3172 #include <asm/cache.h>
3173 diff --git a/arch/arm/lib/copy_to_user.S b/arch/arm/lib/copy_to_user.S
3174 index d066df6..df28194 100644
3175 --- a/arch/arm/lib/copy_to_user.S
3176 +++ b/arch/arm/lib/copy_to_user.S
3177 @@ -16,7 +16,7 @@
3178 /*
3179 * Prototype:
3180 *
3181 - * size_t __copy_to_user(void *to, const void *from, size_t n)
3182 + * size_t ___copy_to_user(void *to, const void *from, size_t n)
3183 *
3184 * Purpose:
3185 *
3186 @@ -88,11 +88,11 @@
3187 .text
3188
3189 ENTRY(__copy_to_user_std)
3190 -WEAK(__copy_to_user)
3191 +WEAK(___copy_to_user)
3192
3193 #include "copy_template.S"
3194
3195 -ENDPROC(__copy_to_user)
3196 +ENDPROC(___copy_to_user)
3197 ENDPROC(__copy_to_user_std)
3198
3199 .pushsection .fixup,"ax"
3200 diff --git a/arch/arm/lib/csumpartialcopyuser.S b/arch/arm/lib/csumpartialcopyuser.S
3201 index 7d08b43..f7ca7ea 100644
3202 --- a/arch/arm/lib/csumpartialcopyuser.S
3203 +++ b/arch/arm/lib/csumpartialcopyuser.S
3204 @@ -57,8 +57,8 @@
3205 * Returns : r0 = checksum, [[sp, #0], #0] = 0 or -EFAULT
3206 */
3207
3208 -#define FN_ENTRY ENTRY(csum_partial_copy_from_user)
3209 -#define FN_EXIT ENDPROC(csum_partial_copy_from_user)
3210 +#define FN_ENTRY ENTRY(__csum_partial_copy_from_user)
3211 +#define FN_EXIT ENDPROC(__csum_partial_copy_from_user)
3212
3213 #include "csumpartialcopygeneric.S"
3214
3215 diff --git a/arch/arm/lib/delay.c b/arch/arm/lib/delay.c
3216 index 64dbfa5..84a3fd9 100644
3217 --- a/arch/arm/lib/delay.c
3218 +++ b/arch/arm/lib/delay.c
3219 @@ -28,7 +28,7 @@
3220 /*
3221 * Default to the loop-based delay implementation.
3222 */
3223 -struct arm_delay_ops arm_delay_ops = {
3224 +struct arm_delay_ops arm_delay_ops __read_only = {
3225 .delay = __loop_delay,
3226 .const_udelay = __loop_const_udelay,
3227 .udelay = __loop_udelay,
3228 diff --git a/arch/arm/lib/uaccess_with_memcpy.c b/arch/arm/lib/uaccess_with_memcpy.c
3229 index 025f742..8432b08 100644
3230 --- a/arch/arm/lib/uaccess_with_memcpy.c
3231 +++ b/arch/arm/lib/uaccess_with_memcpy.c
3232 @@ -104,7 +104,7 @@ out:
3233 }
3234
3235 unsigned long
3236 -__copy_to_user(void __user *to, const void *from, unsigned long n)
3237 +___copy_to_user(void __user *to, const void *from, unsigned long n)
3238 {
3239 /*
3240 * This test is stubbed out of the main function above to keep
3241 diff --git a/arch/arm/mach-kirkwood/common.c b/arch/arm/mach-kirkwood/common.c
3242 index 49792a0..f192052 100644
3243 --- a/arch/arm/mach-kirkwood/common.c
3244 +++ b/arch/arm/mach-kirkwood/common.c
3245 @@ -150,7 +150,16 @@ static void clk_gate_fn_disable(struct clk_hw *hw)
3246 clk_gate_ops.disable(hw);
3247 }
3248
3249 -static struct clk_ops clk_gate_fn_ops;
3250 +static int clk_gate_fn_is_enabled(struct clk_hw *hw)
3251 +{
3252 + return clk_gate_ops.is_enabled(hw);
3253 +}
3254 +
3255 +static struct clk_ops clk_gate_fn_ops = {
3256 + .enable = clk_gate_fn_enable,
3257 + .disable = clk_gate_fn_disable,
3258 + .is_enabled = clk_gate_fn_is_enabled,
3259 +};
3260
3261 static struct clk __init *clk_register_gate_fn(struct device *dev,
3262 const char *name,
3263 @@ -184,14 +193,6 @@ static struct clk __init *clk_register_gate_fn(struct device *dev,
3264 gate_fn->fn_en = fn_en;
3265 gate_fn->fn_dis = fn_dis;
3266
3267 - /* ops is the gate ops, but with our enable/disable functions */
3268 - if (clk_gate_fn_ops.enable != clk_gate_fn_enable ||
3269 - clk_gate_fn_ops.disable != clk_gate_fn_disable) {
3270 - clk_gate_fn_ops = clk_gate_ops;
3271 - clk_gate_fn_ops.enable = clk_gate_fn_enable;
3272 - clk_gate_fn_ops.disable = clk_gate_fn_disable;
3273 - }
3274 -
3275 clk = clk_register(dev, &gate_fn->gate.hw);
3276
3277 if (IS_ERR(clk))
3278 diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
3279 index f6eeb87..cc90868 100644
3280 --- a/arch/arm/mach-omap2/board-n8x0.c
3281 +++ b/arch/arm/mach-omap2/board-n8x0.c
3282 @@ -631,7 +631,7 @@ static int n8x0_menelaus_late_init(struct device *dev)
3283 }
3284 #endif
3285
3286 -static struct menelaus_platform_data n8x0_menelaus_platform_data __initdata = {
3287 +static struct menelaus_platform_data n8x0_menelaus_platform_data __initconst = {
3288 .late_init = n8x0_menelaus_late_init,
3289 };
3290
3291 diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
3292 index 410e1ba..1d2dd59 100644
3293 --- a/arch/arm/mach-omap2/gpmc.c
3294 +++ b/arch/arm/mach-omap2/gpmc.c
3295 @@ -145,7 +145,6 @@ struct omap3_gpmc_regs {
3296 };
3297
3298 static struct gpmc_client_irq gpmc_client_irq[GPMC_NR_IRQ];
3299 -static struct irq_chip gpmc_irq_chip;
3300 static unsigned gpmc_irq_start;
3301
3302 static struct resource gpmc_mem_root;
3303 @@ -707,6 +706,18 @@ static void gpmc_irq_noop(struct irq_data *data) { }
3304
3305 static unsigned int gpmc_irq_noop_ret(struct irq_data *data) { return 0; }
3306
3307 +static struct irq_chip gpmc_irq_chip = {
3308 + .name = "gpmc",
3309 + .irq_startup = gpmc_irq_noop_ret,
3310 + .irq_enable = gpmc_irq_enable,
3311 + .irq_disable = gpmc_irq_disable,
3312 + .irq_shutdown = gpmc_irq_noop,
3313 + .irq_ack = gpmc_irq_noop,
3314 + .irq_mask = gpmc_irq_noop,
3315 + .irq_unmask = gpmc_irq_noop,
3316 +
3317 +};
3318 +
3319 static int gpmc_setup_irq(void)
3320 {
3321 int i;
3322 @@ -721,15 +732,6 @@ static int gpmc_setup_irq(void)
3323 return gpmc_irq_start;
3324 }
3325
3326 - gpmc_irq_chip.name = "gpmc";
3327 - gpmc_irq_chip.irq_startup = gpmc_irq_noop_ret;
3328 - gpmc_irq_chip.irq_enable = gpmc_irq_enable;
3329 - gpmc_irq_chip.irq_disable = gpmc_irq_disable;
3330 - gpmc_irq_chip.irq_shutdown = gpmc_irq_noop;
3331 - gpmc_irq_chip.irq_ack = gpmc_irq_noop;
3332 - gpmc_irq_chip.irq_mask = gpmc_irq_noop;
3333 - gpmc_irq_chip.irq_unmask = gpmc_irq_noop;
3334 -
3335 gpmc_client_irq[0].bitmask = GPMC_IRQ_FIFOEVENTENABLE;
3336 gpmc_client_irq[1].bitmask = GPMC_IRQ_COUNT_EVENT;
3337
3338 diff --git a/arch/arm/mach-omap2/omap-wakeupgen.c b/arch/arm/mach-omap2/omap-wakeupgen.c
3339 index f8bb3b9..831e7b8 100644
3340 --- a/arch/arm/mach-omap2/omap-wakeupgen.c
3341 +++ b/arch/arm/mach-omap2/omap-wakeupgen.c
3342 @@ -339,7 +339,7 @@ static int __cpuinit irq_cpu_hotplug_notify(struct notifier_block *self,
3343 return NOTIFY_OK;
3344 }
3345
3346 -static struct notifier_block __refdata irq_hotplug_notifier = {
3347 +static struct notifier_block irq_hotplug_notifier = {
3348 .notifier_call = irq_cpu_hotplug_notify,
3349 };
3350
3351 diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c
3352 index 381be7a..89b9c7e 100644
3353 --- a/arch/arm/mach-omap2/omap_device.c
3354 +++ b/arch/arm/mach-omap2/omap_device.c
3355 @@ -499,7 +499,7 @@ void omap_device_delete(struct omap_device *od)
3356 struct platform_device __init *omap_device_build(const char *pdev_name,
3357 int pdev_id,
3358 struct omap_hwmod *oh,
3359 - void *pdata, int pdata_len)
3360 + const void *pdata, int pdata_len)
3361 {
3362 struct omap_hwmod *ohs[] = { oh };
3363
3364 @@ -527,7 +527,7 @@ struct platform_device __init *omap_device_build(const char *pdev_name,
3365 struct platform_device __init *omap_device_build_ss(const char *pdev_name,
3366 int pdev_id,
3367 struct omap_hwmod **ohs,
3368 - int oh_cnt, void *pdata,
3369 + int oh_cnt, const void *pdata,
3370 int pdata_len)
3371 {
3372 int ret = -ENOMEM;
3373 diff --git a/arch/arm/mach-omap2/omap_device.h b/arch/arm/mach-omap2/omap_device.h
3374 index 044c31d..2ee0861 100644
3375 --- a/arch/arm/mach-omap2/omap_device.h
3376 +++ b/arch/arm/mach-omap2/omap_device.h
3377 @@ -72,12 +72,12 @@ int omap_device_idle(struct platform_device *pdev);
3378 /* Core code interface */
3379
3380 struct platform_device *omap_device_build(const char *pdev_name, int pdev_id,
3381 - struct omap_hwmod *oh, void *pdata,
3382 + struct omap_hwmod *oh, const void *pdata,
3383 int pdata_len);
3384
3385 struct platform_device *omap_device_build_ss(const char *pdev_name, int pdev_id,
3386 struct omap_hwmod **oh, int oh_cnt,
3387 - void *pdata, int pdata_len);
3388 + const void *pdata, int pdata_len);
3389
3390 struct omap_device *omap_device_alloc(struct platform_device *pdev,
3391 struct omap_hwmod **ohs, int oh_cnt);
3392 diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
3393 index a202a47..c430564 100644
3394 --- a/arch/arm/mach-omap2/omap_hwmod.c
3395 +++ b/arch/arm/mach-omap2/omap_hwmod.c
3396 @@ -191,10 +191,10 @@ struct omap_hwmod_soc_ops {
3397 int (*init_clkdm)(struct omap_hwmod *oh);
3398 void (*update_context_lost)(struct omap_hwmod *oh);
3399 int (*get_context_lost)(struct omap_hwmod *oh);
3400 -};
3401 +} __no_const;
3402
3403 /* soc_ops: adapts the omap_hwmod code to the currently-booted SoC */
3404 -static struct omap_hwmod_soc_ops soc_ops;
3405 +static struct omap_hwmod_soc_ops soc_ops __read_only;
3406
3407 /* omap_hwmod_list contains all registered struct omap_hwmods */
3408 static LIST_HEAD(omap_hwmod_list);
3409 diff --git a/arch/arm/mach-omap2/wd_timer.c b/arch/arm/mach-omap2/wd_timer.c
3410 index d15c7bb..b2d1f0c 100644
3411 --- a/arch/arm/mach-omap2/wd_timer.c
3412 +++ b/arch/arm/mach-omap2/wd_timer.c
3413 @@ -110,7 +110,9 @@ static int __init omap_init_wdt(void)
3414 struct omap_hwmod *oh;
3415 char *oh_name = "wd_timer2";
3416 char *dev_name = "omap_wdt";
3417 - struct omap_wd_timer_platform_data pdata;
3418 + static struct omap_wd_timer_platform_data pdata = {
3419 + .read_reset_sources = prm_read_reset_sources
3420 + };
3421
3422 if (!cpu_class_is_omap2() || of_have_populated_dt())
3423 return 0;
3424 @@ -121,8 +123,6 @@ static int __init omap_init_wdt(void)
3425 return -EINVAL;
3426 }
3427
3428 - pdata.read_reset_sources = prm_read_reset_sources;
3429 -
3430 pdev = omap_device_build(dev_name, id, oh, &pdata,
3431 sizeof(struct omap_wd_timer_platform_data));
3432 WARN(IS_ERR(pdev), "Can't build omap_device for %s:%s.\n",
3433 diff --git a/arch/arm/mach-ux500/include/mach/setup.h b/arch/arm/mach-ux500/include/mach/setup.h
3434 index bddce2b..3eb04e2 100644
3435 --- a/arch/arm/mach-ux500/include/mach/setup.h
3436 +++ b/arch/arm/mach-ux500/include/mach/setup.h
3437 @@ -37,13 +37,6 @@ extern void ux500_timer_init(void);
3438 .type = MT_DEVICE, \
3439 }
3440
3441 -#define __MEM_DEV_DESC(x, sz) { \
3442 - .virtual = IO_ADDRESS(x), \
3443 - .pfn = __phys_to_pfn(x), \
3444 - .length = sz, \
3445 - .type = MT_MEMORY, \
3446 -}
3447 -
3448 extern struct smp_operations ux500_smp_ops;
3449 extern void ux500_cpu_die(unsigned int cpu);
3450
3451 diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
3452 index 4045c49..4e26c79 100644
3453 --- a/arch/arm/mm/Kconfig
3454 +++ b/arch/arm/mm/Kconfig
3455 @@ -425,7 +425,7 @@ config CPU_32v5
3456
3457 config CPU_32v6
3458 bool
3459 - select CPU_USE_DOMAINS if CPU_V6 && MMU
3460 + select CPU_USE_DOMAINS if CPU_V6 && MMU && !PAX_KERNEXEC
3461 select TLS_REG_EMUL if !CPU_32v6K && !MMU
3462
3463 config CPU_32v6K
3464 @@ -574,6 +574,7 @@ config CPU_CP15_MPU
3465
3466 config CPU_USE_DOMAINS
3467 bool
3468 + depends on !ARM_LPAE && !PAX_KERNEXEC
3469 help
3470 This option enables or disables the use of domain switching
3471 via the set_fs() function.
3472 diff --git a/arch/arm/mm/alignment.c b/arch/arm/mm/alignment.c
3473 index db26e2e..ee44569 100644
3474 --- a/arch/arm/mm/alignment.c
3475 +++ b/arch/arm/mm/alignment.c
3476 @@ -211,10 +211,12 @@ union offset_union {
3477 #define __get16_unaligned_check(ins,val,addr) \
3478 do { \
3479 unsigned int err = 0, v, a = addr; \
3480 + pax_open_userland(); \
3481 __get8_unaligned_check(ins,v,a,err); \
3482 val = v << ((BE) ? 8 : 0); \
3483 __get8_unaligned_check(ins,v,a,err); \
3484 val |= v << ((BE) ? 0 : 8); \
3485 + pax_close_userland(); \
3486 if (err) \
3487 goto fault; \
3488 } while (0)
3489 @@ -228,6 +230,7 @@ union offset_union {
3490 #define __get32_unaligned_check(ins,val,addr) \
3491 do { \
3492 unsigned int err = 0, v, a = addr; \
3493 + pax_open_userland(); \
3494 __get8_unaligned_check(ins,v,a,err); \
3495 val = v << ((BE) ? 24 : 0); \
3496 __get8_unaligned_check(ins,v,a,err); \
3497 @@ -236,6 +239,7 @@ union offset_union {
3498 val |= v << ((BE) ? 8 : 16); \
3499 __get8_unaligned_check(ins,v,a,err); \
3500 val |= v << ((BE) ? 0 : 24); \
3501 + pax_close_userland(); \
3502 if (err) \
3503 goto fault; \
3504 } while (0)
3505 @@ -249,6 +253,7 @@ union offset_union {
3506 #define __put16_unaligned_check(ins,val,addr) \
3507 do { \
3508 unsigned int err = 0, v = val, a = addr; \
3509 + pax_open_userland(); \
3510 __asm__( FIRST_BYTE_16 \
3511 ARM( "1: "ins" %1, [%2], #1\n" ) \
3512 THUMB( "1: "ins" %1, [%2]\n" ) \
3513 @@ -268,6 +273,7 @@ union offset_union {
3514 " .popsection\n" \
3515 : "=r" (err), "=&r" (v), "=&r" (a) \
3516 : "0" (err), "1" (v), "2" (a)); \
3517 + pax_close_userland(); \
3518 if (err) \
3519 goto fault; \
3520 } while (0)
3521 @@ -281,6 +287,7 @@ union offset_union {
3522 #define __put32_unaligned_check(ins,val,addr) \
3523 do { \
3524 unsigned int err = 0, v = val, a = addr; \
3525 + pax_open_userland(); \
3526 __asm__( FIRST_BYTE_32 \
3527 ARM( "1: "ins" %1, [%2], #1\n" ) \
3528 THUMB( "1: "ins" %1, [%2]\n" ) \
3529 @@ -310,6 +317,7 @@ union offset_union {
3530 " .popsection\n" \
3531 : "=r" (err), "=&r" (v), "=&r" (a) \
3532 : "0" (err), "1" (v), "2" (a)); \
3533 + pax_close_userland(); \
3534 if (err) \
3535 goto fault; \
3536 } while (0)
3537 diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
3538 index 5dbf13f..1a60561 100644
3539 --- a/arch/arm/mm/fault.c
3540 +++ b/arch/arm/mm/fault.c
3541 @@ -25,6 +25,7 @@
3542 #include <asm/system_misc.h>
3543 #include <asm/system_info.h>
3544 #include <asm/tlbflush.h>
3545 +#include <asm/sections.h>
3546
3547 #include "fault.h"
3548
3549 @@ -138,6 +139,20 @@ __do_kernel_fault(struct mm_struct *mm, unsigned long addr, unsigned int fsr,
3550 if (fixup_exception(regs))
3551 return;
3552
3553 +#ifdef CONFIG_PAX_KERNEXEC
3554 + if ((fsr & FSR_WRITE) &&
3555 + (((unsigned long)_stext <= addr && addr < init_mm.end_code) ||
3556 + (MODULES_VADDR <= addr && addr < MODULES_END)))
3557 + {
3558 + if (current->signal->curr_ip)
3559 + 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),
3560 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3561 + else
3562 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
3563 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3564 + }
3565 +#endif
3566 +
3567 /*
3568 * No handler, we'll have to terminate things with extreme prejudice.
3569 */
3570 @@ -174,6 +189,13 @@ __do_user_fault(struct task_struct *tsk, unsigned long addr,
3571 }
3572 #endif
3573
3574 +#ifdef CONFIG_PAX_PAGEEXEC
3575 + if (fsr & FSR_LNX_PF) {
3576 + pax_report_fault(regs, (void *)regs->ARM_pc, (void *)regs->ARM_sp);
3577 + do_group_exit(SIGKILL);
3578 + }
3579 +#endif
3580 +
3581 tsk->thread.address = addr;
3582 tsk->thread.error_code = fsr;
3583 tsk->thread.trap_no = 14;
3584 @@ -398,6 +420,33 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3585 }
3586 #endif /* CONFIG_MMU */
3587
3588 +#ifdef CONFIG_PAX_PAGEEXEC
3589 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
3590 +{
3591 + long i;
3592 +
3593 + printk(KERN_ERR "PAX: bytes at PC: ");
3594 + for (i = 0; i < 20; i++) {
3595 + unsigned char c;
3596 + if (get_user(c, (__force unsigned char __user *)pc+i))
3597 + printk(KERN_CONT "?? ");
3598 + else
3599 + printk(KERN_CONT "%02x ", c);
3600 + }
3601 + printk("\n");
3602 +
3603 + printk(KERN_ERR "PAX: bytes at SP-4: ");
3604 + for (i = -1; i < 20; i++) {
3605 + unsigned long c;
3606 + if (get_user(c, (__force unsigned long __user *)sp+i))
3607 + printk(KERN_CONT "???????? ");
3608 + else
3609 + printk(KERN_CONT "%08lx ", c);
3610 + }
3611 + printk("\n");
3612 +}
3613 +#endif
3614 +
3615 /*
3616 * First Level Translation Fault Handler
3617 *
3618 @@ -543,9 +592,22 @@ do_DataAbort(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3619 const struct fsr_info *inf = fsr_info + fsr_fs(fsr);
3620 struct siginfo info;
3621
3622 +#ifdef CONFIG_PAX_MEMORY_UDEREF
3623 + if (addr < TASK_SIZE && is_domain_fault(fsr)) {
3624 + if (current->signal->curr_ip)
3625 + 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),
3626 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3627 + else
3628 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", current->comm, task_pid_nr(current),
3629 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3630 + goto die;
3631 + }
3632 +#endif
3633 +
3634 if (!inf->fn(addr, fsr & ~FSR_LNX_PF, regs))
3635 return;
3636
3637 +die:
3638 printk(KERN_ALERT "Unhandled fault: %s (0x%03x) at 0x%08lx\n",
3639 inf->name, fsr, addr);
3640
3641 @@ -575,9 +637,49 @@ do_PrefetchAbort(unsigned long addr, unsigned int ifsr, struct pt_regs *regs)
3642 const struct fsr_info *inf = ifsr_info + fsr_fs(ifsr);
3643 struct siginfo info;
3644
3645 + if (user_mode(regs)) {
3646 + if (addr == 0xffff0fe0UL) {
3647 + /*
3648 + * PaX: __kuser_get_tls emulation
3649 + */
3650 + regs->ARM_r0 = current_thread_info()->tp_value;
3651 + regs->ARM_pc = regs->ARM_lr;
3652 + return;
3653 + }
3654 + }
3655 +
3656 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
3657 + else if (is_domain_fault(ifsr) || is_xn_fault(ifsr)) {
3658 + if (current->signal->curr_ip)
3659 + 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),
3660 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3661 + addr >= TASK_SIZE ? "non-executable kernel" : "userland", addr);
3662 + else
3663 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to execute %s memory at %08lx\n", current->comm, task_pid_nr(current),
3664 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3665 + addr >= TASK_SIZE ? "non-executable kernel" : "userland", addr);
3666 + goto die;
3667 + }
3668 +#endif
3669 +
3670 +#ifdef CONFIG_PAX_REFCOUNT
3671 + if (fsr_fs(ifsr) == FAULT_CODE_DEBUG) {
3672 + unsigned int bkpt;
3673 +
3674 + if (!probe_kernel_address((unsigned int *)addr, bkpt) && bkpt == 0xe12f1073) {
3675 + current->thread.error_code = ifsr;
3676 + current->thread.trap_no = 0;
3677 + pax_report_refcount_overflow(regs);
3678 + fixup_exception(regs);
3679 + return;
3680 + }
3681 + }
3682 +#endif
3683 +
3684 if (!inf->fn(addr, ifsr | FSR_LNX_PF, regs))
3685 return;
3686
3687 +die:
3688 printk(KERN_ALERT "Unhandled prefetch abort: %s (0x%03x) at 0x%08lx\n",
3689 inf->name, ifsr, addr);
3690
3691 diff --git a/arch/arm/mm/fault.h b/arch/arm/mm/fault.h
3692 index cf08bdf..772656c 100644
3693 --- a/arch/arm/mm/fault.h
3694 +++ b/arch/arm/mm/fault.h
3695 @@ -3,6 +3,7 @@
3696
3697 /*
3698 * Fault status register encodings. We steal bit 31 for our own purposes.
3699 + * Set when the FSR value is from an instruction fault.
3700 */
3701 #define FSR_LNX_PF (1 << 31)
3702 #define FSR_WRITE (1 << 11)
3703 @@ -22,6 +23,17 @@ static inline int fsr_fs(unsigned int fsr)
3704 }
3705 #endif
3706
3707 +/* valid for LPAE and !LPAE */
3708 +static inline int is_xn_fault(unsigned int fsr)
3709 +{
3710 + return ((fsr_fs(fsr) & 0x3c) == 0xc);
3711 +}
3712 +
3713 +static inline int is_domain_fault(unsigned int fsr)
3714 +{
3715 + return ((fsr_fs(fsr) & 0xD) == 0x9);
3716 +}
3717 +
3718 void do_bad_area(unsigned long addr, unsigned int fsr, struct pt_regs *regs);
3719 unsigned long search_exception_table(unsigned long addr);
3720
3721 diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
3722 index ad722f1..763fdd3 100644
3723 --- a/arch/arm/mm/init.c
3724 +++ b/arch/arm/mm/init.c
3725 @@ -30,6 +30,8 @@
3726 #include <asm/setup.h>
3727 #include <asm/tlb.h>
3728 #include <asm/fixmap.h>
3729 +#include <asm/system_info.h>
3730 +#include <asm/cp15.h>
3731
3732 #include <asm/mach/arch.h>
3733 #include <asm/mach/map.h>
3734 @@ -736,7 +738,46 @@ void free_initmem(void)
3735 {
3736 #ifdef CONFIG_HAVE_TCM
3737 extern char __tcm_start, __tcm_end;
3738 +#endif
3739
3740 +#ifdef CONFIG_PAX_KERNEXEC
3741 + unsigned long addr;
3742 + pgd_t *pgd;
3743 + pud_t *pud;
3744 + pmd_t *pmd;
3745 + int cpu_arch = cpu_architecture();
3746 + unsigned int cr = get_cr();
3747 +
3748 + if (cpu_arch >= CPU_ARCH_ARMv6 && (cr & CR_XP)) {
3749 + /* make pages tables, etc before .text NX */
3750 + for (addr = PAGE_OFFSET; addr < (unsigned long)_stext; addr += SECTION_SIZE) {
3751 + pgd = pgd_offset_k(addr);
3752 + pud = pud_offset(pgd, addr);
3753 + pmd = pmd_offset(pud, addr);
3754 + __section_update(pmd, addr, PMD_SECT_XN);
3755 + }
3756 + /* make init NX */
3757 + for (addr = (unsigned long)__init_begin; addr < (unsigned long)_sdata; addr += SECTION_SIZE) {
3758 + pgd = pgd_offset_k(addr);
3759 + pud = pud_offset(pgd, addr);
3760 + pmd = pmd_offset(pud, addr);
3761 + __section_update(pmd, addr, PMD_SECT_XN);
3762 + }
3763 + /* make kernel code/rodata RX */
3764 + for (addr = (unsigned long)_stext; addr < (unsigned long)__init_begin; addr += SECTION_SIZE) {
3765 + pgd = pgd_offset_k(addr);
3766 + pud = pud_offset(pgd, addr);
3767 + pmd = pmd_offset(pud, addr);
3768 +#ifdef CONFIG_ARM_LPAE
3769 + __section_update(pmd, addr, PMD_SECT_RDONLY);
3770 +#else
3771 + __section_update(pmd, addr, PMD_SECT_APX|PMD_SECT_AP_WRITE);
3772 +#endif
3773 + }
3774 + }
3775 +#endif
3776 +
3777 +#ifdef CONFIG_HAVE_TCM
3778 poison_init_mem(&__tcm_start, &__tcm_end - &__tcm_start);
3779 totalram_pages += free_area(__phys_to_pfn(__pa(&__tcm_start)),
3780 __phys_to_pfn(__pa(&__tcm_end)),
3781 diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
3782 index 04d9006..c547d85 100644
3783 --- a/arch/arm/mm/ioremap.c
3784 +++ b/arch/arm/mm/ioremap.c
3785 @@ -392,9 +392,9 @@ __arm_ioremap_exec(unsigned long phys_addr, size_t size, bool cached)
3786 unsigned int mtype;
3787
3788 if (cached)
3789 - mtype = MT_MEMORY;
3790 + mtype = MT_MEMORY_RX;
3791 else
3792 - mtype = MT_MEMORY_NONCACHED;
3793 + mtype = MT_MEMORY_NONCACHED_RX;
3794
3795 return __arm_ioremap_caller(phys_addr, size, mtype,
3796 __builtin_return_address(0));
3797 diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c
3798 index 10062ce..cd34fb9 100644
3799 --- a/arch/arm/mm/mmap.c
3800 +++ b/arch/arm/mm/mmap.c
3801 @@ -59,6 +59,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
3802 struct vm_area_struct *vma;
3803 int do_align = 0;
3804 int aliasing = cache_is_vipt_aliasing();
3805 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
3806 struct vm_unmapped_area_info info;
3807
3808 /*
3809 @@ -81,6 +82,10 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
3810 if (len > TASK_SIZE)
3811 return -ENOMEM;
3812
3813 +#ifdef CONFIG_PAX_RANDMMAP
3814 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
3815 +#endif
3816 +
3817 if (addr) {
3818 if (do_align)
3819 addr = COLOUR_ALIGN(addr, pgoff);
3820 @@ -88,8 +93,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
3821 addr = PAGE_ALIGN(addr);
3822
3823 vma = find_vma(mm, addr);
3824 - if (TASK_SIZE - len >= addr &&
3825 - (!vma || addr + len <= vma->vm_start))
3826 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
3827 return addr;
3828 }
3829
3830 @@ -99,6 +103,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
3831 info.high_limit = TASK_SIZE;
3832 info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
3833 info.align_offset = pgoff << PAGE_SHIFT;
3834 + info.threadstack_offset = offset;
3835 return vm_unmapped_area(&info);
3836 }
3837
3838 @@ -112,6 +117,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
3839 unsigned long addr = addr0;
3840 int do_align = 0;
3841 int aliasing = cache_is_vipt_aliasing();
3842 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
3843 struct vm_unmapped_area_info info;
3844
3845 /*
3846 @@ -132,6 +138,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
3847 return addr;
3848 }
3849
3850 +#ifdef CONFIG_PAX_RANDMMAP
3851 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
3852 +#endif
3853 +
3854 /* requesting a specific address */
3855 if (addr) {
3856 if (do_align)
3857 @@ -139,8 +149,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
3858 else
3859 addr = PAGE_ALIGN(addr);
3860 vma = find_vma(mm, addr);
3861 - if (TASK_SIZE - len >= addr &&
3862 - (!vma || addr + len <= vma->vm_start))
3863 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
3864 return addr;
3865 }
3866
3867 @@ -150,6 +159,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
3868 info.high_limit = mm->mmap_base;
3869 info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
3870 info.align_offset = pgoff << PAGE_SHIFT;
3871 + info.threadstack_offset = offset;
3872 addr = vm_unmapped_area(&info);
3873
3874 /*
3875 @@ -162,6 +172,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
3876 VM_BUG_ON(addr != -ENOMEM);
3877 info.flags = 0;
3878 info.low_limit = mm->mmap_base;
3879 +
3880 +#ifdef CONFIG_PAX_RANDMMAP
3881 + if (mm->pax_flags & MF_PAX_RANDMMAP)
3882 + info.low_limit += mm->delta_mmap;
3883 +#endif
3884 +
3885 info.high_limit = TASK_SIZE;
3886 addr = vm_unmapped_area(&info);
3887 }
3888 @@ -173,6 +189,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
3889 {
3890 unsigned long random_factor = 0UL;
3891
3892 +#ifdef CONFIG_PAX_RANDMMAP
3893 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
3894 +#endif
3895 +
3896 /* 8 bits of randomness in 20 address space bits */
3897 if ((current->flags & PF_RANDOMIZE) &&
3898 !(current->personality & ADDR_NO_RANDOMIZE))
3899 @@ -180,10 +200,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
3900
3901 if (mmap_is_legacy()) {
3902 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
3903 +
3904 +#ifdef CONFIG_PAX_RANDMMAP
3905 + if (mm->pax_flags & MF_PAX_RANDMMAP)
3906 + mm->mmap_base += mm->delta_mmap;
3907 +#endif
3908 +
3909 mm->get_unmapped_area = arch_get_unmapped_area;
3910 mm->unmap_area = arch_unmap_area;
3911 } else {
3912 mm->mmap_base = mmap_base(random_factor);
3913 +
3914 +#ifdef CONFIG_PAX_RANDMMAP
3915 + if (mm->pax_flags & MF_PAX_RANDMMAP)
3916 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
3917 +#endif
3918 +
3919 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
3920 mm->unmap_area = arch_unmap_area_topdown;
3921 }
3922 diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
3923 index a84ff76..f221c1d 100644
3924 --- a/arch/arm/mm/mmu.c
3925 +++ b/arch/arm/mm/mmu.c
3926 @@ -36,6 +36,22 @@
3927 #include "mm.h"
3928 #include "tcm.h"
3929
3930 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
3931 +void modify_domain(unsigned int dom, unsigned int type)
3932 +{
3933 + struct thread_info *thread = current_thread_info();
3934 + unsigned int domain = thread->cpu_domain;
3935 + /*
3936 + * DOMAIN_MANAGER might be defined to some other value,
3937 + * use the arch-defined constant
3938 + */
3939 + domain &= ~domain_val(dom, 3);
3940 + thread->cpu_domain = domain | domain_val(dom, type);
3941 + set_domain(thread->cpu_domain);
3942 +}
3943 +EXPORT_SYMBOL(modify_domain);
3944 +#endif
3945 +
3946 /*
3947 * empty_zero_page is a special page that is used for
3948 * zero-initialized data and COW.
3949 @@ -211,10 +227,18 @@ void adjust_cr(unsigned long mask, unsigned long set)
3950 }
3951 #endif
3952
3953 -#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY|L_PTE_XN
3954 +#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY
3955 #define PROT_SECT_DEVICE PMD_TYPE_SECT|PMD_SECT_AP_WRITE
3956
3957 -static struct mem_type mem_types[] = {
3958 +#ifdef CONFIG_PAX_KERNEXEC
3959 +#define L_PTE_KERNEXEC L_PTE_RDONLY
3960 +#define PMD_SECT_KERNEXEC PMD_SECT_RDONLY
3961 +#else
3962 +#define L_PTE_KERNEXEC L_PTE_DIRTY
3963 +#define PMD_SECT_KERNEXEC PMD_SECT_AP_WRITE
3964 +#endif
3965 +
3966 +static struct mem_type mem_types[] __read_only = {
3967 [MT_DEVICE] = { /* Strongly ordered / ARMv6 shared device */
3968 .prot_pte = PROT_PTE_DEVICE | L_PTE_MT_DEV_SHARED |
3969 L_PTE_SHARED,
3970 @@ -243,16 +267,16 @@ static struct mem_type mem_types[] = {
3971 [MT_UNCACHED] = {
3972 .prot_pte = PROT_PTE_DEVICE,
3973 .prot_l1 = PMD_TYPE_TABLE,
3974 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
3975 + .prot_sect = PROT_SECT_DEVICE,
3976 .domain = DOMAIN_IO,
3977 },
3978 [MT_CACHECLEAN] = {
3979 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
3980 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
3981 .domain = DOMAIN_KERNEL,
3982 },
3983 #ifndef CONFIG_ARM_LPAE
3984 [MT_MINICLEAN] = {
3985 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN | PMD_SECT_MINICACHE,
3986 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_MINICACHE | PMD_SECT_RDONLY,
3987 .domain = DOMAIN_KERNEL,
3988 },
3989 #endif
3990 @@ -260,36 +284,54 @@ static struct mem_type mem_types[] = {
3991 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
3992 L_PTE_RDONLY,
3993 .prot_l1 = PMD_TYPE_TABLE,
3994 - .domain = DOMAIN_USER,
3995 + .domain = DOMAIN_VECTORS,
3996 },
3997 [MT_HIGH_VECTORS] = {
3998 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
3999 - L_PTE_USER | L_PTE_RDONLY,
4000 + L_PTE_RDONLY,
4001 .prot_l1 = PMD_TYPE_TABLE,
4002 - .domain = DOMAIN_USER,
4003 + .domain = DOMAIN_VECTORS,
4004 },
4005 - [MT_MEMORY] = {
4006 + [MT_MEMORY_RWX] = {
4007 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4008 .prot_l1 = PMD_TYPE_TABLE,
4009 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4010 .domain = DOMAIN_KERNEL,
4011 },
4012 + [MT_MEMORY_RW] = {
4013 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4014 + .prot_l1 = PMD_TYPE_TABLE,
4015 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4016 + .domain = DOMAIN_KERNEL,
4017 + },
4018 + [MT_MEMORY_RX] = {
4019 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC,
4020 + .prot_l1 = PMD_TYPE_TABLE,
4021 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4022 + .domain = DOMAIN_KERNEL,
4023 + },
4024 [MT_ROM] = {
4025 - .prot_sect = PMD_TYPE_SECT,
4026 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4027 .domain = DOMAIN_KERNEL,
4028 },
4029 - [MT_MEMORY_NONCACHED] = {
4030 + [MT_MEMORY_NONCACHED_RW] = {
4031 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4032 L_PTE_MT_BUFFERABLE,
4033 .prot_l1 = PMD_TYPE_TABLE,
4034 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4035 .domain = DOMAIN_KERNEL,
4036 },
4037 + [MT_MEMORY_NONCACHED_RX] = {
4038 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC |
4039 + L_PTE_MT_BUFFERABLE,
4040 + .prot_l1 = PMD_TYPE_TABLE,
4041 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4042 + .domain = DOMAIN_KERNEL,
4043 + },
4044 [MT_MEMORY_DTCM] = {
4045 - .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4046 - L_PTE_XN,
4047 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4048 .prot_l1 = PMD_TYPE_TABLE,
4049 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4050 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4051 .domain = DOMAIN_KERNEL,
4052 },
4053 [MT_MEMORY_ITCM] = {
4054 @@ -299,10 +341,10 @@ static struct mem_type mem_types[] = {
4055 },
4056 [MT_MEMORY_SO] = {
4057 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4058 - L_PTE_MT_UNCACHED | L_PTE_XN,
4059 + L_PTE_MT_UNCACHED,
4060 .prot_l1 = PMD_TYPE_TABLE,
4061 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_SECT_S |
4062 - PMD_SECT_UNCACHED | PMD_SECT_XN,
4063 + PMD_SECT_UNCACHED,
4064 .domain = DOMAIN_KERNEL,
4065 },
4066 [MT_MEMORY_DMA_READY] = {
4067 @@ -388,9 +430,35 @@ static void __init build_mem_type_table(void)
4068 * to prevent speculative instruction fetches.
4069 */
4070 mem_types[MT_DEVICE].prot_sect |= PMD_SECT_XN;
4071 + mem_types[MT_DEVICE].prot_pte |= L_PTE_XN;
4072 mem_types[MT_DEVICE_NONSHARED].prot_sect |= PMD_SECT_XN;
4073 + mem_types[MT_DEVICE_NONSHARED].prot_pte |= L_PTE_XN;
4074 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_XN;
4075 + mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_XN;
4076 mem_types[MT_DEVICE_WC].prot_sect |= PMD_SECT_XN;
4077 + mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_XN;
4078 +
4079 + /* Mark other regions on ARMv6+ as execute-never */
4080 +
4081 +#ifdef CONFIG_PAX_KERNEXEC
4082 + mem_types[MT_UNCACHED].prot_sect |= PMD_SECT_XN;
4083 + mem_types[MT_UNCACHED].prot_pte |= L_PTE_XN;
4084 + mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_XN;
4085 + mem_types[MT_CACHECLEAN].prot_pte |= L_PTE_XN;
4086 +#ifndef CONFIG_ARM_LPAE
4087 + mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_XN;
4088 + mem_types[MT_MINICLEAN].prot_pte |= L_PTE_XN;
4089 +#endif
4090 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_XN;
4091 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_XN;
4092 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_XN;
4093 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= PMD_SECT_XN;
4094 + mem_types[MT_MEMORY_DTCM].prot_sect |= PMD_SECT_XN;
4095 + mem_types[MT_MEMORY_DTCM].prot_pte |= L_PTE_XN;
4096 +#endif
4097 +
4098 + mem_types[MT_MEMORY_SO].prot_sect |= PMD_SECT_XN;
4099 + mem_types[MT_MEMORY_SO].prot_pte |= L_PTE_XN;
4100 }
4101 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4102 /*
4103 @@ -451,6 +519,9 @@ static void __init build_mem_type_table(void)
4104 * from SVC mode and no access from userspace.
4105 */
4106 mem_types[MT_ROM].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4107 +#ifdef CONFIG_PAX_KERNEXEC
4108 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4109 +#endif
4110 mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4111 mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4112 #endif
4113 @@ -468,11 +539,17 @@ static void __init build_mem_type_table(void)
4114 mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_SHARED;
4115 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_S;
4116 mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_SHARED;
4117 - mem_types[MT_MEMORY].prot_sect |= PMD_SECT_S;
4118 - mem_types[MT_MEMORY].prot_pte |= L_PTE_SHARED;
4119 + mem_types[MT_MEMORY_RWX].prot_sect |= PMD_SECT_S;
4120 + mem_types[MT_MEMORY_RWX].prot_pte |= L_PTE_SHARED;
4121 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_S;
4122 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_SHARED;
4123 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_S;
4124 + mem_types[MT_MEMORY_RX].prot_pte |= L_PTE_SHARED;
4125 mem_types[MT_MEMORY_DMA_READY].prot_pte |= L_PTE_SHARED;
4126 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_S;
4127 - mem_types[MT_MEMORY_NONCACHED].prot_pte |= L_PTE_SHARED;
4128 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_S;
4129 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= L_PTE_SHARED;
4130 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_S;
4131 + mem_types[MT_MEMORY_NONCACHED_RX].prot_pte |= L_PTE_SHARED;
4132 }
4133 }
4134
4135 @@ -483,15 +560,20 @@ static void __init build_mem_type_table(void)
4136 if (cpu_arch >= CPU_ARCH_ARMv6) {
4137 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4138 /* Non-cacheable Normal is XCB = 001 */
4139 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4140 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4141 + PMD_SECT_BUFFERED;
4142 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4143 PMD_SECT_BUFFERED;
4144 } else {
4145 /* For both ARMv6 and non-TEX-remapping ARMv7 */
4146 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4147 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4148 + PMD_SECT_TEX(1);
4149 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4150 PMD_SECT_TEX(1);
4151 }
4152 } else {
4153 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_BUFFERABLE;
4154 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_BUFFERABLE;
4155 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_BUFFERABLE;
4156 }
4157
4158 #ifdef CONFIG_ARM_LPAE
4159 @@ -507,6 +589,8 @@ static void __init build_mem_type_table(void)
4160 vecs_pgprot |= PTE_EXT_AF;
4161 #endif
4162
4163 + user_pgprot |= __supported_pte_mask;
4164 +
4165 for (i = 0; i < 16; i++) {
4166 pteval_t v = pgprot_val(protection_map[i]);
4167 protection_map[i] = __pgprot(v | user_pgprot);
4168 @@ -524,10 +608,15 @@ static void __init build_mem_type_table(void)
4169
4170 mem_types[MT_LOW_VECTORS].prot_l1 |= ecc_mask;
4171 mem_types[MT_HIGH_VECTORS].prot_l1 |= ecc_mask;
4172 - mem_types[MT_MEMORY].prot_sect |= ecc_mask | cp->pmd;
4173 - mem_types[MT_MEMORY].prot_pte |= kern_pgprot;
4174 + mem_types[MT_MEMORY_RWX].prot_sect |= ecc_mask | cp->pmd;
4175 + mem_types[MT_MEMORY_RWX].prot_pte |= kern_pgprot;
4176 + mem_types[MT_MEMORY_RW].prot_sect |= ecc_mask | cp->pmd;
4177 + mem_types[MT_MEMORY_RW].prot_pte |= kern_pgprot;
4178 + mem_types[MT_MEMORY_RX].prot_sect |= ecc_mask | cp->pmd;
4179 + mem_types[MT_MEMORY_RX].prot_pte |= kern_pgprot;
4180 mem_types[MT_MEMORY_DMA_READY].prot_pte |= kern_pgprot;
4181 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= ecc_mask;
4182 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= ecc_mask;
4183 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= ecc_mask;
4184 mem_types[MT_ROM].prot_sect |= cp->pmd;
4185
4186 switch (cp->pmd) {
4187 @@ -1147,18 +1236,15 @@ void __init arm_mm_memblock_reserve(void)
4188 * called function. This means you can't use any function or debugging
4189 * method which may touch any device, otherwise the kernel _will_ crash.
4190 */
4191 +
4192 +static char vectors[PAGE_SIZE] __read_only __aligned(PAGE_SIZE);
4193 +
4194 static void __init devicemaps_init(struct machine_desc *mdesc)
4195 {
4196 struct map_desc map;
4197 unsigned long addr;
4198 - void *vectors;
4199
4200 - /*
4201 - * Allocate the vector page early.
4202 - */
4203 - vectors = early_alloc(PAGE_SIZE);
4204 -
4205 - early_trap_init(vectors);
4206 + early_trap_init(&vectors);
4207
4208 for (addr = VMALLOC_START; addr; addr += PMD_SIZE)
4209 pmd_clear(pmd_off_k(addr));
4210 @@ -1198,7 +1284,7 @@ static void __init devicemaps_init(struct machine_desc *mdesc)
4211 * location (0xffff0000). If we aren't using high-vectors, also
4212 * create a mapping at the low-vectors virtual address.
4213 */
4214 - map.pfn = __phys_to_pfn(virt_to_phys(vectors));
4215 + map.pfn = __phys_to_pfn(virt_to_phys(&vectors));
4216 map.virtual = 0xffff0000;
4217 map.length = PAGE_SIZE;
4218 map.type = MT_HIGH_VECTORS;
4219 @@ -1256,8 +1342,39 @@ static void __init map_lowmem(void)
4220 map.pfn = __phys_to_pfn(start);
4221 map.virtual = __phys_to_virt(start);
4222 map.length = end - start;
4223 - map.type = MT_MEMORY;
4224
4225 +#ifdef CONFIG_PAX_KERNEXEC
4226 + if (map.virtual <= (unsigned long)_stext && ((unsigned long)_end < (map.virtual + map.length))) {
4227 + struct map_desc kernel;
4228 + struct map_desc initmap;
4229 +
4230 + /* when freeing initmem we will make this RW */
4231 + initmap.pfn = __phys_to_pfn(__pa(__init_begin));
4232 + initmap.virtual = (unsigned long)__init_begin;
4233 + initmap.length = _sdata - __init_begin;
4234 + initmap.type = MT_MEMORY_RWX;
4235 + create_mapping(&initmap);
4236 +
4237 + /* when freeing initmem we will make this RX */
4238 + kernel.pfn = __phys_to_pfn(__pa(_stext));
4239 + kernel.virtual = (unsigned long)_stext;
4240 + kernel.length = __init_begin - _stext;
4241 + kernel.type = MT_MEMORY_RWX;
4242 + create_mapping(&kernel);
4243 +
4244 + if (map.virtual < (unsigned long)_stext) {
4245 + map.length = (unsigned long)_stext - map.virtual;
4246 + map.type = MT_MEMORY_RWX;
4247 + create_mapping(&map);
4248 + }
4249 +
4250 + map.pfn = __phys_to_pfn(__pa(_sdata));
4251 + map.virtual = (unsigned long)_sdata;
4252 + map.length = end - __pa(_sdata);
4253 + }
4254 +#endif
4255 +
4256 + map.type = MT_MEMORY_RW;
4257 create_mapping(&map);
4258 }
4259 }
4260 diff --git a/arch/arm/mm/proc-v7-2level.S b/arch/arm/mm/proc-v7-2level.S
4261 index 78f520b..31f0cb6 100644
4262 --- a/arch/arm/mm/proc-v7-2level.S
4263 +++ b/arch/arm/mm/proc-v7-2level.S
4264 @@ -99,6 +99,9 @@ ENTRY(cpu_v7_set_pte_ext)
4265 tst r1, #L_PTE_XN
4266 orrne r3, r3, #PTE_EXT_XN
4267
4268 + tst r1, #L_PTE_PXN
4269 + orrne r3, r3, #PTE_EXT_PXN
4270 +
4271 tst r1, #L_PTE_YOUNG
4272 tstne r1, #L_PTE_VALID
4273 #ifndef CONFIG_CPU_USE_DOMAINS
4274 diff --git a/arch/arm/plat-omap/sram.c b/arch/arm/plat-omap/sram.c
4275 index a5bc92d..0bb4730 100644
4276 --- a/arch/arm/plat-omap/sram.c
4277 +++ b/arch/arm/plat-omap/sram.c
4278 @@ -93,6 +93,8 @@ void __init omap_map_sram(unsigned long start, unsigned long size,
4279 * Looks like we need to preserve some bootloader code at the
4280 * beginning of SRAM for jumping to flash for reboot to work...
4281 */
4282 + pax_open_kernel();
4283 memset_io(omap_sram_base + omap_sram_skip, 0,
4284 omap_sram_size - omap_sram_skip);
4285 + pax_close_kernel();
4286 }
4287 diff --git a/arch/arm/plat-samsung/include/plat/dma-ops.h b/arch/arm/plat-samsung/include/plat/dma-ops.h
4288 index 1141782..0959d64 100644
4289 --- a/arch/arm/plat-samsung/include/plat/dma-ops.h
4290 +++ b/arch/arm/plat-samsung/include/plat/dma-ops.h
4291 @@ -48,7 +48,7 @@ struct samsung_dma_ops {
4292 int (*started)(unsigned ch);
4293 int (*flush)(unsigned ch);
4294 int (*stop)(unsigned ch);
4295 -};
4296 +} __no_const;
4297
4298 extern void *samsung_dmadev_get_ops(void);
4299 extern void *s3c_dma_get_ops(void);
4300 diff --git a/arch/arm64/kernel/debug-monitors.c b/arch/arm64/kernel/debug-monitors.c
4301 index f4726dc..39ed646 100644
4302 --- a/arch/arm64/kernel/debug-monitors.c
4303 +++ b/arch/arm64/kernel/debug-monitors.c
4304 @@ -149,7 +149,7 @@ static int __cpuinit os_lock_notify(struct notifier_block *self,
4305 return NOTIFY_OK;
4306 }
4307
4308 -static struct notifier_block __cpuinitdata os_lock_nb = {
4309 +static struct notifier_block os_lock_nb = {
4310 .notifier_call = os_lock_notify,
4311 };
4312
4313 diff --git a/arch/arm64/kernel/hw_breakpoint.c b/arch/arm64/kernel/hw_breakpoint.c
4314 index 5ab825c..96aaec8 100644
4315 --- a/arch/arm64/kernel/hw_breakpoint.c
4316 +++ b/arch/arm64/kernel/hw_breakpoint.c
4317 @@ -831,7 +831,7 @@ static int __cpuinit hw_breakpoint_reset_notify(struct notifier_block *self,
4318 return NOTIFY_OK;
4319 }
4320
4321 -static struct notifier_block __cpuinitdata hw_breakpoint_reset_nb = {
4322 +static struct notifier_block hw_breakpoint_reset_nb = {
4323 .notifier_call = hw_breakpoint_reset_notify,
4324 };
4325
4326 diff --git a/arch/avr32/include/asm/cache.h b/arch/avr32/include/asm/cache.h
4327 index c3a58a1..78fbf54 100644
4328 --- a/arch/avr32/include/asm/cache.h
4329 +++ b/arch/avr32/include/asm/cache.h
4330 @@ -1,8 +1,10 @@
4331 #ifndef __ASM_AVR32_CACHE_H
4332 #define __ASM_AVR32_CACHE_H
4333
4334 +#include <linux/const.h>
4335 +
4336 #define L1_CACHE_SHIFT 5
4337 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4338 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4339
4340 /*
4341 * Memory returned by kmalloc() may be used for DMA, so we must make
4342 diff --git a/arch/avr32/include/asm/elf.h b/arch/avr32/include/asm/elf.h
4343 index d232888..87c8df1 100644
4344 --- a/arch/avr32/include/asm/elf.h
4345 +++ b/arch/avr32/include/asm/elf.h
4346 @@ -84,8 +84,14 @@ typedef struct user_fpu_struct elf_fpregset_t;
4347 the loader. We need to make sure that it is out of the way of the program
4348 that it will "exec", and that there is sufficient room for the brk. */
4349
4350 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
4351 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
4352
4353 +#ifdef CONFIG_PAX_ASLR
4354 +#define PAX_ELF_ET_DYN_BASE 0x00001000UL
4355 +
4356 +#define PAX_DELTA_MMAP_LEN 15
4357 +#define PAX_DELTA_STACK_LEN 15
4358 +#endif
4359
4360 /* This yields a mask that user programs can use to figure out what
4361 instruction set this CPU supports. This could be done in user space,
4362 diff --git a/arch/avr32/include/asm/kmap_types.h b/arch/avr32/include/asm/kmap_types.h
4363 index 479330b..53717a8 100644
4364 --- a/arch/avr32/include/asm/kmap_types.h
4365 +++ b/arch/avr32/include/asm/kmap_types.h
4366 @@ -2,9 +2,9 @@
4367 #define __ASM_AVR32_KMAP_TYPES_H
4368
4369 #ifdef CONFIG_DEBUG_HIGHMEM
4370 -# define KM_TYPE_NR 29
4371 +# define KM_TYPE_NR 30
4372 #else
4373 -# define KM_TYPE_NR 14
4374 +# define KM_TYPE_NR 15
4375 #endif
4376
4377 #endif /* __ASM_AVR32_KMAP_TYPES_H */
4378 diff --git a/arch/avr32/mm/fault.c b/arch/avr32/mm/fault.c
4379 index b2f2d2d..d1c85cb 100644
4380 --- a/arch/avr32/mm/fault.c
4381 +++ b/arch/avr32/mm/fault.c
4382 @@ -41,6 +41,23 @@ static inline int notify_page_fault(struct pt_regs *regs, int trap)
4383
4384 int exception_trace = 1;
4385
4386 +#ifdef CONFIG_PAX_PAGEEXEC
4387 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
4388 +{
4389 + unsigned long i;
4390 +
4391 + printk(KERN_ERR "PAX: bytes at PC: ");
4392 + for (i = 0; i < 20; i++) {
4393 + unsigned char c;
4394 + if (get_user(c, (unsigned char *)pc+i))
4395 + printk(KERN_CONT "???????? ");
4396 + else
4397 + printk(KERN_CONT "%02x ", c);
4398 + }
4399 + printk("\n");
4400 +}
4401 +#endif
4402 +
4403 /*
4404 * This routine handles page faults. It determines the address and the
4405 * problem, and then passes it off to one of the appropriate routines.
4406 @@ -174,6 +191,16 @@ bad_area:
4407 up_read(&mm->mmap_sem);
4408
4409 if (user_mode(regs)) {
4410 +
4411 +#ifdef CONFIG_PAX_PAGEEXEC
4412 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
4413 + if (ecr == ECR_PROTECTION_X || ecr == ECR_TLB_MISS_X) {
4414 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->sp);
4415 + do_group_exit(SIGKILL);
4416 + }
4417 + }
4418 +#endif
4419 +
4420 if (exception_trace && printk_ratelimit())
4421 printk("%s%s[%d]: segfault at %08lx pc %08lx "
4422 "sp %08lx ecr %lu\n",
4423 diff --git a/arch/blackfin/include/asm/cache.h b/arch/blackfin/include/asm/cache.h
4424 index 568885a..f8008df 100644
4425 --- a/arch/blackfin/include/asm/cache.h
4426 +++ b/arch/blackfin/include/asm/cache.h
4427 @@ -7,6 +7,7 @@
4428 #ifndef __ARCH_BLACKFIN_CACHE_H
4429 #define __ARCH_BLACKFIN_CACHE_H
4430
4431 +#include <linux/const.h>
4432 #include <linux/linkage.h> /* for asmlinkage */
4433
4434 /*
4435 @@ -14,7 +15,7 @@
4436 * Blackfin loads 32 bytes for cache
4437 */
4438 #define L1_CACHE_SHIFT 5
4439 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4440 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4441 #define SMP_CACHE_BYTES L1_CACHE_BYTES
4442
4443 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
4444 diff --git a/arch/cris/include/arch-v10/arch/cache.h b/arch/cris/include/arch-v10/arch/cache.h
4445 index aea2718..3639a60 100644
4446 --- a/arch/cris/include/arch-v10/arch/cache.h
4447 +++ b/arch/cris/include/arch-v10/arch/cache.h
4448 @@ -1,8 +1,9 @@
4449 #ifndef _ASM_ARCH_CACHE_H
4450 #define _ASM_ARCH_CACHE_H
4451
4452 +#include <linux/const.h>
4453 /* Etrax 100LX have 32-byte cache-lines. */
4454 -#define L1_CACHE_BYTES 32
4455 #define L1_CACHE_SHIFT 5
4456 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4457
4458 #endif /* _ASM_ARCH_CACHE_H */
4459 diff --git a/arch/cris/include/arch-v32/arch/cache.h b/arch/cris/include/arch-v32/arch/cache.h
4460 index 7caf25d..ee65ac5 100644
4461 --- a/arch/cris/include/arch-v32/arch/cache.h
4462 +++ b/arch/cris/include/arch-v32/arch/cache.h
4463 @@ -1,11 +1,12 @@
4464 #ifndef _ASM_CRIS_ARCH_CACHE_H
4465 #define _ASM_CRIS_ARCH_CACHE_H
4466
4467 +#include <linux/const.h>
4468 #include <arch/hwregs/dma.h>
4469
4470 /* A cache-line is 32 bytes. */
4471 -#define L1_CACHE_BYTES 32
4472 #define L1_CACHE_SHIFT 5
4473 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4474
4475 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
4476
4477 diff --git a/arch/frv/include/asm/atomic.h b/arch/frv/include/asm/atomic.h
4478 index b86329d..6709906 100644
4479 --- a/arch/frv/include/asm/atomic.h
4480 +++ b/arch/frv/include/asm/atomic.h
4481 @@ -186,6 +186,16 @@ static inline void atomic64_dec(atomic64_t *v)
4482 #define atomic64_cmpxchg(v, old, new) (__cmpxchg_64(old, new, &(v)->counter))
4483 #define atomic64_xchg(v, new) (__xchg_64(new, &(v)->counter))
4484
4485 +#define atomic64_read_unchecked(v) atomic64_read(v)
4486 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4487 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4488 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4489 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4490 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4491 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4492 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4493 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4494 +
4495 static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
4496 {
4497 int c, old;
4498 diff --git a/arch/frv/include/asm/cache.h b/arch/frv/include/asm/cache.h
4499 index 2797163..c2a401d 100644
4500 --- a/arch/frv/include/asm/cache.h
4501 +++ b/arch/frv/include/asm/cache.h
4502 @@ -12,10 +12,11 @@
4503 #ifndef __ASM_CACHE_H
4504 #define __ASM_CACHE_H
4505
4506 +#include <linux/const.h>
4507
4508 /* bytes per L1 cache line */
4509 #define L1_CACHE_SHIFT (CONFIG_FRV_L1_CACHE_SHIFT)
4510 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4511 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4512
4513 #define __cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4514 #define ____cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4515 diff --git a/arch/frv/include/asm/kmap_types.h b/arch/frv/include/asm/kmap_types.h
4516 index 43901f2..0d8b865 100644
4517 --- a/arch/frv/include/asm/kmap_types.h
4518 +++ b/arch/frv/include/asm/kmap_types.h
4519 @@ -2,6 +2,6 @@
4520 #ifndef _ASM_KMAP_TYPES_H
4521 #define _ASM_KMAP_TYPES_H
4522
4523 -#define KM_TYPE_NR 17
4524 +#define KM_TYPE_NR 18
4525
4526 #endif
4527 diff --git a/arch/frv/mm/elf-fdpic.c b/arch/frv/mm/elf-fdpic.c
4528 index 836f147..4cf23f5 100644
4529 --- a/arch/frv/mm/elf-fdpic.c
4530 +++ b/arch/frv/mm/elf-fdpic.c
4531 @@ -61,6 +61,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4532 {
4533 struct vm_area_struct *vma;
4534 struct vm_unmapped_area_info info;
4535 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
4536
4537 if (len > TASK_SIZE)
4538 return -ENOMEM;
4539 @@ -73,8 +74,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4540 if (addr) {
4541 addr = PAGE_ALIGN(addr);
4542 vma = find_vma(current->mm, addr);
4543 - if (TASK_SIZE - len >= addr &&
4544 - (!vma || addr + len <= vma->vm_start))
4545 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4546 goto success;
4547 }
4548
4549 @@ -85,6 +85,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4550 info.high_limit = (current->mm->start_stack - 0x00200000);
4551 info.align_mask = 0;
4552 info.align_offset = 0;
4553 + info.threadstack_offset = offset;
4554 addr = vm_unmapped_area(&info);
4555 if (!(addr & ~PAGE_MASK))
4556 goto success;
4557 diff --git a/arch/hexagon/include/asm/cache.h b/arch/hexagon/include/asm/cache.h
4558 index f4ca594..adc72fd6 100644
4559 --- a/arch/hexagon/include/asm/cache.h
4560 +++ b/arch/hexagon/include/asm/cache.h
4561 @@ -21,9 +21,11 @@
4562 #ifndef __ASM_CACHE_H
4563 #define __ASM_CACHE_H
4564
4565 +#include <linux/const.h>
4566 +
4567 /* Bytes per L1 cache line */
4568 -#define L1_CACHE_SHIFT (5)
4569 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4570 +#define L1_CACHE_SHIFT 5
4571 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4572
4573 #define __cacheline_aligned __aligned(L1_CACHE_BYTES)
4574 #define ____cacheline_aligned __aligned(L1_CACHE_BYTES)
4575 diff --git a/arch/ia64/include/asm/atomic.h b/arch/ia64/include/asm/atomic.h
4576 index 6e6fe18..a6ae668 100644
4577 --- a/arch/ia64/include/asm/atomic.h
4578 +++ b/arch/ia64/include/asm/atomic.h
4579 @@ -208,6 +208,16 @@ atomic64_add_negative (__s64 i, atomic64_t *v)
4580 #define atomic64_inc(v) atomic64_add(1, (v))
4581 #define atomic64_dec(v) atomic64_sub(1, (v))
4582
4583 +#define atomic64_read_unchecked(v) atomic64_read(v)
4584 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4585 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4586 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4587 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4588 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4589 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4590 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4591 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4592 +
4593 /* Atomic operations are already serializing */
4594 #define smp_mb__before_atomic_dec() barrier()
4595 #define smp_mb__after_atomic_dec() barrier()
4596 diff --git a/arch/ia64/include/asm/cache.h b/arch/ia64/include/asm/cache.h
4597 index 988254a..e1ee885 100644
4598 --- a/arch/ia64/include/asm/cache.h
4599 +++ b/arch/ia64/include/asm/cache.h
4600 @@ -1,6 +1,7 @@
4601 #ifndef _ASM_IA64_CACHE_H
4602 #define _ASM_IA64_CACHE_H
4603
4604 +#include <linux/const.h>
4605
4606 /*
4607 * Copyright (C) 1998-2000 Hewlett-Packard Co
4608 @@ -9,7 +10,7 @@
4609
4610 /* Bytes per L1 (data) cache line. */
4611 #define L1_CACHE_SHIFT CONFIG_IA64_L1_CACHE_SHIFT
4612 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4613 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4614
4615 #ifdef CONFIG_SMP
4616 # define SMP_CACHE_SHIFT L1_CACHE_SHIFT
4617 diff --git a/arch/ia64/include/asm/elf.h b/arch/ia64/include/asm/elf.h
4618 index 5a83c5c..4d7f553 100644
4619 --- a/arch/ia64/include/asm/elf.h
4620 +++ b/arch/ia64/include/asm/elf.h
4621 @@ -42,6 +42,13 @@
4622 */
4623 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x800000000UL)
4624
4625 +#ifdef CONFIG_PAX_ASLR
4626 +#define PAX_ELF_ET_DYN_BASE (current->personality == PER_LINUX32 ? 0x08048000UL : 0x4000000000000000UL)
4627 +
4628 +#define PAX_DELTA_MMAP_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4629 +#define PAX_DELTA_STACK_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4630 +#endif
4631 +
4632 #define PT_IA_64_UNWIND 0x70000001
4633
4634 /* IA-64 relocations: */
4635 diff --git a/arch/ia64/include/asm/pgalloc.h b/arch/ia64/include/asm/pgalloc.h
4636 index 96a8d92..617a1cf 100644
4637 --- a/arch/ia64/include/asm/pgalloc.h
4638 +++ b/arch/ia64/include/asm/pgalloc.h
4639 @@ -39,6 +39,12 @@ pgd_populate(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4640 pgd_val(*pgd_entry) = __pa(pud);
4641 }
4642
4643 +static inline void
4644 +pgd_populate_kernel(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4645 +{
4646 + pgd_populate(mm, pgd_entry, pud);
4647 +}
4648 +
4649 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
4650 {
4651 return quicklist_alloc(0, GFP_KERNEL, NULL);
4652 @@ -57,6 +63,12 @@ pud_populate(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4653 pud_val(*pud_entry) = __pa(pmd);
4654 }
4655
4656 +static inline void
4657 +pud_populate_kernel(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4658 +{
4659 + pud_populate(mm, pud_entry, pmd);
4660 +}
4661 +
4662 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
4663 {
4664 return quicklist_alloc(0, GFP_KERNEL, NULL);
4665 diff --git a/arch/ia64/include/asm/pgtable.h b/arch/ia64/include/asm/pgtable.h
4666 index 815810c..d60bd4c 100644
4667 --- a/arch/ia64/include/asm/pgtable.h
4668 +++ b/arch/ia64/include/asm/pgtable.h
4669 @@ -12,7 +12,7 @@
4670 * David Mosberger-Tang <davidm@hpl.hp.com>
4671 */
4672
4673 -
4674 +#include <linux/const.h>
4675 #include <asm/mman.h>
4676 #include <asm/page.h>
4677 #include <asm/processor.h>
4678 @@ -142,6 +142,17 @@
4679 #define PAGE_READONLY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4680 #define PAGE_COPY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4681 #define PAGE_COPY_EXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RX)
4682 +
4683 +#ifdef CONFIG_PAX_PAGEEXEC
4684 +# define PAGE_SHARED_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RW)
4685 +# define PAGE_READONLY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4686 +# define PAGE_COPY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4687 +#else
4688 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
4689 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
4690 +# define PAGE_COPY_NOEXEC PAGE_COPY
4691 +#endif
4692 +
4693 #define PAGE_GATE __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_X_RX)
4694 #define PAGE_KERNEL __pgprot(__DIRTY_BITS | _PAGE_PL_0 | _PAGE_AR_RWX)
4695 #define PAGE_KERNELRX __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_RX)
4696 diff --git a/arch/ia64/include/asm/spinlock.h b/arch/ia64/include/asm/spinlock.h
4697 index 54ff557..70c88b7 100644
4698 --- a/arch/ia64/include/asm/spinlock.h
4699 +++ b/arch/ia64/include/asm/spinlock.h
4700 @@ -71,7 +71,7 @@ static __always_inline void __ticket_spin_unlock(arch_spinlock_t *lock)
4701 unsigned short *p = (unsigned short *)&lock->lock + 1, tmp;
4702
4703 asm volatile ("ld2.bias %0=[%1]" : "=r"(tmp) : "r"(p));
4704 - ACCESS_ONCE(*p) = (tmp + 2) & ~1;
4705 + ACCESS_ONCE_RW(*p) = (tmp + 2) & ~1;
4706 }
4707
4708 static __always_inline void __ticket_spin_unlock_wait(arch_spinlock_t *lock)
4709 diff --git a/arch/ia64/include/asm/uaccess.h b/arch/ia64/include/asm/uaccess.h
4710 index 449c8c0..18965fb 100644
4711 --- a/arch/ia64/include/asm/uaccess.h
4712 +++ b/arch/ia64/include/asm/uaccess.h
4713 @@ -240,12 +240,24 @@ extern unsigned long __must_check __copy_user (void __user *to, const void __use
4714 static inline unsigned long
4715 __copy_to_user (void __user *to, const void *from, unsigned long count)
4716 {
4717 + if (count > INT_MAX)
4718 + return count;
4719 +
4720 + if (!__builtin_constant_p(count))
4721 + check_object_size(from, count, true);
4722 +
4723 return __copy_user(to, (__force void __user *) from, count);
4724 }
4725
4726 static inline unsigned long
4727 __copy_from_user (void *to, const void __user *from, unsigned long count)
4728 {
4729 + if (count > INT_MAX)
4730 + return count;
4731 +
4732 + if (!__builtin_constant_p(count))
4733 + check_object_size(to, count, false);
4734 +
4735 return __copy_user((__force void __user *) to, from, count);
4736 }
4737
4738 @@ -255,10 +267,13 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
4739 ({ \
4740 void __user *__cu_to = (to); \
4741 const void *__cu_from = (from); \
4742 - long __cu_len = (n); \
4743 + unsigned long __cu_len = (n); \
4744 \
4745 - if (__access_ok(__cu_to, __cu_len, get_fs())) \
4746 + if (__cu_len <= INT_MAX && __access_ok(__cu_to, __cu_len, get_fs())) { \
4747 + if (!__builtin_constant_p(n)) \
4748 + check_object_size(__cu_from, __cu_len, true); \
4749 __cu_len = __copy_user(__cu_to, (__force void __user *) __cu_from, __cu_len); \
4750 + } \
4751 __cu_len; \
4752 })
4753
4754 @@ -266,11 +281,14 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
4755 ({ \
4756 void *__cu_to = (to); \
4757 const void __user *__cu_from = (from); \
4758 - long __cu_len = (n); \
4759 + unsigned long __cu_len = (n); \
4760 \
4761 __chk_user_ptr(__cu_from); \
4762 - if (__access_ok(__cu_from, __cu_len, get_fs())) \
4763 + if (__cu_len <= INT_MAX && __access_ok(__cu_from, __cu_len, get_fs())) { \
4764 + if (!__builtin_constant_p(n)) \
4765 + check_object_size(__cu_to, __cu_len, false); \
4766 __cu_len = __copy_user((__force void __user *) __cu_to, __cu_from, __cu_len); \
4767 + } \
4768 __cu_len; \
4769 })
4770
4771 diff --git a/arch/ia64/kernel/err_inject.c b/arch/ia64/kernel/err_inject.c
4772 index 2d67317..07d8bfa 100644
4773 --- a/arch/ia64/kernel/err_inject.c
4774 +++ b/arch/ia64/kernel/err_inject.c
4775 @@ -256,7 +256,7 @@ static int __cpuinit err_inject_cpu_callback(struct notifier_block *nfb,
4776 return NOTIFY_OK;
4777 }
4778
4779 -static struct notifier_block __cpuinitdata err_inject_cpu_notifier =
4780 +static struct notifier_block err_inject_cpu_notifier =
4781 {
4782 .notifier_call = err_inject_cpu_callback,
4783 };
4784 diff --git a/arch/ia64/kernel/mca.c b/arch/ia64/kernel/mca.c
4785 index d7396db..b33e873 100644
4786 --- a/arch/ia64/kernel/mca.c
4787 +++ b/arch/ia64/kernel/mca.c
4788 @@ -1922,7 +1922,7 @@ static int __cpuinit mca_cpu_callback(struct notifier_block *nfb,
4789 return NOTIFY_OK;
4790 }
4791
4792 -static struct notifier_block mca_cpu_notifier __cpuinitdata = {
4793 +static struct notifier_block mca_cpu_notifier = {
4794 .notifier_call = mca_cpu_callback
4795 };
4796
4797 diff --git a/arch/ia64/kernel/module.c b/arch/ia64/kernel/module.c
4798 index 24603be..948052d 100644
4799 --- a/arch/ia64/kernel/module.c
4800 +++ b/arch/ia64/kernel/module.c
4801 @@ -307,8 +307,7 @@ plt_target (struct plt_entry *plt)
4802 void
4803 module_free (struct module *mod, void *module_region)
4804 {
4805 - if (mod && mod->arch.init_unw_table &&
4806 - module_region == mod->module_init) {
4807 + if (mod && mod->arch.init_unw_table && module_region == mod->module_init_rx) {
4808 unw_remove_unwind_table(mod->arch.init_unw_table);
4809 mod->arch.init_unw_table = NULL;
4810 }
4811 @@ -494,15 +493,39 @@ module_frob_arch_sections (Elf_Ehdr *ehdr, Elf_Shdr *sechdrs, char *secstrings,
4812 }
4813
4814 static inline int
4815 +in_init_rx (const struct module *mod, uint64_t addr)
4816 +{
4817 + return addr - (uint64_t) mod->module_init_rx < mod->init_size_rx;
4818 +}
4819 +
4820 +static inline int
4821 +in_init_rw (const struct module *mod, uint64_t addr)
4822 +{
4823 + return addr - (uint64_t) mod->module_init_rw < mod->init_size_rw;
4824 +}
4825 +
4826 +static inline int
4827 in_init (const struct module *mod, uint64_t addr)
4828 {
4829 - return addr - (uint64_t) mod->module_init < mod->init_size;
4830 + return in_init_rx(mod, addr) || in_init_rw(mod, addr);
4831 +}
4832 +
4833 +static inline int
4834 +in_core_rx (const struct module *mod, uint64_t addr)
4835 +{
4836 + return addr - (uint64_t) mod->module_core_rx < mod->core_size_rx;
4837 +}
4838 +
4839 +static inline int
4840 +in_core_rw (const struct module *mod, uint64_t addr)
4841 +{
4842 + return addr - (uint64_t) mod->module_core_rw < mod->core_size_rw;
4843 }
4844
4845 static inline int
4846 in_core (const struct module *mod, uint64_t addr)
4847 {
4848 - return addr - (uint64_t) mod->module_core < mod->core_size;
4849 + return in_core_rx(mod, addr) || in_core_rw(mod, addr);
4850 }
4851
4852 static inline int
4853 @@ -685,7 +708,14 @@ do_reloc (struct module *mod, uint8_t r_type, Elf64_Sym *sym, uint64_t addend,
4854 break;
4855
4856 case RV_BDREL:
4857 - val -= (uint64_t) (in_init(mod, val) ? mod->module_init : mod->module_core);
4858 + if (in_init_rx(mod, val))
4859 + val -= (uint64_t) mod->module_init_rx;
4860 + else if (in_init_rw(mod, val))
4861 + val -= (uint64_t) mod->module_init_rw;
4862 + else if (in_core_rx(mod, val))
4863 + val -= (uint64_t) mod->module_core_rx;
4864 + else if (in_core_rw(mod, val))
4865 + val -= (uint64_t) mod->module_core_rw;
4866 break;
4867
4868 case RV_LTV:
4869 @@ -820,15 +850,15 @@ apply_relocate_add (Elf64_Shdr *sechdrs, const char *strtab, unsigned int symind
4870 * addresses have been selected...
4871 */
4872 uint64_t gp;
4873 - if (mod->core_size > MAX_LTOFF)
4874 + if (mod->core_size_rx + mod->core_size_rw > MAX_LTOFF)
4875 /*
4876 * This takes advantage of fact that SHF_ARCH_SMALL gets allocated
4877 * at the end of the module.
4878 */
4879 - gp = mod->core_size - MAX_LTOFF / 2;
4880 + gp = mod->core_size_rx + mod->core_size_rw - MAX_LTOFF / 2;
4881 else
4882 - gp = mod->core_size / 2;
4883 - gp = (uint64_t) mod->module_core + ((gp + 7) & -8);
4884 + gp = (mod->core_size_rx + mod->core_size_rw) / 2;
4885 + gp = (uint64_t) mod->module_core_rx + ((gp + 7) & -8);
4886 mod->arch.gp = gp;
4887 DEBUGP("%s: placing gp at 0x%lx\n", __func__, gp);
4888 }
4889 diff --git a/arch/ia64/kernel/palinfo.c b/arch/ia64/kernel/palinfo.c
4890 index 79521d5..43dddff 100644
4891 --- a/arch/ia64/kernel/palinfo.c
4892 +++ b/arch/ia64/kernel/palinfo.c
4893 @@ -1006,7 +1006,7 @@ static int __cpuinit palinfo_cpu_callback(struct notifier_block *nfb,
4894 return NOTIFY_OK;
4895 }
4896
4897 -static struct notifier_block __refdata palinfo_cpu_notifier =
4898 +static struct notifier_block palinfo_cpu_notifier =
4899 {
4900 .notifier_call = palinfo_cpu_callback,
4901 .priority = 0,
4902 diff --git a/arch/ia64/kernel/salinfo.c b/arch/ia64/kernel/salinfo.c
4903 index aa527d7..f237752 100644
4904 --- a/arch/ia64/kernel/salinfo.c
4905 +++ b/arch/ia64/kernel/salinfo.c
4906 @@ -616,7 +616,7 @@ salinfo_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu
4907 return NOTIFY_OK;
4908 }
4909
4910 -static struct notifier_block salinfo_cpu_notifier __cpuinitdata =
4911 +static struct notifier_block salinfo_cpu_notifier =
4912 {
4913 .notifier_call = salinfo_cpu_callback,
4914 .priority = 0,
4915 diff --git a/arch/ia64/kernel/sys_ia64.c b/arch/ia64/kernel/sys_ia64.c
4916 index 41e33f8..65180b2 100644
4917 --- a/arch/ia64/kernel/sys_ia64.c
4918 +++ b/arch/ia64/kernel/sys_ia64.c
4919 @@ -28,6 +28,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
4920 unsigned long align_mask = 0;
4921 struct mm_struct *mm = current->mm;
4922 struct vm_unmapped_area_info info;
4923 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4924
4925 if (len > RGN_MAP_LIMIT)
4926 return -ENOMEM;
4927 @@ -43,6 +44,13 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
4928 if (REGION_NUMBER(addr) == RGN_HPAGE)
4929 addr = 0;
4930 #endif
4931 +
4932 +#ifdef CONFIG_PAX_RANDMMAP
4933 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4934 + addr = mm->free_area_cache;
4935 + else
4936 +#endif
4937 +
4938 if (!addr)
4939 addr = TASK_UNMAPPED_BASE;
4940
4941 @@ -61,6 +69,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
4942 info.high_limit = TASK_SIZE;
4943 info.align_mask = align_mask;
4944 info.align_offset = 0;
4945 + info.threadstack_offset = offset;
4946 return vm_unmapped_area(&info);
4947 }
4948
4949 diff --git a/arch/ia64/kernel/topology.c b/arch/ia64/kernel/topology.c
4950 index dc00b2c..cce53c2 100644
4951 --- a/arch/ia64/kernel/topology.c
4952 +++ b/arch/ia64/kernel/topology.c
4953 @@ -445,7 +445,7 @@ static int __cpuinit cache_cpu_callback(struct notifier_block *nfb,
4954 return NOTIFY_OK;
4955 }
4956
4957 -static struct notifier_block __cpuinitdata cache_cpu_notifier =
4958 +static struct notifier_block cache_cpu_notifier =
4959 {
4960 .notifier_call = cache_cpu_callback
4961 };
4962 diff --git a/arch/ia64/kernel/vmlinux.lds.S b/arch/ia64/kernel/vmlinux.lds.S
4963 index 0ccb28f..8992469 100644
4964 --- a/arch/ia64/kernel/vmlinux.lds.S
4965 +++ b/arch/ia64/kernel/vmlinux.lds.S
4966 @@ -198,7 +198,7 @@ SECTIONS {
4967 /* Per-cpu data: */
4968 . = ALIGN(PERCPU_PAGE_SIZE);
4969 PERCPU_VADDR(SMP_CACHE_BYTES, PERCPU_ADDR, :percpu)
4970 - __phys_per_cpu_start = __per_cpu_load;
4971 + __phys_per_cpu_start = per_cpu_load;
4972 /*
4973 * ensure percpu data fits
4974 * into percpu page size
4975 diff --git a/arch/ia64/mm/fault.c b/arch/ia64/mm/fault.c
4976 index 6cf0341..d352594 100644
4977 --- a/arch/ia64/mm/fault.c
4978 +++ b/arch/ia64/mm/fault.c
4979 @@ -72,6 +72,23 @@ mapped_kernel_page_is_present (unsigned long address)
4980 return pte_present(pte);
4981 }
4982
4983 +#ifdef CONFIG_PAX_PAGEEXEC
4984 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
4985 +{
4986 + unsigned long i;
4987 +
4988 + printk(KERN_ERR "PAX: bytes at PC: ");
4989 + for (i = 0; i < 8; i++) {
4990 + unsigned int c;
4991 + if (get_user(c, (unsigned int *)pc+i))
4992 + printk(KERN_CONT "???????? ");
4993 + else
4994 + printk(KERN_CONT "%08x ", c);
4995 + }
4996 + printk("\n");
4997 +}
4998 +#endif
4999 +
5000 # define VM_READ_BIT 0
5001 # define VM_WRITE_BIT 1
5002 # define VM_EXEC_BIT 2
5003 @@ -149,8 +166,21 @@ retry:
5004 if (((isr >> IA64_ISR_R_BIT) & 1UL) && (!(vma->vm_flags & (VM_READ | VM_WRITE))))
5005 goto bad_area;
5006
5007 - if ((vma->vm_flags & mask) != mask)
5008 + if ((vma->vm_flags & mask) != mask) {
5009 +
5010 +#ifdef CONFIG_PAX_PAGEEXEC
5011 + if (!(vma->vm_flags & VM_EXEC) && (mask & VM_EXEC)) {
5012 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->cr_iip)
5013 + goto bad_area;
5014 +
5015 + up_read(&mm->mmap_sem);
5016 + pax_report_fault(regs, (void *)regs->cr_iip, (void *)regs->r12);
5017 + do_group_exit(SIGKILL);
5018 + }
5019 +#endif
5020 +
5021 goto bad_area;
5022 + }
5023
5024 /*
5025 * If for any reason at all we couldn't handle the fault, make
5026 diff --git a/arch/ia64/mm/hugetlbpage.c b/arch/ia64/mm/hugetlbpage.c
5027 index 76069c1..c2aa816 100644
5028 --- a/arch/ia64/mm/hugetlbpage.c
5029 +++ b/arch/ia64/mm/hugetlbpage.c
5030 @@ -149,6 +149,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5031 unsigned long pgoff, unsigned long flags)
5032 {
5033 struct vm_unmapped_area_info info;
5034 + unsigned long offset = gr_rand_threadstack_offset(current->mm, file, flags);
5035
5036 if (len > RGN_MAP_LIMIT)
5037 return -ENOMEM;
5038 @@ -172,6 +173,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5039 info.high_limit = HPAGE_REGION_BASE + RGN_MAP_LIMIT;
5040 info.align_mask = PAGE_MASK & (HPAGE_SIZE - 1);
5041 info.align_offset = 0;
5042 + info.threadstack_offset = offset;
5043 return vm_unmapped_area(&info);
5044 }
5045
5046 diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
5047 index 20bc967..a26993e 100644
5048 --- a/arch/ia64/mm/init.c
5049 +++ b/arch/ia64/mm/init.c
5050 @@ -120,6 +120,19 @@ ia64_init_addr_space (void)
5051 vma->vm_start = current->thread.rbs_bot & PAGE_MASK;
5052 vma->vm_end = vma->vm_start + PAGE_SIZE;
5053 vma->vm_flags = VM_DATA_DEFAULT_FLAGS|VM_GROWSUP|VM_ACCOUNT;
5054 +
5055 +#ifdef CONFIG_PAX_PAGEEXEC
5056 + if (current->mm->pax_flags & MF_PAX_PAGEEXEC) {
5057 + vma->vm_flags &= ~VM_EXEC;
5058 +
5059 +#ifdef CONFIG_PAX_MPROTECT
5060 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
5061 + vma->vm_flags &= ~VM_MAYEXEC;
5062 +#endif
5063 +
5064 + }
5065 +#endif
5066 +
5067 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
5068 down_write(&current->mm->mmap_sem);
5069 if (insert_vm_struct(current->mm, vma)) {
5070 diff --git a/arch/m32r/include/asm/cache.h b/arch/m32r/include/asm/cache.h
5071 index 40b3ee9..8c2c112 100644
5072 --- a/arch/m32r/include/asm/cache.h
5073 +++ b/arch/m32r/include/asm/cache.h
5074 @@ -1,8 +1,10 @@
5075 #ifndef _ASM_M32R_CACHE_H
5076 #define _ASM_M32R_CACHE_H
5077
5078 +#include <linux/const.h>
5079 +
5080 /* L1 cache line size */
5081 #define L1_CACHE_SHIFT 4
5082 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5083 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5084
5085 #endif /* _ASM_M32R_CACHE_H */
5086 diff --git a/arch/m32r/lib/usercopy.c b/arch/m32r/lib/usercopy.c
5087 index 82abd15..d95ae5d 100644
5088 --- a/arch/m32r/lib/usercopy.c
5089 +++ b/arch/m32r/lib/usercopy.c
5090 @@ -14,6 +14,9 @@
5091 unsigned long
5092 __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5093 {
5094 + if ((long)n < 0)
5095 + return n;
5096 +
5097 prefetch(from);
5098 if (access_ok(VERIFY_WRITE, to, n))
5099 __copy_user(to,from,n);
5100 @@ -23,6 +26,9 @@ __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5101 unsigned long
5102 __generic_copy_from_user(void *to, const void __user *from, unsigned long n)
5103 {
5104 + if ((long)n < 0)
5105 + return n;
5106 +
5107 prefetchw(to);
5108 if (access_ok(VERIFY_READ, from, n))
5109 __copy_user_zeroing(to,from,n);
5110 diff --git a/arch/m68k/include/asm/cache.h b/arch/m68k/include/asm/cache.h
5111 index 0395c51..5f26031 100644
5112 --- a/arch/m68k/include/asm/cache.h
5113 +++ b/arch/m68k/include/asm/cache.h
5114 @@ -4,9 +4,11 @@
5115 #ifndef __ARCH_M68K_CACHE_H
5116 #define __ARCH_M68K_CACHE_H
5117
5118 +#include <linux/const.h>
5119 +
5120 /* bytes per L1 cache line */
5121 #define L1_CACHE_SHIFT 4
5122 -#define L1_CACHE_BYTES (1<< L1_CACHE_SHIFT)
5123 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5124
5125 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
5126
5127 diff --git a/arch/metag/mm/hugetlbpage.c b/arch/metag/mm/hugetlbpage.c
5128 index 3c52fa6..11b2ad8 100644
5129 --- a/arch/metag/mm/hugetlbpage.c
5130 +++ b/arch/metag/mm/hugetlbpage.c
5131 @@ -200,6 +200,7 @@ hugetlb_get_unmapped_area_new_pmd(unsigned long len)
5132 info.high_limit = TASK_SIZE;
5133 info.align_mask = PAGE_MASK & HUGEPT_MASK;
5134 info.align_offset = 0;
5135 + info.threadstack_offset = 0;
5136 return vm_unmapped_area(&info);
5137 }
5138
5139 diff --git a/arch/microblaze/include/asm/cache.h b/arch/microblaze/include/asm/cache.h
5140 index 4efe96a..60e8699 100644
5141 --- a/arch/microblaze/include/asm/cache.h
5142 +++ b/arch/microblaze/include/asm/cache.h
5143 @@ -13,11 +13,12 @@
5144 #ifndef _ASM_MICROBLAZE_CACHE_H
5145 #define _ASM_MICROBLAZE_CACHE_H
5146
5147 +#include <linux/const.h>
5148 #include <asm/registers.h>
5149
5150 #define L1_CACHE_SHIFT 5
5151 /* word-granular cache in microblaze */
5152 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5153 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5154
5155 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5156
5157 diff --git a/arch/mips/include/asm/atomic.h b/arch/mips/include/asm/atomic.h
5158 index 08b6079..eb272cf 100644
5159 --- a/arch/mips/include/asm/atomic.h
5160 +++ b/arch/mips/include/asm/atomic.h
5161 @@ -21,6 +21,10 @@
5162 #include <asm/cmpxchg.h>
5163 #include <asm/war.h>
5164
5165 +#ifdef CONFIG_GENERIC_ATOMIC64
5166 +#include <asm-generic/atomic64.h>
5167 +#endif
5168 +
5169 #define ATOMIC_INIT(i) { (i) }
5170
5171 /*
5172 @@ -759,6 +763,16 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
5173 */
5174 #define atomic64_add_negative(i, v) (atomic64_add_return(i, (v)) < 0)
5175
5176 +#define atomic64_read_unchecked(v) atomic64_read(v)
5177 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
5178 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
5179 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
5180 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
5181 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
5182 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
5183 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
5184 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
5185 +
5186 #endif /* CONFIG_64BIT */
5187
5188 /*
5189 diff --git a/arch/mips/include/asm/cache.h b/arch/mips/include/asm/cache.h
5190 index b4db69f..8f3b093 100644
5191 --- a/arch/mips/include/asm/cache.h
5192 +++ b/arch/mips/include/asm/cache.h
5193 @@ -9,10 +9,11 @@
5194 #ifndef _ASM_CACHE_H
5195 #define _ASM_CACHE_H
5196
5197 +#include <linux/const.h>
5198 #include <kmalloc.h>
5199
5200 #define L1_CACHE_SHIFT CONFIG_MIPS_L1_CACHE_SHIFT
5201 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5202 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5203
5204 #define SMP_CACHE_SHIFT L1_CACHE_SHIFT
5205 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5206 diff --git a/arch/mips/include/asm/elf.h b/arch/mips/include/asm/elf.h
5207 index cf3ae24..238d22f 100644
5208 --- a/arch/mips/include/asm/elf.h
5209 +++ b/arch/mips/include/asm/elf.h
5210 @@ -372,13 +372,16 @@ extern const char *__elf_platform;
5211 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
5212 #endif
5213
5214 +#ifdef CONFIG_PAX_ASLR
5215 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5216 +
5217 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5218 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5219 +#endif
5220 +
5221 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
5222 struct linux_binprm;
5223 extern int arch_setup_additional_pages(struct linux_binprm *bprm,
5224 int uses_interp);
5225
5226 -struct mm_struct;
5227 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
5228 -#define arch_randomize_brk arch_randomize_brk
5229 -
5230 #endif /* _ASM_ELF_H */
5231 diff --git a/arch/mips/include/asm/exec.h b/arch/mips/include/asm/exec.h
5232 index c1f6afa..38cc6e9 100644
5233 --- a/arch/mips/include/asm/exec.h
5234 +++ b/arch/mips/include/asm/exec.h
5235 @@ -12,6 +12,6 @@
5236 #ifndef _ASM_EXEC_H
5237 #define _ASM_EXEC_H
5238
5239 -extern unsigned long arch_align_stack(unsigned long sp);
5240 +#define arch_align_stack(x) ((x) & ~0xfUL)
5241
5242 #endif /* _ASM_EXEC_H */
5243 diff --git a/arch/mips/include/asm/page.h b/arch/mips/include/asm/page.h
5244 index eab99e5..607c98e 100644
5245 --- a/arch/mips/include/asm/page.h
5246 +++ b/arch/mips/include/asm/page.h
5247 @@ -96,7 +96,7 @@ extern void copy_user_highpage(struct page *to, struct page *from,
5248 #ifdef CONFIG_CPU_MIPS32
5249 typedef struct { unsigned long pte_low, pte_high; } pte_t;
5250 #define pte_val(x) ((x).pte_low | ((unsigned long long)(x).pte_high << 32))
5251 - #define __pte(x) ({ pte_t __pte = {(x), ((unsigned long long)(x)) >> 32}; __pte; })
5252 + #define __pte(x) ({ pte_t __pte = {(x), (x) >> 32}; __pte; })
5253 #else
5254 typedef struct { unsigned long long pte; } pte_t;
5255 #define pte_val(x) ((x).pte)
5256 diff --git a/arch/mips/include/asm/pgalloc.h b/arch/mips/include/asm/pgalloc.h
5257 index 881d18b..cea38bc 100644
5258 --- a/arch/mips/include/asm/pgalloc.h
5259 +++ b/arch/mips/include/asm/pgalloc.h
5260 @@ -37,6 +37,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
5261 {
5262 set_pud(pud, __pud((unsigned long)pmd));
5263 }
5264 +
5265 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
5266 +{
5267 + pud_populate(mm, pud, pmd);
5268 +}
5269 #endif
5270
5271 /*
5272 diff --git a/arch/mips/include/asm/thread_info.h b/arch/mips/include/asm/thread_info.h
5273 index 178f792..8ebc510 100644
5274 --- a/arch/mips/include/asm/thread_info.h
5275 +++ b/arch/mips/include/asm/thread_info.h
5276 @@ -111,6 +111,8 @@ register struct thread_info *__current_thread_info __asm__("$28");
5277 #define TIF_32BIT_ADDR 23 /* 32-bit address space (o32/n32) */
5278 #define TIF_FPUBOUND 24 /* thread bound to FPU-full CPU set */
5279 #define TIF_LOAD_WATCH 25 /* If set, load watch registers */
5280 +/* li takes a 32bit immediate */
5281 +#define TIF_GRSEC_SETXID 29 /* update credentials on syscall entry/exit */
5282 #define TIF_SYSCALL_TRACE 31 /* syscall trace active */
5283
5284 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
5285 @@ -126,15 +128,18 @@ register struct thread_info *__current_thread_info __asm__("$28");
5286 #define _TIF_32BIT_ADDR (1<<TIF_32BIT_ADDR)
5287 #define _TIF_FPUBOUND (1<<TIF_FPUBOUND)
5288 #define _TIF_LOAD_WATCH (1<<TIF_LOAD_WATCH)
5289 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
5290 +
5291 +#define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
5292
5293 /* work to do in syscall_trace_leave() */
5294 -#define _TIF_WORK_SYSCALL_EXIT (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT)
5295 +#define _TIF_WORK_SYSCALL_EXIT (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
5296
5297 /* work to do on interrupt/exception return */
5298 #define _TIF_WORK_MASK \
5299 (_TIF_SIGPENDING | _TIF_NEED_RESCHED | _TIF_NOTIFY_RESUME)
5300 /* work to do on any return to u-space */
5301 -#define _TIF_ALLWORK_MASK (_TIF_WORK_MASK | _TIF_WORK_SYSCALL_EXIT)
5302 +#define _TIF_ALLWORK_MASK (_TIF_WORK_MASK | _TIF_WORK_SYSCALL_EXIT | _TIF_GRSEC_SETXID)
5303
5304 #endif /* __KERNEL__ */
5305
5306 diff --git a/arch/mips/kernel/binfmt_elfn32.c b/arch/mips/kernel/binfmt_elfn32.c
5307 index e06f777..3244284 100644
5308 --- a/arch/mips/kernel/binfmt_elfn32.c
5309 +++ b/arch/mips/kernel/binfmt_elfn32.c
5310 @@ -50,6 +50,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
5311 #undef ELF_ET_DYN_BASE
5312 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
5313
5314 +#ifdef CONFIG_PAX_ASLR
5315 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5316 +
5317 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5318 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5319 +#endif
5320 +
5321 #include <asm/processor.h>
5322 #include <linux/module.h>
5323 #include <linux/elfcore.h>
5324 diff --git a/arch/mips/kernel/binfmt_elfo32.c b/arch/mips/kernel/binfmt_elfo32.c
5325 index 556a435..b4fd2e3 100644
5326 --- a/arch/mips/kernel/binfmt_elfo32.c
5327 +++ b/arch/mips/kernel/binfmt_elfo32.c
5328 @@ -52,6 +52,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
5329 #undef ELF_ET_DYN_BASE
5330 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
5331
5332 +#ifdef CONFIG_PAX_ASLR
5333 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5334 +
5335 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5336 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5337 +#endif
5338 +
5339 #include <asm/processor.h>
5340
5341 /*
5342 diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
5343 index 3be4405..a799827 100644
5344 --- a/arch/mips/kernel/process.c
5345 +++ b/arch/mips/kernel/process.c
5346 @@ -461,15 +461,3 @@ unsigned long get_wchan(struct task_struct *task)
5347 out:
5348 return pc;
5349 }
5350 -
5351 -/*
5352 - * Don't forget that the stack pointer must be aligned on a 8 bytes
5353 - * boundary for 32-bits ABI and 16 bytes for 64-bits ABI.
5354 - */
5355 -unsigned long arch_align_stack(unsigned long sp)
5356 -{
5357 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
5358 - sp -= get_random_int() & ~PAGE_MASK;
5359 -
5360 - return sp & ALMASK;
5361 -}
5362 diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
5363 index 9c6299c..2fb4c22 100644
5364 --- a/arch/mips/kernel/ptrace.c
5365 +++ b/arch/mips/kernel/ptrace.c
5366 @@ -528,6 +528,10 @@ static inline int audit_arch(void)
5367 return arch;
5368 }
5369
5370 +#ifdef CONFIG_GRKERNSEC_SETXID
5371 +extern void gr_delayed_cred_worker(void);
5372 +#endif
5373 +
5374 /*
5375 * Notification of system call entry/exit
5376 * - triggered by current->work.syscall_trace
5377 @@ -537,6 +541,11 @@ asmlinkage void syscall_trace_enter(struct pt_regs *regs)
5378 /* do the secure computing check first */
5379 secure_computing_strict(regs->regs[2]);
5380
5381 +#ifdef CONFIG_GRKERNSEC_SETXID
5382 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
5383 + gr_delayed_cred_worker();
5384 +#endif
5385 +
5386 if (!(current->ptrace & PT_PTRACED))
5387 goto out;
5388
5389 diff --git a/arch/mips/kernel/scall32-o32.S b/arch/mips/kernel/scall32-o32.S
5390 index 9ea2964..c4329c3 100644
5391 --- a/arch/mips/kernel/scall32-o32.S
5392 +++ b/arch/mips/kernel/scall32-o32.S
5393 @@ -52,7 +52,7 @@ NESTED(handle_sys, PT_SIZE, sp)
5394
5395 stack_done:
5396 lw t0, TI_FLAGS($28) # syscall tracing enabled?
5397 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5398 + li t1, _TIF_SYSCALL_WORK
5399 and t0, t1
5400 bnez t0, syscall_trace_entry # -> yes
5401
5402 diff --git a/arch/mips/kernel/scall64-64.S b/arch/mips/kernel/scall64-64.S
5403 index 36cfd40..b1436e0 100644
5404 --- a/arch/mips/kernel/scall64-64.S
5405 +++ b/arch/mips/kernel/scall64-64.S
5406 @@ -54,7 +54,7 @@ NESTED(handle_sys64, PT_SIZE, sp)
5407
5408 sd a3, PT_R26(sp) # save a3 for syscall restarting
5409
5410 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5411 + li t1, _TIF_SYSCALL_WORK
5412 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
5413 and t0, t1, t0
5414 bnez t0, syscall_trace_entry
5415 diff --git a/arch/mips/kernel/scall64-n32.S b/arch/mips/kernel/scall64-n32.S
5416 index 693d60b..ae0ba75 100644
5417 --- a/arch/mips/kernel/scall64-n32.S
5418 +++ b/arch/mips/kernel/scall64-n32.S
5419 @@ -47,7 +47,7 @@ NESTED(handle_sysn32, PT_SIZE, sp)
5420
5421 sd a3, PT_R26(sp) # save a3 for syscall restarting
5422
5423 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5424 + li t1, _TIF_SYSCALL_WORK
5425 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
5426 and t0, t1, t0
5427 bnez t0, n32_syscall_trace_entry
5428 diff --git a/arch/mips/kernel/scall64-o32.S b/arch/mips/kernel/scall64-o32.S
5429 index af8887f..611ccb6 100644
5430 --- a/arch/mips/kernel/scall64-o32.S
5431 +++ b/arch/mips/kernel/scall64-o32.S
5432 @@ -81,7 +81,7 @@ NESTED(handle_sys, PT_SIZE, sp)
5433 PTR 4b, bad_stack
5434 .previous
5435
5436 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5437 + li t1, _TIF_SYSCALL_WORK
5438 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
5439 and t0, t1, t0
5440 bnez t0, trace_a_syscall
5441 diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
5442 index 0fead53..a2c0fb5 100644
5443 --- a/arch/mips/mm/fault.c
5444 +++ b/arch/mips/mm/fault.c
5445 @@ -27,6 +27,23 @@
5446 #include <asm/highmem.h> /* For VMALLOC_END */
5447 #include <linux/kdebug.h>
5448
5449 +#ifdef CONFIG_PAX_PAGEEXEC
5450 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
5451 +{
5452 + unsigned long i;
5453 +
5454 + printk(KERN_ERR "PAX: bytes at PC: ");
5455 + for (i = 0; i < 5; i++) {
5456 + unsigned int c;
5457 + if (get_user(c, (unsigned int *)pc+i))
5458 + printk(KERN_CONT "???????? ");
5459 + else
5460 + printk(KERN_CONT "%08x ", c);
5461 + }
5462 + printk("\n");
5463 +}
5464 +#endif
5465 +
5466 /*
5467 * This routine handles page faults. It determines the address,
5468 * and the problem, and then passes it off to one of the appropriate
5469 diff --git a/arch/mips/mm/mmap.c b/arch/mips/mm/mmap.c
5470 index 7e5fe27..9656513 100644
5471 --- a/arch/mips/mm/mmap.c
5472 +++ b/arch/mips/mm/mmap.c
5473 @@ -59,6 +59,7 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5474 struct vm_area_struct *vma;
5475 unsigned long addr = addr0;
5476 int do_color_align;
5477 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
5478 struct vm_unmapped_area_info info;
5479
5480 if (unlikely(len > TASK_SIZE))
5481 @@ -84,6 +85,11 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5482 do_color_align = 1;
5483
5484 /* requesting a specific address */
5485 +
5486 +#ifdef CONFIG_PAX_RANDMMAP
5487 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
5488 +#endif
5489 +
5490 if (addr) {
5491 if (do_color_align)
5492 addr = COLOUR_ALIGN(addr, pgoff);
5493 @@ -91,14 +97,14 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5494 addr = PAGE_ALIGN(addr);
5495
5496 vma = find_vma(mm, addr);
5497 - if (TASK_SIZE - len >= addr &&
5498 - (!vma || addr + len <= vma->vm_start))
5499 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vmm, addr, len, offset))
5500 return addr;
5501 }
5502
5503 info.length = len;
5504 info.align_mask = do_color_align ? (PAGE_MASK & shm_align_mask) : 0;
5505 info.align_offset = pgoff << PAGE_SHIFT;
5506 + info.threadstack_offset = offset;
5507
5508 if (dir == DOWN) {
5509 info.flags = VM_UNMAPPED_AREA_TOPDOWN;
5510 @@ -146,6 +152,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
5511 {
5512 unsigned long random_factor = 0UL;
5513
5514 +#ifdef CONFIG_PAX_RANDMMAP
5515 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
5516 +#endif
5517 +
5518 if (current->flags & PF_RANDOMIZE) {
5519 random_factor = get_random_int();
5520 random_factor = random_factor << PAGE_SHIFT;
5521 @@ -157,42 +167,27 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
5522
5523 if (mmap_is_legacy()) {
5524 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
5525 +
5526 +#ifdef CONFIG_PAX_RANDMMAP
5527 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5528 + mm->mmap_base += mm->delta_mmap;
5529 +#endif
5530 +
5531 mm->get_unmapped_area = arch_get_unmapped_area;
5532 mm->unmap_area = arch_unmap_area;
5533 } else {
5534 mm->mmap_base = mmap_base(random_factor);
5535 +
5536 +#ifdef CONFIG_PAX_RANDMMAP
5537 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5538 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
5539 +#endif
5540 +
5541 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
5542 mm->unmap_area = arch_unmap_area_topdown;
5543 }
5544 }
5545
5546 -static inline unsigned long brk_rnd(void)
5547 -{
5548 - unsigned long rnd = get_random_int();
5549 -
5550 - rnd = rnd << PAGE_SHIFT;
5551 - /* 8MB for 32bit, 256MB for 64bit */
5552 - if (TASK_IS_32BIT_ADDR)
5553 - rnd = rnd & 0x7ffffful;
5554 - else
5555 - rnd = rnd & 0xffffffful;
5556 -
5557 - return rnd;
5558 -}
5559 -
5560 -unsigned long arch_randomize_brk(struct mm_struct *mm)
5561 -{
5562 - unsigned long base = mm->brk;
5563 - unsigned long ret;
5564 -
5565 - ret = PAGE_ALIGN(base + brk_rnd());
5566 -
5567 - if (ret < mm->brk)
5568 - return mm->brk;
5569 -
5570 - return ret;
5571 -}
5572 -
5573 int __virt_addr_valid(const volatile void *kaddr)
5574 {
5575 return pfn_valid(PFN_DOWN(virt_to_phys(kaddr)));
5576 diff --git a/arch/mn10300/proc-mn103e010/include/proc/cache.h b/arch/mn10300/proc-mn103e010/include/proc/cache.h
5577 index 967d144..db12197 100644
5578 --- a/arch/mn10300/proc-mn103e010/include/proc/cache.h
5579 +++ b/arch/mn10300/proc-mn103e010/include/proc/cache.h
5580 @@ -11,12 +11,14 @@
5581 #ifndef _ASM_PROC_CACHE_H
5582 #define _ASM_PROC_CACHE_H
5583
5584 +#include <linux/const.h>
5585 +
5586 /* L1 cache */
5587
5588 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
5589 #define L1_CACHE_NENTRIES 256 /* number of entries in each way */
5590 -#define L1_CACHE_BYTES 16 /* bytes per entry */
5591 #define L1_CACHE_SHIFT 4 /* shift for bytes per entry */
5592 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
5593 #define L1_CACHE_WAYDISP 0x1000 /* displacement of one way from the next */
5594
5595 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
5596 diff --git a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
5597 index bcb5df2..84fabd2 100644
5598 --- a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
5599 +++ b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
5600 @@ -16,13 +16,15 @@
5601 #ifndef _ASM_PROC_CACHE_H
5602 #define _ASM_PROC_CACHE_H
5603
5604 +#include <linux/const.h>
5605 +
5606 /*
5607 * L1 cache
5608 */
5609 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
5610 #define L1_CACHE_NENTRIES 128 /* number of entries in each way */
5611 -#define L1_CACHE_BYTES 32 /* bytes per entry */
5612 #define L1_CACHE_SHIFT 5 /* shift for bytes per entry */
5613 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
5614 #define L1_CACHE_WAYDISP 0x1000 /* distance from one way to the next */
5615
5616 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
5617 diff --git a/arch/openrisc/include/asm/cache.h b/arch/openrisc/include/asm/cache.h
5618 index 4ce7a01..449202a 100644
5619 --- a/arch/openrisc/include/asm/cache.h
5620 +++ b/arch/openrisc/include/asm/cache.h
5621 @@ -19,11 +19,13 @@
5622 #ifndef __ASM_OPENRISC_CACHE_H
5623 #define __ASM_OPENRISC_CACHE_H
5624
5625 +#include <linux/const.h>
5626 +
5627 /* FIXME: How can we replace these with values from the CPU...
5628 * they shouldn't be hard-coded!
5629 */
5630
5631 -#define L1_CACHE_BYTES 16
5632 #define L1_CACHE_SHIFT 4
5633 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5634
5635 #endif /* __ASM_OPENRISC_CACHE_H */
5636 diff --git a/arch/parisc/include/asm/atomic.h b/arch/parisc/include/asm/atomic.h
5637 index f38e198..4179e38 100644
5638 --- a/arch/parisc/include/asm/atomic.h
5639 +++ b/arch/parisc/include/asm/atomic.h
5640 @@ -229,6 +229,16 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
5641
5642 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
5643
5644 +#define atomic64_read_unchecked(v) atomic64_read(v)
5645 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
5646 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
5647 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
5648 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
5649 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
5650 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
5651 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
5652 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
5653 +
5654 #endif /* !CONFIG_64BIT */
5655
5656
5657 diff --git a/arch/parisc/include/asm/cache.h b/arch/parisc/include/asm/cache.h
5658 index 47f11c7..3420df2 100644
5659 --- a/arch/parisc/include/asm/cache.h
5660 +++ b/arch/parisc/include/asm/cache.h
5661 @@ -5,6 +5,7 @@
5662 #ifndef __ARCH_PARISC_CACHE_H
5663 #define __ARCH_PARISC_CACHE_H
5664
5665 +#include <linux/const.h>
5666
5667 /*
5668 * PA 2.0 processors have 64-byte cachelines; PA 1.1 processors have
5669 @@ -15,13 +16,13 @@
5670 * just ruin performance.
5671 */
5672 #ifdef CONFIG_PA20
5673 -#define L1_CACHE_BYTES 64
5674 #define L1_CACHE_SHIFT 6
5675 #else
5676 -#define L1_CACHE_BYTES 32
5677 #define L1_CACHE_SHIFT 5
5678 #endif
5679
5680 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5681 +
5682 #ifndef __ASSEMBLY__
5683
5684 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5685 diff --git a/arch/parisc/include/asm/elf.h b/arch/parisc/include/asm/elf.h
5686 index ad2b503..bdf1651 100644
5687 --- a/arch/parisc/include/asm/elf.h
5688 +++ b/arch/parisc/include/asm/elf.h
5689 @@ -342,6 +342,13 @@ struct pt_regs; /* forward declaration... */
5690
5691 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x01000000)
5692
5693 +#ifdef CONFIG_PAX_ASLR
5694 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
5695 +
5696 +#define PAX_DELTA_MMAP_LEN 16
5697 +#define PAX_DELTA_STACK_LEN 16
5698 +#endif
5699 +
5700 /* This yields a mask that user programs can use to figure out what
5701 instruction set this CPU supports. This could be done in user space,
5702 but it's not easy, and we've already done it here. */
5703 diff --git a/arch/parisc/include/asm/pgalloc.h b/arch/parisc/include/asm/pgalloc.h
5704 index fc987a1..6e068ef 100644
5705 --- a/arch/parisc/include/asm/pgalloc.h
5706 +++ b/arch/parisc/include/asm/pgalloc.h
5707 @@ -61,6 +61,11 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
5708 (__u32)(__pa((unsigned long)pmd) >> PxD_VALUE_SHIFT));
5709 }
5710
5711 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
5712 +{
5713 + pgd_populate(mm, pgd, pmd);
5714 +}
5715 +
5716 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
5717 {
5718 pmd_t *pmd = (pmd_t *)__get_free_pages(GFP_KERNEL|__GFP_REPEAT,
5719 @@ -93,6 +98,7 @@ static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
5720 #define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *)2); })
5721 #define pmd_free(mm, x) do { } while (0)
5722 #define pgd_populate(mm, pmd, pte) BUG()
5723 +#define pgd_populate_kernel(mm, pmd, pte) BUG()
5724
5725 #endif
5726
5727 diff --git a/arch/parisc/include/asm/pgtable.h b/arch/parisc/include/asm/pgtable.h
5728 index 1e40d7f..a3eb445 100644
5729 --- a/arch/parisc/include/asm/pgtable.h
5730 +++ b/arch/parisc/include/asm/pgtable.h
5731 @@ -223,6 +223,17 @@ extern void purge_tlb_entries(struct mm_struct *, unsigned long);
5732 #define PAGE_EXECREAD __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_EXEC |_PAGE_ACCESSED)
5733 #define PAGE_COPY PAGE_EXECREAD
5734 #define PAGE_RWX __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_EXEC |_PAGE_ACCESSED)
5735 +
5736 +#ifdef CONFIG_PAX_PAGEEXEC
5737 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_ACCESSED)
5738 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
5739 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
5740 +#else
5741 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
5742 +# define PAGE_COPY_NOEXEC PAGE_COPY
5743 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
5744 +#endif
5745 +
5746 #define PAGE_KERNEL __pgprot(_PAGE_KERNEL)
5747 #define PAGE_KERNEL_EXEC __pgprot(_PAGE_KERNEL_EXEC)
5748 #define PAGE_KERNEL_RWX __pgprot(_PAGE_KERNEL_RWX)
5749 diff --git a/arch/parisc/include/asm/uaccess.h b/arch/parisc/include/asm/uaccess.h
5750 index e0a8235..ce2f1e1 100644
5751 --- a/arch/parisc/include/asm/uaccess.h
5752 +++ b/arch/parisc/include/asm/uaccess.h
5753 @@ -245,10 +245,10 @@ static inline unsigned long __must_check copy_from_user(void *to,
5754 const void __user *from,
5755 unsigned long n)
5756 {
5757 - int sz = __compiletime_object_size(to);
5758 + size_t sz = __compiletime_object_size(to);
5759 int ret = -EFAULT;
5760
5761 - if (likely(sz == -1 || !__builtin_constant_p(n) || sz >= n))
5762 + if (likely(sz == (size_t)-1 || !__builtin_constant_p(n) || sz >= n))
5763 ret = __copy_from_user(to, from, n);
5764 else
5765 copy_from_user_overflow();
5766 diff --git a/arch/parisc/kernel/module.c b/arch/parisc/kernel/module.c
5767 index 2a625fb..9908930 100644
5768 --- a/arch/parisc/kernel/module.c
5769 +++ b/arch/parisc/kernel/module.c
5770 @@ -98,16 +98,38 @@
5771
5772 /* three functions to determine where in the module core
5773 * or init pieces the location is */
5774 +static inline int in_init_rx(struct module *me, void *loc)
5775 +{
5776 + return (loc >= me->module_init_rx &&
5777 + loc < (me->module_init_rx + me->init_size_rx));
5778 +}
5779 +
5780 +static inline int in_init_rw(struct module *me, void *loc)
5781 +{
5782 + return (loc >= me->module_init_rw &&
5783 + loc < (me->module_init_rw + me->init_size_rw));
5784 +}
5785 +
5786 static inline int in_init(struct module *me, void *loc)
5787 {
5788 - return (loc >= me->module_init &&
5789 - loc <= (me->module_init + me->init_size));
5790 + return in_init_rx(me, loc) || in_init_rw(me, loc);
5791 +}
5792 +
5793 +static inline int in_core_rx(struct module *me, void *loc)
5794 +{
5795 + return (loc >= me->module_core_rx &&
5796 + loc < (me->module_core_rx + me->core_size_rx));
5797 +}
5798 +
5799 +static inline int in_core_rw(struct module *me, void *loc)
5800 +{
5801 + return (loc >= me->module_core_rw &&
5802 + loc < (me->module_core_rw + me->core_size_rw));
5803 }
5804
5805 static inline int in_core(struct module *me, void *loc)
5806 {
5807 - return (loc >= me->module_core &&
5808 - loc <= (me->module_core + me->core_size));
5809 + return in_core_rx(me, loc) || in_core_rw(me, loc);
5810 }
5811
5812 static inline int in_local(struct module *me, void *loc)
5813 @@ -371,13 +393,13 @@ int module_frob_arch_sections(CONST Elf_Ehdr *hdr,
5814 }
5815
5816 /* align things a bit */
5817 - me->core_size = ALIGN(me->core_size, 16);
5818 - me->arch.got_offset = me->core_size;
5819 - me->core_size += gots * sizeof(struct got_entry);
5820 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
5821 + me->arch.got_offset = me->core_size_rw;
5822 + me->core_size_rw += gots * sizeof(struct got_entry);
5823
5824 - me->core_size = ALIGN(me->core_size, 16);
5825 - me->arch.fdesc_offset = me->core_size;
5826 - me->core_size += fdescs * sizeof(Elf_Fdesc);
5827 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
5828 + me->arch.fdesc_offset = me->core_size_rw;
5829 + me->core_size_rw += fdescs * sizeof(Elf_Fdesc);
5830
5831 me->arch.got_max = gots;
5832 me->arch.fdesc_max = fdescs;
5833 @@ -395,7 +417,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
5834
5835 BUG_ON(value == 0);
5836
5837 - got = me->module_core + me->arch.got_offset;
5838 + got = me->module_core_rw + me->arch.got_offset;
5839 for (i = 0; got[i].addr; i++)
5840 if (got[i].addr == value)
5841 goto out;
5842 @@ -413,7 +435,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
5843 #ifdef CONFIG_64BIT
5844 static Elf_Addr get_fdesc(struct module *me, unsigned long value)
5845 {
5846 - Elf_Fdesc *fdesc = me->module_core + me->arch.fdesc_offset;
5847 + Elf_Fdesc *fdesc = me->module_core_rw + me->arch.fdesc_offset;
5848
5849 if (!value) {
5850 printk(KERN_ERR "%s: zero OPD requested!\n", me->name);
5851 @@ -431,7 +453,7 @@ static Elf_Addr get_fdesc(struct module *me, unsigned long value)
5852
5853 /* Create new one */
5854 fdesc->addr = value;
5855 - fdesc->gp = (Elf_Addr)me->module_core + me->arch.got_offset;
5856 + fdesc->gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
5857 return (Elf_Addr)fdesc;
5858 }
5859 #endif /* CONFIG_64BIT */
5860 @@ -843,7 +865,7 @@ register_unwind_table(struct module *me,
5861
5862 table = (unsigned char *)sechdrs[me->arch.unwind_section].sh_addr;
5863 end = table + sechdrs[me->arch.unwind_section].sh_size;
5864 - gp = (Elf_Addr)me->module_core + me->arch.got_offset;
5865 + gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
5866
5867 DEBUGP("register_unwind_table(), sect = %d at 0x%p - 0x%p (gp=0x%lx)\n",
5868 me->arch.unwind_section, table, end, gp);
5869 diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
5870 index 5dfd248..64914ac 100644
5871 --- a/arch/parisc/kernel/sys_parisc.c
5872 +++ b/arch/parisc/kernel/sys_parisc.c
5873 @@ -33,9 +33,11 @@
5874 #include <linux/utsname.h>
5875 #include <linux/personality.h>
5876
5877 -static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
5878 +static unsigned long get_unshared_area(struct file *filp, unsigned long addr, unsigned long len,
5879 + unsigned long flags)
5880 {
5881 struct vm_unmapped_area_info info;
5882 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
5883
5884 info.flags = 0;
5885 info.length = len;
5886 @@ -43,6 +45,7 @@ static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
5887 info.high_limit = TASK_SIZE;
5888 info.align_mask = 0;
5889 info.align_offset = 0;
5890 + info.threadstack_offset = offset;
5891 return vm_unmapped_area(&info);
5892 }
5893
5894 @@ -61,10 +64,11 @@ static int get_offset(struct address_space *mapping)
5895 return (unsigned long) mapping >> 8;
5896 }
5897
5898 -static unsigned long get_shared_area(struct address_space *mapping,
5899 - unsigned long addr, unsigned long len, unsigned long pgoff)
5900 +static unsigned long get_shared_area(struct file *filp, struct address_space *mapping,
5901 + unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags)
5902 {
5903 struct vm_unmapped_area_info info;
5904 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
5905
5906 info.flags = 0;
5907 info.length = len;
5908 @@ -72,6 +76,7 @@ static unsigned long get_shared_area(struct address_space *mapping,
5909 info.high_limit = TASK_SIZE;
5910 info.align_mask = PAGE_MASK & (SHMLBA - 1);
5911 info.align_offset = (get_offset(mapping) + pgoff) << PAGE_SHIFT;
5912 + info.threadstack_offset = offset;
5913 return vm_unmapped_area(&info);
5914 }
5915
5916 @@ -86,15 +91,22 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
5917 return -EINVAL;
5918 return addr;
5919 }
5920 - if (!addr)
5921 + if (!addr) {
5922 addr = TASK_UNMAPPED_BASE;
5923
5924 +#ifdef CONFIG_PAX_RANDMMAP
5925 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
5926 + addr += current->mm->delta_mmap;
5927 +#endif
5928 +
5929 + }
5930 +
5931 if (filp) {
5932 - addr = get_shared_area(filp->f_mapping, addr, len, pgoff);
5933 + addr = get_shared_area(filp, filp->f_mapping, addr, len, pgoff, flags);
5934 } else if(flags & MAP_SHARED) {
5935 - addr = get_shared_area(NULL, addr, len, pgoff);
5936 + addr = get_shared_area(filp, NULL, addr, len, pgoff, flags);
5937 } else {
5938 - addr = get_unshared_area(addr, len);
5939 + addr = get_unshared_area(filp, addr, len, flags);
5940 }
5941 return addr;
5942 }
5943 diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c
5944 index aeb8f8f..27a6c2f 100644
5945 --- a/arch/parisc/kernel/traps.c
5946 +++ b/arch/parisc/kernel/traps.c
5947 @@ -732,9 +732,7 @@ void notrace handle_interruption(int code, struct pt_regs *regs)
5948
5949 down_read(&current->mm->mmap_sem);
5950 vma = find_vma(current->mm,regs->iaoq[0]);
5951 - if (vma && (regs->iaoq[0] >= vma->vm_start)
5952 - && (vma->vm_flags & VM_EXEC)) {
5953 -
5954 + if (vma && (regs->iaoq[0] >= vma->vm_start)) {
5955 fault_address = regs->iaoq[0];
5956 fault_space = regs->iasq[0];
5957
5958 diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c
5959 index f247a34..dc0f219 100644
5960 --- a/arch/parisc/mm/fault.c
5961 +++ b/arch/parisc/mm/fault.c
5962 @@ -15,6 +15,7 @@
5963 #include <linux/sched.h>
5964 #include <linux/interrupt.h>
5965 #include <linux/module.h>
5966 +#include <linux/unistd.h>
5967
5968 #include <asm/uaccess.h>
5969 #include <asm/traps.h>
5970 @@ -52,7 +53,7 @@ DEFINE_PER_CPU(struct exception_data, exception_data);
5971 static unsigned long
5972 parisc_acctyp(unsigned long code, unsigned int inst)
5973 {
5974 - if (code == 6 || code == 16)
5975 + if (code == 6 || code == 7 || code == 16)
5976 return VM_EXEC;
5977
5978 switch (inst & 0xf0000000) {
5979 @@ -138,6 +139,116 @@ parisc_acctyp(unsigned long code, unsigned int inst)
5980 }
5981 #endif
5982
5983 +#ifdef CONFIG_PAX_PAGEEXEC
5984 +/*
5985 + * PaX: decide what to do with offenders (instruction_pointer(regs) = fault address)
5986 + *
5987 + * returns 1 when task should be killed
5988 + * 2 when rt_sigreturn trampoline was detected
5989 + * 3 when unpatched PLT trampoline was detected
5990 + */
5991 +static int pax_handle_fetch_fault(struct pt_regs *regs)
5992 +{
5993 +
5994 +#ifdef CONFIG_PAX_EMUPLT
5995 + int err;
5996 +
5997 + do { /* PaX: unpatched PLT emulation */
5998 + unsigned int bl, depwi;
5999 +
6000 + err = get_user(bl, (unsigned int *)instruction_pointer(regs));
6001 + err |= get_user(depwi, (unsigned int *)(instruction_pointer(regs)+4));
6002 +
6003 + if (err)
6004 + break;
6005 +
6006 + if (bl == 0xEA9F1FDDU && depwi == 0xD6801C1EU) {
6007 + unsigned int ldw, bv, ldw2, addr = instruction_pointer(regs)-12;
6008 +
6009 + err = get_user(ldw, (unsigned int *)addr);
6010 + err |= get_user(bv, (unsigned int *)(addr+4));
6011 + err |= get_user(ldw2, (unsigned int *)(addr+8));
6012 +
6013 + if (err)
6014 + break;
6015 +
6016 + if (ldw == 0x0E801096U &&
6017 + bv == 0xEAC0C000U &&
6018 + ldw2 == 0x0E881095U)
6019 + {
6020 + unsigned int resolver, map;
6021 +
6022 + err = get_user(resolver, (unsigned int *)(instruction_pointer(regs)+8));
6023 + err |= get_user(map, (unsigned int *)(instruction_pointer(regs)+12));
6024 + if (err)
6025 + break;
6026 +
6027 + regs->gr[20] = instruction_pointer(regs)+8;
6028 + regs->gr[21] = map;
6029 + regs->gr[22] = resolver;
6030 + regs->iaoq[0] = resolver | 3UL;
6031 + regs->iaoq[1] = regs->iaoq[0] + 4;
6032 + return 3;
6033 + }
6034 + }
6035 + } while (0);
6036 +#endif
6037 +
6038 +#ifdef CONFIG_PAX_EMUTRAMP
6039 +
6040 +#ifndef CONFIG_PAX_EMUSIGRT
6041 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
6042 + return 1;
6043 +#endif
6044 +
6045 + do { /* PaX: rt_sigreturn emulation */
6046 + unsigned int ldi1, ldi2, bel, nop;
6047 +
6048 + err = get_user(ldi1, (unsigned int *)instruction_pointer(regs));
6049 + err |= get_user(ldi2, (unsigned int *)(instruction_pointer(regs)+4));
6050 + err |= get_user(bel, (unsigned int *)(instruction_pointer(regs)+8));
6051 + err |= get_user(nop, (unsigned int *)(instruction_pointer(regs)+12));
6052 +
6053 + if (err)
6054 + break;
6055 +
6056 + if ((ldi1 == 0x34190000U || ldi1 == 0x34190002U) &&
6057 + ldi2 == 0x3414015AU &&
6058 + bel == 0xE4008200U &&
6059 + nop == 0x08000240U)
6060 + {
6061 + regs->gr[25] = (ldi1 & 2) >> 1;
6062 + regs->gr[20] = __NR_rt_sigreturn;
6063 + regs->gr[31] = regs->iaoq[1] + 16;
6064 + regs->sr[0] = regs->iasq[1];
6065 + regs->iaoq[0] = 0x100UL;
6066 + regs->iaoq[1] = regs->iaoq[0] + 4;
6067 + regs->iasq[0] = regs->sr[2];
6068 + regs->iasq[1] = regs->sr[2];
6069 + return 2;
6070 + }
6071 + } while (0);
6072 +#endif
6073 +
6074 + return 1;
6075 +}
6076 +
6077 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
6078 +{
6079 + unsigned long i;
6080 +
6081 + printk(KERN_ERR "PAX: bytes at PC: ");
6082 + for (i = 0; i < 5; i++) {
6083 + unsigned int c;
6084 + if (get_user(c, (unsigned int *)pc+i))
6085 + printk(KERN_CONT "???????? ");
6086 + else
6087 + printk(KERN_CONT "%08x ", c);
6088 + }
6089 + printk("\n");
6090 +}
6091 +#endif
6092 +
6093 int fixup_exception(struct pt_regs *regs)
6094 {
6095 const struct exception_table_entry *fix;
6096 @@ -194,8 +305,33 @@ good_area:
6097
6098 acc_type = parisc_acctyp(code,regs->iir);
6099
6100 - if ((vma->vm_flags & acc_type) != acc_type)
6101 + if ((vma->vm_flags & acc_type) != acc_type) {
6102 +
6103 +#ifdef CONFIG_PAX_PAGEEXEC
6104 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && (acc_type & VM_EXEC) &&
6105 + (address & ~3UL) == instruction_pointer(regs))
6106 + {
6107 + up_read(&mm->mmap_sem);
6108 + switch (pax_handle_fetch_fault(regs)) {
6109 +
6110 +#ifdef CONFIG_PAX_EMUPLT
6111 + case 3:
6112 + return;
6113 +#endif
6114 +
6115 +#ifdef CONFIG_PAX_EMUTRAMP
6116 + case 2:
6117 + return;
6118 +#endif
6119 +
6120 + }
6121 + pax_report_fault(regs, (void *)instruction_pointer(regs), (void *)regs->gr[30]);
6122 + do_group_exit(SIGKILL);
6123 + }
6124 +#endif
6125 +
6126 goto bad_area;
6127 + }
6128
6129 /*
6130 * If for any reason at all we couldn't handle the fault, make
6131 diff --git a/arch/powerpc/include/asm/atomic.h b/arch/powerpc/include/asm/atomic.h
6132 index e3b1d41..8e81edf 100644
6133 --- a/arch/powerpc/include/asm/atomic.h
6134 +++ b/arch/powerpc/include/asm/atomic.h
6135 @@ -523,6 +523,16 @@ static __inline__ long atomic64_inc_not_zero(atomic64_t *v)
6136 return t1;
6137 }
6138
6139 +#define atomic64_read_unchecked(v) atomic64_read(v)
6140 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
6141 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
6142 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
6143 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
6144 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
6145 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
6146 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
6147 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
6148 +
6149 #endif /* __powerpc64__ */
6150
6151 #endif /* __KERNEL__ */
6152 diff --git a/arch/powerpc/include/asm/cache.h b/arch/powerpc/include/asm/cache.h
6153 index 9e495c9..b6878e5 100644
6154 --- a/arch/powerpc/include/asm/cache.h
6155 +++ b/arch/powerpc/include/asm/cache.h
6156 @@ -3,6 +3,7 @@
6157
6158 #ifdef __KERNEL__
6159
6160 +#include <linux/const.h>
6161
6162 /* bytes per L1 cache line */
6163 #if defined(CONFIG_8xx) || defined(CONFIG_403GCX)
6164 @@ -22,7 +23,7 @@
6165 #define L1_CACHE_SHIFT 7
6166 #endif
6167
6168 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
6169 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
6170
6171 #define SMP_CACHE_BYTES L1_CACHE_BYTES
6172
6173 diff --git a/arch/powerpc/include/asm/elf.h b/arch/powerpc/include/asm/elf.h
6174 index ac9790f..6d30741 100644
6175 --- a/arch/powerpc/include/asm/elf.h
6176 +++ b/arch/powerpc/include/asm/elf.h
6177 @@ -28,8 +28,19 @@
6178 the loader. We need to make sure that it is out of the way of the program
6179 that it will "exec", and that there is sufficient room for the brk. */
6180
6181 -extern unsigned long randomize_et_dyn(unsigned long base);
6182 -#define ELF_ET_DYN_BASE (randomize_et_dyn(0x20000000))
6183 +#define ELF_ET_DYN_BASE (0x20000000)
6184 +
6185 +#ifdef CONFIG_PAX_ASLR
6186 +#define PAX_ELF_ET_DYN_BASE (0x10000000UL)
6187 +
6188 +#ifdef __powerpc64__
6189 +#define PAX_DELTA_MMAP_LEN (is_32bit_task() ? 16 : 28)
6190 +#define PAX_DELTA_STACK_LEN (is_32bit_task() ? 16 : 28)
6191 +#else
6192 +#define PAX_DELTA_MMAP_LEN 15
6193 +#define PAX_DELTA_STACK_LEN 15
6194 +#endif
6195 +#endif
6196
6197 /*
6198 * Our registers are always unsigned longs, whether we're a 32 bit
6199 @@ -122,10 +133,6 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,
6200 (0x7ff >> (PAGE_SHIFT - 12)) : \
6201 (0x3ffff >> (PAGE_SHIFT - 12)))
6202
6203 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
6204 -#define arch_randomize_brk arch_randomize_brk
6205 -
6206 -
6207 #ifdef CONFIG_SPU_BASE
6208 /* Notes used in ET_CORE. Note name is "SPU/<fd>/<filename>". */
6209 #define NT_SPU 1
6210 diff --git a/arch/powerpc/include/asm/exec.h b/arch/powerpc/include/asm/exec.h
6211 index 8196e9c..d83a9f3 100644
6212 --- a/arch/powerpc/include/asm/exec.h
6213 +++ b/arch/powerpc/include/asm/exec.h
6214 @@ -4,6 +4,6 @@
6215 #ifndef _ASM_POWERPC_EXEC_H
6216 #define _ASM_POWERPC_EXEC_H
6217
6218 -extern unsigned long arch_align_stack(unsigned long sp);
6219 +#define arch_align_stack(x) ((x) & ~0xfUL)
6220
6221 #endif /* _ASM_POWERPC_EXEC_H */
6222 diff --git a/arch/powerpc/include/asm/kmap_types.h b/arch/powerpc/include/asm/kmap_types.h
6223 index 5acabbd..7ea14fa 100644
6224 --- a/arch/powerpc/include/asm/kmap_types.h
6225 +++ b/arch/powerpc/include/asm/kmap_types.h
6226 @@ -10,7 +10,7 @@
6227 * 2 of the License, or (at your option) any later version.
6228 */
6229
6230 -#define KM_TYPE_NR 16
6231 +#define KM_TYPE_NR 17
6232
6233 #endif /* __KERNEL__ */
6234 #endif /* _ASM_POWERPC_KMAP_TYPES_H */
6235 diff --git a/arch/powerpc/include/asm/mman.h b/arch/powerpc/include/asm/mman.h
6236 index 8565c25..2865190 100644
6237 --- a/arch/powerpc/include/asm/mman.h
6238 +++ b/arch/powerpc/include/asm/mman.h
6239 @@ -24,7 +24,7 @@ static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot)
6240 }
6241 #define arch_calc_vm_prot_bits(prot) arch_calc_vm_prot_bits(prot)
6242
6243 -static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags)
6244 +static inline pgprot_t arch_vm_get_page_prot(vm_flags_t vm_flags)
6245 {
6246 return (vm_flags & VM_SAO) ? __pgprot(_PAGE_SAO) : __pgprot(0);
6247 }
6248 diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
6249 index f072e97..b436dee 100644
6250 --- a/arch/powerpc/include/asm/page.h
6251 +++ b/arch/powerpc/include/asm/page.h
6252 @@ -220,8 +220,9 @@ extern long long virt_phys_offset;
6253 * and needs to be executable. This means the whole heap ends
6254 * up being executable.
6255 */
6256 -#define VM_DATA_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
6257 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6258 +#define VM_DATA_DEFAULT_FLAGS32 \
6259 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
6260 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6261
6262 #define VM_DATA_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
6263 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6264 @@ -249,6 +250,9 @@ extern long long virt_phys_offset;
6265 #define is_kernel_addr(x) ((x) >= PAGE_OFFSET)
6266 #endif
6267
6268 +#define ktla_ktva(addr) (addr)
6269 +#define ktva_ktla(addr) (addr)
6270 +
6271 /*
6272 * Use the top bit of the higher-level page table entries to indicate whether
6273 * the entries we point to contain hugepages. This works because we know that
6274 diff --git a/arch/powerpc/include/asm/page_64.h b/arch/powerpc/include/asm/page_64.h
6275 index cd915d6..c10cee8 100644
6276 --- a/arch/powerpc/include/asm/page_64.h
6277 +++ b/arch/powerpc/include/asm/page_64.h
6278 @@ -154,15 +154,18 @@ do { \
6279 * stack by default, so in the absence of a PT_GNU_STACK program header
6280 * we turn execute permission off.
6281 */
6282 -#define VM_STACK_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
6283 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6284 +#define VM_STACK_DEFAULT_FLAGS32 \
6285 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
6286 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6287
6288 #define VM_STACK_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
6289 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6290
6291 +#ifndef CONFIG_PAX_PAGEEXEC
6292 #define VM_STACK_DEFAULT_FLAGS \
6293 (is_32bit_task() ? \
6294 VM_STACK_DEFAULT_FLAGS32 : VM_STACK_DEFAULT_FLAGS64)
6295 +#endif
6296
6297 #include <asm-generic/getorder.h>
6298
6299 diff --git a/arch/powerpc/include/asm/pgalloc-64.h b/arch/powerpc/include/asm/pgalloc-64.h
6300 index 292725c..f87ae14 100644
6301 --- a/arch/powerpc/include/asm/pgalloc-64.h
6302 +++ b/arch/powerpc/include/asm/pgalloc-64.h
6303 @@ -50,6 +50,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
6304 #ifndef CONFIG_PPC_64K_PAGES
6305
6306 #define pgd_populate(MM, PGD, PUD) pgd_set(PGD, PUD)
6307 +#define pgd_populate_kernel(MM, PGD, PUD) pgd_populate((MM), (PGD), (PUD))
6308
6309 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
6310 {
6311 @@ -67,6 +68,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6312 pud_set(pud, (unsigned long)pmd);
6313 }
6314
6315 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6316 +{
6317 + pud_populate(mm, pud, pmd);
6318 +}
6319 +
6320 #define pmd_populate(mm, pmd, pte_page) \
6321 pmd_populate_kernel(mm, pmd, page_address(pte_page))
6322 #define pmd_populate_kernel(mm, pmd, pte) pmd_set(pmd, (unsigned long)(pte))
6323 @@ -76,6 +82,7 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6324 #else /* CONFIG_PPC_64K_PAGES */
6325
6326 #define pud_populate(mm, pud, pmd) pud_set(pud, (unsigned long)pmd)
6327 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
6328
6329 static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
6330 pte_t *pte)
6331 diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h
6332 index a9cbd3b..3b67efa 100644
6333 --- a/arch/powerpc/include/asm/pgtable.h
6334 +++ b/arch/powerpc/include/asm/pgtable.h
6335 @@ -2,6 +2,7 @@
6336 #define _ASM_POWERPC_PGTABLE_H
6337 #ifdef __KERNEL__
6338
6339 +#include <linux/const.h>
6340 #ifndef __ASSEMBLY__
6341 #include <asm/processor.h> /* For TASK_SIZE */
6342 #include <asm/mmu.h>
6343 diff --git a/arch/powerpc/include/asm/pte-hash32.h b/arch/powerpc/include/asm/pte-hash32.h
6344 index 4aad413..85d86bf 100644
6345 --- a/arch/powerpc/include/asm/pte-hash32.h
6346 +++ b/arch/powerpc/include/asm/pte-hash32.h
6347 @@ -21,6 +21,7 @@
6348 #define _PAGE_FILE 0x004 /* when !present: nonlinear file mapping */
6349 #define _PAGE_USER 0x004 /* usermode access allowed */
6350 #define _PAGE_GUARDED 0x008 /* G: prohibit speculative access */
6351 +#define _PAGE_EXEC _PAGE_GUARDED
6352 #define _PAGE_COHERENT 0x010 /* M: enforce memory coherence (SMP systems) */
6353 #define _PAGE_NO_CACHE 0x020 /* I: cache inhibit */
6354 #define _PAGE_WRITETHRU 0x040 /* W: cache write-through */
6355 diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
6356 index c9c67fc..e10c012 100644
6357 --- a/arch/powerpc/include/asm/reg.h
6358 +++ b/arch/powerpc/include/asm/reg.h
6359 @@ -245,6 +245,7 @@
6360 #define SPRN_DBCR 0x136 /* e300 Data Breakpoint Control Reg */
6361 #define SPRN_DSISR 0x012 /* Data Storage Interrupt Status Register */
6362 #define DSISR_NOHPTE 0x40000000 /* no translation found */
6363 +#define DSISR_GUARDED 0x10000000 /* fetch from guarded storage */
6364 #define DSISR_PROTFAULT 0x08000000 /* protection fault */
6365 #define DSISR_ISSTORE 0x02000000 /* access was a store */
6366 #define DSISR_DABRMATCH 0x00400000 /* hit data breakpoint */
6367 diff --git a/arch/powerpc/include/asm/smp.h b/arch/powerpc/include/asm/smp.h
6368 index 195ce2a..ab5c614 100644
6369 --- a/arch/powerpc/include/asm/smp.h
6370 +++ b/arch/powerpc/include/asm/smp.h
6371 @@ -50,7 +50,7 @@ struct smp_ops_t {
6372 int (*cpu_disable)(void);
6373 void (*cpu_die)(unsigned int nr);
6374 int (*cpu_bootable)(unsigned int nr);
6375 -};
6376 +} __no_const;
6377
6378 extern void smp_send_debugger_break(void);
6379 extern void start_secondary_resume(void);
6380 diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
6381 index 406b7b9..af63426 100644
6382 --- a/arch/powerpc/include/asm/thread_info.h
6383 +++ b/arch/powerpc/include/asm/thread_info.h
6384 @@ -97,7 +97,6 @@ static inline struct thread_info *current_thread_info(void)
6385 #define TIF_PERFMON_CTXSW 6 /* perfmon needs ctxsw calls */
6386 #define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */
6387 #define TIF_SINGLESTEP 8 /* singlestepping active */
6388 -#define TIF_MEMDIE 9 /* is terminating due to OOM killer */
6389 #define TIF_SECCOMP 10 /* secure computing */
6390 #define TIF_RESTOREALL 11 /* Restore all regs (implies NOERROR) */
6391 #define TIF_NOERROR 12 /* Force successful syscall return */
6392 @@ -106,6 +105,9 @@ static inline struct thread_info *current_thread_info(void)
6393 #define TIF_SYSCALL_TRACEPOINT 15 /* syscall tracepoint instrumentation */
6394 #define TIF_EMULATE_STACK_STORE 16 /* Is an instruction emulation
6395 for stack store? */
6396 +#define TIF_MEMDIE 17 /* is terminating due to OOM killer */
6397 +/* mask must be expressable within 16 bits to satisfy 'andi' instruction reqs */
6398 +#define TIF_GRSEC_SETXID 9 /* update credentials on syscall entry/exit */
6399
6400 /* as above, but as bit values */
6401 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
6402 @@ -124,8 +126,10 @@ static inline struct thread_info *current_thread_info(void)
6403 #define _TIF_UPROBE (1<<TIF_UPROBE)
6404 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
6405 #define _TIF_EMULATE_STACK_STORE (1<<TIF_EMULATE_STACK_STORE)
6406 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
6407 #define _TIF_SYSCALL_T_OR_A (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
6408 - _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT)
6409 + _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT | \
6410 + _TIF_GRSEC_SETXID)
6411
6412 #define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
6413 _TIF_NOTIFY_RESUME | _TIF_UPROBE)
6414 diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
6415 index 4db4959..aba5c41 100644
6416 --- a/arch/powerpc/include/asm/uaccess.h
6417 +++ b/arch/powerpc/include/asm/uaccess.h
6418 @@ -318,52 +318,6 @@ do { \
6419 extern unsigned long __copy_tofrom_user(void __user *to,
6420 const void __user *from, unsigned long size);
6421
6422 -#ifndef __powerpc64__
6423 -
6424 -static inline unsigned long copy_from_user(void *to,
6425 - const void __user *from, unsigned long n)
6426 -{
6427 - unsigned long over;
6428 -
6429 - if (access_ok(VERIFY_READ, from, n))
6430 - return __copy_tofrom_user((__force void __user *)to, from, n);
6431 - if ((unsigned long)from < TASK_SIZE) {
6432 - over = (unsigned long)from + n - TASK_SIZE;
6433 - return __copy_tofrom_user((__force void __user *)to, from,
6434 - n - over) + over;
6435 - }
6436 - return n;
6437 -}
6438 -
6439 -static inline unsigned long copy_to_user(void __user *to,
6440 - const void *from, unsigned long n)
6441 -{
6442 - unsigned long over;
6443 -
6444 - if (access_ok(VERIFY_WRITE, to, n))
6445 - return __copy_tofrom_user(to, (__force void __user *)from, n);
6446 - if ((unsigned long)to < TASK_SIZE) {
6447 - over = (unsigned long)to + n - TASK_SIZE;
6448 - return __copy_tofrom_user(to, (__force void __user *)from,
6449 - n - over) + over;
6450 - }
6451 - return n;
6452 -}
6453 -
6454 -#else /* __powerpc64__ */
6455 -
6456 -#define __copy_in_user(to, from, size) \
6457 - __copy_tofrom_user((to), (from), (size))
6458 -
6459 -extern unsigned long copy_from_user(void *to, const void __user *from,
6460 - unsigned long n);
6461 -extern unsigned long copy_to_user(void __user *to, const void *from,
6462 - unsigned long n);
6463 -extern unsigned long copy_in_user(void __user *to, const void __user *from,
6464 - unsigned long n);
6465 -
6466 -#endif /* __powerpc64__ */
6467 -
6468 static inline unsigned long __copy_from_user_inatomic(void *to,
6469 const void __user *from, unsigned long n)
6470 {
6471 @@ -387,6 +341,10 @@ static inline unsigned long __copy_from_user_inatomic(void *to,
6472 if (ret == 0)
6473 return 0;
6474 }
6475 +
6476 + if (!__builtin_constant_p(n))
6477 + check_object_size(to, n, false);
6478 +
6479 return __copy_tofrom_user((__force void __user *)to, from, n);
6480 }
6481
6482 @@ -413,6 +371,10 @@ static inline unsigned long __copy_to_user_inatomic(void __user *to,
6483 if (ret == 0)
6484 return 0;
6485 }
6486 +
6487 + if (!__builtin_constant_p(n))
6488 + check_object_size(from, n, true);
6489 +
6490 return __copy_tofrom_user(to, (__force const void __user *)from, n);
6491 }
6492
6493 @@ -430,6 +392,92 @@ static inline unsigned long __copy_to_user(void __user *to,
6494 return __copy_to_user_inatomic(to, from, size);
6495 }
6496
6497 +#ifndef __powerpc64__
6498 +
6499 +static inline unsigned long __must_check copy_from_user(void *to,
6500 + const void __user *from, unsigned long n)
6501 +{
6502 + unsigned long over;
6503 +
6504 + if ((long)n < 0)
6505 + return n;
6506 +
6507 + if (access_ok(VERIFY_READ, from, n)) {
6508 + if (!__builtin_constant_p(n))
6509 + check_object_size(to, n, false);
6510 + return __copy_tofrom_user((__force void __user *)to, from, n);
6511 + }
6512 + if ((unsigned long)from < TASK_SIZE) {
6513 + over = (unsigned long)from + n - TASK_SIZE;
6514 + if (!__builtin_constant_p(n - over))
6515 + check_object_size(to, n - over, false);
6516 + return __copy_tofrom_user((__force void __user *)to, from,
6517 + n - over) + over;
6518 + }
6519 + return n;
6520 +}
6521 +
6522 +static inline unsigned long __must_check copy_to_user(void __user *to,
6523 + const void *from, unsigned long n)
6524 +{
6525 + unsigned long over;
6526 +
6527 + if ((long)n < 0)
6528 + return n;
6529 +
6530 + if (access_ok(VERIFY_WRITE, to, n)) {
6531 + if (!__builtin_constant_p(n))
6532 + check_object_size(from, n, true);
6533 + return __copy_tofrom_user(to, (__force void __user *)from, n);
6534 + }
6535 + if ((unsigned long)to < TASK_SIZE) {
6536 + over = (unsigned long)to + n - TASK_SIZE;
6537 + if (!__builtin_constant_p(n))
6538 + check_object_size(from, n - over, true);
6539 + return __copy_tofrom_user(to, (__force void __user *)from,
6540 + n - over) + over;
6541 + }
6542 + return n;
6543 +}
6544 +
6545 +#else /* __powerpc64__ */
6546 +
6547 +#define __copy_in_user(to, from, size) \
6548 + __copy_tofrom_user((to), (from), (size))
6549 +
6550 +static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
6551 +{
6552 + if ((long)n < 0 || n > INT_MAX)
6553 + return n;
6554 +
6555 + if (!__builtin_constant_p(n))
6556 + check_object_size(to, n, false);
6557 +
6558 + if (likely(access_ok(VERIFY_READ, from, n)))
6559 + n = __copy_from_user(to, from, n);
6560 + else
6561 + memset(to, 0, n);
6562 + return n;
6563 +}
6564 +
6565 +static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
6566 +{
6567 + if ((long)n < 0 || n > INT_MAX)
6568 + return n;
6569 +
6570 + if (likely(access_ok(VERIFY_WRITE, to, n))) {
6571 + if (!__builtin_constant_p(n))
6572 + check_object_size(from, n, true);
6573 + n = __copy_to_user(to, from, n);
6574 + }
6575 + return n;
6576 +}
6577 +
6578 +extern unsigned long copy_in_user(void __user *to, const void __user *from,
6579 + unsigned long n);
6580 +
6581 +#endif /* __powerpc64__ */
6582 +
6583 extern unsigned long __clear_user(void __user *addr, unsigned long size);
6584
6585 static inline unsigned long clear_user(void __user *addr, unsigned long size)
6586 diff --git a/arch/powerpc/kernel/exceptions-64e.S b/arch/powerpc/kernel/exceptions-64e.S
6587 index ae54553..cf2184d 100644
6588 --- a/arch/powerpc/kernel/exceptions-64e.S
6589 +++ b/arch/powerpc/kernel/exceptions-64e.S
6590 @@ -716,6 +716,7 @@ storage_fault_common:
6591 std r14,_DAR(r1)
6592 std r15,_DSISR(r1)
6593 addi r3,r1,STACK_FRAME_OVERHEAD
6594 + bl .save_nvgprs
6595 mr r4,r14
6596 mr r5,r15
6597 ld r14,PACA_EXGEN+EX_R14(r13)
6598 @@ -724,8 +725,7 @@ storage_fault_common:
6599 cmpdi r3,0
6600 bne- 1f
6601 b .ret_from_except_lite
6602 -1: bl .save_nvgprs
6603 - mr r5,r3
6604 +1: mr r5,r3
6605 addi r3,r1,STACK_FRAME_OVERHEAD
6606 ld r4,_DAR(r1)
6607 bl .bad_page_fault
6608 diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
6609 index 3bbe7ed..14ec3eb 100644
6610 --- a/arch/powerpc/kernel/exceptions-64s.S
6611 +++ b/arch/powerpc/kernel/exceptions-64s.S
6612 @@ -1390,10 +1390,10 @@ handle_page_fault:
6613 11: ld r4,_DAR(r1)
6614 ld r5,_DSISR(r1)
6615 addi r3,r1,STACK_FRAME_OVERHEAD
6616 + bl .save_nvgprs
6617 bl .do_page_fault
6618 cmpdi r3,0
6619 beq+ 12f
6620 - bl .save_nvgprs
6621 mr r5,r3
6622 addi r3,r1,STACK_FRAME_OVERHEAD
6623 lwz r4,_DAR(r1)
6624 diff --git a/arch/powerpc/kernel/module_32.c b/arch/powerpc/kernel/module_32.c
6625 index 2e3200c..72095ce 100644
6626 --- a/arch/powerpc/kernel/module_32.c
6627 +++ b/arch/powerpc/kernel/module_32.c
6628 @@ -162,7 +162,7 @@ int module_frob_arch_sections(Elf32_Ehdr *hdr,
6629 me->arch.core_plt_section = i;
6630 }
6631 if (!me->arch.core_plt_section || !me->arch.init_plt_section) {
6632 - printk("Module doesn't contain .plt or .init.plt sections.\n");
6633 + printk("Module %s doesn't contain .plt or .init.plt sections.\n", me->name);
6634 return -ENOEXEC;
6635 }
6636
6637 @@ -192,11 +192,16 @@ static uint32_t do_plt_call(void *location,
6638
6639 DEBUGP("Doing plt for call to 0x%x at 0x%x\n", val, (unsigned int)location);
6640 /* Init, or core PLT? */
6641 - if (location >= mod->module_core
6642 - && location < mod->module_core + mod->core_size)
6643 + if ((location >= mod->module_core_rx && location < mod->module_core_rx + mod->core_size_rx) ||
6644 + (location >= mod->module_core_rw && location < mod->module_core_rw + mod->core_size_rw))
6645 entry = (void *)sechdrs[mod->arch.core_plt_section].sh_addr;
6646 - else
6647 + else if ((location >= mod->module_init_rx && location < mod->module_init_rx + mod->init_size_rx) ||
6648 + (location >= mod->module_init_rw && location < mod->module_init_rw + mod->init_size_rw))
6649 entry = (void *)sechdrs[mod->arch.init_plt_section].sh_addr;
6650 + else {
6651 + printk(KERN_ERR "%s: invalid R_PPC_REL24 entry found\n", mod->name);
6652 + return ~0UL;
6653 + }
6654
6655 /* Find this entry, or if that fails, the next avail. entry */
6656 while (entry->jump[0]) {
6657 diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
6658 index 16e77a8..4501b41 100644
6659 --- a/arch/powerpc/kernel/process.c
6660 +++ b/arch/powerpc/kernel/process.c
6661 @@ -870,8 +870,8 @@ void show_regs(struct pt_regs * regs)
6662 * Lookup NIP late so we have the best change of getting the
6663 * above info out without failing
6664 */
6665 - printk("NIP ["REG"] %pS\n", regs->nip, (void *)regs->nip);
6666 - printk("LR ["REG"] %pS\n", regs->link, (void *)regs->link);
6667 + printk("NIP ["REG"] %pA\n", regs->nip, (void *)regs->nip);
6668 + printk("LR ["REG"] %pA\n", regs->link, (void *)regs->link);
6669 #endif
6670 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
6671 printk("PACATMSCRATCH [%llx]\n", get_paca()->tm_scratch);
6672 @@ -1330,10 +1330,10 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
6673 newsp = stack[0];
6674 ip = stack[STACK_FRAME_LR_SAVE];
6675 if (!firstframe || ip != lr) {
6676 - printk("["REG"] ["REG"] %pS", sp, ip, (void *)ip);
6677 + printk("["REG"] ["REG"] %pA", sp, ip, (void *)ip);
6678 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
6679 if ((ip == rth || ip == mrth) && curr_frame >= 0) {
6680 - printk(" (%pS)",
6681 + printk(" (%pA)",
6682 (void *)current->ret_stack[curr_frame].ret);
6683 curr_frame--;
6684 }
6685 @@ -1353,7 +1353,7 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
6686 struct pt_regs *regs = (struct pt_regs *)
6687 (sp + STACK_FRAME_OVERHEAD);
6688 lr = regs->link;
6689 - printk("--- Exception: %lx at %pS\n LR = %pS\n",
6690 + printk("--- Exception: %lx at %pA\n LR = %pA\n",
6691 regs->trap, (void *)regs->nip, (void *)lr);
6692 firstframe = 1;
6693 }
6694 @@ -1395,58 +1395,3 @@ void __ppc64_runlatch_off(void)
6695 mtspr(SPRN_CTRLT, ctrl);
6696 }
6697 #endif /* CONFIG_PPC64 */
6698 -
6699 -unsigned long arch_align_stack(unsigned long sp)
6700 -{
6701 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
6702 - sp -= get_random_int() & ~PAGE_MASK;
6703 - return sp & ~0xf;
6704 -}
6705 -
6706 -static inline unsigned long brk_rnd(void)
6707 -{
6708 - unsigned long rnd = 0;
6709 -
6710 - /* 8MB for 32bit, 1GB for 64bit */
6711 - if (is_32bit_task())
6712 - rnd = (long)(get_random_int() % (1<<(23-PAGE_SHIFT)));
6713 - else
6714 - rnd = (long)(get_random_int() % (1<<(30-PAGE_SHIFT)));
6715 -
6716 - return rnd << PAGE_SHIFT;
6717 -}
6718 -
6719 -unsigned long arch_randomize_brk(struct mm_struct *mm)
6720 -{
6721 - unsigned long base = mm->brk;
6722 - unsigned long ret;
6723 -
6724 -#ifdef CONFIG_PPC_STD_MMU_64
6725 - /*
6726 - * If we are using 1TB segments and we are allowed to randomise
6727 - * the heap, we can put it above 1TB so it is backed by a 1TB
6728 - * segment. Otherwise the heap will be in the bottom 1TB
6729 - * which always uses 256MB segments and this may result in a
6730 - * performance penalty.
6731 - */
6732 - if (!is_32bit_task() && (mmu_highuser_ssize == MMU_SEGSIZE_1T))
6733 - base = max_t(unsigned long, mm->brk, 1UL << SID_SHIFT_1T);
6734 -#endif
6735 -
6736 - ret = PAGE_ALIGN(base + brk_rnd());
6737 -
6738 - if (ret < mm->brk)
6739 - return mm->brk;
6740 -
6741 - return ret;
6742 -}
6743 -
6744 -unsigned long randomize_et_dyn(unsigned long base)
6745 -{
6746 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
6747 -
6748 - if (ret < base)
6749 - return base;
6750 -
6751 - return ret;
6752 -}
6753 diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
6754 index f9b30c6..d72e7a3 100644
6755 --- a/arch/powerpc/kernel/ptrace.c
6756 +++ b/arch/powerpc/kernel/ptrace.c
6757 @@ -1771,6 +1771,10 @@ long arch_ptrace(struct task_struct *child, long request,
6758 return ret;
6759 }
6760
6761 +#ifdef CONFIG_GRKERNSEC_SETXID
6762 +extern void gr_delayed_cred_worker(void);
6763 +#endif
6764 +
6765 /*
6766 * We must return the syscall number to actually look up in the table.
6767 * This can be -1L to skip running any syscall at all.
6768 @@ -1781,6 +1785,11 @@ long do_syscall_trace_enter(struct pt_regs *regs)
6769
6770 secure_computing_strict(regs->gpr[0]);
6771
6772 +#ifdef CONFIG_GRKERNSEC_SETXID
6773 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
6774 + gr_delayed_cred_worker();
6775 +#endif
6776 +
6777 if (test_thread_flag(TIF_SYSCALL_TRACE) &&
6778 tracehook_report_syscall_entry(regs))
6779 /*
6780 @@ -1815,6 +1824,11 @@ void do_syscall_trace_leave(struct pt_regs *regs)
6781 {
6782 int step;
6783
6784 +#ifdef CONFIG_GRKERNSEC_SETXID
6785 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
6786 + gr_delayed_cred_worker();
6787 +#endif
6788 +
6789 audit_syscall_exit(regs);
6790
6791 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
6792 diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
6793 index 95068bf..9ba1814 100644
6794 --- a/arch/powerpc/kernel/signal_32.c
6795 +++ b/arch/powerpc/kernel/signal_32.c
6796 @@ -982,7 +982,7 @@ int handle_rt_signal32(unsigned long sig, struct k_sigaction *ka,
6797 /* Save user registers on the stack */
6798 frame = &rt_sf->uc.uc_mcontext;
6799 addr = frame;
6800 - if (vdso32_rt_sigtramp && current->mm->context.vdso_base) {
6801 + if (vdso32_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
6802 sigret = 0;
6803 tramp = current->mm->context.vdso_base + vdso32_rt_sigtramp;
6804 } else {
6805 diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
6806 index c179428..58acdaa 100644
6807 --- a/arch/powerpc/kernel/signal_64.c
6808 +++ b/arch/powerpc/kernel/signal_64.c
6809 @@ -758,7 +758,7 @@ int handle_rt_signal64(int signr, struct k_sigaction *ka, siginfo_t *info,
6810 #endif
6811
6812 /* Set up to return from userspace. */
6813 - if (vdso64_rt_sigtramp && current->mm->context.vdso_base) {
6814 + if (vdso64_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
6815 regs->link = current->mm->context.vdso_base + vdso64_rt_sigtramp;
6816 } else {
6817 err |= setup_trampoline(__NR_rt_sigreturn, &frame->tramp[0]);
6818 diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c
6819 index 3ce1f86..c30e629 100644
6820 --- a/arch/powerpc/kernel/sysfs.c
6821 +++ b/arch/powerpc/kernel/sysfs.c
6822 @@ -522,7 +522,7 @@ static int __cpuinit sysfs_cpu_notify(struct notifier_block *self,
6823 return NOTIFY_OK;
6824 }
6825
6826 -static struct notifier_block __cpuinitdata sysfs_cpu_nb = {
6827 +static struct notifier_block sysfs_cpu_nb = {
6828 .notifier_call = sysfs_cpu_notify,
6829 };
6830
6831 diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
6832 index 83efa2f..6bb5839 100644
6833 --- a/arch/powerpc/kernel/traps.c
6834 +++ b/arch/powerpc/kernel/traps.c
6835 @@ -141,6 +141,8 @@ static unsigned __kprobes long oops_begin(struct pt_regs *regs)
6836 return flags;
6837 }
6838
6839 +extern void gr_handle_kernel_exploit(void);
6840 +
6841 static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
6842 int signr)
6843 {
6844 @@ -190,6 +192,9 @@ static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
6845 panic("Fatal exception in interrupt");
6846 if (panic_on_oops)
6847 panic("Fatal exception");
6848 +
6849 + gr_handle_kernel_exploit();
6850 +
6851 do_exit(signr);
6852 }
6853
6854 diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
6855 index 1b2076f..835e4be 100644
6856 --- a/arch/powerpc/kernel/vdso.c
6857 +++ b/arch/powerpc/kernel/vdso.c
6858 @@ -34,6 +34,7 @@
6859 #include <asm/firmware.h>
6860 #include <asm/vdso.h>
6861 #include <asm/vdso_datapage.h>
6862 +#include <asm/mman.h>
6863
6864 #include "setup.h"
6865
6866 @@ -218,7 +219,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
6867 vdso_base = VDSO32_MBASE;
6868 #endif
6869
6870 - current->mm->context.vdso_base = 0;
6871 + current->mm->context.vdso_base = ~0UL;
6872
6873 /* vDSO has a problem and was disabled, just don't "enable" it for the
6874 * process
6875 @@ -238,7 +239,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
6876 vdso_base = get_unmapped_area(NULL, vdso_base,
6877 (vdso_pages << PAGE_SHIFT) +
6878 ((VDSO_ALIGNMENT - 1) & PAGE_MASK),
6879 - 0, 0);
6880 + 0, MAP_PRIVATE | MAP_EXECUTABLE);
6881 if (IS_ERR_VALUE(vdso_base)) {
6882 rc = vdso_base;
6883 goto fail_mmapsem;
6884 diff --git a/arch/powerpc/lib/usercopy_64.c b/arch/powerpc/lib/usercopy_64.c
6885 index 5eea6f3..5d10396 100644
6886 --- a/arch/powerpc/lib/usercopy_64.c
6887 +++ b/arch/powerpc/lib/usercopy_64.c
6888 @@ -9,22 +9,6 @@
6889 #include <linux/module.h>
6890 #include <asm/uaccess.h>
6891
6892 -unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
6893 -{
6894 - if (likely(access_ok(VERIFY_READ, from, n)))
6895 - n = __copy_from_user(to, from, n);
6896 - else
6897 - memset(to, 0, n);
6898 - return n;
6899 -}
6900 -
6901 -unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
6902 -{
6903 - if (likely(access_ok(VERIFY_WRITE, to, n)))
6904 - n = __copy_to_user(to, from, n);
6905 - return n;
6906 -}
6907 -
6908 unsigned long copy_in_user(void __user *to, const void __user *from,
6909 unsigned long n)
6910 {
6911 @@ -35,7 +19,5 @@ unsigned long copy_in_user(void __user *to, const void __user *from,
6912 return n;
6913 }
6914
6915 -EXPORT_SYMBOL(copy_from_user);
6916 -EXPORT_SYMBOL(copy_to_user);
6917 EXPORT_SYMBOL(copy_in_user);
6918
6919 diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
6920 index 229951f..cdeca42 100644
6921 --- a/arch/powerpc/mm/fault.c
6922 +++ b/arch/powerpc/mm/fault.c
6923 @@ -32,6 +32,10 @@
6924 #include <linux/perf_event.h>
6925 #include <linux/magic.h>
6926 #include <linux/ratelimit.h>
6927 +#include <linux/slab.h>
6928 +#include <linux/pagemap.h>
6929 +#include <linux/compiler.h>
6930 +#include <linux/unistd.h>
6931
6932 #include <asm/firmware.h>
6933 #include <asm/page.h>
6934 @@ -68,6 +72,33 @@ static inline int notify_page_fault(struct pt_regs *regs)
6935 }
6936 #endif
6937
6938 +#ifdef CONFIG_PAX_PAGEEXEC
6939 +/*
6940 + * PaX: decide what to do with offenders (regs->nip = fault address)
6941 + *
6942 + * returns 1 when task should be killed
6943 + */
6944 +static int pax_handle_fetch_fault(struct pt_regs *regs)
6945 +{
6946 + return 1;
6947 +}
6948 +
6949 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
6950 +{
6951 + unsigned long i;
6952 +
6953 + printk(KERN_ERR "PAX: bytes at PC: ");
6954 + for (i = 0; i < 5; i++) {
6955 + unsigned int c;
6956 + if (get_user(c, (unsigned int __user *)pc+i))
6957 + printk(KERN_CONT "???????? ");
6958 + else
6959 + printk(KERN_CONT "%08x ", c);
6960 + }
6961 + printk("\n");
6962 +}
6963 +#endif
6964 +
6965 /*
6966 * Check whether the instruction at regs->nip is a store using
6967 * an update addressing form which will update r1.
6968 @@ -213,7 +244,7 @@ int __kprobes do_page_fault(struct pt_regs *regs, unsigned long address,
6969 * indicate errors in DSISR but can validly be set in SRR1.
6970 */
6971 if (trap == 0x400)
6972 - error_code &= 0x48200000;
6973 + error_code &= 0x58200000;
6974 else
6975 is_write = error_code & DSISR_ISSTORE;
6976 #else
6977 @@ -364,7 +395,7 @@ good_area:
6978 * "undefined". Of those that can be set, this is the only
6979 * one which seems bad.
6980 */
6981 - if (error_code & 0x10000000)
6982 + if (error_code & DSISR_GUARDED)
6983 /* Guarded storage error. */
6984 goto bad_area;
6985 #endif /* CONFIG_8xx */
6986 @@ -379,7 +410,7 @@ good_area:
6987 * processors use the same I/D cache coherency mechanism
6988 * as embedded.
6989 */
6990 - if (error_code & DSISR_PROTFAULT)
6991 + if (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))
6992 goto bad_area;
6993 #endif /* CONFIG_PPC_STD_MMU */
6994
6995 @@ -462,6 +493,23 @@ bad_area:
6996 bad_area_nosemaphore:
6997 /* User mode accesses cause a SIGSEGV */
6998 if (user_mode(regs)) {
6999 +
7000 +#ifdef CONFIG_PAX_PAGEEXEC
7001 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
7002 +#ifdef CONFIG_PPC_STD_MMU
7003 + if (is_exec && (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))) {
7004 +#else
7005 + if (is_exec && regs->nip == address) {
7006 +#endif
7007 + switch (pax_handle_fetch_fault(regs)) {
7008 + }
7009 +
7010 + pax_report_fault(regs, (void *)regs->nip, (void *)regs->gpr[PT_R1]);
7011 + do_group_exit(SIGKILL);
7012 + }
7013 + }
7014 +#endif
7015 +
7016 _exception(SIGSEGV, regs, code, address);
7017 return 0;
7018 }
7019 diff --git a/arch/powerpc/mm/mmap_64.c b/arch/powerpc/mm/mmap_64.c
7020 index 67a42ed..cd463e0 100644
7021 --- a/arch/powerpc/mm/mmap_64.c
7022 +++ b/arch/powerpc/mm/mmap_64.c
7023 @@ -57,6 +57,10 @@ static unsigned long mmap_rnd(void)
7024 {
7025 unsigned long rnd = 0;
7026
7027 +#ifdef CONFIG_PAX_RANDMMAP
7028 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7029 +#endif
7030 +
7031 if (current->flags & PF_RANDOMIZE) {
7032 /* 8MB for 32bit, 1GB for 64bit */
7033 if (is_32bit_task())
7034 @@ -91,10 +95,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7035 */
7036 if (mmap_is_legacy()) {
7037 mm->mmap_base = TASK_UNMAPPED_BASE;
7038 +
7039 +#ifdef CONFIG_PAX_RANDMMAP
7040 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7041 + mm->mmap_base += mm->delta_mmap;
7042 +#endif
7043 +
7044 mm->get_unmapped_area = arch_get_unmapped_area;
7045 mm->unmap_area = arch_unmap_area;
7046 } else {
7047 mm->mmap_base = mmap_base();
7048 +
7049 +#ifdef CONFIG_PAX_RANDMMAP
7050 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7051 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7052 +#endif
7053 +
7054 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
7055 mm->unmap_area = arch_unmap_area_topdown;
7056 }
7057 diff --git a/arch/powerpc/mm/mmu_context_nohash.c b/arch/powerpc/mm/mmu_context_nohash.c
7058 index e779642..e5bb889 100644
7059 --- a/arch/powerpc/mm/mmu_context_nohash.c
7060 +++ b/arch/powerpc/mm/mmu_context_nohash.c
7061 @@ -363,7 +363,7 @@ static int __cpuinit mmu_context_cpu_notify(struct notifier_block *self,
7062 return NOTIFY_OK;
7063 }
7064
7065 -static struct notifier_block __cpuinitdata mmu_context_cpu_nb = {
7066 +static struct notifier_block mmu_context_cpu_nb = {
7067 .notifier_call = mmu_context_cpu_notify,
7068 };
7069
7070 diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
7071 index 6a252c4..3024d81 100644
7072 --- a/arch/powerpc/mm/numa.c
7073 +++ b/arch/powerpc/mm/numa.c
7074 @@ -932,7 +932,7 @@ static void __init *careful_zallocation(int nid, unsigned long size,
7075 return ret;
7076 }
7077
7078 -static struct notifier_block __cpuinitdata ppc64_numa_nb = {
7079 +static struct notifier_block ppc64_numa_nb = {
7080 .notifier_call = cpu_numa_callback,
7081 .priority = 1 /* Must run before sched domains notifier. */
7082 };
7083 diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c
7084 index cf9dada..241529f 100644
7085 --- a/arch/powerpc/mm/slice.c
7086 +++ b/arch/powerpc/mm/slice.c
7087 @@ -103,7 +103,7 @@ static int slice_area_is_free(struct mm_struct *mm, unsigned long addr,
7088 if ((mm->task_size - len) < addr)
7089 return 0;
7090 vma = find_vma(mm, addr);
7091 - return (!vma || (addr + len) <= vma->vm_start);
7092 + return check_heap_stack_gap(vma, addr, len, 0);
7093 }
7094
7095 static int slice_low_has_vma(struct mm_struct *mm, unsigned long slice)
7096 @@ -272,7 +272,7 @@ full_search:
7097 addr = _ALIGN_UP(addr + 1, 1ul << SLICE_HIGH_SHIFT);
7098 continue;
7099 }
7100 - if (!vma || addr + len <= vma->vm_start) {
7101 + if (check_heap_stack_gap(vma, addr, len, 0)) {
7102 /*
7103 * Remember the place where we stopped the search:
7104 */
7105 @@ -329,10 +329,14 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
7106 }
7107 }
7108
7109 - addr = mm->mmap_base;
7110 - while (addr > len) {
7111 + if (mm->mmap_base < len)
7112 + addr = -ENOMEM;
7113 + else
7114 + addr = mm->mmap_base - len;
7115 +
7116 + while (!IS_ERR_VALUE(addr)) {
7117 /* Go down by chunk size */
7118 - addr = _ALIGN_DOWN(addr - len, 1ul << pshift);
7119 + addr = _ALIGN_DOWN(addr, 1ul << pshift);
7120
7121 /* Check for hit with different page size */
7122 mask = slice_range_to_mask(addr, len);
7123 @@ -352,7 +356,7 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
7124 * return with success:
7125 */
7126 vma = find_vma(mm, addr);
7127 - if (!vma || (addr + len) <= vma->vm_start) {
7128 + if (check_heap_stack_gap(vma, addr, len, 0)) {
7129 /* remember the address as a hint for next time */
7130 if (use_cache)
7131 mm->free_area_cache = addr;
7132 @@ -364,7 +368,7 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
7133 mm->cached_hole_size = vma->vm_start - addr;
7134
7135 /* try just below the current vma->vm_start */
7136 - addr = vma->vm_start;
7137 + addr = skip_heap_stack_gap(vma, len, 0);
7138 }
7139
7140 /*
7141 @@ -442,6 +446,11 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,
7142 if (fixed && addr > (mm->task_size - len))
7143 return -EINVAL;
7144
7145 +#ifdef CONFIG_PAX_RANDMMAP
7146 + if (!fixed && (mm->pax_flags & MF_PAX_RANDMMAP))
7147 + addr = 0;
7148 +#endif
7149 +
7150 /* If hint, make sure it matches our alignment restrictions */
7151 if (!fixed && addr) {
7152 addr = _ALIGN_UP(addr, 1ul << pshift);
7153 diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
7154 index 68c57d3..1fdcfb2 100644
7155 --- a/arch/powerpc/platforms/cell/spufs/file.c
7156 +++ b/arch/powerpc/platforms/cell/spufs/file.c
7157 @@ -281,9 +281,9 @@ spufs_mem_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
7158 return VM_FAULT_NOPAGE;
7159 }
7160
7161 -static int spufs_mem_mmap_access(struct vm_area_struct *vma,
7162 +static ssize_t spufs_mem_mmap_access(struct vm_area_struct *vma,
7163 unsigned long address,
7164 - void *buf, int len, int write)
7165 + void *buf, size_t len, int write)
7166 {
7167 struct spu_context *ctx = vma->vm_file->private_data;
7168 unsigned long offset = address - vma->vm_start;
7169 diff --git a/arch/powerpc/platforms/powermac/smp.c b/arch/powerpc/platforms/powermac/smp.c
7170 index bdb738a..49c9f95 100644
7171 --- a/arch/powerpc/platforms/powermac/smp.c
7172 +++ b/arch/powerpc/platforms/powermac/smp.c
7173 @@ -885,7 +885,7 @@ static int smp_core99_cpu_notify(struct notifier_block *self,
7174 return NOTIFY_OK;
7175 }
7176
7177 -static struct notifier_block __cpuinitdata smp_core99_cpu_nb = {
7178 +static struct notifier_block smp_core99_cpu_nb = {
7179 .notifier_call = smp_core99_cpu_notify,
7180 };
7181 #endif /* CONFIG_HOTPLUG_CPU */
7182 diff --git a/arch/s390/include/asm/atomic.h b/arch/s390/include/asm/atomic.h
7183 index c797832..ce575c8 100644
7184 --- a/arch/s390/include/asm/atomic.h
7185 +++ b/arch/s390/include/asm/atomic.h
7186 @@ -326,6 +326,16 @@ static inline long long atomic64_dec_if_positive(atomic64_t *v)
7187 #define atomic64_dec_and_test(_v) (atomic64_sub_return(1, _v) == 0)
7188 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
7189
7190 +#define atomic64_read_unchecked(v) atomic64_read(v)
7191 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
7192 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
7193 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
7194 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
7195 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
7196 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
7197 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
7198 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
7199 +
7200 #define smp_mb__before_atomic_dec() smp_mb()
7201 #define smp_mb__after_atomic_dec() smp_mb()
7202 #define smp_mb__before_atomic_inc() smp_mb()
7203 diff --git a/arch/s390/include/asm/cache.h b/arch/s390/include/asm/cache.h
7204 index 4d7ccac..d03d0ad 100644
7205 --- a/arch/s390/include/asm/cache.h
7206 +++ b/arch/s390/include/asm/cache.h
7207 @@ -9,8 +9,10 @@
7208 #ifndef __ARCH_S390_CACHE_H
7209 #define __ARCH_S390_CACHE_H
7210
7211 -#define L1_CACHE_BYTES 256
7212 +#include <linux/const.h>
7213 +
7214 #define L1_CACHE_SHIFT 8
7215 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7216 #define NET_SKB_PAD 32
7217
7218 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
7219 diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h
7220 index 1bfdf24..9c9ab2e 100644
7221 --- a/arch/s390/include/asm/elf.h
7222 +++ b/arch/s390/include/asm/elf.h
7223 @@ -160,8 +160,14 @@ extern unsigned int vdso_enabled;
7224 the loader. We need to make sure that it is out of the way of the program
7225 that it will "exec", and that there is sufficient room for the brk. */
7226
7227 -extern unsigned long randomize_et_dyn(unsigned long base);
7228 -#define ELF_ET_DYN_BASE (randomize_et_dyn(STACK_TOP / 3 * 2))
7229 +#define ELF_ET_DYN_BASE (STACK_TOP / 3 * 2)
7230 +
7231 +#ifdef CONFIG_PAX_ASLR
7232 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_31BIT) ? 0x10000UL : 0x80000000UL)
7233 +
7234 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
7235 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
7236 +#endif
7237
7238 /* This yields a mask that user programs can use to figure out what
7239 instruction set this CPU supports. */
7240 @@ -207,9 +213,6 @@ struct linux_binprm;
7241 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
7242 int arch_setup_additional_pages(struct linux_binprm *, int);
7243
7244 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
7245 -#define arch_randomize_brk arch_randomize_brk
7246 -
7247 void *fill_cpu_elf_notes(void *ptr, struct save_area *sa);
7248
7249 #endif
7250 diff --git a/arch/s390/include/asm/exec.h b/arch/s390/include/asm/exec.h
7251 index c4a93d6..4d2a9b4 100644
7252 --- a/arch/s390/include/asm/exec.h
7253 +++ b/arch/s390/include/asm/exec.h
7254 @@ -7,6 +7,6 @@
7255 #ifndef __ASM_EXEC_H
7256 #define __ASM_EXEC_H
7257
7258 -extern unsigned long arch_align_stack(unsigned long sp);
7259 +#define arch_align_stack(x) ((x) & ~0xfUL)
7260
7261 #endif /* __ASM_EXEC_H */
7262 diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h
7263 index 9c33ed4..e40cbef 100644
7264 --- a/arch/s390/include/asm/uaccess.h
7265 +++ b/arch/s390/include/asm/uaccess.h
7266 @@ -252,6 +252,10 @@ static inline unsigned long __must_check
7267 copy_to_user(void __user *to, const void *from, unsigned long n)
7268 {
7269 might_fault();
7270 +
7271 + if ((long)n < 0)
7272 + return n;
7273 +
7274 return __copy_to_user(to, from, n);
7275 }
7276
7277 @@ -275,6 +279,9 @@ copy_to_user(void __user *to, const void *from, unsigned long n)
7278 static inline unsigned long __must_check
7279 __copy_from_user(void *to, const void __user *from, unsigned long n)
7280 {
7281 + if ((long)n < 0)
7282 + return n;
7283 +
7284 if (__builtin_constant_p(n) && (n <= 256))
7285 return uaccess.copy_from_user_small(n, from, to);
7286 else
7287 @@ -306,10 +313,14 @@ __compiletime_warning("copy_from_user() buffer size is not provably correct")
7288 static inline unsigned long __must_check
7289 copy_from_user(void *to, const void __user *from, unsigned long n)
7290 {
7291 - unsigned int sz = __compiletime_object_size(to);
7292 + size_t sz = __compiletime_object_size(to);
7293
7294 might_fault();
7295 - if (unlikely(sz != -1 && sz < n)) {
7296 +
7297 + if ((long)n < 0)
7298 + return n;
7299 +
7300 + if (unlikely(sz != (size_t)-1 && sz < n)) {
7301 copy_from_user_overflow();
7302 return n;
7303 }
7304 diff --git a/arch/s390/kernel/module.c b/arch/s390/kernel/module.c
7305 index 7845e15..59c4353 100644
7306 --- a/arch/s390/kernel/module.c
7307 +++ b/arch/s390/kernel/module.c
7308 @@ -169,11 +169,11 @@ int module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
7309
7310 /* Increase core size by size of got & plt and set start
7311 offsets for got and plt. */
7312 - me->core_size = ALIGN(me->core_size, 4);
7313 - me->arch.got_offset = me->core_size;
7314 - me->core_size += me->arch.got_size;
7315 - me->arch.plt_offset = me->core_size;
7316 - me->core_size += me->arch.plt_size;
7317 + me->core_size_rw = ALIGN(me->core_size_rw, 4);
7318 + me->arch.got_offset = me->core_size_rw;
7319 + me->core_size_rw += me->arch.got_size;
7320 + me->arch.plt_offset = me->core_size_rx;
7321 + me->core_size_rx += me->arch.plt_size;
7322 return 0;
7323 }
7324
7325 @@ -289,7 +289,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7326 if (info->got_initialized == 0) {
7327 Elf_Addr *gotent;
7328
7329 - gotent = me->module_core + me->arch.got_offset +
7330 + gotent = me->module_core_rw + me->arch.got_offset +
7331 info->got_offset;
7332 *gotent = val;
7333 info->got_initialized = 1;
7334 @@ -312,7 +312,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7335 rc = apply_rela_bits(loc, val, 0, 64, 0);
7336 else if (r_type == R_390_GOTENT ||
7337 r_type == R_390_GOTPLTENT) {
7338 - val += (Elf_Addr) me->module_core - loc;
7339 + val += (Elf_Addr) me->module_core_rw - loc;
7340 rc = apply_rela_bits(loc, val, 1, 32, 1);
7341 }
7342 break;
7343 @@ -325,7 +325,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7344 case R_390_PLTOFF64: /* 16 bit offset from GOT to PLT. */
7345 if (info->plt_initialized == 0) {
7346 unsigned int *ip;
7347 - ip = me->module_core + me->arch.plt_offset +
7348 + ip = me->module_core_rx + me->arch.plt_offset +
7349 info->plt_offset;
7350 #ifndef CONFIG_64BIT
7351 ip[0] = 0x0d105810; /* basr 1,0; l 1,6(1); br 1 */
7352 @@ -350,7 +350,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7353 val - loc + 0xffffUL < 0x1ffffeUL) ||
7354 (r_type == R_390_PLT32DBL &&
7355 val - loc + 0xffffffffULL < 0x1fffffffeULL)))
7356 - val = (Elf_Addr) me->module_core +
7357 + val = (Elf_Addr) me->module_core_rx +
7358 me->arch.plt_offset +
7359 info->plt_offset;
7360 val += rela->r_addend - loc;
7361 @@ -372,7 +372,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7362 case R_390_GOTOFF32: /* 32 bit offset to GOT. */
7363 case R_390_GOTOFF64: /* 64 bit offset to GOT. */
7364 val = val + rela->r_addend -
7365 - ((Elf_Addr) me->module_core + me->arch.got_offset);
7366 + ((Elf_Addr) me->module_core_rw + me->arch.got_offset);
7367 if (r_type == R_390_GOTOFF16)
7368 rc = apply_rela_bits(loc, val, 0, 16, 0);
7369 else if (r_type == R_390_GOTOFF32)
7370 @@ -382,7 +382,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7371 break;
7372 case R_390_GOTPC: /* 32 bit PC relative offset to GOT. */
7373 case R_390_GOTPCDBL: /* 32 bit PC rel. off. to GOT shifted by 1. */
7374 - val = (Elf_Addr) me->module_core + me->arch.got_offset +
7375 + val = (Elf_Addr) me->module_core_rw + me->arch.got_offset +
7376 rela->r_addend - loc;
7377 if (r_type == R_390_GOTPC)
7378 rc = apply_rela_bits(loc, val, 1, 32, 0);
7379 diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
7380 index 536d645..4a5bd9e 100644
7381 --- a/arch/s390/kernel/process.c
7382 +++ b/arch/s390/kernel/process.c
7383 @@ -250,39 +250,3 @@ unsigned long get_wchan(struct task_struct *p)
7384 }
7385 return 0;
7386 }
7387 -
7388 -unsigned long arch_align_stack(unsigned long sp)
7389 -{
7390 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
7391 - sp -= get_random_int() & ~PAGE_MASK;
7392 - return sp & ~0xf;
7393 -}
7394 -
7395 -static inline unsigned long brk_rnd(void)
7396 -{
7397 - /* 8MB for 32bit, 1GB for 64bit */
7398 - if (is_32bit_task())
7399 - return (get_random_int() & 0x7ffUL) << PAGE_SHIFT;
7400 - else
7401 - return (get_random_int() & 0x3ffffUL) << PAGE_SHIFT;
7402 -}
7403 -
7404 -unsigned long arch_randomize_brk(struct mm_struct *mm)
7405 -{
7406 - unsigned long ret = PAGE_ALIGN(mm->brk + brk_rnd());
7407 -
7408 - if (ret < mm->brk)
7409 - return mm->brk;
7410 - return ret;
7411 -}
7412 -
7413 -unsigned long randomize_et_dyn(unsigned long base)
7414 -{
7415 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
7416 -
7417 - if (!(current->flags & PF_RANDOMIZE))
7418 - return base;
7419 - if (ret < base)
7420 - return base;
7421 - return ret;
7422 -}
7423 diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
7424 index 06bafec..2bca531 100644
7425 --- a/arch/s390/mm/mmap.c
7426 +++ b/arch/s390/mm/mmap.c
7427 @@ -90,10 +90,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7428 */
7429 if (mmap_is_legacy()) {
7430 mm->mmap_base = TASK_UNMAPPED_BASE;
7431 +
7432 +#ifdef CONFIG_PAX_RANDMMAP
7433 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7434 + mm->mmap_base += mm->delta_mmap;
7435 +#endif
7436 +
7437 mm->get_unmapped_area = arch_get_unmapped_area;
7438 mm->unmap_area = arch_unmap_area;
7439 } else {
7440 mm->mmap_base = mmap_base();
7441 +
7442 +#ifdef CONFIG_PAX_RANDMMAP
7443 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7444 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7445 +#endif
7446 +
7447 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
7448 mm->unmap_area = arch_unmap_area_topdown;
7449 }
7450 @@ -175,10 +187,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7451 */
7452 if (mmap_is_legacy()) {
7453 mm->mmap_base = TASK_UNMAPPED_BASE;
7454 +
7455 +#ifdef CONFIG_PAX_RANDMMAP
7456 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7457 + mm->mmap_base += mm->delta_mmap;
7458 +#endif
7459 +
7460 mm->get_unmapped_area = s390_get_unmapped_area;
7461 mm->unmap_area = arch_unmap_area;
7462 } else {
7463 mm->mmap_base = mmap_base();
7464 +
7465 +#ifdef CONFIG_PAX_RANDMMAP
7466 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7467 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7468 +#endif
7469 +
7470 mm->get_unmapped_area = s390_get_unmapped_area_topdown;
7471 mm->unmap_area = arch_unmap_area_topdown;
7472 }
7473 diff --git a/arch/score/include/asm/cache.h b/arch/score/include/asm/cache.h
7474 index ae3d59f..f65f075 100644
7475 --- a/arch/score/include/asm/cache.h
7476 +++ b/arch/score/include/asm/cache.h
7477 @@ -1,7 +1,9 @@
7478 #ifndef _ASM_SCORE_CACHE_H
7479 #define _ASM_SCORE_CACHE_H
7480
7481 +#include <linux/const.h>
7482 +
7483 #define L1_CACHE_SHIFT 4
7484 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7485 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7486
7487 #endif /* _ASM_SCORE_CACHE_H */
7488 diff --git a/arch/score/include/asm/exec.h b/arch/score/include/asm/exec.h
7489 index f9f3cd5..58ff438 100644
7490 --- a/arch/score/include/asm/exec.h
7491 +++ b/arch/score/include/asm/exec.h
7492 @@ -1,6 +1,6 @@
7493 #ifndef _ASM_SCORE_EXEC_H
7494 #define _ASM_SCORE_EXEC_H
7495
7496 -extern unsigned long arch_align_stack(unsigned long sp);
7497 +#define arch_align_stack(x) (x)
7498
7499 #endif /* _ASM_SCORE_EXEC_H */
7500 diff --git a/arch/score/kernel/process.c b/arch/score/kernel/process.c
7501 index 7956846..5f37677 100644
7502 --- a/arch/score/kernel/process.c
7503 +++ b/arch/score/kernel/process.c
7504 @@ -134,8 +134,3 @@ unsigned long get_wchan(struct task_struct *task)
7505
7506 return task_pt_regs(task)->cp0_epc;
7507 }
7508 -
7509 -unsigned long arch_align_stack(unsigned long sp)
7510 -{
7511 - return sp;
7512 -}
7513 diff --git a/arch/sh/include/asm/cache.h b/arch/sh/include/asm/cache.h
7514 index ef9e555..331bd29 100644
7515 --- a/arch/sh/include/asm/cache.h
7516 +++ b/arch/sh/include/asm/cache.h
7517 @@ -9,10 +9,11 @@
7518 #define __ASM_SH_CACHE_H
7519 #ifdef __KERNEL__
7520
7521 +#include <linux/const.h>
7522 #include <linux/init.h>
7523 #include <cpu/cache.h>
7524
7525 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7526 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7527
7528 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
7529
7530 diff --git a/arch/sh/kernel/cpu/sh4a/smp-shx3.c b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7531 index 03f2b55..b0270327 100644
7532 --- a/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7533 +++ b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7534 @@ -143,7 +143,7 @@ shx3_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
7535 return NOTIFY_OK;
7536 }
7537
7538 -static struct notifier_block __cpuinitdata shx3_cpu_notifier = {
7539 +static struct notifier_block shx3_cpu_notifier = {
7540 .notifier_call = shx3_cpu_callback,
7541 };
7542
7543 diff --git a/arch/sh/mm/mmap.c b/arch/sh/mm/mmap.c
7544 index 6777177..cb5e44f 100644
7545 --- a/arch/sh/mm/mmap.c
7546 +++ b/arch/sh/mm/mmap.c
7547 @@ -36,6 +36,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7548 struct mm_struct *mm = current->mm;
7549 struct vm_area_struct *vma;
7550 int do_colour_align;
7551 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
7552 struct vm_unmapped_area_info info;
7553
7554 if (flags & MAP_FIXED) {
7555 @@ -55,6 +56,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7556 if (filp || (flags & MAP_SHARED))
7557 do_colour_align = 1;
7558
7559 +#ifdef CONFIG_PAX_RANDMMAP
7560 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7561 +#endif
7562 +
7563 if (addr) {
7564 if (do_colour_align)
7565 addr = COLOUR_ALIGN(addr, pgoff);
7566 @@ -62,14 +67,13 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7567 addr = PAGE_ALIGN(addr);
7568
7569 vma = find_vma(mm, addr);
7570 - if (TASK_SIZE - len >= addr &&
7571 - (!vma || addr + len <= vma->vm_start))
7572 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
7573 return addr;
7574 }
7575
7576 info.flags = 0;
7577 info.length = len;
7578 - info.low_limit = TASK_UNMAPPED_BASE;
7579 + info.low_limit = mm->mmap_base;
7580 info.high_limit = TASK_SIZE;
7581 info.align_mask = do_colour_align ? (PAGE_MASK & shm_align_mask) : 0;
7582 info.align_offset = pgoff << PAGE_SHIFT;
7583 @@ -85,6 +89,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7584 struct mm_struct *mm = current->mm;
7585 unsigned long addr = addr0;
7586 int do_colour_align;
7587 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
7588 struct vm_unmapped_area_info info;
7589
7590 if (flags & MAP_FIXED) {
7591 @@ -104,6 +109,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7592 if (filp || (flags & MAP_SHARED))
7593 do_colour_align = 1;
7594
7595 +#ifdef CONFIG_PAX_RANDMMAP
7596 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7597 +#endif
7598 +
7599 /* requesting a specific address */
7600 if (addr) {
7601 if (do_colour_align)
7602 @@ -112,8 +121,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7603 addr = PAGE_ALIGN(addr);
7604
7605 vma = find_vma(mm, addr);
7606 - if (TASK_SIZE - len >= addr &&
7607 - (!vma || addr + len <= vma->vm_start))
7608 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
7609 return addr;
7610 }
7611
7612 @@ -135,6 +143,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7613 VM_BUG_ON(addr != -ENOMEM);
7614 info.flags = 0;
7615 info.low_limit = TASK_UNMAPPED_BASE;
7616 +
7617 +#ifdef CONFIG_PAX_RANDMMAP
7618 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7619 + info.low_limit += mm->delta_mmap;
7620 +#endif
7621 +
7622 info.high_limit = TASK_SIZE;
7623 addr = vm_unmapped_area(&info);
7624 }
7625 diff --git a/arch/sparc/include/asm/atomic_64.h b/arch/sparc/include/asm/atomic_64.h
7626 index be56a24..443328f 100644
7627 --- a/arch/sparc/include/asm/atomic_64.h
7628 +++ b/arch/sparc/include/asm/atomic_64.h
7629 @@ -14,18 +14,40 @@
7630 #define ATOMIC64_INIT(i) { (i) }
7631
7632 #define atomic_read(v) (*(volatile int *)&(v)->counter)
7633 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
7634 +{
7635 + return v->counter;
7636 +}
7637 #define atomic64_read(v) (*(volatile long *)&(v)->counter)
7638 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
7639 +{
7640 + return v->counter;
7641 +}
7642
7643 #define atomic_set(v, i) (((v)->counter) = i)
7644 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
7645 +{
7646 + v->counter = i;
7647 +}
7648 #define atomic64_set(v, i) (((v)->counter) = i)
7649 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
7650 +{
7651 + v->counter = i;
7652 +}
7653
7654 extern void atomic_add(int, atomic_t *);
7655 +extern void atomic_add_unchecked(int, atomic_unchecked_t *);
7656 extern void atomic64_add(long, atomic64_t *);
7657 +extern void atomic64_add_unchecked(long, atomic64_unchecked_t *);
7658 extern void atomic_sub(int, atomic_t *);
7659 +extern void atomic_sub_unchecked(int, atomic_unchecked_t *);
7660 extern void atomic64_sub(long, atomic64_t *);
7661 +extern void atomic64_sub_unchecked(long, atomic64_unchecked_t *);
7662
7663 extern int atomic_add_ret(int, atomic_t *);
7664 +extern int atomic_add_ret_unchecked(int, atomic_unchecked_t *);
7665 extern long atomic64_add_ret(long, atomic64_t *);
7666 +extern long atomic64_add_ret_unchecked(long, atomic64_unchecked_t *);
7667 extern int atomic_sub_ret(int, atomic_t *);
7668 extern long atomic64_sub_ret(long, atomic64_t *);
7669
7670 @@ -33,13 +55,29 @@ extern long atomic64_sub_ret(long, atomic64_t *);
7671 #define atomic64_dec_return(v) atomic64_sub_ret(1, v)
7672
7673 #define atomic_inc_return(v) atomic_add_ret(1, v)
7674 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
7675 +{
7676 + return atomic_add_ret_unchecked(1, v);
7677 +}
7678 #define atomic64_inc_return(v) atomic64_add_ret(1, v)
7679 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
7680 +{
7681 + return atomic64_add_ret_unchecked(1, v);
7682 +}
7683
7684 #define atomic_sub_return(i, v) atomic_sub_ret(i, v)
7685 #define atomic64_sub_return(i, v) atomic64_sub_ret(i, v)
7686
7687 #define atomic_add_return(i, v) atomic_add_ret(i, v)
7688 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
7689 +{
7690 + return atomic_add_ret_unchecked(i, v);
7691 +}
7692 #define atomic64_add_return(i, v) atomic64_add_ret(i, v)
7693 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
7694 +{
7695 + return atomic64_add_ret_unchecked(i, v);
7696 +}
7697
7698 /*
7699 * atomic_inc_and_test - increment and test
7700 @@ -50,6 +88,10 @@ extern long atomic64_sub_ret(long, atomic64_t *);
7701 * other cases.
7702 */
7703 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
7704 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
7705 +{
7706 + return atomic_inc_return_unchecked(v) == 0;
7707 +}
7708 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
7709
7710 #define atomic_sub_and_test(i, v) (atomic_sub_ret(i, v) == 0)
7711 @@ -59,25 +101,60 @@ extern long atomic64_sub_ret(long, atomic64_t *);
7712 #define atomic64_dec_and_test(v) (atomic64_sub_ret(1, v) == 0)
7713
7714 #define atomic_inc(v) atomic_add(1, v)
7715 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
7716 +{
7717 + atomic_add_unchecked(1, v);
7718 +}
7719 #define atomic64_inc(v) atomic64_add(1, v)
7720 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
7721 +{
7722 + atomic64_add_unchecked(1, v);
7723 +}
7724
7725 #define atomic_dec(v) atomic_sub(1, v)
7726 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
7727 +{
7728 + atomic_sub_unchecked(1, v);
7729 +}
7730 #define atomic64_dec(v) atomic64_sub(1, v)
7731 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
7732 +{
7733 + atomic64_sub_unchecked(1, v);
7734 +}
7735
7736 #define atomic_add_negative(i, v) (atomic_add_ret(i, v) < 0)
7737 #define atomic64_add_negative(i, v) (atomic64_add_ret(i, v) < 0)
7738
7739 #define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
7740 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
7741 +{
7742 + return cmpxchg(&v->counter, old, new);
7743 +}
7744 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
7745 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
7746 +{
7747 + return xchg(&v->counter, new);
7748 +}
7749
7750 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
7751 {
7752 - int c, old;
7753 + int c, old, new;
7754 c = atomic_read(v);
7755 for (;;) {
7756 - if (unlikely(c == (u)))
7757 + if (unlikely(c == u))
7758 break;
7759 - old = atomic_cmpxchg((v), c, c + (a));
7760 +
7761 + asm volatile("addcc %2, %0, %0\n"
7762 +
7763 +#ifdef CONFIG_PAX_REFCOUNT
7764 + "tvs %%icc, 6\n"
7765 +#endif
7766 +
7767 + : "=r" (new)
7768 + : "0" (c), "ir" (a)
7769 + : "cc");
7770 +
7771 + old = atomic_cmpxchg(v, c, new);
7772 if (likely(old == c))
7773 break;
7774 c = old;
7775 @@ -88,20 +165,35 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
7776 #define atomic64_cmpxchg(v, o, n) \
7777 ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
7778 #define atomic64_xchg(v, new) (xchg(&((v)->counter), new))
7779 +static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
7780 +{
7781 + return xchg(&v->counter, new);
7782 +}
7783
7784 static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
7785 {
7786 - long c, old;
7787 + long c, old, new;
7788 c = atomic64_read(v);
7789 for (;;) {
7790 - if (unlikely(c == (u)))
7791 + if (unlikely(c == u))
7792 break;
7793 - old = atomic64_cmpxchg((v), c, c + (a));
7794 +
7795 + asm volatile("addcc %2, %0, %0\n"
7796 +
7797 +#ifdef CONFIG_PAX_REFCOUNT
7798 + "tvs %%xcc, 6\n"
7799 +#endif
7800 +
7801 + : "=r" (new)
7802 + : "0" (c), "ir" (a)
7803 + : "cc");
7804 +
7805 + old = atomic64_cmpxchg(v, c, new);
7806 if (likely(old == c))
7807 break;
7808 c = old;
7809 }
7810 - return c != (u);
7811 + return c != u;
7812 }
7813
7814 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
7815 diff --git a/arch/sparc/include/asm/cache.h b/arch/sparc/include/asm/cache.h
7816 index 5bb6991..5c2132e 100644
7817 --- a/arch/sparc/include/asm/cache.h
7818 +++ b/arch/sparc/include/asm/cache.h
7819 @@ -7,10 +7,12 @@
7820 #ifndef _SPARC_CACHE_H
7821 #define _SPARC_CACHE_H
7822
7823 +#include <linux/const.h>
7824 +
7825 #define ARCH_SLAB_MINALIGN __alignof__(unsigned long long)
7826
7827 #define L1_CACHE_SHIFT 5
7828 -#define L1_CACHE_BYTES 32
7829 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7830
7831 #ifdef CONFIG_SPARC32
7832 #define SMP_CACHE_BYTES_SHIFT 5
7833 diff --git a/arch/sparc/include/asm/elf_32.h b/arch/sparc/include/asm/elf_32.h
7834 index a24e41f..47677ff 100644
7835 --- a/arch/sparc/include/asm/elf_32.h
7836 +++ b/arch/sparc/include/asm/elf_32.h
7837 @@ -114,6 +114,13 @@ typedef struct {
7838
7839 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE)
7840
7841 +#ifdef CONFIG_PAX_ASLR
7842 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
7843 +
7844 +#define PAX_DELTA_MMAP_LEN 16
7845 +#define PAX_DELTA_STACK_LEN 16
7846 +#endif
7847 +
7848 /* This yields a mask that user programs can use to figure out what
7849 instruction set this cpu supports. This can NOT be done in userspace
7850 on Sparc. */
7851 diff --git a/arch/sparc/include/asm/elf_64.h b/arch/sparc/include/asm/elf_64.h
7852 index 370ca1e..d4f4a98 100644
7853 --- a/arch/sparc/include/asm/elf_64.h
7854 +++ b/arch/sparc/include/asm/elf_64.h
7855 @@ -189,6 +189,13 @@ typedef struct {
7856 #define ELF_ET_DYN_BASE 0x0000010000000000UL
7857 #define COMPAT_ELF_ET_DYN_BASE 0x0000000070000000UL
7858
7859 +#ifdef CONFIG_PAX_ASLR
7860 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_32BIT) ? 0x10000UL : 0x100000UL)
7861 +
7862 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_32BIT) ? 14 : 28)
7863 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_32BIT) ? 15 : 29)
7864 +#endif
7865 +
7866 extern unsigned long sparc64_elf_hwcap;
7867 #define ELF_HWCAP sparc64_elf_hwcap
7868
7869 diff --git a/arch/sparc/include/asm/pgalloc_32.h b/arch/sparc/include/asm/pgalloc_32.h
7870 index 9b1c36d..209298b 100644
7871 --- a/arch/sparc/include/asm/pgalloc_32.h
7872 +++ b/arch/sparc/include/asm/pgalloc_32.h
7873 @@ -33,6 +33,7 @@ static inline void pgd_set(pgd_t * pgdp, pmd_t * pmdp)
7874 }
7875
7876 #define pgd_populate(MM, PGD, PMD) pgd_set(PGD, PMD)
7877 +#define pgd_populate_kernel(MM, PGD, PMD) pgd_populate((MM), (PGD), (PMD))
7878
7879 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm,
7880 unsigned long address)
7881 diff --git a/arch/sparc/include/asm/pgalloc_64.h b/arch/sparc/include/asm/pgalloc_64.h
7882 index bcfe063..b333142 100644
7883 --- a/arch/sparc/include/asm/pgalloc_64.h
7884 +++ b/arch/sparc/include/asm/pgalloc_64.h
7885 @@ -26,6 +26,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
7886 }
7887
7888 #define pud_populate(MM, PUD, PMD) pud_set(PUD, PMD)
7889 +#define pud_populate_kernel(MM, PUD, PMD) pud_populate((MM), (PUD), (PMD))
7890
7891 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
7892 {
7893 diff --git a/arch/sparc/include/asm/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h
7894 index 6fc1348..390c50a 100644
7895 --- a/arch/sparc/include/asm/pgtable_32.h
7896 +++ b/arch/sparc/include/asm/pgtable_32.h
7897 @@ -50,6 +50,9 @@ extern unsigned long calc_highpages(void);
7898 #define PAGE_SHARED SRMMU_PAGE_SHARED
7899 #define PAGE_COPY SRMMU_PAGE_COPY
7900 #define PAGE_READONLY SRMMU_PAGE_RDONLY
7901 +#define PAGE_SHARED_NOEXEC SRMMU_PAGE_SHARED_NOEXEC
7902 +#define PAGE_COPY_NOEXEC SRMMU_PAGE_COPY_NOEXEC
7903 +#define PAGE_READONLY_NOEXEC SRMMU_PAGE_RDONLY_NOEXEC
7904 #define PAGE_KERNEL SRMMU_PAGE_KERNEL
7905
7906 /* Top-level page directory - dummy used by init-mm.
7907 @@ -62,18 +65,18 @@ extern unsigned long ptr_in_current_pgd;
7908
7909 /* xwr */
7910 #define __P000 PAGE_NONE
7911 -#define __P001 PAGE_READONLY
7912 -#define __P010 PAGE_COPY
7913 -#define __P011 PAGE_COPY
7914 +#define __P001 PAGE_READONLY_NOEXEC
7915 +#define __P010 PAGE_COPY_NOEXEC
7916 +#define __P011 PAGE_COPY_NOEXEC
7917 #define __P100 PAGE_READONLY
7918 #define __P101 PAGE_READONLY
7919 #define __P110 PAGE_COPY
7920 #define __P111 PAGE_COPY
7921
7922 #define __S000 PAGE_NONE
7923 -#define __S001 PAGE_READONLY
7924 -#define __S010 PAGE_SHARED
7925 -#define __S011 PAGE_SHARED
7926 +#define __S001 PAGE_READONLY_NOEXEC
7927 +#define __S010 PAGE_SHARED_NOEXEC
7928 +#define __S011 PAGE_SHARED_NOEXEC
7929 #define __S100 PAGE_READONLY
7930 #define __S101 PAGE_READONLY
7931 #define __S110 PAGE_SHARED
7932 diff --git a/arch/sparc/include/asm/pgtsrmmu.h b/arch/sparc/include/asm/pgtsrmmu.h
7933 index 79da178..c2eede8 100644
7934 --- a/arch/sparc/include/asm/pgtsrmmu.h
7935 +++ b/arch/sparc/include/asm/pgtsrmmu.h
7936 @@ -115,6 +115,11 @@
7937 SRMMU_EXEC | SRMMU_REF)
7938 #define SRMMU_PAGE_RDONLY __pgprot(SRMMU_VALID | SRMMU_CACHE | \
7939 SRMMU_EXEC | SRMMU_REF)
7940 +
7941 +#define SRMMU_PAGE_SHARED_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_WRITE | SRMMU_REF)
7942 +#define SRMMU_PAGE_COPY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
7943 +#define SRMMU_PAGE_RDONLY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
7944 +
7945 #define SRMMU_PAGE_KERNEL __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_PRIV | \
7946 SRMMU_DIRTY | SRMMU_REF)
7947
7948 diff --git a/arch/sparc/include/asm/spinlock_64.h b/arch/sparc/include/asm/spinlock_64.h
7949 index 9689176..63c18ea 100644
7950 --- a/arch/sparc/include/asm/spinlock_64.h
7951 +++ b/arch/sparc/include/asm/spinlock_64.h
7952 @@ -92,14 +92,19 @@ static inline void arch_spin_lock_flags(arch_spinlock_t *lock, unsigned long fla
7953
7954 /* Multi-reader locks, these are much saner than the 32-bit Sparc ones... */
7955
7956 -static void inline arch_read_lock(arch_rwlock_t *lock)
7957 +static inline void arch_read_lock(arch_rwlock_t *lock)
7958 {
7959 unsigned long tmp1, tmp2;
7960
7961 __asm__ __volatile__ (
7962 "1: ldsw [%2], %0\n"
7963 " brlz,pn %0, 2f\n"
7964 -"4: add %0, 1, %1\n"
7965 +"4: addcc %0, 1, %1\n"
7966 +
7967 +#ifdef CONFIG_PAX_REFCOUNT
7968 +" tvs %%icc, 6\n"
7969 +#endif
7970 +
7971 " cas [%2], %0, %1\n"
7972 " cmp %0, %1\n"
7973 " bne,pn %%icc, 1b\n"
7974 @@ -112,10 +117,10 @@ static void inline arch_read_lock(arch_rwlock_t *lock)
7975 " .previous"
7976 : "=&r" (tmp1), "=&r" (tmp2)
7977 : "r" (lock)
7978 - : "memory");
7979 + : "memory", "cc");
7980 }
7981
7982 -static int inline arch_read_trylock(arch_rwlock_t *lock)
7983 +static inline int arch_read_trylock(arch_rwlock_t *lock)
7984 {
7985 int tmp1, tmp2;
7986
7987 @@ -123,7 +128,12 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
7988 "1: ldsw [%2], %0\n"
7989 " brlz,a,pn %0, 2f\n"
7990 " mov 0, %0\n"
7991 -" add %0, 1, %1\n"
7992 +" addcc %0, 1, %1\n"
7993 +
7994 +#ifdef CONFIG_PAX_REFCOUNT
7995 +" tvs %%icc, 6\n"
7996 +#endif
7997 +
7998 " cas [%2], %0, %1\n"
7999 " cmp %0, %1\n"
8000 " bne,pn %%icc, 1b\n"
8001 @@ -136,13 +146,18 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
8002 return tmp1;
8003 }
8004
8005 -static void inline arch_read_unlock(arch_rwlock_t *lock)
8006 +static inline void arch_read_unlock(arch_rwlock_t *lock)
8007 {
8008 unsigned long tmp1, tmp2;
8009
8010 __asm__ __volatile__(
8011 "1: lduw [%2], %0\n"
8012 -" sub %0, 1, %1\n"
8013 +" subcc %0, 1, %1\n"
8014 +
8015 +#ifdef CONFIG_PAX_REFCOUNT
8016 +" tvs %%icc, 6\n"
8017 +#endif
8018 +
8019 " cas [%2], %0, %1\n"
8020 " cmp %0, %1\n"
8021 " bne,pn %%xcc, 1b\n"
8022 @@ -152,7 +167,7 @@ static void inline arch_read_unlock(arch_rwlock_t *lock)
8023 : "memory");
8024 }
8025
8026 -static void inline arch_write_lock(arch_rwlock_t *lock)
8027 +static inline void arch_write_lock(arch_rwlock_t *lock)
8028 {
8029 unsigned long mask, tmp1, tmp2;
8030
8031 @@ -177,7 +192,7 @@ static void inline arch_write_lock(arch_rwlock_t *lock)
8032 : "memory");
8033 }
8034
8035 -static void inline arch_write_unlock(arch_rwlock_t *lock)
8036 +static inline void arch_write_unlock(arch_rwlock_t *lock)
8037 {
8038 __asm__ __volatile__(
8039 " stw %%g0, [%0]"
8040 @@ -186,7 +201,7 @@ static void inline arch_write_unlock(arch_rwlock_t *lock)
8041 : "memory");
8042 }
8043
8044 -static int inline arch_write_trylock(arch_rwlock_t *lock)
8045 +static inline int arch_write_trylock(arch_rwlock_t *lock)
8046 {
8047 unsigned long mask, tmp1, tmp2, result;
8048
8049 diff --git a/arch/sparc/include/asm/thread_info_32.h b/arch/sparc/include/asm/thread_info_32.h
8050 index 25849ae..924c54b 100644
8051 --- a/arch/sparc/include/asm/thread_info_32.h
8052 +++ b/arch/sparc/include/asm/thread_info_32.h
8053 @@ -49,6 +49,8 @@ struct thread_info {
8054 unsigned long w_saved;
8055
8056 struct restart_block restart_block;
8057 +
8058 + unsigned long lowest_stack;
8059 };
8060
8061 /*
8062 diff --git a/arch/sparc/include/asm/thread_info_64.h b/arch/sparc/include/asm/thread_info_64.h
8063 index 269bd92..e46a9b8 100644
8064 --- a/arch/sparc/include/asm/thread_info_64.h
8065 +++ b/arch/sparc/include/asm/thread_info_64.h
8066 @@ -63,6 +63,8 @@ struct thread_info {
8067 struct pt_regs *kern_una_regs;
8068 unsigned int kern_una_insn;
8069
8070 + unsigned long lowest_stack;
8071 +
8072 unsigned long fpregs[0] __attribute__ ((aligned(64)));
8073 };
8074
8075 @@ -192,10 +194,11 @@ register struct thread_info *current_thread_info_reg asm("g6");
8076 #define TIF_UNALIGNED 5 /* allowed to do unaligned accesses */
8077 /* flag bit 6 is available */
8078 #define TIF_32BIT 7 /* 32-bit binary */
8079 -/* flag bit 8 is available */
8080 +#define TIF_GRSEC_SETXID 8 /* update credentials on syscall entry/exit */
8081 #define TIF_SECCOMP 9 /* secure computing */
8082 #define TIF_SYSCALL_AUDIT 10 /* syscall auditing active */
8083 #define TIF_SYSCALL_TRACEPOINT 11 /* syscall tracepoint instrumentation */
8084 +
8085 /* NOTE: Thread flags >= 12 should be ones we have no interest
8086 * in using in assembly, else we can't use the mask as
8087 * an immediate value in instructions such as andcc.
8088 @@ -214,12 +217,18 @@ register struct thread_info *current_thread_info_reg asm("g6");
8089 #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
8090 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
8091 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
8092 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
8093
8094 #define _TIF_USER_WORK_MASK ((0xff << TI_FLAG_WSAVED_SHIFT) | \
8095 _TIF_DO_NOTIFY_RESUME_MASK | \
8096 _TIF_NEED_RESCHED)
8097 #define _TIF_DO_NOTIFY_RESUME_MASK (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING)
8098
8099 +#define _TIF_WORK_SYSCALL \
8100 + (_TIF_SYSCALL_TRACE | _TIF_SECCOMP | _TIF_SYSCALL_AUDIT | \
8101 + _TIF_SYSCALL_TRACEPOINT | _TIF_GRSEC_SETXID)
8102 +
8103 +
8104 /*
8105 * Thread-synchronous status.
8106 *
8107 diff --git a/arch/sparc/include/asm/uaccess.h b/arch/sparc/include/asm/uaccess.h
8108 index 0167d26..767bb0c 100644
8109 --- a/arch/sparc/include/asm/uaccess.h
8110 +++ b/arch/sparc/include/asm/uaccess.h
8111 @@ -1,5 +1,6 @@
8112 #ifndef ___ASM_SPARC_UACCESS_H
8113 #define ___ASM_SPARC_UACCESS_H
8114 +
8115 #if defined(__sparc__) && defined(__arch64__)
8116 #include <asm/uaccess_64.h>
8117 #else
8118 diff --git a/arch/sparc/include/asm/uaccess_32.h b/arch/sparc/include/asm/uaccess_32.h
8119 index 53a28dd..50c38c3 100644
8120 --- a/arch/sparc/include/asm/uaccess_32.h
8121 +++ b/arch/sparc/include/asm/uaccess_32.h
8122 @@ -250,27 +250,46 @@ extern unsigned long __copy_user(void __user *to, const void __user *from, unsig
8123
8124 static inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
8125 {
8126 - if (n && __access_ok((unsigned long) to, n))
8127 + if ((long)n < 0)
8128 + return n;
8129 +
8130 + if (n && __access_ok((unsigned long) to, n)) {
8131 + if (!__builtin_constant_p(n))
8132 + check_object_size(from, n, true);
8133 return __copy_user(to, (__force void __user *) from, n);
8134 - else
8135 + } else
8136 return n;
8137 }
8138
8139 static inline unsigned long __copy_to_user(void __user *to, const void *from, unsigned long n)
8140 {
8141 + if ((long)n < 0)
8142 + return n;
8143 +
8144 + if (!__builtin_constant_p(n))
8145 + check_object_size(from, n, true);
8146 +
8147 return __copy_user(to, (__force void __user *) from, n);
8148 }
8149
8150 static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
8151 {
8152 - if (n && __access_ok((unsigned long) from, n))
8153 + if ((long)n < 0)
8154 + return n;
8155 +
8156 + if (n && __access_ok((unsigned long) from, n)) {
8157 + if (!__builtin_constant_p(n))
8158 + check_object_size(to, n, false);
8159 return __copy_user((__force void __user *) to, from, n);
8160 - else
8161 + } else
8162 return n;
8163 }
8164
8165 static inline unsigned long __copy_from_user(void *to, const void __user *from, unsigned long n)
8166 {
8167 + if ((long)n < 0)
8168 + return n;
8169 +
8170 return __copy_user((__force void __user *) to, from, n);
8171 }
8172
8173 diff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h
8174 index e562d3c..191f176 100644
8175 --- a/arch/sparc/include/asm/uaccess_64.h
8176 +++ b/arch/sparc/include/asm/uaccess_64.h
8177 @@ -10,6 +10,7 @@
8178 #include <linux/compiler.h>
8179 #include <linux/string.h>
8180 #include <linux/thread_info.h>
8181 +#include <linux/kernel.h>
8182 #include <asm/asi.h>
8183 #include <asm/spitfire.h>
8184 #include <asm-generic/uaccess-unaligned.h>
8185 @@ -214,8 +215,15 @@ extern unsigned long copy_from_user_fixup(void *to, const void __user *from,
8186 static inline unsigned long __must_check
8187 copy_from_user(void *to, const void __user *from, unsigned long size)
8188 {
8189 - unsigned long ret = ___copy_from_user(to, from, size);
8190 + unsigned long ret;
8191
8192 + if ((long)size < 0 || size > INT_MAX)
8193 + return size;
8194 +
8195 + if (!__builtin_constant_p(size))
8196 + check_object_size(to, size, false);
8197 +
8198 + ret = ___copy_from_user(to, from, size);
8199 if (unlikely(ret))
8200 ret = copy_from_user_fixup(to, from, size);
8201
8202 @@ -231,8 +239,15 @@ extern unsigned long copy_to_user_fixup(void __user *to, const void *from,
8203 static inline unsigned long __must_check
8204 copy_to_user(void __user *to, const void *from, unsigned long size)
8205 {
8206 - unsigned long ret = ___copy_to_user(to, from, size);
8207 + unsigned long ret;
8208
8209 + if ((long)size < 0 || size > INT_MAX)
8210 + return size;
8211 +
8212 + if (!__builtin_constant_p(size))
8213 + check_object_size(from, size, true);
8214 +
8215 + ret = ___copy_to_user(to, from, size);
8216 if (unlikely(ret))
8217 ret = copy_to_user_fixup(to, from, size);
8218 return ret;
8219 diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
8220 index 6cf591b..b49e65a 100644
8221 --- a/arch/sparc/kernel/Makefile
8222 +++ b/arch/sparc/kernel/Makefile
8223 @@ -3,7 +3,7 @@
8224 #
8225
8226 asflags-y := -ansi
8227 -ccflags-y := -Werror
8228 +#ccflags-y := -Werror
8229
8230 extra-y := head_$(BITS).o
8231
8232 diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c
8233 index 62eede1..9c5b904 100644
8234 --- a/arch/sparc/kernel/process_32.c
8235 +++ b/arch/sparc/kernel/process_32.c
8236 @@ -125,14 +125,14 @@ void show_regs(struct pt_regs *r)
8237
8238 printk("PSR: %08lx PC: %08lx NPC: %08lx Y: %08lx %s\n",
8239 r->psr, r->pc, r->npc, r->y, print_tainted());
8240 - printk("PC: <%pS>\n", (void *) r->pc);
8241 + printk("PC: <%pA>\n", (void *) r->pc);
8242 printk("%%G: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8243 r->u_regs[0], r->u_regs[1], r->u_regs[2], r->u_regs[3],
8244 r->u_regs[4], r->u_regs[5], r->u_regs[6], r->u_regs[7]);
8245 printk("%%O: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8246 r->u_regs[8], r->u_regs[9], r->u_regs[10], r->u_regs[11],
8247 r->u_regs[12], r->u_regs[13], r->u_regs[14], r->u_regs[15]);
8248 - printk("RPC: <%pS>\n", (void *) r->u_regs[15]);
8249 + printk("RPC: <%pA>\n", (void *) r->u_regs[15]);
8250
8251 printk("%%L: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8252 rw->locals[0], rw->locals[1], rw->locals[2], rw->locals[3],
8253 @@ -167,7 +167,7 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
8254 rw = (struct reg_window32 *) fp;
8255 pc = rw->ins[7];
8256 printk("[%08lx : ", pc);
8257 - printk("%pS ] ", (void *) pc);
8258 + printk("%pA ] ", (void *) pc);
8259 fp = rw->ins[6];
8260 } while (++count < 16);
8261 printk("\n");
8262 diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
8263 index cdb80b2..5ca141d 100644
8264 --- a/arch/sparc/kernel/process_64.c
8265 +++ b/arch/sparc/kernel/process_64.c
8266 @@ -181,14 +181,14 @@ static void show_regwindow(struct pt_regs *regs)
8267 printk("i4: %016lx i5: %016lx i6: %016lx i7: %016lx\n",
8268 rwk->ins[4], rwk->ins[5], rwk->ins[6], rwk->ins[7]);
8269 if (regs->tstate & TSTATE_PRIV)
8270 - printk("I7: <%pS>\n", (void *) rwk->ins[7]);
8271 + printk("I7: <%pA>\n", (void *) rwk->ins[7]);
8272 }
8273
8274 void show_regs(struct pt_regs *regs)
8275 {
8276 printk("TSTATE: %016lx TPC: %016lx TNPC: %016lx Y: %08x %s\n", regs->tstate,
8277 regs->tpc, regs->tnpc, regs->y, print_tainted());
8278 - printk("TPC: <%pS>\n", (void *) regs->tpc);
8279 + printk("TPC: <%pA>\n", (void *) regs->tpc);
8280 printk("g0: %016lx g1: %016lx g2: %016lx g3: %016lx\n",
8281 regs->u_regs[0], regs->u_regs[1], regs->u_regs[2],
8282 regs->u_regs[3]);
8283 @@ -201,7 +201,7 @@ void show_regs(struct pt_regs *regs)
8284 printk("o4: %016lx o5: %016lx sp: %016lx ret_pc: %016lx\n",
8285 regs->u_regs[12], regs->u_regs[13], regs->u_regs[14],
8286 regs->u_regs[15]);
8287 - printk("RPC: <%pS>\n", (void *) regs->u_regs[15]);
8288 + printk("RPC: <%pA>\n", (void *) regs->u_regs[15]);
8289 show_regwindow(regs);
8290 show_stack(current, (unsigned long *) regs->u_regs[UREG_FP]);
8291 }
8292 @@ -290,7 +290,7 @@ void arch_trigger_all_cpu_backtrace(void)
8293 ((tp && tp->task) ? tp->task->pid : -1));
8294
8295 if (gp->tstate & TSTATE_PRIV) {
8296 - printk(" TPC[%pS] O7[%pS] I7[%pS] RPC[%pS]\n",
8297 + printk(" TPC[%pA] O7[%pA] I7[%pA] RPC[%pA]\n",
8298 (void *) gp->tpc,
8299 (void *) gp->o7,
8300 (void *) gp->i7,
8301 diff --git a/arch/sparc/kernel/prom_common.c b/arch/sparc/kernel/prom_common.c
8302 index 9f20566..67eb41b 100644
8303 --- a/arch/sparc/kernel/prom_common.c
8304 +++ b/arch/sparc/kernel/prom_common.c
8305 @@ -143,7 +143,7 @@ static int __init prom_common_nextprop(phandle node, char *prev, char *buf)
8306
8307 unsigned int prom_early_allocated __initdata;
8308
8309 -static struct of_pdt_ops prom_sparc_ops __initdata = {
8310 +static struct of_pdt_ops prom_sparc_ops __initconst = {
8311 .nextprop = prom_common_nextprop,
8312 .getproplen = prom_getproplen,
8313 .getproperty = prom_getproperty,
8314 diff --git a/arch/sparc/kernel/ptrace_64.c b/arch/sparc/kernel/ptrace_64.c
8315 index 7ff45e4..a58f271 100644
8316 --- a/arch/sparc/kernel/ptrace_64.c
8317 +++ b/arch/sparc/kernel/ptrace_64.c
8318 @@ -1057,6 +1057,10 @@ long arch_ptrace(struct task_struct *child, long request,
8319 return ret;
8320 }
8321
8322 +#ifdef CONFIG_GRKERNSEC_SETXID
8323 +extern void gr_delayed_cred_worker(void);
8324 +#endif
8325 +
8326 asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8327 {
8328 int ret = 0;
8329 @@ -1064,6 +1068,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8330 /* do the secure computing check first */
8331 secure_computing_strict(regs->u_regs[UREG_G1]);
8332
8333 +#ifdef CONFIG_GRKERNSEC_SETXID
8334 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8335 + gr_delayed_cred_worker();
8336 +#endif
8337 +
8338 if (test_thread_flag(TIF_SYSCALL_TRACE))
8339 ret = tracehook_report_syscall_entry(regs);
8340
8341 @@ -1084,6 +1093,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8342
8343 asmlinkage void syscall_trace_leave(struct pt_regs *regs)
8344 {
8345 +#ifdef CONFIG_GRKERNSEC_SETXID
8346 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8347 + gr_delayed_cred_worker();
8348 +#endif
8349 +
8350 audit_syscall_exit(regs);
8351
8352 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
8353 diff --git a/arch/sparc/kernel/sys_sparc_32.c b/arch/sparc/kernel/sys_sparc_32.c
8354 index 3a8d184..49498a8 100644
8355 --- a/arch/sparc/kernel/sys_sparc_32.c
8356 +++ b/arch/sparc/kernel/sys_sparc_32.c
8357 @@ -52,7 +52,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8358 if (len > TASK_SIZE - PAGE_SIZE)
8359 return -ENOMEM;
8360 if (!addr)
8361 - addr = TASK_UNMAPPED_BASE;
8362 + addr = current->mm->mmap_base;
8363
8364 info.flags = 0;
8365 info.length = len;
8366 diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c
8367 index 708bc29..6bfdfad 100644
8368 --- a/arch/sparc/kernel/sys_sparc_64.c
8369 +++ b/arch/sparc/kernel/sys_sparc_64.c
8370 @@ -90,13 +90,14 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8371 struct vm_area_struct * vma;
8372 unsigned long task_size = TASK_SIZE;
8373 int do_color_align;
8374 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8375 struct vm_unmapped_area_info info;
8376
8377 if (flags & MAP_FIXED) {
8378 /* We do not accept a shared mapping if it would violate
8379 * cache aliasing constraints.
8380 */
8381 - if ((flags & MAP_SHARED) &&
8382 + if ((filp || (flags & MAP_SHARED)) &&
8383 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
8384 return -EINVAL;
8385 return addr;
8386 @@ -111,6 +112,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8387 if (filp || (flags & MAP_SHARED))
8388 do_color_align = 1;
8389
8390 +#ifdef CONFIG_PAX_RANDMMAP
8391 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8392 +#endif
8393 +
8394 if (addr) {
8395 if (do_color_align)
8396 addr = COLOR_ALIGN(addr, pgoff);
8397 @@ -118,22 +123,28 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8398 addr = PAGE_ALIGN(addr);
8399
8400 vma = find_vma(mm, addr);
8401 - if (task_size - len >= addr &&
8402 - (!vma || addr + len <= vma->vm_start))
8403 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8404 return addr;
8405 }
8406
8407 info.flags = 0;
8408 info.length = len;
8409 - info.low_limit = TASK_UNMAPPED_BASE;
8410 + info.low_limit = mm->mmap_base;
8411 info.high_limit = min(task_size, VA_EXCLUDE_START);
8412 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
8413 info.align_offset = pgoff << PAGE_SHIFT;
8414 + info.threadstack_offset = offset;
8415 addr = vm_unmapped_area(&info);
8416
8417 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
8418 VM_BUG_ON(addr != -ENOMEM);
8419 info.low_limit = VA_EXCLUDE_END;
8420 +
8421 +#ifdef CONFIG_PAX_RANDMMAP
8422 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8423 + info.low_limit += mm->delta_mmap;
8424 +#endif
8425 +
8426 info.high_limit = task_size;
8427 addr = vm_unmapped_area(&info);
8428 }
8429 @@ -151,6 +162,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8430 unsigned long task_size = STACK_TOP32;
8431 unsigned long addr = addr0;
8432 int do_color_align;
8433 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8434 struct vm_unmapped_area_info info;
8435
8436 /* This should only ever run for 32-bit processes. */
8437 @@ -160,7 +172,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8438 /* We do not accept a shared mapping if it would violate
8439 * cache aliasing constraints.
8440 */
8441 - if ((flags & MAP_SHARED) &&
8442 + if ((filp || (flags & MAP_SHARED)) &&
8443 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
8444 return -EINVAL;
8445 return addr;
8446 @@ -173,6 +185,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8447 if (filp || (flags & MAP_SHARED))
8448 do_color_align = 1;
8449
8450 +#ifdef CONFIG_PAX_RANDMMAP
8451 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8452 +#endif
8453 +
8454 /* requesting a specific address */
8455 if (addr) {
8456 if (do_color_align)
8457 @@ -181,8 +197,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8458 addr = PAGE_ALIGN(addr);
8459
8460 vma = find_vma(mm, addr);
8461 - if (task_size - len >= addr &&
8462 - (!vma || addr + len <= vma->vm_start))
8463 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8464 return addr;
8465 }
8466
8467 @@ -192,6 +207,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8468 info.high_limit = mm->mmap_base;
8469 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
8470 info.align_offset = pgoff << PAGE_SHIFT;
8471 + info.threadstack_offset = offset;
8472 addr = vm_unmapped_area(&info);
8473
8474 /*
8475 @@ -204,6 +220,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8476 VM_BUG_ON(addr != -ENOMEM);
8477 info.flags = 0;
8478 info.low_limit = TASK_UNMAPPED_BASE;
8479 +
8480 +#ifdef CONFIG_PAX_RANDMMAP
8481 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8482 + info.low_limit += mm->delta_mmap;
8483 +#endif
8484 +
8485 info.high_limit = STACK_TOP32;
8486 addr = vm_unmapped_area(&info);
8487 }
8488 @@ -264,6 +286,10 @@ static unsigned long mmap_rnd(void)
8489 {
8490 unsigned long rnd = 0UL;
8491
8492 +#ifdef CONFIG_PAX_RANDMMAP
8493 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8494 +#endif
8495 +
8496 if (current->flags & PF_RANDOMIZE) {
8497 unsigned long val = get_random_int();
8498 if (test_thread_flag(TIF_32BIT))
8499 @@ -289,6 +315,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8500 gap == RLIM_INFINITY ||
8501 sysctl_legacy_va_layout) {
8502 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
8503 +
8504 +#ifdef CONFIG_PAX_RANDMMAP
8505 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8506 + mm->mmap_base += mm->delta_mmap;
8507 +#endif
8508 +
8509 mm->get_unmapped_area = arch_get_unmapped_area;
8510 mm->unmap_area = arch_unmap_area;
8511 } else {
8512 @@ -301,6 +333,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8513 gap = (task_size / 6 * 5);
8514
8515 mm->mmap_base = PAGE_ALIGN(task_size - gap - random_factor);
8516 +
8517 +#ifdef CONFIG_PAX_RANDMMAP
8518 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8519 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8520 +#endif
8521 +
8522 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
8523 mm->unmap_area = arch_unmap_area_topdown;
8524 }
8525 diff --git a/arch/sparc/kernel/syscalls.S b/arch/sparc/kernel/syscalls.S
8526 index 22a1098..6255eb9 100644
8527 --- a/arch/sparc/kernel/syscalls.S
8528 +++ b/arch/sparc/kernel/syscalls.S
8529 @@ -52,7 +52,7 @@ sys32_rt_sigreturn:
8530 #endif
8531 .align 32
8532 1: ldx [%g6 + TI_FLAGS], %l5
8533 - andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8534 + andcc %l5, _TIF_WORK_SYSCALL, %g0
8535 be,pt %icc, rtrap
8536 nop
8537 call syscall_trace_leave
8538 @@ -184,7 +184,7 @@ linux_sparc_syscall32:
8539
8540 srl %i5, 0, %o5 ! IEU1
8541 srl %i2, 0, %o2 ! IEU0 Group
8542 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8543 + andcc %l0, _TIF_WORK_SYSCALL, %g0
8544 bne,pn %icc, linux_syscall_trace32 ! CTI
8545 mov %i0, %l5 ! IEU1
8546 call %l7 ! CTI Group brk forced
8547 @@ -207,7 +207,7 @@ linux_sparc_syscall:
8548
8549 mov %i3, %o3 ! IEU1
8550 mov %i4, %o4 ! IEU0 Group
8551 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8552 + andcc %l0, _TIF_WORK_SYSCALL, %g0
8553 bne,pn %icc, linux_syscall_trace ! CTI Group
8554 mov %i0, %l5 ! IEU0
8555 2: call %l7 ! CTI Group brk forced
8556 @@ -223,7 +223,7 @@ ret_sys_call:
8557
8558 cmp %o0, -ERESTART_RESTARTBLOCK
8559 bgeu,pn %xcc, 1f
8560 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8561 + andcc %l0, _TIF_WORK_SYSCALL, %g0
8562 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
8563
8564 2:
8565 diff --git a/arch/sparc/kernel/sysfs.c b/arch/sparc/kernel/sysfs.c
8566 index 654e8aa..45f431b 100644
8567 --- a/arch/sparc/kernel/sysfs.c
8568 +++ b/arch/sparc/kernel/sysfs.c
8569 @@ -266,7 +266,7 @@ static int __cpuinit sysfs_cpu_notify(struct notifier_block *self,
8570 return NOTIFY_OK;
8571 }
8572
8573 -static struct notifier_block __cpuinitdata sysfs_cpu_nb = {
8574 +static struct notifier_block sysfs_cpu_nb = {
8575 .notifier_call = sysfs_cpu_notify,
8576 };
8577
8578 diff --git a/arch/sparc/kernel/traps_32.c b/arch/sparc/kernel/traps_32.c
8579 index 6629829..036032d 100644
8580 --- a/arch/sparc/kernel/traps_32.c
8581 +++ b/arch/sparc/kernel/traps_32.c
8582 @@ -44,6 +44,8 @@ static void instruction_dump(unsigned long *pc)
8583 #define __SAVE __asm__ __volatile__("save %sp, -0x40, %sp\n\t")
8584 #define __RESTORE __asm__ __volatile__("restore %g0, %g0, %g0\n\t")
8585
8586 +extern void gr_handle_kernel_exploit(void);
8587 +
8588 void die_if_kernel(char *str, struct pt_regs *regs)
8589 {
8590 static int die_counter;
8591 @@ -76,15 +78,17 @@ void die_if_kernel(char *str, struct pt_regs *regs)
8592 count++ < 30 &&
8593 (((unsigned long) rw) >= PAGE_OFFSET) &&
8594 !(((unsigned long) rw) & 0x7)) {
8595 - printk("Caller[%08lx]: %pS\n", rw->ins[7],
8596 + printk("Caller[%08lx]: %pA\n", rw->ins[7],
8597 (void *) rw->ins[7]);
8598 rw = (struct reg_window32 *)rw->ins[6];
8599 }
8600 }
8601 printk("Instruction DUMP:");
8602 instruction_dump ((unsigned long *) regs->pc);
8603 - if(regs->psr & PSR_PS)
8604 + if(regs->psr & PSR_PS) {
8605 + gr_handle_kernel_exploit();
8606 do_exit(SIGKILL);
8607 + }
8608 do_exit(SIGSEGV);
8609 }
8610
8611 diff --git a/arch/sparc/kernel/traps_64.c b/arch/sparc/kernel/traps_64.c
8612 index 8d38ca9..845b1d6 100644
8613 --- a/arch/sparc/kernel/traps_64.c
8614 +++ b/arch/sparc/kernel/traps_64.c
8615 @@ -76,7 +76,7 @@ static void dump_tl1_traplog(struct tl1_traplog *p)
8616 i + 1,
8617 p->trapstack[i].tstate, p->trapstack[i].tpc,
8618 p->trapstack[i].tnpc, p->trapstack[i].tt);
8619 - printk("TRAPLOG: TPC<%pS>\n", (void *) p->trapstack[i].tpc);
8620 + printk("TRAPLOG: TPC<%pA>\n", (void *) p->trapstack[i].tpc);
8621 }
8622 }
8623
8624 @@ -96,6 +96,12 @@ void bad_trap(struct pt_regs *regs, long lvl)
8625
8626 lvl -= 0x100;
8627 if (regs->tstate & TSTATE_PRIV) {
8628 +
8629 +#ifdef CONFIG_PAX_REFCOUNT
8630 + if (lvl == 6)
8631 + pax_report_refcount_overflow(regs);
8632 +#endif
8633 +
8634 sprintf(buffer, "Kernel bad sw trap %lx", lvl);
8635 die_if_kernel(buffer, regs);
8636 }
8637 @@ -114,11 +120,16 @@ void bad_trap(struct pt_regs *regs, long lvl)
8638 void bad_trap_tl1(struct pt_regs *regs, long lvl)
8639 {
8640 char buffer[32];
8641 -
8642 +
8643 if (notify_die(DIE_TRAP_TL1, "bad trap tl1", regs,
8644 0, lvl, SIGTRAP) == NOTIFY_STOP)
8645 return;
8646
8647 +#ifdef CONFIG_PAX_REFCOUNT
8648 + if (lvl == 6)
8649 + pax_report_refcount_overflow(regs);
8650 +#endif
8651 +
8652 dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
8653
8654 sprintf (buffer, "Bad trap %lx at tl>0", lvl);
8655 @@ -1142,7 +1153,7 @@ static void cheetah_log_errors(struct pt_regs *regs, struct cheetah_err_info *in
8656 regs->tpc, regs->tnpc, regs->u_regs[UREG_I7], regs->tstate);
8657 printk("%s" "ERROR(%d): ",
8658 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id());
8659 - printk("TPC<%pS>\n", (void *) regs->tpc);
8660 + printk("TPC<%pA>\n", (void *) regs->tpc);
8661 printk("%s" "ERROR(%d): M_SYND(%lx), E_SYND(%lx)%s%s\n",
8662 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
8663 (afsr & CHAFSR_M_SYNDROME) >> CHAFSR_M_SYNDROME_SHIFT,
8664 @@ -1749,7 +1760,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
8665 smp_processor_id(),
8666 (type & 0x1) ? 'I' : 'D',
8667 regs->tpc);
8668 - printk(KERN_EMERG "TPC<%pS>\n", (void *) regs->tpc);
8669 + printk(KERN_EMERG "TPC<%pA>\n", (void *) regs->tpc);
8670 panic("Irrecoverable Cheetah+ parity error.");
8671 }
8672
8673 @@ -1757,7 +1768,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
8674 smp_processor_id(),
8675 (type & 0x1) ? 'I' : 'D',
8676 regs->tpc);
8677 - printk(KERN_WARNING "TPC<%pS>\n", (void *) regs->tpc);
8678 + printk(KERN_WARNING "TPC<%pA>\n", (void *) regs->tpc);
8679 }
8680
8681 struct sun4v_error_entry {
8682 @@ -2104,9 +2115,9 @@ void sun4v_itlb_error_report(struct pt_regs *regs, int tl)
8683
8684 printk(KERN_EMERG "SUN4V-ITLB: Error at TPC[%lx], tl %d\n",
8685 regs->tpc, tl);
8686 - printk(KERN_EMERG "SUN4V-ITLB: TPC<%pS>\n", (void *) regs->tpc);
8687 + printk(KERN_EMERG "SUN4V-ITLB: TPC<%pA>\n", (void *) regs->tpc);
8688 printk(KERN_EMERG "SUN4V-ITLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
8689 - printk(KERN_EMERG "SUN4V-ITLB: O7<%pS>\n",
8690 + printk(KERN_EMERG "SUN4V-ITLB: O7<%pA>\n",
8691 (void *) regs->u_regs[UREG_I7]);
8692 printk(KERN_EMERG "SUN4V-ITLB: vaddr[%lx] ctx[%lx] "
8693 "pte[%lx] error[%lx]\n",
8694 @@ -2128,9 +2139,9 @@ void sun4v_dtlb_error_report(struct pt_regs *regs, int tl)
8695
8696 printk(KERN_EMERG "SUN4V-DTLB: Error at TPC[%lx], tl %d\n",
8697 regs->tpc, tl);
8698 - printk(KERN_EMERG "SUN4V-DTLB: TPC<%pS>\n", (void *) regs->tpc);
8699 + printk(KERN_EMERG "SUN4V-DTLB: TPC<%pA>\n", (void *) regs->tpc);
8700 printk(KERN_EMERG "SUN4V-DTLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
8701 - printk(KERN_EMERG "SUN4V-DTLB: O7<%pS>\n",
8702 + printk(KERN_EMERG "SUN4V-DTLB: O7<%pA>\n",
8703 (void *) regs->u_regs[UREG_I7]);
8704 printk(KERN_EMERG "SUN4V-DTLB: vaddr[%lx] ctx[%lx] "
8705 "pte[%lx] error[%lx]\n",
8706 @@ -2336,13 +2347,13 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
8707 fp = (unsigned long)sf->fp + STACK_BIAS;
8708 }
8709
8710 - printk(" [%016lx] %pS\n", pc, (void *) pc);
8711 + printk(" [%016lx] %pA\n", pc, (void *) pc);
8712 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
8713 if ((pc + 8UL) == (unsigned long) &return_to_handler) {
8714 int index = tsk->curr_ret_stack;
8715 if (tsk->ret_stack && index >= graph) {
8716 pc = tsk->ret_stack[index - graph].ret;
8717 - printk(" [%016lx] %pS\n", pc, (void *) pc);
8718 + printk(" [%016lx] %pA\n", pc, (void *) pc);
8719 graph++;
8720 }
8721 }
8722 @@ -2367,6 +2378,8 @@ static inline struct reg_window *kernel_stack_up(struct reg_window *rw)
8723 return (struct reg_window *) (fp + STACK_BIAS);
8724 }
8725
8726 +extern void gr_handle_kernel_exploit(void);
8727 +
8728 void die_if_kernel(char *str, struct pt_regs *regs)
8729 {
8730 static int die_counter;
8731 @@ -2395,7 +2408,7 @@ void die_if_kernel(char *str, struct pt_regs *regs)
8732 while (rw &&
8733 count++ < 30 &&
8734 kstack_valid(tp, (unsigned long) rw)) {
8735 - printk("Caller[%016lx]: %pS\n", rw->ins[7],
8736 + printk("Caller[%016lx]: %pA\n", rw->ins[7],
8737 (void *) rw->ins[7]);
8738
8739 rw = kernel_stack_up(rw);
8740 @@ -2408,8 +2421,10 @@ void die_if_kernel(char *str, struct pt_regs *regs)
8741 }
8742 user_instruction_dump ((unsigned int __user *) regs->tpc);
8743 }
8744 - if (regs->tstate & TSTATE_PRIV)
8745 + if (regs->tstate & TSTATE_PRIV) {
8746 + gr_handle_kernel_exploit();
8747 do_exit(SIGKILL);
8748 + }
8749 do_exit(SIGSEGV);
8750 }
8751 EXPORT_SYMBOL(die_if_kernel);
8752 diff --git a/arch/sparc/kernel/unaligned_64.c b/arch/sparc/kernel/unaligned_64.c
8753 index 8201c25e..072a2a7 100644
8754 --- a/arch/sparc/kernel/unaligned_64.c
8755 +++ b/arch/sparc/kernel/unaligned_64.c
8756 @@ -286,7 +286,7 @@ static void log_unaligned(struct pt_regs *regs)
8757 static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 5);
8758
8759 if (__ratelimit(&ratelimit)) {
8760 - printk("Kernel unaligned access at TPC[%lx] %pS\n",
8761 + printk("Kernel unaligned access at TPC[%lx] %pA\n",
8762 regs->tpc, (void *) regs->tpc);
8763 }
8764 }
8765 diff --git a/arch/sparc/kernel/us3_cpufreq.c b/arch/sparc/kernel/us3_cpufreq.c
8766 index eb1624b..55100de 100644
8767 --- a/arch/sparc/kernel/us3_cpufreq.c
8768 +++ b/arch/sparc/kernel/us3_cpufreq.c
8769 @@ -18,14 +18,12 @@
8770 #include <asm/head.h>
8771 #include <asm/timer.h>
8772
8773 -static struct cpufreq_driver *cpufreq_us3_driver;
8774 -
8775 struct us3_freq_percpu_info {
8776 struct cpufreq_frequency_table table[4];
8777 };
8778
8779 /* Indexed by cpu number. */
8780 -static struct us3_freq_percpu_info *us3_freq_table;
8781 +static struct us3_freq_percpu_info us3_freq_table[NR_CPUS];
8782
8783 /* UltraSPARC-III has three dividers: 1, 2, and 32. These are controlled
8784 * in the Safari config register.
8785 @@ -191,12 +189,25 @@ static int __init us3_freq_cpu_init(struct cpufreq_policy *policy)
8786
8787 static int us3_freq_cpu_exit(struct cpufreq_policy *policy)
8788 {
8789 - if (cpufreq_us3_driver)
8790 - us3_set_cpu_divider_index(policy->cpu, 0);
8791 + us3_set_cpu_divider_index(policy->cpu, 0);
8792
8793 return 0;
8794 }
8795
8796 +static int __init us3_freq_init(void);
8797 +static void __exit us3_freq_exit(void);
8798 +
8799 +static struct cpufreq_driver cpufreq_us3_driver = {
8800 + .init = us3_freq_cpu_init,
8801 + .verify = us3_freq_verify,
8802 + .target = us3_freq_target,
8803 + .get = us3_freq_get,
8804 + .exit = us3_freq_cpu_exit,
8805 + .owner = THIS_MODULE,
8806 + .name = "UltraSPARC-III",
8807 +
8808 +};
8809 +
8810 static int __init us3_freq_init(void)
8811 {
8812 unsigned long manuf, impl, ver;
8813 @@ -213,57 +224,15 @@ static int __init us3_freq_init(void)
8814 (impl == CHEETAH_IMPL ||
8815 impl == CHEETAH_PLUS_IMPL ||
8816 impl == JAGUAR_IMPL ||
8817 - impl == PANTHER_IMPL)) {
8818 - struct cpufreq_driver *driver;
8819 -
8820 - ret = -ENOMEM;
8821 - driver = kzalloc(sizeof(struct cpufreq_driver), GFP_KERNEL);
8822 - if (!driver)
8823 - goto err_out;
8824 -
8825 - us3_freq_table = kzalloc(
8826 - (NR_CPUS * sizeof(struct us3_freq_percpu_info)),
8827 - GFP_KERNEL);
8828 - if (!us3_freq_table)
8829 - goto err_out;
8830 -
8831 - driver->init = us3_freq_cpu_init;
8832 - driver->verify = us3_freq_verify;
8833 - driver->target = us3_freq_target;
8834 - driver->get = us3_freq_get;
8835 - driver->exit = us3_freq_cpu_exit;
8836 - driver->owner = THIS_MODULE,
8837 - strcpy(driver->name, "UltraSPARC-III");
8838 -
8839 - cpufreq_us3_driver = driver;
8840 - ret = cpufreq_register_driver(driver);
8841 - if (ret)
8842 - goto err_out;
8843 -
8844 - return 0;
8845 -
8846 -err_out:
8847 - if (driver) {
8848 - kfree(driver);
8849 - cpufreq_us3_driver = NULL;
8850 - }
8851 - kfree(us3_freq_table);
8852 - us3_freq_table = NULL;
8853 - return ret;
8854 - }
8855 + impl == PANTHER_IMPL))
8856 + return cpufreq_register_driver(&cpufreq_us3_driver);
8857
8858 return -ENODEV;
8859 }
8860
8861 static void __exit us3_freq_exit(void)
8862 {
8863 - if (cpufreq_us3_driver) {
8864 - cpufreq_unregister_driver(cpufreq_us3_driver);
8865 - kfree(cpufreq_us3_driver);
8866 - cpufreq_us3_driver = NULL;
8867 - kfree(us3_freq_table);
8868 - us3_freq_table = NULL;
8869 - }
8870 + cpufreq_unregister_driver(&cpufreq_us3_driver);
8871 }
8872
8873 MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
8874 diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile
8875 index 8410065f2..4fd4ca22 100644
8876 --- a/arch/sparc/lib/Makefile
8877 +++ b/arch/sparc/lib/Makefile
8878 @@ -2,7 +2,7 @@
8879 #
8880
8881 asflags-y := -ansi -DST_DIV0=0x02
8882 -ccflags-y := -Werror
8883 +#ccflags-y := -Werror
8884
8885 lib-$(CONFIG_SPARC32) += ashrdi3.o
8886 lib-$(CONFIG_SPARC32) += memcpy.o memset.o
8887 diff --git a/arch/sparc/lib/atomic_64.S b/arch/sparc/lib/atomic_64.S
8888 index 85c233d..68500e0 100644
8889 --- a/arch/sparc/lib/atomic_64.S
8890 +++ b/arch/sparc/lib/atomic_64.S
8891 @@ -17,7 +17,12 @@
8892 ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
8893 BACKOFF_SETUP(%o2)
8894 1: lduw [%o1], %g1
8895 - add %g1, %o0, %g7
8896 + addcc %g1, %o0, %g7
8897 +
8898 +#ifdef CONFIG_PAX_REFCOUNT
8899 + tvs %icc, 6
8900 +#endif
8901 +
8902 cas [%o1], %g1, %g7
8903 cmp %g1, %g7
8904 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
8905 @@ -27,10 +32,28 @@ ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
8906 2: BACKOFF_SPIN(%o2, %o3, 1b)
8907 ENDPROC(atomic_add)
8908
8909 +ENTRY(atomic_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
8910 + BACKOFF_SETUP(%o2)
8911 +1: lduw [%o1], %g1
8912 + add %g1, %o0, %g7
8913 + cas [%o1], %g1, %g7
8914 + cmp %g1, %g7
8915 + bne,pn %icc, 2f
8916 + nop
8917 + retl
8918 + nop
8919 +2: BACKOFF_SPIN(%o2, %o3, 1b)
8920 +ENDPROC(atomic_add_unchecked)
8921 +
8922 ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
8923 BACKOFF_SETUP(%o2)
8924 1: lduw [%o1], %g1
8925 - sub %g1, %o0, %g7
8926 + subcc %g1, %o0, %g7
8927 +
8928 +#ifdef CONFIG_PAX_REFCOUNT
8929 + tvs %icc, 6
8930 +#endif
8931 +
8932 cas [%o1], %g1, %g7
8933 cmp %g1, %g7
8934 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
8935 @@ -40,10 +63,28 @@ ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
8936 2: BACKOFF_SPIN(%o2, %o3, 1b)
8937 ENDPROC(atomic_sub)
8938
8939 +ENTRY(atomic_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
8940 + BACKOFF_SETUP(%o2)
8941 +1: lduw [%o1], %g1
8942 + sub %g1, %o0, %g7
8943 + cas [%o1], %g1, %g7
8944 + cmp %g1, %g7
8945 + bne,pn %icc, 2f
8946 + nop
8947 + retl
8948 + nop
8949 +2: BACKOFF_SPIN(%o2, %o3, 1b)
8950 +ENDPROC(atomic_sub_unchecked)
8951 +
8952 ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
8953 BACKOFF_SETUP(%o2)
8954 1: lduw [%o1], %g1
8955 - add %g1, %o0, %g7
8956 + addcc %g1, %o0, %g7
8957 +
8958 +#ifdef CONFIG_PAX_REFCOUNT
8959 + tvs %icc, 6
8960 +#endif
8961 +
8962 cas [%o1], %g1, %g7
8963 cmp %g1, %g7
8964 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
8965 @@ -53,10 +94,29 @@ ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
8966 2: BACKOFF_SPIN(%o2, %o3, 1b)
8967 ENDPROC(atomic_add_ret)
8968
8969 +ENTRY(atomic_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
8970 + BACKOFF_SETUP(%o2)
8971 +1: lduw [%o1], %g1
8972 + addcc %g1, %o0, %g7
8973 + cas [%o1], %g1, %g7
8974 + cmp %g1, %g7
8975 + bne,pn %icc, 2f
8976 + add %g7, %o0, %g7
8977 + sra %g7, 0, %o0
8978 + retl
8979 + nop
8980 +2: BACKOFF_SPIN(%o2, %o3, 1b)
8981 +ENDPROC(atomic_add_ret_unchecked)
8982 +
8983 ENTRY(atomic_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
8984 BACKOFF_SETUP(%o2)
8985 1: lduw [%o1], %g1
8986 - sub %g1, %o0, %g7
8987 + subcc %g1, %o0, %g7
8988 +
8989 +#ifdef CONFIG_PAX_REFCOUNT
8990 + tvs %icc, 6
8991 +#endif
8992 +
8993 cas [%o1], %g1, %g7
8994 cmp %g1, %g7
8995 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
8996 @@ -69,7 +129,12 @@ ENDPROC(atomic_sub_ret)
8997 ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
8998 BACKOFF_SETUP(%o2)
8999 1: ldx [%o1], %g1
9000 - add %g1, %o0, %g7
9001 + addcc %g1, %o0, %g7
9002 +
9003 +#ifdef CONFIG_PAX_REFCOUNT
9004 + tvs %xcc, 6
9005 +#endif
9006 +
9007 casx [%o1], %g1, %g7
9008 cmp %g1, %g7
9009 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9010 @@ -79,10 +144,28 @@ ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
9011 2: BACKOFF_SPIN(%o2, %o3, 1b)
9012 ENDPROC(atomic64_add)
9013
9014 +ENTRY(atomic64_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
9015 + BACKOFF_SETUP(%o2)
9016 +1: ldx [%o1], %g1
9017 + addcc %g1, %o0, %g7
9018 + casx [%o1], %g1, %g7
9019 + cmp %g1, %g7
9020 + bne,pn %xcc, 2f
9021 + nop
9022 + retl
9023 + nop
9024 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9025 +ENDPROC(atomic64_add_unchecked)
9026 +
9027 ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
9028 BACKOFF_SETUP(%o2)
9029 1: ldx [%o1], %g1
9030 - sub %g1, %o0, %g7
9031 + subcc %g1, %o0, %g7
9032 +
9033 +#ifdef CONFIG_PAX_REFCOUNT
9034 + tvs %xcc, 6
9035 +#endif
9036 +
9037 casx [%o1], %g1, %g7
9038 cmp %g1, %g7
9039 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9040 @@ -92,10 +175,28 @@ ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
9041 2: BACKOFF_SPIN(%o2, %o3, 1b)
9042 ENDPROC(atomic64_sub)
9043
9044 +ENTRY(atomic64_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
9045 + BACKOFF_SETUP(%o2)
9046 +1: ldx [%o1], %g1
9047 + subcc %g1, %o0, %g7
9048 + casx [%o1], %g1, %g7
9049 + cmp %g1, %g7
9050 + bne,pn %xcc, 2f
9051 + nop
9052 + retl
9053 + nop
9054 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9055 +ENDPROC(atomic64_sub_unchecked)
9056 +
9057 ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
9058 BACKOFF_SETUP(%o2)
9059 1: ldx [%o1], %g1
9060 - add %g1, %o0, %g7
9061 + addcc %g1, %o0, %g7
9062 +
9063 +#ifdef CONFIG_PAX_REFCOUNT
9064 + tvs %xcc, 6
9065 +#endif
9066 +
9067 casx [%o1], %g1, %g7
9068 cmp %g1, %g7
9069 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9070 @@ -105,10 +206,29 @@ ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
9071 2: BACKOFF_SPIN(%o2, %o3, 1b)
9072 ENDPROC(atomic64_add_ret)
9073
9074 +ENTRY(atomic64_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
9075 + BACKOFF_SETUP(%o2)
9076 +1: ldx [%o1], %g1
9077 + addcc %g1, %o0, %g7
9078 + casx [%o1], %g1, %g7
9079 + cmp %g1, %g7
9080 + bne,pn %xcc, 2f
9081 + add %g7, %o0, %g7
9082 + mov %g7, %o0
9083 + retl
9084 + nop
9085 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9086 +ENDPROC(atomic64_add_ret_unchecked)
9087 +
9088 ENTRY(atomic64_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
9089 BACKOFF_SETUP(%o2)
9090 1: ldx [%o1], %g1
9091 - sub %g1, %o0, %g7
9092 + subcc %g1, %o0, %g7
9093 +
9094 +#ifdef CONFIG_PAX_REFCOUNT
9095 + tvs %xcc, 6
9096 +#endif
9097 +
9098 casx [%o1], %g1, %g7
9099 cmp %g1, %g7
9100 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9101 diff --git a/arch/sparc/lib/ksyms.c b/arch/sparc/lib/ksyms.c
9102 index 0c4e35e..745d3e4 100644
9103 --- a/arch/sparc/lib/ksyms.c
9104 +++ b/arch/sparc/lib/ksyms.c
9105 @@ -109,12 +109,18 @@ EXPORT_SYMBOL(__downgrade_write);
9106
9107 /* Atomic counter implementation. */
9108 EXPORT_SYMBOL(atomic_add);
9109 +EXPORT_SYMBOL(atomic_add_unchecked);
9110 EXPORT_SYMBOL(atomic_add_ret);
9111 +EXPORT_SYMBOL(atomic_add_ret_unchecked);
9112 EXPORT_SYMBOL(atomic_sub);
9113 +EXPORT_SYMBOL(atomic_sub_unchecked);
9114 EXPORT_SYMBOL(atomic_sub_ret);
9115 EXPORT_SYMBOL(atomic64_add);
9116 +EXPORT_SYMBOL(atomic64_add_unchecked);
9117 EXPORT_SYMBOL(atomic64_add_ret);
9118 +EXPORT_SYMBOL(atomic64_add_ret_unchecked);
9119 EXPORT_SYMBOL(atomic64_sub);
9120 +EXPORT_SYMBOL(atomic64_sub_unchecked);
9121 EXPORT_SYMBOL(atomic64_sub_ret);
9122 EXPORT_SYMBOL(atomic64_dec_if_positive);
9123
9124 diff --git a/arch/sparc/mm/Makefile b/arch/sparc/mm/Makefile
9125 index 30c3ecc..736f015 100644
9126 --- a/arch/sparc/mm/Makefile
9127 +++ b/arch/sparc/mm/Makefile
9128 @@ -2,7 +2,7 @@
9129 #
9130
9131 asflags-y := -ansi
9132 -ccflags-y := -Werror
9133 +#ccflags-y := -Werror
9134
9135 obj-$(CONFIG_SPARC64) += ultra.o tlb.o tsb.o gup.o
9136 obj-y += fault_$(BITS).o
9137 diff --git a/arch/sparc/mm/fault_32.c b/arch/sparc/mm/fault_32.c
9138 index e98bfda..ea8d221 100644
9139 --- a/arch/sparc/mm/fault_32.c
9140 +++ b/arch/sparc/mm/fault_32.c
9141 @@ -21,6 +21,9 @@
9142 #include <linux/perf_event.h>
9143 #include <linux/interrupt.h>
9144 #include <linux/kdebug.h>
9145 +#include <linux/slab.h>
9146 +#include <linux/pagemap.h>
9147 +#include <linux/compiler.h>
9148
9149 #include <asm/page.h>
9150 #include <asm/pgtable.h>
9151 @@ -159,6 +162,277 @@ static unsigned long compute_si_addr(struct pt_regs *regs, int text_fault)
9152 return safe_compute_effective_address(regs, insn);
9153 }
9154
9155 +#ifdef CONFIG_PAX_PAGEEXEC
9156 +#ifdef CONFIG_PAX_DLRESOLVE
9157 +static void pax_emuplt_close(struct vm_area_struct *vma)
9158 +{
9159 + vma->vm_mm->call_dl_resolve = 0UL;
9160 +}
9161 +
9162 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
9163 +{
9164 + unsigned int *kaddr;
9165 +
9166 + vmf->page = alloc_page(GFP_HIGHUSER);
9167 + if (!vmf->page)
9168 + return VM_FAULT_OOM;
9169 +
9170 + kaddr = kmap(vmf->page);
9171 + memset(kaddr, 0, PAGE_SIZE);
9172 + kaddr[0] = 0x9DE3BFA8U; /* save */
9173 + flush_dcache_page(vmf->page);
9174 + kunmap(vmf->page);
9175 + return VM_FAULT_MAJOR;
9176 +}
9177 +
9178 +static const struct vm_operations_struct pax_vm_ops = {
9179 + .close = pax_emuplt_close,
9180 + .fault = pax_emuplt_fault
9181 +};
9182 +
9183 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
9184 +{
9185 + int ret;
9186 +
9187 + INIT_LIST_HEAD(&vma->anon_vma_chain);
9188 + vma->vm_mm = current->mm;
9189 + vma->vm_start = addr;
9190 + vma->vm_end = addr + PAGE_SIZE;
9191 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
9192 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
9193 + vma->vm_ops = &pax_vm_ops;
9194 +
9195 + ret = insert_vm_struct(current->mm, vma);
9196 + if (ret)
9197 + return ret;
9198 +
9199 + ++current->mm->total_vm;
9200 + return 0;
9201 +}
9202 +#endif
9203 +
9204 +/*
9205 + * PaX: decide what to do with offenders (regs->pc = fault address)
9206 + *
9207 + * returns 1 when task should be killed
9208 + * 2 when patched PLT trampoline was detected
9209 + * 3 when unpatched PLT trampoline was detected
9210 + */
9211 +static int pax_handle_fetch_fault(struct pt_regs *regs)
9212 +{
9213 +
9214 +#ifdef CONFIG_PAX_EMUPLT
9215 + int err;
9216 +
9217 + do { /* PaX: patched PLT emulation #1 */
9218 + unsigned int sethi1, sethi2, jmpl;
9219 +
9220 + err = get_user(sethi1, (unsigned int *)regs->pc);
9221 + err |= get_user(sethi2, (unsigned int *)(regs->pc+4));
9222 + err |= get_user(jmpl, (unsigned int *)(regs->pc+8));
9223 +
9224 + if (err)
9225 + break;
9226 +
9227 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
9228 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
9229 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
9230 + {
9231 + unsigned int addr;
9232 +
9233 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
9234 + addr = regs->u_regs[UREG_G1];
9235 + addr += (((jmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9236 + regs->pc = addr;
9237 + regs->npc = addr+4;
9238 + return 2;
9239 + }
9240 + } while (0);
9241 +
9242 + do { /* PaX: patched PLT emulation #2 */
9243 + unsigned int ba;
9244 +
9245 + err = get_user(ba, (unsigned int *)regs->pc);
9246 +
9247 + if (err)
9248 + break;
9249 +
9250 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
9251 + unsigned int addr;
9252 +
9253 + if ((ba & 0xFFC00000U) == 0x30800000U)
9254 + addr = regs->pc + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
9255 + else
9256 + addr = regs->pc + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9257 + regs->pc = addr;
9258 + regs->npc = addr+4;
9259 + return 2;
9260 + }
9261 + } while (0);
9262 +
9263 + do { /* PaX: patched PLT emulation #3 */
9264 + unsigned int sethi, bajmpl, nop;
9265 +
9266 + err = get_user(sethi, (unsigned int *)regs->pc);
9267 + err |= get_user(bajmpl, (unsigned int *)(regs->pc+4));
9268 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
9269 +
9270 + if (err)
9271 + break;
9272 +
9273 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9274 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
9275 + nop == 0x01000000U)
9276 + {
9277 + unsigned int addr;
9278 +
9279 + addr = (sethi & 0x003FFFFFU) << 10;
9280 + regs->u_regs[UREG_G1] = addr;
9281 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
9282 + addr += (((bajmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9283 + else
9284 + addr = regs->pc + ((((bajmpl | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9285 + regs->pc = addr;
9286 + regs->npc = addr+4;
9287 + return 2;
9288 + }
9289 + } while (0);
9290 +
9291 + do { /* PaX: unpatched PLT emulation step 1 */
9292 + unsigned int sethi, ba, nop;
9293 +
9294 + err = get_user(sethi, (unsigned int *)regs->pc);
9295 + err |= get_user(ba, (unsigned int *)(regs->pc+4));
9296 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
9297 +
9298 + if (err)
9299 + break;
9300 +
9301 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9302 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
9303 + nop == 0x01000000U)
9304 + {
9305 + unsigned int addr, save, call;
9306 +
9307 + if ((ba & 0xFFC00000U) == 0x30800000U)
9308 + addr = regs->pc + 4 + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
9309 + else
9310 + addr = regs->pc + 4 + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9311 +
9312 + err = get_user(save, (unsigned int *)addr);
9313 + err |= get_user(call, (unsigned int *)(addr+4));
9314 + err |= get_user(nop, (unsigned int *)(addr+8));
9315 + if (err)
9316 + break;
9317 +
9318 +#ifdef CONFIG_PAX_DLRESOLVE
9319 + if (save == 0x9DE3BFA8U &&
9320 + (call & 0xC0000000U) == 0x40000000U &&
9321 + nop == 0x01000000U)
9322 + {
9323 + struct vm_area_struct *vma;
9324 + unsigned long call_dl_resolve;
9325 +
9326 + down_read(&current->mm->mmap_sem);
9327 + call_dl_resolve = current->mm->call_dl_resolve;
9328 + up_read(&current->mm->mmap_sem);
9329 + if (likely(call_dl_resolve))
9330 + goto emulate;
9331 +
9332 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
9333 +
9334 + down_write(&current->mm->mmap_sem);
9335 + if (current->mm->call_dl_resolve) {
9336 + call_dl_resolve = current->mm->call_dl_resolve;
9337 + up_write(&current->mm->mmap_sem);
9338 + if (vma)
9339 + kmem_cache_free(vm_area_cachep, vma);
9340 + goto emulate;
9341 + }
9342 +
9343 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
9344 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
9345 + up_write(&current->mm->mmap_sem);
9346 + if (vma)
9347 + kmem_cache_free(vm_area_cachep, vma);
9348 + return 1;
9349 + }
9350 +
9351 + if (pax_insert_vma(vma, call_dl_resolve)) {
9352 + up_write(&current->mm->mmap_sem);
9353 + kmem_cache_free(vm_area_cachep, vma);
9354 + return 1;
9355 + }
9356 +
9357 + current->mm->call_dl_resolve = call_dl_resolve;
9358 + up_write(&current->mm->mmap_sem);
9359 +
9360 +emulate:
9361 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9362 + regs->pc = call_dl_resolve;
9363 + regs->npc = addr+4;
9364 + return 3;
9365 + }
9366 +#endif
9367 +
9368 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
9369 + if ((save & 0xFFC00000U) == 0x05000000U &&
9370 + (call & 0xFFFFE000U) == 0x85C0A000U &&
9371 + nop == 0x01000000U)
9372 + {
9373 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9374 + regs->u_regs[UREG_G2] = addr + 4;
9375 + addr = (save & 0x003FFFFFU) << 10;
9376 + addr += (((call | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9377 + regs->pc = addr;
9378 + regs->npc = addr+4;
9379 + return 3;
9380 + }
9381 + }
9382 + } while (0);
9383 +
9384 + do { /* PaX: unpatched PLT emulation step 2 */
9385 + unsigned int save, call, nop;
9386 +
9387 + err = get_user(save, (unsigned int *)(regs->pc-4));
9388 + err |= get_user(call, (unsigned int *)regs->pc);
9389 + err |= get_user(nop, (unsigned int *)(regs->pc+4));
9390 + if (err)
9391 + break;
9392 +
9393 + if (save == 0x9DE3BFA8U &&
9394 + (call & 0xC0000000U) == 0x40000000U &&
9395 + nop == 0x01000000U)
9396 + {
9397 + unsigned int dl_resolve = regs->pc + ((((call | 0xC0000000U) ^ 0x20000000U) + 0x20000000U) << 2);
9398 +
9399 + regs->u_regs[UREG_RETPC] = regs->pc;
9400 + regs->pc = dl_resolve;
9401 + regs->npc = dl_resolve+4;
9402 + return 3;
9403 + }
9404 + } while (0);
9405 +#endif
9406 +
9407 + return 1;
9408 +}
9409 +
9410 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
9411 +{
9412 + unsigned long i;
9413 +
9414 + printk(KERN_ERR "PAX: bytes at PC: ");
9415 + for (i = 0; i < 8; i++) {
9416 + unsigned int c;
9417 + if (get_user(c, (unsigned int *)pc+i))
9418 + printk(KERN_CONT "???????? ");
9419 + else
9420 + printk(KERN_CONT "%08x ", c);
9421 + }
9422 + printk("\n");
9423 +}
9424 +#endif
9425 +
9426 static noinline void do_fault_siginfo(int code, int sig, struct pt_regs *regs,
9427 int text_fault)
9428 {
9429 @@ -230,6 +504,24 @@ good_area:
9430 if (!(vma->vm_flags & VM_WRITE))
9431 goto bad_area;
9432 } else {
9433 +
9434 +#ifdef CONFIG_PAX_PAGEEXEC
9435 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && text_fault && !(vma->vm_flags & VM_EXEC)) {
9436 + up_read(&mm->mmap_sem);
9437 + switch (pax_handle_fetch_fault(regs)) {
9438 +
9439 +#ifdef CONFIG_PAX_EMUPLT
9440 + case 2:
9441 + case 3:
9442 + return;
9443 +#endif
9444 +
9445 + }
9446 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->u_regs[UREG_FP]);
9447 + do_group_exit(SIGKILL);
9448 + }
9449 +#endif
9450 +
9451 /* Allow reads even for write-only mappings */
9452 if (!(vma->vm_flags & (VM_READ | VM_EXEC)))
9453 goto bad_area;
9454 diff --git a/arch/sparc/mm/fault_64.c b/arch/sparc/mm/fault_64.c
9455 index 5062ff3..e0b75f3 100644
9456 --- a/arch/sparc/mm/fault_64.c
9457 +++ b/arch/sparc/mm/fault_64.c
9458 @@ -21,6 +21,9 @@
9459 #include <linux/kprobes.h>
9460 #include <linux/kdebug.h>
9461 #include <linux/percpu.h>
9462 +#include <linux/slab.h>
9463 +#include <linux/pagemap.h>
9464 +#include <linux/compiler.h>
9465
9466 #include <asm/page.h>
9467 #include <asm/pgtable.h>
9468 @@ -74,7 +77,7 @@ static void __kprobes bad_kernel_pc(struct pt_regs *regs, unsigned long vaddr)
9469 printk(KERN_CRIT "OOPS: Bogus kernel PC [%016lx] in fault handler\n",
9470 regs->tpc);
9471 printk(KERN_CRIT "OOPS: RPC [%016lx]\n", regs->u_regs[15]);
9472 - printk("OOPS: RPC <%pS>\n", (void *) regs->u_regs[15]);
9473 + printk("OOPS: RPC <%pA>\n", (void *) regs->u_regs[15]);
9474 printk(KERN_CRIT "OOPS: Fault was to vaddr[%lx]\n", vaddr);
9475 dump_stack();
9476 unhandled_fault(regs->tpc, current, regs);
9477 @@ -270,6 +273,466 @@ static void noinline __kprobes bogus_32bit_fault_address(struct pt_regs *regs,
9478 show_regs(regs);
9479 }
9480
9481 +#ifdef CONFIG_PAX_PAGEEXEC
9482 +#ifdef CONFIG_PAX_DLRESOLVE
9483 +static void pax_emuplt_close(struct vm_area_struct *vma)
9484 +{
9485 + vma->vm_mm->call_dl_resolve = 0UL;
9486 +}
9487 +
9488 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
9489 +{
9490 + unsigned int *kaddr;
9491 +
9492 + vmf->page = alloc_page(GFP_HIGHUSER);
9493 + if (!vmf->page)
9494 + return VM_FAULT_OOM;
9495 +
9496 + kaddr = kmap(vmf->page);
9497 + memset(kaddr, 0, PAGE_SIZE);
9498 + kaddr[0] = 0x9DE3BFA8U; /* save */
9499 + flush_dcache_page(vmf->page);
9500 + kunmap(vmf->page);
9501 + return VM_FAULT_MAJOR;
9502 +}
9503 +
9504 +static const struct vm_operations_struct pax_vm_ops = {
9505 + .close = pax_emuplt_close,
9506 + .fault = pax_emuplt_fault
9507 +};
9508 +
9509 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
9510 +{
9511 + int ret;
9512 +
9513 + INIT_LIST_HEAD(&vma->anon_vma_chain);
9514 + vma->vm_mm = current->mm;
9515 + vma->vm_start = addr;
9516 + vma->vm_end = addr + PAGE_SIZE;
9517 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
9518 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
9519 + vma->vm_ops = &pax_vm_ops;
9520 +
9521 + ret = insert_vm_struct(current->mm, vma);
9522 + if (ret)
9523 + return ret;
9524 +
9525 + ++current->mm->total_vm;
9526 + return 0;
9527 +}
9528 +#endif
9529 +
9530 +/*
9531 + * PaX: decide what to do with offenders (regs->tpc = fault address)
9532 + *
9533 + * returns 1 when task should be killed
9534 + * 2 when patched PLT trampoline was detected
9535 + * 3 when unpatched PLT trampoline was detected
9536 + */
9537 +static int pax_handle_fetch_fault(struct pt_regs *regs)
9538 +{
9539 +
9540 +#ifdef CONFIG_PAX_EMUPLT
9541 + int err;
9542 +
9543 + do { /* PaX: patched PLT emulation #1 */
9544 + unsigned int sethi1, sethi2, jmpl;
9545 +
9546 + err = get_user(sethi1, (unsigned int *)regs->tpc);
9547 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+4));
9548 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+8));
9549 +
9550 + if (err)
9551 + break;
9552 +
9553 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
9554 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
9555 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
9556 + {
9557 + unsigned long addr;
9558 +
9559 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
9560 + addr = regs->u_regs[UREG_G1];
9561 + addr += (((jmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
9562 +
9563 + if (test_thread_flag(TIF_32BIT))
9564 + addr &= 0xFFFFFFFFUL;
9565 +
9566 + regs->tpc = addr;
9567 + regs->tnpc = addr+4;
9568 + return 2;
9569 + }
9570 + } while (0);
9571 +
9572 + do { /* PaX: patched PLT emulation #2 */
9573 + unsigned int ba;
9574 +
9575 + err = get_user(ba, (unsigned int *)regs->tpc);
9576 +
9577 + if (err)
9578 + break;
9579 +
9580 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
9581 + unsigned long addr;
9582 +
9583 + if ((ba & 0xFFC00000U) == 0x30800000U)
9584 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
9585 + else
9586 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9587 +
9588 + if (test_thread_flag(TIF_32BIT))
9589 + addr &= 0xFFFFFFFFUL;
9590 +
9591 + regs->tpc = addr;
9592 + regs->tnpc = addr+4;
9593 + return 2;
9594 + }
9595 + } while (0);
9596 +
9597 + do { /* PaX: patched PLT emulation #3 */
9598 + unsigned int sethi, bajmpl, nop;
9599 +
9600 + err = get_user(sethi, (unsigned int *)regs->tpc);
9601 + err |= get_user(bajmpl, (unsigned int *)(regs->tpc+4));
9602 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
9603 +
9604 + if (err)
9605 + break;
9606 +
9607 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9608 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
9609 + nop == 0x01000000U)
9610 + {
9611 + unsigned long addr;
9612 +
9613 + addr = (sethi & 0x003FFFFFU) << 10;
9614 + regs->u_regs[UREG_G1] = addr;
9615 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
9616 + addr += (((bajmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
9617 + else
9618 + addr = regs->tpc + ((((bajmpl | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9619 +
9620 + if (test_thread_flag(TIF_32BIT))
9621 + addr &= 0xFFFFFFFFUL;
9622 +
9623 + regs->tpc = addr;
9624 + regs->tnpc = addr+4;
9625 + return 2;
9626 + }
9627 + } while (0);
9628 +
9629 + do { /* PaX: patched PLT emulation #4 */
9630 + unsigned int sethi, mov1, call, mov2;
9631 +
9632 + err = get_user(sethi, (unsigned int *)regs->tpc);
9633 + err |= get_user(mov1, (unsigned int *)(regs->tpc+4));
9634 + err |= get_user(call, (unsigned int *)(regs->tpc+8));
9635 + err |= get_user(mov2, (unsigned int *)(regs->tpc+12));
9636 +
9637 + if (err)
9638 + break;
9639 +
9640 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9641 + mov1 == 0x8210000FU &&
9642 + (call & 0xC0000000U) == 0x40000000U &&
9643 + mov2 == 0x9E100001U)
9644 + {
9645 + unsigned long addr;
9646 +
9647 + regs->u_regs[UREG_G1] = regs->u_regs[UREG_RETPC];
9648 + addr = regs->tpc + 4 + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
9649 +
9650 + if (test_thread_flag(TIF_32BIT))
9651 + addr &= 0xFFFFFFFFUL;
9652 +
9653 + regs->tpc = addr;
9654 + regs->tnpc = addr+4;
9655 + return 2;
9656 + }
9657 + } while (0);
9658 +
9659 + do { /* PaX: patched PLT emulation #5 */
9660 + unsigned int sethi, sethi1, sethi2, or1, or2, sllx, jmpl, nop;
9661 +
9662 + err = get_user(sethi, (unsigned int *)regs->tpc);
9663 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
9664 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
9665 + err |= get_user(or1, (unsigned int *)(regs->tpc+12));
9666 + err |= get_user(or2, (unsigned int *)(regs->tpc+16));
9667 + err |= get_user(sllx, (unsigned int *)(regs->tpc+20));
9668 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+24));
9669 + err |= get_user(nop, (unsigned int *)(regs->tpc+28));
9670 +
9671 + if (err)
9672 + break;
9673 +
9674 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9675 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
9676 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
9677 + (or1 & 0xFFFFE000U) == 0x82106000U &&
9678 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
9679 + sllx == 0x83287020U &&
9680 + jmpl == 0x81C04005U &&
9681 + nop == 0x01000000U)
9682 + {
9683 + unsigned long addr;
9684 +
9685 + regs->u_regs[UREG_G1] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
9686 + regs->u_regs[UREG_G1] <<= 32;
9687 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
9688 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
9689 + regs->tpc = addr;
9690 + regs->tnpc = addr+4;
9691 + return 2;
9692 + }
9693 + } while (0);
9694 +
9695 + do { /* PaX: patched PLT emulation #6 */
9696 + unsigned int sethi, sethi1, sethi2, sllx, or, jmpl, nop;
9697 +
9698 + err = get_user(sethi, (unsigned int *)regs->tpc);
9699 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
9700 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
9701 + err |= get_user(sllx, (unsigned int *)(regs->tpc+12));
9702 + err |= get_user(or, (unsigned int *)(regs->tpc+16));
9703 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+20));
9704 + err |= get_user(nop, (unsigned int *)(regs->tpc+24));
9705 +
9706 + if (err)
9707 + break;
9708 +
9709 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9710 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
9711 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
9712 + sllx == 0x83287020U &&
9713 + (or & 0xFFFFE000U) == 0x8A116000U &&
9714 + jmpl == 0x81C04005U &&
9715 + nop == 0x01000000U)
9716 + {
9717 + unsigned long addr;
9718 +
9719 + regs->u_regs[UREG_G1] = (sethi1 & 0x003FFFFFU) << 10;
9720 + regs->u_regs[UREG_G1] <<= 32;
9721 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or & 0x3FFU);
9722 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
9723 + regs->tpc = addr;
9724 + regs->tnpc = addr+4;
9725 + return 2;
9726 + }
9727 + } while (0);
9728 +
9729 + do { /* PaX: unpatched PLT emulation step 1 */
9730 + unsigned int sethi, ba, nop;
9731 +
9732 + err = get_user(sethi, (unsigned int *)regs->tpc);
9733 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
9734 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
9735 +
9736 + if (err)
9737 + break;
9738 +
9739 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9740 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
9741 + nop == 0x01000000U)
9742 + {
9743 + unsigned long addr;
9744 + unsigned int save, call;
9745 + unsigned int sethi1, sethi2, or1, or2, sllx, add, jmpl;
9746 +
9747 + if ((ba & 0xFFC00000U) == 0x30800000U)
9748 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
9749 + else
9750 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9751 +
9752 + if (test_thread_flag(TIF_32BIT))
9753 + addr &= 0xFFFFFFFFUL;
9754 +
9755 + err = get_user(save, (unsigned int *)addr);
9756 + err |= get_user(call, (unsigned int *)(addr+4));
9757 + err |= get_user(nop, (unsigned int *)(addr+8));
9758 + if (err)
9759 + break;
9760 +
9761 +#ifdef CONFIG_PAX_DLRESOLVE
9762 + if (save == 0x9DE3BFA8U &&
9763 + (call & 0xC0000000U) == 0x40000000U &&
9764 + nop == 0x01000000U)
9765 + {
9766 + struct vm_area_struct *vma;
9767 + unsigned long call_dl_resolve;
9768 +
9769 + down_read(&current->mm->mmap_sem);
9770 + call_dl_resolve = current->mm->call_dl_resolve;
9771 + up_read(&current->mm->mmap_sem);
9772 + if (likely(call_dl_resolve))
9773 + goto emulate;
9774 +
9775 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
9776 +
9777 + down_write(&current->mm->mmap_sem);
9778 + if (current->mm->call_dl_resolve) {
9779 + call_dl_resolve = current->mm->call_dl_resolve;
9780 + up_write(&current->mm->mmap_sem);
9781 + if (vma)
9782 + kmem_cache_free(vm_area_cachep, vma);
9783 + goto emulate;
9784 + }
9785 +
9786 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
9787 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
9788 + up_write(&current->mm->mmap_sem);
9789 + if (vma)
9790 + kmem_cache_free(vm_area_cachep, vma);
9791 + return 1;
9792 + }
9793 +
9794 + if (pax_insert_vma(vma, call_dl_resolve)) {
9795 + up_write(&current->mm->mmap_sem);
9796 + kmem_cache_free(vm_area_cachep, vma);
9797 + return 1;
9798 + }
9799 +
9800 + current->mm->call_dl_resolve = call_dl_resolve;
9801 + up_write(&current->mm->mmap_sem);
9802 +
9803 +emulate:
9804 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9805 + regs->tpc = call_dl_resolve;
9806 + regs->tnpc = addr+4;
9807 + return 3;
9808 + }
9809 +#endif
9810 +
9811 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
9812 + if ((save & 0xFFC00000U) == 0x05000000U &&
9813 + (call & 0xFFFFE000U) == 0x85C0A000U &&
9814 + nop == 0x01000000U)
9815 + {
9816 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9817 + regs->u_regs[UREG_G2] = addr + 4;
9818 + addr = (save & 0x003FFFFFU) << 10;
9819 + addr += (((call | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
9820 +
9821 + if (test_thread_flag(TIF_32BIT))
9822 + addr &= 0xFFFFFFFFUL;
9823 +
9824 + regs->tpc = addr;
9825 + regs->tnpc = addr+4;
9826 + return 3;
9827 + }
9828 +
9829 + /* PaX: 64-bit PLT stub */
9830 + err = get_user(sethi1, (unsigned int *)addr);
9831 + err |= get_user(sethi2, (unsigned int *)(addr+4));
9832 + err |= get_user(or1, (unsigned int *)(addr+8));
9833 + err |= get_user(or2, (unsigned int *)(addr+12));
9834 + err |= get_user(sllx, (unsigned int *)(addr+16));
9835 + err |= get_user(add, (unsigned int *)(addr+20));
9836 + err |= get_user(jmpl, (unsigned int *)(addr+24));
9837 + err |= get_user(nop, (unsigned int *)(addr+28));
9838 + if (err)
9839 + break;
9840 +
9841 + if ((sethi1 & 0xFFC00000U) == 0x09000000U &&
9842 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
9843 + (or1 & 0xFFFFE000U) == 0x88112000U &&
9844 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
9845 + sllx == 0x89293020U &&
9846 + add == 0x8A010005U &&
9847 + jmpl == 0x89C14000U &&
9848 + nop == 0x01000000U)
9849 + {
9850 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9851 + regs->u_regs[UREG_G4] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
9852 + regs->u_regs[UREG_G4] <<= 32;
9853 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
9854 + regs->u_regs[UREG_G5] += regs->u_regs[UREG_G4];
9855 + regs->u_regs[UREG_G4] = addr + 24;
9856 + addr = regs->u_regs[UREG_G5];
9857 + regs->tpc = addr;
9858 + regs->tnpc = addr+4;
9859 + return 3;
9860 + }
9861 + }
9862 + } while (0);
9863 +
9864 +#ifdef CONFIG_PAX_DLRESOLVE
9865 + do { /* PaX: unpatched PLT emulation step 2 */
9866 + unsigned int save, call, nop;
9867 +
9868 + err = get_user(save, (unsigned int *)(regs->tpc-4));
9869 + err |= get_user(call, (unsigned int *)regs->tpc);
9870 + err |= get_user(nop, (unsigned int *)(regs->tpc+4));
9871 + if (err)
9872 + break;
9873 +
9874 + if (save == 0x9DE3BFA8U &&
9875 + (call & 0xC0000000U) == 0x40000000U &&
9876 + nop == 0x01000000U)
9877 + {
9878 + unsigned long dl_resolve = regs->tpc + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
9879 +
9880 + if (test_thread_flag(TIF_32BIT))
9881 + dl_resolve &= 0xFFFFFFFFUL;
9882 +
9883 + regs->u_regs[UREG_RETPC] = regs->tpc;
9884 + regs->tpc = dl_resolve;
9885 + regs->tnpc = dl_resolve+4;
9886 + return 3;
9887 + }
9888 + } while (0);
9889 +#endif
9890 +
9891 + do { /* PaX: patched PLT emulation #7, must be AFTER the unpatched PLT emulation */
9892 + unsigned int sethi, ba, nop;
9893 +
9894 + err = get_user(sethi, (unsigned int *)regs->tpc);
9895 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
9896 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
9897 +
9898 + if (err)
9899 + break;
9900 +
9901 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9902 + (ba & 0xFFF00000U) == 0x30600000U &&
9903 + nop == 0x01000000U)
9904 + {
9905 + unsigned long addr;
9906 +
9907 + addr = (sethi & 0x003FFFFFU) << 10;
9908 + regs->u_regs[UREG_G1] = addr;
9909 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9910 +
9911 + if (test_thread_flag(TIF_32BIT))
9912 + addr &= 0xFFFFFFFFUL;
9913 +
9914 + regs->tpc = addr;
9915 + regs->tnpc = addr+4;
9916 + return 2;
9917 + }
9918 + } while (0);
9919 +
9920 +#endif
9921 +
9922 + return 1;
9923 +}
9924 +
9925 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
9926 +{
9927 + unsigned long i;
9928 +
9929 + printk(KERN_ERR "PAX: bytes at PC: ");
9930 + for (i = 0; i < 8; i++) {
9931 + unsigned int c;
9932 + if (get_user(c, (unsigned int *)pc+i))
9933 + printk(KERN_CONT "???????? ");
9934 + else
9935 + printk(KERN_CONT "%08x ", c);
9936 + }
9937 + printk("\n");
9938 +}
9939 +#endif
9940 +
9941 asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)
9942 {
9943 struct mm_struct *mm = current->mm;
9944 @@ -341,6 +804,29 @@ retry:
9945 if (!vma)
9946 goto bad_area;
9947
9948 +#ifdef CONFIG_PAX_PAGEEXEC
9949 + /* PaX: detect ITLB misses on non-exec pages */
9950 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && vma->vm_start <= address &&
9951 + !(vma->vm_flags & VM_EXEC) && (fault_code & FAULT_CODE_ITLB))
9952 + {
9953 + if (address != regs->tpc)
9954 + goto good_area;
9955 +
9956 + up_read(&mm->mmap_sem);
9957 + switch (pax_handle_fetch_fault(regs)) {
9958 +
9959 +#ifdef CONFIG_PAX_EMUPLT
9960 + case 2:
9961 + case 3:
9962 + return;
9963 +#endif
9964 +
9965 + }
9966 + pax_report_fault(regs, (void *)regs->tpc, (void *)(regs->u_regs[UREG_FP] + STACK_BIAS));
9967 + do_group_exit(SIGKILL);
9968 + }
9969 +#endif
9970 +
9971 /* Pure DTLB misses do not tell us whether the fault causing
9972 * load/store/atomic was a write or not, it only says that there
9973 * was no match. So in such a case we (carefully) read the
9974 diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c
9975 index d2b5944..bd813f2 100644
9976 --- a/arch/sparc/mm/hugetlbpage.c
9977 +++ b/arch/sparc/mm/hugetlbpage.c
9978 @@ -38,7 +38,7 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
9979
9980 info.flags = 0;
9981 info.length = len;
9982 - info.low_limit = TASK_UNMAPPED_BASE;
9983 + info.low_limit = mm->mmap_base;
9984 info.high_limit = min(task_size, VA_EXCLUDE_START);
9985 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
9986 info.align_offset = 0;
9987 @@ -47,6 +47,12 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
9988 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
9989 VM_BUG_ON(addr != -ENOMEM);
9990 info.low_limit = VA_EXCLUDE_END;
9991 +
9992 +#ifdef CONFIG_PAX_RANDMMAP
9993 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9994 + info.low_limit += mm->delta_mmap;
9995 +#endif
9996 +
9997 info.high_limit = task_size;
9998 addr = vm_unmapped_area(&info);
9999 }
10000 @@ -85,6 +91,12 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
10001 VM_BUG_ON(addr != -ENOMEM);
10002 info.flags = 0;
10003 info.low_limit = TASK_UNMAPPED_BASE;
10004 +
10005 +#ifdef CONFIG_PAX_RANDMMAP
10006 + if (mm->pax_flags & MF_PAX_RANDMMAP)
10007 + info.low_limit += mm->delta_mmap;
10008 +#endif
10009 +
10010 info.high_limit = STACK_TOP32;
10011 addr = vm_unmapped_area(&info);
10012 }
10013 @@ -99,6 +111,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
10014 struct mm_struct *mm = current->mm;
10015 struct vm_area_struct *vma;
10016 unsigned long task_size = TASK_SIZE;
10017 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
10018
10019 if (test_thread_flag(TIF_32BIT))
10020 task_size = STACK_TOP32;
10021 @@ -114,11 +127,14 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
10022 return addr;
10023 }
10024
10025 +#ifdef CONFIG_PAX_RANDMMAP
10026 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
10027 +#endif
10028 +
10029 if (addr) {
10030 addr = ALIGN(addr, HPAGE_SIZE);
10031 vma = find_vma(mm, addr);
10032 - if (task_size - len >= addr &&
10033 - (!vma || addr + len <= vma->vm_start))
10034 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
10035 return addr;
10036 }
10037 if (mm->get_unmapped_area == arch_get_unmapped_area)
10038 diff --git a/arch/tile/include/asm/atomic_64.h b/arch/tile/include/asm/atomic_64.h
10039 index f4500c6..889656c 100644
10040 --- a/arch/tile/include/asm/atomic_64.h
10041 +++ b/arch/tile/include/asm/atomic_64.h
10042 @@ -143,6 +143,16 @@ static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
10043
10044 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
10045
10046 +#define atomic64_read_unchecked(v) atomic64_read(v)
10047 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
10048 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
10049 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
10050 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
10051 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
10052 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
10053 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
10054 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
10055 +
10056 /* Atomic dec and inc don't implement barrier, so provide them if needed. */
10057 #define smp_mb__before_atomic_dec() smp_mb()
10058 #define smp_mb__after_atomic_dec() smp_mb()
10059 diff --git a/arch/tile/include/asm/cache.h b/arch/tile/include/asm/cache.h
10060 index a9a5299..0fce79e 100644
10061 --- a/arch/tile/include/asm/cache.h
10062 +++ b/arch/tile/include/asm/cache.h
10063 @@ -15,11 +15,12 @@
10064 #ifndef _ASM_TILE_CACHE_H
10065 #define _ASM_TILE_CACHE_H
10066
10067 +#include <linux/const.h>
10068 #include <arch/chip.h>
10069
10070 /* bytes per L1 data cache line */
10071 #define L1_CACHE_SHIFT CHIP_L1D_LOG_LINE_SIZE()
10072 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10073 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10074
10075 /* bytes per L2 cache line */
10076 #define L2_CACHE_SHIFT CHIP_L2_LOG_LINE_SIZE()
10077 diff --git a/arch/tile/include/asm/uaccess.h b/arch/tile/include/asm/uaccess.h
10078 index 9ab078a..d6635c2 100644
10079 --- a/arch/tile/include/asm/uaccess.h
10080 +++ b/arch/tile/include/asm/uaccess.h
10081 @@ -403,9 +403,9 @@ static inline unsigned long __must_check copy_from_user(void *to,
10082 const void __user *from,
10083 unsigned long n)
10084 {
10085 - int sz = __compiletime_object_size(to);
10086 + size_t sz = __compiletime_object_size(to);
10087
10088 - if (likely(sz == -1 || sz >= n))
10089 + if (likely(sz == (size_t)-1 || sz >= n))
10090 n = _copy_from_user(to, from, n);
10091 else
10092 copy_from_user_overflow();
10093 diff --git a/arch/tile/mm/hugetlbpage.c b/arch/tile/mm/hugetlbpage.c
10094 index 650ccff..45fe2d6 100644
10095 --- a/arch/tile/mm/hugetlbpage.c
10096 +++ b/arch/tile/mm/hugetlbpage.c
10097 @@ -239,6 +239,7 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
10098 info.high_limit = TASK_SIZE;
10099 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
10100 info.align_offset = 0;
10101 + info.threadstack_offset = 0;
10102 return vm_unmapped_area(&info);
10103 }
10104
10105 @@ -256,6 +257,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
10106 info.high_limit = current->mm->mmap_base;
10107 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
10108 info.align_offset = 0;
10109 + info.threadstack_offset = 0;
10110 addr = vm_unmapped_area(&info);
10111
10112 /*
10113 diff --git a/arch/um/Makefile b/arch/um/Makefile
10114 index 133f7de..1d6f2f1 100644
10115 --- a/arch/um/Makefile
10116 +++ b/arch/um/Makefile
10117 @@ -62,6 +62,10 @@ USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\
10118 $(patsubst -I%,,$(KBUILD_CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \
10119 $(filter -I%,$(CFLAGS)) -D_FILE_OFFSET_BITS=64 -idirafter include
10120
10121 +ifdef CONSTIFY_PLUGIN
10122 +USER_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10123 +endif
10124 +
10125 #This will adjust *FLAGS accordingly to the platform.
10126 include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
10127
10128 diff --git a/arch/um/defconfig b/arch/um/defconfig
10129 index 08107a7..ab22afe 100644
10130 --- a/arch/um/defconfig
10131 +++ b/arch/um/defconfig
10132 @@ -51,7 +51,6 @@ CONFIG_X86_CMPXCHG=y
10133 CONFIG_X86_L1_CACHE_SHIFT=5
10134 CONFIG_X86_XADD=y
10135 CONFIG_X86_PPRO_FENCE=y
10136 -CONFIG_X86_WP_WORKS_OK=y
10137 CONFIG_X86_INVLPG=y
10138 CONFIG_X86_BSWAP=y
10139 CONFIG_X86_POPAD_OK=y
10140 diff --git a/arch/um/include/asm/cache.h b/arch/um/include/asm/cache.h
10141 index 19e1bdd..3665b77 100644
10142 --- a/arch/um/include/asm/cache.h
10143 +++ b/arch/um/include/asm/cache.h
10144 @@ -1,6 +1,7 @@
10145 #ifndef __UM_CACHE_H
10146 #define __UM_CACHE_H
10147
10148 +#include <linux/const.h>
10149
10150 #if defined(CONFIG_UML_X86) && !defined(CONFIG_64BIT)
10151 # define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
10152 @@ -12,6 +13,6 @@
10153 # define L1_CACHE_SHIFT 5
10154 #endif
10155
10156 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10157 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10158
10159 #endif
10160 diff --git a/arch/um/include/asm/kmap_types.h b/arch/um/include/asm/kmap_types.h
10161 index 2e0a6b1..a64d0f5 100644
10162 --- a/arch/um/include/asm/kmap_types.h
10163 +++ b/arch/um/include/asm/kmap_types.h
10164 @@ -8,6 +8,6 @@
10165
10166 /* No more #include "asm/arch/kmap_types.h" ! */
10167
10168 -#define KM_TYPE_NR 14
10169 +#define KM_TYPE_NR 15
10170
10171 #endif
10172 diff --git a/arch/um/include/asm/page.h b/arch/um/include/asm/page.h
10173 index 5ff53d9..5850cdf 100644
10174 --- a/arch/um/include/asm/page.h
10175 +++ b/arch/um/include/asm/page.h
10176 @@ -14,6 +14,9 @@
10177 #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
10178 #define PAGE_MASK (~(PAGE_SIZE-1))
10179
10180 +#define ktla_ktva(addr) (addr)
10181 +#define ktva_ktla(addr) (addr)
10182 +
10183 #ifndef __ASSEMBLY__
10184
10185 struct page;
10186 diff --git a/arch/um/include/asm/pgtable-3level.h b/arch/um/include/asm/pgtable-3level.h
10187 index 0032f92..cd151e0 100644
10188 --- a/arch/um/include/asm/pgtable-3level.h
10189 +++ b/arch/um/include/asm/pgtable-3level.h
10190 @@ -58,6 +58,7 @@
10191 #define pud_present(x) (pud_val(x) & _PAGE_PRESENT)
10192 #define pud_populate(mm, pud, pmd) \
10193 set_pud(pud, __pud(_PAGE_TABLE + __pa(pmd)))
10194 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
10195
10196 #ifdef CONFIG_64BIT
10197 #define set_pud(pudptr, pudval) set_64bit((u64 *) (pudptr), pud_val(pudval))
10198 diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
10199 index b462b13..e7a19aa 100644
10200 --- a/arch/um/kernel/process.c
10201 +++ b/arch/um/kernel/process.c
10202 @@ -386,22 +386,6 @@ int singlestepping(void * t)
10203 return 2;
10204 }
10205
10206 -/*
10207 - * Only x86 and x86_64 have an arch_align_stack().
10208 - * All other arches have "#define arch_align_stack(x) (x)"
10209 - * in their asm/system.h
10210 - * As this is included in UML from asm-um/system-generic.h,
10211 - * we can use it to behave as the subarch does.
10212 - */
10213 -#ifndef arch_align_stack
10214 -unsigned long arch_align_stack(unsigned long sp)
10215 -{
10216 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
10217 - sp -= get_random_int() % 8192;
10218 - return sp & ~0xf;
10219 -}
10220 -#endif
10221 -
10222 unsigned long get_wchan(struct task_struct *p)
10223 {
10224 unsigned long stack_page, sp, ip;
10225 diff --git a/arch/unicore32/include/asm/cache.h b/arch/unicore32/include/asm/cache.h
10226 index ad8f795..2c7eec6 100644
10227 --- a/arch/unicore32/include/asm/cache.h
10228 +++ b/arch/unicore32/include/asm/cache.h
10229 @@ -12,8 +12,10 @@
10230 #ifndef __UNICORE_CACHE_H__
10231 #define __UNICORE_CACHE_H__
10232
10233 -#define L1_CACHE_SHIFT (5)
10234 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10235 +#include <linux/const.h>
10236 +
10237 +#define L1_CACHE_SHIFT 5
10238 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10239
10240 /*
10241 * Memory returned by kmalloc() may be used for DMA, so we must make
10242 diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
10243 index 6ef2a37..74ad6ad 100644
10244 --- a/arch/x86/Kconfig
10245 +++ b/arch/x86/Kconfig
10246 @@ -243,7 +243,7 @@ config X86_HT
10247
10248 config X86_32_LAZY_GS
10249 def_bool y
10250 - depends on X86_32 && !CC_STACKPROTECTOR
10251 + depends on X86_32 && !CC_STACKPROTECTOR && !PAX_MEMORY_UDEREF
10252
10253 config ARCH_HWEIGHT_CFLAGS
10254 string
10255 @@ -1076,6 +1076,7 @@ config MICROCODE_EARLY
10256
10257 config X86_MSR
10258 tristate "/dev/cpu/*/msr - Model-specific register support"
10259 + depends on !GRKERNSEC_KMEM
10260 ---help---
10261 This device gives privileged processes access to the x86
10262 Model-Specific Registers (MSRs). It is a character device with
10263 @@ -1099,7 +1100,7 @@ choice
10264
10265 config NOHIGHMEM
10266 bool "off"
10267 - depends on !X86_NUMAQ
10268 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
10269 ---help---
10270 Linux can use up to 64 Gigabytes of physical memory on x86 systems.
10271 However, the address space of 32-bit x86 processors is only 4
10272 @@ -1136,7 +1137,7 @@ config NOHIGHMEM
10273
10274 config HIGHMEM4G
10275 bool "4GB"
10276 - depends on !X86_NUMAQ
10277 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
10278 ---help---
10279 Select this if you have a 32-bit processor and between 1 and 4
10280 gigabytes of physical RAM.
10281 @@ -1189,7 +1190,7 @@ config PAGE_OFFSET
10282 hex
10283 default 0xB0000000 if VMSPLIT_3G_OPT
10284 default 0x80000000 if VMSPLIT_2G
10285 - default 0x78000000 if VMSPLIT_2G_OPT
10286 + default 0x70000000 if VMSPLIT_2G_OPT
10287 default 0x40000000 if VMSPLIT_1G
10288 default 0xC0000000
10289 depends on X86_32
10290 @@ -1587,6 +1588,7 @@ config SECCOMP
10291
10292 config CC_STACKPROTECTOR
10293 bool "Enable -fstack-protector buffer overflow detection"
10294 + depends on X86_64 || !PAX_MEMORY_UDEREF
10295 ---help---
10296 This option turns on the -fstack-protector GCC feature. This
10297 feature puts, at the beginning of functions, a canary value on
10298 @@ -1706,6 +1708,8 @@ config X86_NEED_RELOCS
10299 config PHYSICAL_ALIGN
10300 hex "Alignment value to which kernel should be aligned" if X86_32
10301 default "0x1000000"
10302 + range 0x200000 0x1000000 if PAX_KERNEXEC && X86_PAE
10303 + range 0x400000 0x1000000 if PAX_KERNEXEC && !X86_PAE
10304 range 0x2000 0x1000000
10305 ---help---
10306 This value puts the alignment restrictions on physical address
10307 @@ -1781,9 +1785,10 @@ config DEBUG_HOTPLUG_CPU0
10308 If unsure, say N.
10309
10310 config COMPAT_VDSO
10311 - def_bool y
10312 + def_bool n
10313 prompt "Compat VDSO support"
10314 depends on X86_32 || IA32_EMULATION
10315 + depends on !PAX_PAGEEXEC && !PAX_SEGMEXEC && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
10316 ---help---
10317 Map the 32-bit VDSO to the predictable old-style address too.
10318
10319 diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
10320 index c026cca..14657ae 100644
10321 --- a/arch/x86/Kconfig.cpu
10322 +++ b/arch/x86/Kconfig.cpu
10323 @@ -319,7 +319,7 @@ config X86_PPRO_FENCE
10324
10325 config X86_F00F_BUG
10326 def_bool y
10327 - depends on M586MMX || M586TSC || M586 || M486
10328 + depends on (M586MMX || M586TSC || M586 || M486) && !PAX_KERNEXEC
10329
10330 config X86_INVD_BUG
10331 def_bool y
10332 @@ -327,7 +327,7 @@ config X86_INVD_BUG
10333
10334 config X86_ALIGNMENT_16
10335 def_bool y
10336 - depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MELAN || MK6 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
10337 + depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || X86_ELAN || MK8 || MK7 || MK6 || MCORE2 || MPENTIUM4 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
10338
10339 config X86_INTEL_USERCOPY
10340 def_bool y
10341 @@ -373,7 +373,7 @@ config X86_CMPXCHG64
10342 # generates cmov.
10343 config X86_CMOV
10344 def_bool y
10345 - depends on (MK8 || MK7 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
10346 + depends on (MK8 || MK7 || MCORE2 || MPSC || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
10347
10348 config X86_MINIMUM_CPU_FAMILY
10349 int
10350 diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
10351 index b322f12..652d0d9 100644
10352 --- a/arch/x86/Kconfig.debug
10353 +++ b/arch/x86/Kconfig.debug
10354 @@ -84,7 +84,7 @@ config X86_PTDUMP
10355 config DEBUG_RODATA
10356 bool "Write protect kernel read-only data structures"
10357 default y
10358 - depends on DEBUG_KERNEL
10359 + depends on DEBUG_KERNEL && BROKEN
10360 ---help---
10361 Mark the kernel read-only data as write-protected in the pagetables,
10362 in order to catch accidental (and incorrect) writes to such const
10363 @@ -102,7 +102,7 @@ config DEBUG_RODATA_TEST
10364
10365 config DEBUG_SET_MODULE_RONX
10366 bool "Set loadable kernel module data as NX and text as RO"
10367 - depends on MODULES
10368 + depends on MODULES && BROKEN
10369 ---help---
10370 This option helps catch unintended modifications to loadable
10371 kernel module's text and read-only data. It also prevents execution
10372 @@ -294,7 +294,7 @@ config OPTIMIZE_INLINING
10373
10374 config DEBUG_STRICT_USER_COPY_CHECKS
10375 bool "Strict copy size checks"
10376 - depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING
10377 + depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING && !PAX_SIZE_OVERFLOW
10378 ---help---
10379 Enabling this option turns a certain set of sanity checks for user
10380 copy operations into compile time failures.
10381 diff --git a/arch/x86/Makefile b/arch/x86/Makefile
10382 index 5c47726..8c4fa67 100644
10383 --- a/arch/x86/Makefile
10384 +++ b/arch/x86/Makefile
10385 @@ -54,6 +54,7 @@ else
10386 UTS_MACHINE := x86_64
10387 CHECKFLAGS += -D__x86_64__ -m64
10388
10389 + biarch := $(call cc-option,-m64)
10390 KBUILD_AFLAGS += -m64
10391 KBUILD_CFLAGS += -m64
10392
10393 @@ -234,3 +235,12 @@ define archhelp
10394 echo ' FDARGS="..." arguments for the booted kernel'
10395 echo ' FDINITRD=file initrd for the booted kernel'
10396 endef
10397 +
10398 +define OLD_LD
10399 +
10400 +*** ${VERSION}.${PATCHLEVEL} PaX kernels no longer build correctly with old versions of binutils.
10401 +*** Please upgrade your binutils to 2.18 or newer
10402 +endef
10403 +
10404 +archprepare:
10405 + $(if $(LDFLAGS_BUILD_ID),,$(error $(OLD_LD)))
10406 diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
10407 index 379814b..add62ce 100644
10408 --- a/arch/x86/boot/Makefile
10409 +++ b/arch/x86/boot/Makefile
10410 @@ -65,6 +65,9 @@ KBUILD_CFLAGS := $(USERINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \
10411 $(call cc-option, -fno-stack-protector) \
10412 $(call cc-option, -mpreferred-stack-boundary=2)
10413 KBUILD_CFLAGS += $(call cc-option, -m32)
10414 +ifdef CONSTIFY_PLUGIN
10415 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10416 +endif
10417 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
10418 GCOV_PROFILE := n
10419
10420 diff --git a/arch/x86/boot/bitops.h b/arch/x86/boot/bitops.h
10421 index 878e4b9..20537ab 100644
10422 --- a/arch/x86/boot/bitops.h
10423 +++ b/arch/x86/boot/bitops.h
10424 @@ -26,7 +26,7 @@ static inline int variable_test_bit(int nr, const void *addr)
10425 u8 v;
10426 const u32 *p = (const u32 *)addr;
10427
10428 - asm("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
10429 + asm volatile("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
10430 return v;
10431 }
10432
10433 @@ -37,7 +37,7 @@ static inline int variable_test_bit(int nr, const void *addr)
10434
10435 static inline void set_bit(int nr, void *addr)
10436 {
10437 - asm("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
10438 + asm volatile("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
10439 }
10440
10441 #endif /* BOOT_BITOPS_H */
10442 diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h
10443 index 5b75319..331a4ca 100644
10444 --- a/arch/x86/boot/boot.h
10445 +++ b/arch/x86/boot/boot.h
10446 @@ -85,7 +85,7 @@ static inline void io_delay(void)
10447 static inline u16 ds(void)
10448 {
10449 u16 seg;
10450 - asm("movw %%ds,%0" : "=rm" (seg));
10451 + asm volatile("movw %%ds,%0" : "=rm" (seg));
10452 return seg;
10453 }
10454
10455 @@ -181,7 +181,7 @@ static inline void wrgs32(u32 v, addr_t addr)
10456 static inline int memcmp(const void *s1, const void *s2, size_t len)
10457 {
10458 u8 diff;
10459 - asm("repe; cmpsb; setnz %0"
10460 + asm volatile("repe; cmpsb; setnz %0"
10461 : "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len));
10462 return diff;
10463 }
10464 diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
10465 index 5ef205c..342191d 100644
10466 --- a/arch/x86/boot/compressed/Makefile
10467 +++ b/arch/x86/boot/compressed/Makefile
10468 @@ -14,6 +14,9 @@ cflags-$(CONFIG_X86_64) := -mcmodel=small
10469 KBUILD_CFLAGS += $(cflags-y)
10470 KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
10471 KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
10472 +ifdef CONSTIFY_PLUGIN
10473 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10474 +endif
10475
10476 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
10477 GCOV_PROFILE := n
10478 diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
10479 index 35ee62f..b6609b6 100644
10480 --- a/arch/x86/boot/compressed/eboot.c
10481 +++ b/arch/x86/boot/compressed/eboot.c
10482 @@ -150,7 +150,6 @@ again:
10483 *addr = max_addr;
10484 }
10485
10486 -free_pool:
10487 efi_call_phys1(sys_table->boottime->free_pool, map);
10488
10489 fail:
10490 @@ -214,7 +213,6 @@ static efi_status_t low_alloc(unsigned long size, unsigned long align,
10491 if (i == map_size / desc_size)
10492 status = EFI_NOT_FOUND;
10493
10494 -free_pool:
10495 efi_call_phys1(sys_table->boottime->free_pool, map);
10496 fail:
10497 return status;
10498 diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S
10499 index 1e3184f..0d11e2e 100644
10500 --- a/arch/x86/boot/compressed/head_32.S
10501 +++ b/arch/x86/boot/compressed/head_32.S
10502 @@ -118,7 +118,7 @@ preferred_addr:
10503 notl %eax
10504 andl %eax, %ebx
10505 #else
10506 - movl $LOAD_PHYSICAL_ADDR, %ebx
10507 + movl $____LOAD_PHYSICAL_ADDR, %ebx
10508 #endif
10509
10510 /* Target address to relocate to for decompression */
10511 @@ -204,7 +204,7 @@ relocated:
10512 * and where it was actually loaded.
10513 */
10514 movl %ebp, %ebx
10515 - subl $LOAD_PHYSICAL_ADDR, %ebx
10516 + subl $____LOAD_PHYSICAL_ADDR, %ebx
10517 jz 2f /* Nothing to be done if loaded at compiled addr. */
10518 /*
10519 * Process relocations.
10520 @@ -212,8 +212,7 @@ relocated:
10521
10522 1: subl $4, %edi
10523 movl (%edi), %ecx
10524 - testl %ecx, %ecx
10525 - jz 2f
10526 + jecxz 2f
10527 addl %ebx, -__PAGE_OFFSET(%ebx, %ecx)
10528 jmp 1b
10529 2:
10530 diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
10531 index c1d383d..57ab51c 100644
10532 --- a/arch/x86/boot/compressed/head_64.S
10533 +++ b/arch/x86/boot/compressed/head_64.S
10534 @@ -97,7 +97,7 @@ ENTRY(startup_32)
10535 notl %eax
10536 andl %eax, %ebx
10537 #else
10538 - movl $LOAD_PHYSICAL_ADDR, %ebx
10539 + movl $____LOAD_PHYSICAL_ADDR, %ebx
10540 #endif
10541
10542 /* Target address to relocate to for decompression */
10543 @@ -272,7 +272,7 @@ preferred_addr:
10544 notq %rax
10545 andq %rax, %rbp
10546 #else
10547 - movq $LOAD_PHYSICAL_ADDR, %rbp
10548 + movq $____LOAD_PHYSICAL_ADDR, %rbp
10549 #endif
10550
10551 /* Target address to relocate to for decompression */
10552 @@ -363,8 +363,8 @@ gdt:
10553 .long gdt
10554 .word 0
10555 .quad 0x0000000000000000 /* NULL descriptor */
10556 - .quad 0x00af9a000000ffff /* __KERNEL_CS */
10557 - .quad 0x00cf92000000ffff /* __KERNEL_DS */
10558 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
10559 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
10560 .quad 0x0080890000000000 /* TS descriptor */
10561 .quad 0x0000000000000000 /* TS continued */
10562 gdt_end:
10563 diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
10564 index 7cb56c6..d382d84 100644
10565 --- a/arch/x86/boot/compressed/misc.c
10566 +++ b/arch/x86/boot/compressed/misc.c
10567 @@ -303,7 +303,7 @@ static void parse_elf(void *output)
10568 case PT_LOAD:
10569 #ifdef CONFIG_RELOCATABLE
10570 dest = output;
10571 - dest += (phdr->p_paddr - LOAD_PHYSICAL_ADDR);
10572 + dest += (phdr->p_paddr - ____LOAD_PHYSICAL_ADDR);
10573 #else
10574 dest = (void *)(phdr->p_paddr);
10575 #endif
10576 @@ -354,7 +354,7 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
10577 error("Destination address too large");
10578 #endif
10579 #ifndef CONFIG_RELOCATABLE
10580 - if ((unsigned long)output != LOAD_PHYSICAL_ADDR)
10581 + if ((unsigned long)output != ____LOAD_PHYSICAL_ADDR)
10582 error("Wrong destination address");
10583 #endif
10584
10585 diff --git a/arch/x86/boot/cpucheck.c b/arch/x86/boot/cpucheck.c
10586 index 4d3ff03..e4972ff 100644
10587 --- a/arch/x86/boot/cpucheck.c
10588 +++ b/arch/x86/boot/cpucheck.c
10589 @@ -74,7 +74,7 @@ static int has_fpu(void)
10590 u16 fcw = -1, fsw = -1;
10591 u32 cr0;
10592
10593 - asm("movl %%cr0,%0" : "=r" (cr0));
10594 + asm volatile("movl %%cr0,%0" : "=r" (cr0));
10595 if (cr0 & (X86_CR0_EM|X86_CR0_TS)) {
10596 cr0 &= ~(X86_CR0_EM|X86_CR0_TS);
10597 asm volatile("movl %0,%%cr0" : : "r" (cr0));
10598 @@ -90,7 +90,7 @@ static int has_eflag(u32 mask)
10599 {
10600 u32 f0, f1;
10601
10602 - asm("pushfl ; "
10603 + asm volatile("pushfl ; "
10604 "pushfl ; "
10605 "popl %0 ; "
10606 "movl %0,%1 ; "
10607 @@ -115,7 +115,7 @@ static void get_flags(void)
10608 set_bit(X86_FEATURE_FPU, cpu.flags);
10609
10610 if (has_eflag(X86_EFLAGS_ID)) {
10611 - asm("cpuid"
10612 + asm volatile("cpuid"
10613 : "=a" (max_intel_level),
10614 "=b" (cpu_vendor[0]),
10615 "=d" (cpu_vendor[1]),
10616 @@ -124,7 +124,7 @@ static void get_flags(void)
10617
10618 if (max_intel_level >= 0x00000001 &&
10619 max_intel_level <= 0x0000ffff) {
10620 - asm("cpuid"
10621 + asm volatile("cpuid"
10622 : "=a" (tfms),
10623 "=c" (cpu.flags[4]),
10624 "=d" (cpu.flags[0])
10625 @@ -136,7 +136,7 @@ static void get_flags(void)
10626 cpu.model += ((tfms >> 16) & 0xf) << 4;
10627 }
10628
10629 - asm("cpuid"
10630 + asm volatile("cpuid"
10631 : "=a" (max_amd_level)
10632 : "a" (0x80000000)
10633 : "ebx", "ecx", "edx");
10634 @@ -144,7 +144,7 @@ static void get_flags(void)
10635 if (max_amd_level >= 0x80000001 &&
10636 max_amd_level <= 0x8000ffff) {
10637 u32 eax = 0x80000001;
10638 - asm("cpuid"
10639 + asm volatile("cpuid"
10640 : "+a" (eax),
10641 "=c" (cpu.flags[6]),
10642 "=d" (cpu.flags[1])
10643 @@ -203,9 +203,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10644 u32 ecx = MSR_K7_HWCR;
10645 u32 eax, edx;
10646
10647 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10648 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10649 eax &= ~(1 << 15);
10650 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10651 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10652
10653 get_flags(); /* Make sure it really did something */
10654 err = check_flags();
10655 @@ -218,9 +218,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10656 u32 ecx = MSR_VIA_FCR;
10657 u32 eax, edx;
10658
10659 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10660 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10661 eax |= (1<<1)|(1<<7);
10662 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10663 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10664
10665 set_bit(X86_FEATURE_CX8, cpu.flags);
10666 err = check_flags();
10667 @@ -231,12 +231,12 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10668 u32 eax, edx;
10669 u32 level = 1;
10670
10671 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10672 - asm("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
10673 - asm("cpuid"
10674 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10675 + asm volatile("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
10676 + asm volatile("cpuid"
10677 : "+a" (level), "=d" (cpu.flags[0])
10678 : : "ecx", "ebx");
10679 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10680 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10681
10682 err = check_flags();
10683 }
10684 diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
10685 index 9ec06a1..2c25e79 100644
10686 --- a/arch/x86/boot/header.S
10687 +++ b/arch/x86/boot/header.S
10688 @@ -409,10 +409,14 @@ setup_data: .quad 0 # 64-bit physical pointer to
10689 # single linked list of
10690 # struct setup_data
10691
10692 -pref_address: .quad LOAD_PHYSICAL_ADDR # preferred load addr
10693 +pref_address: .quad ____LOAD_PHYSICAL_ADDR # preferred load addr
10694
10695 #define ZO_INIT_SIZE (ZO__end - ZO_startup_32 + ZO_z_extract_offset)
10696 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
10697 +#define VO_INIT_SIZE (VO__end - VO__text - __PAGE_OFFSET - ____LOAD_PHYSICAL_ADDR)
10698 +#else
10699 #define VO_INIT_SIZE (VO__end - VO__text)
10700 +#endif
10701 #if ZO_INIT_SIZE > VO_INIT_SIZE
10702 #define INIT_SIZE ZO_INIT_SIZE
10703 #else
10704 diff --git a/arch/x86/boot/memory.c b/arch/x86/boot/memory.c
10705 index db75d07..8e6d0af 100644
10706 --- a/arch/x86/boot/memory.c
10707 +++ b/arch/x86/boot/memory.c
10708 @@ -19,7 +19,7 @@
10709
10710 static int detect_memory_e820(void)
10711 {
10712 - int count = 0;
10713 + unsigned int count = 0;
10714 struct biosregs ireg, oreg;
10715 struct e820entry *desc = boot_params.e820_map;
10716 static struct e820entry buf; /* static so it is zeroed */
10717 diff --git a/arch/x86/boot/video-vesa.c b/arch/x86/boot/video-vesa.c
10718 index 11e8c6e..fdbb1ed 100644
10719 --- a/arch/x86/boot/video-vesa.c
10720 +++ b/arch/x86/boot/video-vesa.c
10721 @@ -200,6 +200,7 @@ static void vesa_store_pm_info(void)
10722
10723 boot_params.screen_info.vesapm_seg = oreg.es;
10724 boot_params.screen_info.vesapm_off = oreg.di;
10725 + boot_params.screen_info.vesapm_size = oreg.cx;
10726 }
10727
10728 /*
10729 diff --git a/arch/x86/boot/video.c b/arch/x86/boot/video.c
10730 index 43eda28..5ab5fdb 100644
10731 --- a/arch/x86/boot/video.c
10732 +++ b/arch/x86/boot/video.c
10733 @@ -96,7 +96,7 @@ static void store_mode_params(void)
10734 static unsigned int get_entry(void)
10735 {
10736 char entry_buf[4];
10737 - int i, len = 0;
10738 + unsigned int i, len = 0;
10739 int key;
10740 unsigned int v;
10741
10742 diff --git a/arch/x86/crypto/aes-x86_64-asm_64.S b/arch/x86/crypto/aes-x86_64-asm_64.S
10743 index 9105655..5e37f27 100644
10744 --- a/arch/x86/crypto/aes-x86_64-asm_64.S
10745 +++ b/arch/x86/crypto/aes-x86_64-asm_64.S
10746 @@ -8,6 +8,8 @@
10747 * including this sentence is retained in full.
10748 */
10749
10750 +#include <asm/alternative-asm.h>
10751 +
10752 .extern crypto_ft_tab
10753 .extern crypto_it_tab
10754 .extern crypto_fl_tab
10755 @@ -70,6 +72,8 @@
10756 je B192; \
10757 leaq 32(r9),r9;
10758
10759 +#define ret pax_force_retaddr 0, 1; ret
10760 +
10761 #define epilogue(FUNC,r1,r2,r3,r4,r5,r6,r7,r8,r9) \
10762 movq r1,r2; \
10763 movq r3,r4; \
10764 diff --git a/arch/x86/crypto/aesni-intel_asm.S b/arch/x86/crypto/aesni-intel_asm.S
10765 index 04b7977..402f223 100644
10766 --- a/arch/x86/crypto/aesni-intel_asm.S
10767 +++ b/arch/x86/crypto/aesni-intel_asm.S
10768 @@ -31,6 +31,7 @@
10769
10770 #include <linux/linkage.h>
10771 #include <asm/inst.h>
10772 +#include <asm/alternative-asm.h>
10773
10774 #ifdef __x86_64__
10775 .data
10776 @@ -1435,6 +1436,7 @@ _return_T_done_decrypt:
10777 pop %r14
10778 pop %r13
10779 pop %r12
10780 + pax_force_retaddr 0, 1
10781 ret
10782 ENDPROC(aesni_gcm_dec)
10783
10784 @@ -1699,6 +1701,7 @@ _return_T_done_encrypt:
10785 pop %r14
10786 pop %r13
10787 pop %r12
10788 + pax_force_retaddr 0, 1
10789 ret
10790 ENDPROC(aesni_gcm_enc)
10791
10792 @@ -1716,6 +1719,7 @@ _key_expansion_256a:
10793 pxor %xmm1, %xmm0
10794 movaps %xmm0, (TKEYP)
10795 add $0x10, TKEYP
10796 + pax_force_retaddr_bts
10797 ret
10798 ENDPROC(_key_expansion_128)
10799 ENDPROC(_key_expansion_256a)
10800 @@ -1742,6 +1746,7 @@ _key_expansion_192a:
10801 shufps $0b01001110, %xmm2, %xmm1
10802 movaps %xmm1, 0x10(TKEYP)
10803 add $0x20, TKEYP
10804 + pax_force_retaddr_bts
10805 ret
10806 ENDPROC(_key_expansion_192a)
10807
10808 @@ -1762,6 +1767,7 @@ _key_expansion_192b:
10809
10810 movaps %xmm0, (TKEYP)
10811 add $0x10, TKEYP
10812 + pax_force_retaddr_bts
10813 ret
10814 ENDPROC(_key_expansion_192b)
10815
10816 @@ -1775,6 +1781,7 @@ _key_expansion_256b:
10817 pxor %xmm1, %xmm2
10818 movaps %xmm2, (TKEYP)
10819 add $0x10, TKEYP
10820 + pax_force_retaddr_bts
10821 ret
10822 ENDPROC(_key_expansion_256b)
10823
10824 @@ -1888,6 +1895,7 @@ ENTRY(aesni_set_key)
10825 #ifndef __x86_64__
10826 popl KEYP
10827 #endif
10828 + pax_force_retaddr 0, 1
10829 ret
10830 ENDPROC(aesni_set_key)
10831
10832 @@ -1910,6 +1918,7 @@ ENTRY(aesni_enc)
10833 popl KLEN
10834 popl KEYP
10835 #endif
10836 + pax_force_retaddr 0, 1
10837 ret
10838 ENDPROC(aesni_enc)
10839
10840 @@ -1968,6 +1977,7 @@ _aesni_enc1:
10841 AESENC KEY STATE
10842 movaps 0x70(TKEYP), KEY
10843 AESENCLAST KEY STATE
10844 + pax_force_retaddr_bts
10845 ret
10846 ENDPROC(_aesni_enc1)
10847
10848 @@ -2077,6 +2087,7 @@ _aesni_enc4:
10849 AESENCLAST KEY STATE2
10850 AESENCLAST KEY STATE3
10851 AESENCLAST KEY STATE4
10852 + pax_force_retaddr_bts
10853 ret
10854 ENDPROC(_aesni_enc4)
10855
10856 @@ -2100,6 +2111,7 @@ ENTRY(aesni_dec)
10857 popl KLEN
10858 popl KEYP
10859 #endif
10860 + pax_force_retaddr 0, 1
10861 ret
10862 ENDPROC(aesni_dec)
10863
10864 @@ -2158,6 +2170,7 @@ _aesni_dec1:
10865 AESDEC KEY STATE
10866 movaps 0x70(TKEYP), KEY
10867 AESDECLAST KEY STATE
10868 + pax_force_retaddr_bts
10869 ret
10870 ENDPROC(_aesni_dec1)
10871
10872 @@ -2267,6 +2280,7 @@ _aesni_dec4:
10873 AESDECLAST KEY STATE2
10874 AESDECLAST KEY STATE3
10875 AESDECLAST KEY STATE4
10876 + pax_force_retaddr_bts
10877 ret
10878 ENDPROC(_aesni_dec4)
10879
10880 @@ -2325,6 +2339,7 @@ ENTRY(aesni_ecb_enc)
10881 popl KEYP
10882 popl LEN
10883 #endif
10884 + pax_force_retaddr 0, 1
10885 ret
10886 ENDPROC(aesni_ecb_enc)
10887
10888 @@ -2384,6 +2399,7 @@ ENTRY(aesni_ecb_dec)
10889 popl KEYP
10890 popl LEN
10891 #endif
10892 + pax_force_retaddr 0, 1
10893 ret
10894 ENDPROC(aesni_ecb_dec)
10895
10896 @@ -2426,6 +2442,7 @@ ENTRY(aesni_cbc_enc)
10897 popl LEN
10898 popl IVP
10899 #endif
10900 + pax_force_retaddr 0, 1
10901 ret
10902 ENDPROC(aesni_cbc_enc)
10903
10904 @@ -2517,6 +2534,7 @@ ENTRY(aesni_cbc_dec)
10905 popl LEN
10906 popl IVP
10907 #endif
10908 + pax_force_retaddr 0, 1
10909 ret
10910 ENDPROC(aesni_cbc_dec)
10911
10912 @@ -2544,6 +2562,7 @@ _aesni_inc_init:
10913 mov $1, TCTR_LOW
10914 MOVQ_R64_XMM TCTR_LOW INC
10915 MOVQ_R64_XMM CTR TCTR_LOW
10916 + pax_force_retaddr_bts
10917 ret
10918 ENDPROC(_aesni_inc_init)
10919
10920 @@ -2573,6 +2592,7 @@ _aesni_inc:
10921 .Linc_low:
10922 movaps CTR, IV
10923 PSHUFB_XMM BSWAP_MASK IV
10924 + pax_force_retaddr_bts
10925 ret
10926 ENDPROC(_aesni_inc)
10927
10928 @@ -2634,6 +2654,7 @@ ENTRY(aesni_ctr_enc)
10929 .Lctr_enc_ret:
10930 movups IV, (IVP)
10931 .Lctr_enc_just_ret:
10932 + pax_force_retaddr 0, 1
10933 ret
10934 ENDPROC(aesni_ctr_enc)
10935 #endif
10936 diff --git a/arch/x86/crypto/blowfish-x86_64-asm_64.S b/arch/x86/crypto/blowfish-x86_64-asm_64.S
10937 index 246c670..4d1ed00 100644
10938 --- a/arch/x86/crypto/blowfish-x86_64-asm_64.S
10939 +++ b/arch/x86/crypto/blowfish-x86_64-asm_64.S
10940 @@ -21,6 +21,7 @@
10941 */
10942
10943 #include <linux/linkage.h>
10944 +#include <asm/alternative-asm.h>
10945
10946 .file "blowfish-x86_64-asm.S"
10947 .text
10948 @@ -149,9 +150,11 @@ ENTRY(__blowfish_enc_blk)
10949 jnz .L__enc_xor;
10950
10951 write_block();
10952 + pax_force_retaddr 0, 1
10953 ret;
10954 .L__enc_xor:
10955 xor_block();
10956 + pax_force_retaddr 0, 1
10957 ret;
10958 ENDPROC(__blowfish_enc_blk)
10959
10960 @@ -183,6 +186,7 @@ ENTRY(blowfish_dec_blk)
10961
10962 movq %r11, %rbp;
10963
10964 + pax_force_retaddr 0, 1
10965 ret;
10966 ENDPROC(blowfish_dec_blk)
10967
10968 @@ -334,6 +338,7 @@ ENTRY(__blowfish_enc_blk_4way)
10969
10970 popq %rbx;
10971 popq %rbp;
10972 + pax_force_retaddr 0, 1
10973 ret;
10974
10975 .L__enc_xor4:
10976 @@ -341,6 +346,7 @@ ENTRY(__blowfish_enc_blk_4way)
10977
10978 popq %rbx;
10979 popq %rbp;
10980 + pax_force_retaddr 0, 1
10981 ret;
10982 ENDPROC(__blowfish_enc_blk_4way)
10983
10984 @@ -375,5 +381,6 @@ ENTRY(blowfish_dec_blk_4way)
10985 popq %rbx;
10986 popq %rbp;
10987
10988 + pax_force_retaddr 0, 1
10989 ret;
10990 ENDPROC(blowfish_dec_blk_4way)
10991 diff --git a/arch/x86/crypto/camellia-x86_64-asm_64.S b/arch/x86/crypto/camellia-x86_64-asm_64.S
10992 index 310319c..ce174a4 100644
10993 --- a/arch/x86/crypto/camellia-x86_64-asm_64.S
10994 +++ b/arch/x86/crypto/camellia-x86_64-asm_64.S
10995 @@ -21,6 +21,7 @@
10996 */
10997
10998 #include <linux/linkage.h>
10999 +#include <asm/alternative-asm.h>
11000
11001 .file "camellia-x86_64-asm_64.S"
11002 .text
11003 @@ -228,12 +229,14 @@ ENTRY(__camellia_enc_blk)
11004 enc_outunpack(mov, RT1);
11005
11006 movq RRBP, %rbp;
11007 + pax_force_retaddr 0, 1
11008 ret;
11009
11010 .L__enc_xor:
11011 enc_outunpack(xor, RT1);
11012
11013 movq RRBP, %rbp;
11014 + pax_force_retaddr 0, 1
11015 ret;
11016 ENDPROC(__camellia_enc_blk)
11017
11018 @@ -272,6 +275,7 @@ ENTRY(camellia_dec_blk)
11019 dec_outunpack();
11020
11021 movq RRBP, %rbp;
11022 + pax_force_retaddr 0, 1
11023 ret;
11024 ENDPROC(camellia_dec_blk)
11025
11026 @@ -463,6 +467,7 @@ ENTRY(__camellia_enc_blk_2way)
11027
11028 movq RRBP, %rbp;
11029 popq %rbx;
11030 + pax_force_retaddr 0, 1
11031 ret;
11032
11033 .L__enc2_xor:
11034 @@ -470,6 +475,7 @@ ENTRY(__camellia_enc_blk_2way)
11035
11036 movq RRBP, %rbp;
11037 popq %rbx;
11038 + pax_force_retaddr 0, 1
11039 ret;
11040 ENDPROC(__camellia_enc_blk_2way)
11041
11042 @@ -510,5 +516,6 @@ ENTRY(camellia_dec_blk_2way)
11043
11044 movq RRBP, %rbp;
11045 movq RXOR, %rbx;
11046 + pax_force_retaddr 0, 1
11047 ret;
11048 ENDPROC(camellia_dec_blk_2way)
11049 diff --git a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
11050 index c35fd5d..c1ee236 100644
11051 --- a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
11052 +++ b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
11053 @@ -24,6 +24,7 @@
11054 */
11055
11056 #include <linux/linkage.h>
11057 +#include <asm/alternative-asm.h>
11058
11059 .file "cast5-avx-x86_64-asm_64.S"
11060
11061 @@ -281,6 +282,7 @@ __cast5_enc_blk16:
11062 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
11063 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
11064
11065 + pax_force_retaddr 0, 1
11066 ret;
11067 ENDPROC(__cast5_enc_blk16)
11068
11069 @@ -352,6 +354,7 @@ __cast5_dec_blk16:
11070 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
11071 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
11072
11073 + pax_force_retaddr 0, 1
11074 ret;
11075
11076 .L__skip_dec:
11077 @@ -388,6 +391,7 @@ ENTRY(cast5_ecb_enc_16way)
11078 vmovdqu RR4, (6*4*4)(%r11);
11079 vmovdqu RL4, (7*4*4)(%r11);
11080
11081 + pax_force_retaddr
11082 ret;
11083 ENDPROC(cast5_ecb_enc_16way)
11084
11085 @@ -420,6 +424,7 @@ ENTRY(cast5_ecb_dec_16way)
11086 vmovdqu RR4, (6*4*4)(%r11);
11087 vmovdqu RL4, (7*4*4)(%r11);
11088
11089 + pax_force_retaddr
11090 ret;
11091 ENDPROC(cast5_ecb_dec_16way)
11092
11093 @@ -469,6 +474,7 @@ ENTRY(cast5_cbc_dec_16way)
11094
11095 popq %r12;
11096
11097 + pax_force_retaddr
11098 ret;
11099 ENDPROC(cast5_cbc_dec_16way)
11100
11101 @@ -542,5 +548,6 @@ ENTRY(cast5_ctr_16way)
11102
11103 popq %r12;
11104
11105 + pax_force_retaddr
11106 ret;
11107 ENDPROC(cast5_ctr_16way)
11108 diff --git a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11109 index f93b610..c09bf40 100644
11110 --- a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11111 +++ b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11112 @@ -24,6 +24,7 @@
11113 */
11114
11115 #include <linux/linkage.h>
11116 +#include <asm/alternative-asm.h>
11117 #include "glue_helper-asm-avx.S"
11118
11119 .file "cast6-avx-x86_64-asm_64.S"
11120 @@ -293,6 +294,7 @@ __cast6_enc_blk8:
11121 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
11122 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
11123
11124 + pax_force_retaddr 0, 1
11125 ret;
11126 ENDPROC(__cast6_enc_blk8)
11127
11128 @@ -338,6 +340,7 @@ __cast6_dec_blk8:
11129 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
11130 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
11131
11132 + pax_force_retaddr 0, 1
11133 ret;
11134 ENDPROC(__cast6_dec_blk8)
11135
11136 @@ -356,6 +359,7 @@ ENTRY(cast6_ecb_enc_8way)
11137
11138 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11139
11140 + pax_force_retaddr
11141 ret;
11142 ENDPROC(cast6_ecb_enc_8way)
11143
11144 @@ -374,6 +378,7 @@ ENTRY(cast6_ecb_dec_8way)
11145
11146 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11147
11148 + pax_force_retaddr
11149 ret;
11150 ENDPROC(cast6_ecb_dec_8way)
11151
11152 @@ -397,6 +402,7 @@ ENTRY(cast6_cbc_dec_8way)
11153
11154 popq %r12;
11155
11156 + pax_force_retaddr
11157 ret;
11158 ENDPROC(cast6_cbc_dec_8way)
11159
11160 @@ -422,5 +428,6 @@ ENTRY(cast6_ctr_8way)
11161
11162 popq %r12;
11163
11164 + pax_force_retaddr
11165 ret;
11166 ENDPROC(cast6_ctr_8way)
11167 diff --git a/arch/x86/crypto/salsa20-x86_64-asm_64.S b/arch/x86/crypto/salsa20-x86_64-asm_64.S
11168 index 9279e0b..9270820 100644
11169 --- a/arch/x86/crypto/salsa20-x86_64-asm_64.S
11170 +++ b/arch/x86/crypto/salsa20-x86_64-asm_64.S
11171 @@ -1,4 +1,5 @@
11172 #include <linux/linkage.h>
11173 +#include <asm/alternative-asm.h>
11174
11175 # enter salsa20_encrypt_bytes
11176 ENTRY(salsa20_encrypt_bytes)
11177 @@ -789,6 +790,7 @@ ENTRY(salsa20_encrypt_bytes)
11178 add %r11,%rsp
11179 mov %rdi,%rax
11180 mov %rsi,%rdx
11181 + pax_force_retaddr 0, 1
11182 ret
11183 # bytesatleast65:
11184 ._bytesatleast65:
11185 @@ -889,6 +891,7 @@ ENTRY(salsa20_keysetup)
11186 add %r11,%rsp
11187 mov %rdi,%rax
11188 mov %rsi,%rdx
11189 + pax_force_retaddr
11190 ret
11191 ENDPROC(salsa20_keysetup)
11192
11193 @@ -914,5 +917,6 @@ ENTRY(salsa20_ivsetup)
11194 add %r11,%rsp
11195 mov %rdi,%rax
11196 mov %rsi,%rdx
11197 + pax_force_retaddr
11198 ret
11199 ENDPROC(salsa20_ivsetup)
11200 diff --git a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11201 index 43c9386..a0e2d60 100644
11202 --- a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11203 +++ b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11204 @@ -25,6 +25,7 @@
11205 */
11206
11207 #include <linux/linkage.h>
11208 +#include <asm/alternative-asm.h>
11209 #include "glue_helper-asm-avx.S"
11210
11211 .file "serpent-avx-x86_64-asm_64.S"
11212 @@ -617,6 +618,7 @@ __serpent_enc_blk8_avx:
11213 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11214 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11215
11216 + pax_force_retaddr
11217 ret;
11218 ENDPROC(__serpent_enc_blk8_avx)
11219
11220 @@ -671,6 +673,7 @@ __serpent_dec_blk8_avx:
11221 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
11222 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
11223
11224 + pax_force_retaddr
11225 ret;
11226 ENDPROC(__serpent_dec_blk8_avx)
11227
11228 @@ -687,6 +690,7 @@ ENTRY(serpent_ecb_enc_8way_avx)
11229
11230 store_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11231
11232 + pax_force_retaddr
11233 ret;
11234 ENDPROC(serpent_ecb_enc_8way_avx)
11235
11236 @@ -703,6 +707,7 @@ ENTRY(serpent_ecb_dec_8way_avx)
11237
11238 store_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
11239
11240 + pax_force_retaddr
11241 ret;
11242 ENDPROC(serpent_ecb_dec_8way_avx)
11243
11244 @@ -719,6 +724,7 @@ ENTRY(serpent_cbc_dec_8way_avx)
11245
11246 store_cbc_8way(%rdx, %rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
11247
11248 + pax_force_retaddr
11249 ret;
11250 ENDPROC(serpent_cbc_dec_8way_avx)
11251
11252 @@ -737,5 +743,6 @@ ENTRY(serpent_ctr_8way_avx)
11253
11254 store_ctr_8way(%rdx, %rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11255
11256 + pax_force_retaddr
11257 ret;
11258 ENDPROC(serpent_ctr_8way_avx)
11259 diff --git a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11260 index acc066c..1559cc4 100644
11261 --- a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11262 +++ b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11263 @@ -25,6 +25,7 @@
11264 */
11265
11266 #include <linux/linkage.h>
11267 +#include <asm/alternative-asm.h>
11268
11269 .file "serpent-sse2-x86_64-asm_64.S"
11270 .text
11271 @@ -690,12 +691,14 @@ ENTRY(__serpent_enc_blk_8way)
11272 write_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11273 write_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11274
11275 + pax_force_retaddr
11276 ret;
11277
11278 .L__enc_xor8:
11279 xor_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11280 xor_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11281
11282 + pax_force_retaddr
11283 ret;
11284 ENDPROC(__serpent_enc_blk_8way)
11285
11286 @@ -750,5 +753,6 @@ ENTRY(serpent_dec_blk_8way)
11287 write_blocks(%rsi, RC1, RD1, RB1, RE1, RK0, RK1, RK2);
11288 write_blocks(%rax, RC2, RD2, RB2, RE2, RK0, RK1, RK2);
11289
11290 + pax_force_retaddr
11291 ret;
11292 ENDPROC(serpent_dec_blk_8way)
11293 diff --git a/arch/x86/crypto/sha1_ssse3_asm.S b/arch/x86/crypto/sha1_ssse3_asm.S
11294 index a410950..3356d42 100644
11295 --- a/arch/x86/crypto/sha1_ssse3_asm.S
11296 +++ b/arch/x86/crypto/sha1_ssse3_asm.S
11297 @@ -29,6 +29,7 @@
11298 */
11299
11300 #include <linux/linkage.h>
11301 +#include <asm/alternative-asm.h>
11302
11303 #define CTX %rdi // arg1
11304 #define BUF %rsi // arg2
11305 @@ -104,6 +105,7 @@
11306 pop %r12
11307 pop %rbp
11308 pop %rbx
11309 + pax_force_retaddr 0, 1
11310 ret
11311
11312 ENDPROC(\name)
11313 diff --git a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
11314 index 8d3e113..898b161 100644
11315 --- a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
11316 +++ b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
11317 @@ -24,6 +24,7 @@
11318 */
11319
11320 #include <linux/linkage.h>
11321 +#include <asm/alternative-asm.h>
11322 #include "glue_helper-asm-avx.S"
11323
11324 .file "twofish-avx-x86_64-asm_64.S"
11325 @@ -282,6 +283,7 @@ __twofish_enc_blk8:
11326 outunpack_blocks(RC1, RD1, RA1, RB1, RK1, RX0, RY0, RK2);
11327 outunpack_blocks(RC2, RD2, RA2, RB2, RK1, RX0, RY0, RK2);
11328
11329 + pax_force_retaddr 0, 1
11330 ret;
11331 ENDPROC(__twofish_enc_blk8)
11332
11333 @@ -322,6 +324,7 @@ __twofish_dec_blk8:
11334 outunpack_blocks(RA1, RB1, RC1, RD1, RK1, RX0, RY0, RK2);
11335 outunpack_blocks(RA2, RB2, RC2, RD2, RK1, RX0, RY0, RK2);
11336
11337 + pax_force_retaddr 0, 1
11338 ret;
11339 ENDPROC(__twofish_dec_blk8)
11340
11341 @@ -340,6 +343,7 @@ ENTRY(twofish_ecb_enc_8way)
11342
11343 store_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
11344
11345 + pax_force_retaddr 0, 1
11346 ret;
11347 ENDPROC(twofish_ecb_enc_8way)
11348
11349 @@ -358,6 +362,7 @@ ENTRY(twofish_ecb_dec_8way)
11350
11351 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11352
11353 + pax_force_retaddr 0, 1
11354 ret;
11355 ENDPROC(twofish_ecb_dec_8way)
11356
11357 @@ -381,6 +386,7 @@ ENTRY(twofish_cbc_dec_8way)
11358
11359 popq %r12;
11360
11361 + pax_force_retaddr 0, 1
11362 ret;
11363 ENDPROC(twofish_cbc_dec_8way)
11364
11365 @@ -406,5 +412,6 @@ ENTRY(twofish_ctr_8way)
11366
11367 popq %r12;
11368
11369 + pax_force_retaddr 0, 1
11370 ret;
11371 ENDPROC(twofish_ctr_8way)
11372 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
11373 index 1c3b7ce..b365c5e 100644
11374 --- a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
11375 +++ b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
11376 @@ -21,6 +21,7 @@
11377 */
11378
11379 #include <linux/linkage.h>
11380 +#include <asm/alternative-asm.h>
11381
11382 .file "twofish-x86_64-asm-3way.S"
11383 .text
11384 @@ -258,6 +259,7 @@ ENTRY(__twofish_enc_blk_3way)
11385 popq %r13;
11386 popq %r14;
11387 popq %r15;
11388 + pax_force_retaddr 0, 1
11389 ret;
11390
11391 .L__enc_xor3:
11392 @@ -269,6 +271,7 @@ ENTRY(__twofish_enc_blk_3way)
11393 popq %r13;
11394 popq %r14;
11395 popq %r15;
11396 + pax_force_retaddr 0, 1
11397 ret;
11398 ENDPROC(__twofish_enc_blk_3way)
11399
11400 @@ -308,5 +311,6 @@ ENTRY(twofish_dec_blk_3way)
11401 popq %r13;
11402 popq %r14;
11403 popq %r15;
11404 + pax_force_retaddr 0, 1
11405 ret;
11406 ENDPROC(twofish_dec_blk_3way)
11407 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64.S b/arch/x86/crypto/twofish-x86_64-asm_64.S
11408 index a039d21..29e7615 100644
11409 --- a/arch/x86/crypto/twofish-x86_64-asm_64.S
11410 +++ b/arch/x86/crypto/twofish-x86_64-asm_64.S
11411 @@ -22,6 +22,7 @@
11412
11413 #include <linux/linkage.h>
11414 #include <asm/asm-offsets.h>
11415 +#include <asm/alternative-asm.h>
11416
11417 #define a_offset 0
11418 #define b_offset 4
11419 @@ -265,6 +266,7 @@ ENTRY(twofish_enc_blk)
11420
11421 popq R1
11422 movq $1,%rax
11423 + pax_force_retaddr 0, 1
11424 ret
11425 ENDPROC(twofish_enc_blk)
11426
11427 @@ -317,5 +319,6 @@ ENTRY(twofish_dec_blk)
11428
11429 popq R1
11430 movq $1,%rax
11431 + pax_force_retaddr 0, 1
11432 ret
11433 ENDPROC(twofish_dec_blk)
11434 diff --git a/arch/x86/ia32/ia32_aout.c b/arch/x86/ia32/ia32_aout.c
11435 index 03abf9b..a42ba29 100644
11436 --- a/arch/x86/ia32/ia32_aout.c
11437 +++ b/arch/x86/ia32/ia32_aout.c
11438 @@ -159,6 +159,8 @@ static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file,
11439 unsigned long dump_start, dump_size;
11440 struct user32 dump;
11441
11442 + memset(&dump, 0, sizeof(dump));
11443 +
11444 fs = get_fs();
11445 set_fs(KERNEL_DS);
11446 has_dumped = 1;
11447 diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
11448 index cf1a471..3bc4cf8 100644
11449 --- a/arch/x86/ia32/ia32_signal.c
11450 +++ b/arch/x86/ia32/ia32_signal.c
11451 @@ -340,7 +340,7 @@ static void __user *get_sigframe(struct ksignal *ksig, struct pt_regs *regs,
11452 sp -= frame_size;
11453 /* Align the stack pointer according to the i386 ABI,
11454 * i.e. so that on function entry ((sp + 4) & 15) == 0. */
11455 - sp = ((sp + 4) & -16ul) - 4;
11456 + sp = ((sp - 12) & -16ul) - 4;
11457 return (void __user *) sp;
11458 }
11459
11460 @@ -398,7 +398,7 @@ int ia32_setup_frame(int sig, struct ksignal *ksig,
11461 * These are actually not used anymore, but left because some
11462 * gdb versions depend on them as a marker.
11463 */
11464 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
11465 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
11466 } put_user_catch(err);
11467
11468 if (err)
11469 @@ -440,7 +440,7 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
11470 0xb8,
11471 __NR_ia32_rt_sigreturn,
11472 0x80cd,
11473 - 0,
11474 + 0
11475 };
11476
11477 frame = get_sigframe(ksig, regs, sizeof(*frame), &fpstate);
11478 @@ -463,16 +463,18 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
11479
11480 if (ksig->ka.sa.sa_flags & SA_RESTORER)
11481 restorer = ksig->ka.sa.sa_restorer;
11482 + else if (current->mm->context.vdso)
11483 + /* Return stub is in 32bit vsyscall page */
11484 + restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
11485 else
11486 - restorer = VDSO32_SYMBOL(current->mm->context.vdso,
11487 - rt_sigreturn);
11488 + restorer = &frame->retcode;
11489 put_user_ex(ptr_to_compat(restorer), &frame->pretcode);
11490
11491 /*
11492 * Not actually used anymore, but left because some gdb
11493 * versions need it.
11494 */
11495 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
11496 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
11497 } put_user_catch(err);
11498
11499 err |= copy_siginfo_to_user32(&frame->info, &ksig->info);
11500 diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
11501 index 474dc1b..be7bff5 100644
11502 --- a/arch/x86/ia32/ia32entry.S
11503 +++ b/arch/x86/ia32/ia32entry.S
11504 @@ -15,8 +15,10 @@
11505 #include <asm/irqflags.h>
11506 #include <asm/asm.h>
11507 #include <asm/smap.h>
11508 +#include <asm/pgtable.h>
11509 #include <linux/linkage.h>
11510 #include <linux/err.h>
11511 +#include <asm/alternative-asm.h>
11512
11513 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
11514 #include <linux/elf-em.h>
11515 @@ -96,6 +98,32 @@ ENTRY(native_irq_enable_sysexit)
11516 ENDPROC(native_irq_enable_sysexit)
11517 #endif
11518
11519 + .macro pax_enter_kernel_user
11520 + pax_set_fptr_mask
11521 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11522 + call pax_enter_kernel_user
11523 +#endif
11524 + .endm
11525 +
11526 + .macro pax_exit_kernel_user
11527 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11528 + call pax_exit_kernel_user
11529 +#endif
11530 +#ifdef CONFIG_PAX_RANDKSTACK
11531 + pushq %rax
11532 + pushq %r11
11533 + call pax_randomize_kstack
11534 + popq %r11
11535 + popq %rax
11536 +#endif
11537 + .endm
11538 +
11539 +.macro pax_erase_kstack
11540 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
11541 + call pax_erase_kstack
11542 +#endif
11543 +.endm
11544 +
11545 /*
11546 * 32bit SYSENTER instruction entry.
11547 *
11548 @@ -122,12 +150,6 @@ ENTRY(ia32_sysenter_target)
11549 CFI_REGISTER rsp,rbp
11550 SWAPGS_UNSAFE_STACK
11551 movq PER_CPU_VAR(kernel_stack), %rsp
11552 - addq $(KERNEL_STACK_OFFSET),%rsp
11553 - /*
11554 - * No need to follow this irqs on/off section: the syscall
11555 - * disabled irqs, here we enable it straight after entry:
11556 - */
11557 - ENABLE_INTERRUPTS(CLBR_NONE)
11558 movl %ebp,%ebp /* zero extension */
11559 pushq_cfi $__USER32_DS
11560 /*CFI_REL_OFFSET ss,0*/
11561 @@ -135,24 +157,44 @@ ENTRY(ia32_sysenter_target)
11562 CFI_REL_OFFSET rsp,0
11563 pushfq_cfi
11564 /*CFI_REL_OFFSET rflags,0*/
11565 - movl TI_sysenter_return+THREAD_INFO(%rsp,3*8-KERNEL_STACK_OFFSET),%r10d
11566 - CFI_REGISTER rip,r10
11567 + orl $X86_EFLAGS_IF,(%rsp)
11568 + GET_THREAD_INFO(%r11)
11569 + movl TI_sysenter_return(%r11), %r11d
11570 + CFI_REGISTER rip,r11
11571 pushq_cfi $__USER32_CS
11572 /*CFI_REL_OFFSET cs,0*/
11573 movl %eax, %eax
11574 - pushq_cfi %r10
11575 + pushq_cfi %r11
11576 CFI_REL_OFFSET rip,0
11577 pushq_cfi %rax
11578 cld
11579 SAVE_ARGS 0,1,0
11580 + pax_enter_kernel_user
11581 +
11582 +#ifdef CONFIG_PAX_RANDKSTACK
11583 + pax_erase_kstack
11584 +#endif
11585 +
11586 + /*
11587 + * No need to follow this irqs on/off section: the syscall
11588 + * disabled irqs, here we enable it straight after entry:
11589 + */
11590 + ENABLE_INTERRUPTS(CLBR_NONE)
11591 /* no need to do an access_ok check here because rbp has been
11592 32bit zero extended */
11593 +
11594 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11595 + mov pax_user_shadow_base,%r11
11596 + add %r11,%rbp
11597 +#endif
11598 +
11599 ASM_STAC
11600 1: movl (%rbp),%ebp
11601 _ASM_EXTABLE(1b,ia32_badarg)
11602 ASM_CLAC
11603 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11604 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11605 + GET_THREAD_INFO(%r11)
11606 + orl $TS_COMPAT,TI_status(%r11)
11607 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
11608 CFI_REMEMBER_STATE
11609 jnz sysenter_tracesys
11610 cmpq $(IA32_NR_syscalls-1),%rax
11611 @@ -162,12 +204,15 @@ sysenter_do_call:
11612 sysenter_dispatch:
11613 call *ia32_sys_call_table(,%rax,8)
11614 movq %rax,RAX-ARGOFFSET(%rsp)
11615 + GET_THREAD_INFO(%r11)
11616 DISABLE_INTERRUPTS(CLBR_NONE)
11617 TRACE_IRQS_OFF
11618 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11619 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
11620 jnz sysexit_audit
11621 sysexit_from_sys_call:
11622 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11623 + pax_exit_kernel_user
11624 + pax_erase_kstack
11625 + andl $~TS_COMPAT,TI_status(%r11)
11626 /* clear IF, that popfq doesn't enable interrupts early */
11627 andl $~0x200,EFLAGS-R11(%rsp)
11628 movl RIP-R11(%rsp),%edx /* User %eip */
11629 @@ -193,6 +238,9 @@ sysexit_from_sys_call:
11630 movl %eax,%esi /* 2nd arg: syscall number */
11631 movl $AUDIT_ARCH_I386,%edi /* 1st arg: audit arch */
11632 call __audit_syscall_entry
11633 +
11634 + pax_erase_kstack
11635 +
11636 movl RAX-ARGOFFSET(%rsp),%eax /* reload syscall number */
11637 cmpq $(IA32_NR_syscalls-1),%rax
11638 ja ia32_badsys
11639 @@ -204,7 +252,7 @@ sysexit_from_sys_call:
11640 .endm
11641
11642 .macro auditsys_exit exit
11643 - testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11644 + testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
11645 jnz ia32_ret_from_sys_call
11646 TRACE_IRQS_ON
11647 ENABLE_INTERRUPTS(CLBR_NONE)
11648 @@ -215,11 +263,12 @@ sysexit_from_sys_call:
11649 1: setbe %al /* 1 if error, 0 if not */
11650 movzbl %al,%edi /* zero-extend that into %edi */
11651 call __audit_syscall_exit
11652 + GET_THREAD_INFO(%r11)
11653 movq RAX-ARGOFFSET(%rsp),%rax /* reload syscall return value */
11654 movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),%edi
11655 DISABLE_INTERRUPTS(CLBR_NONE)
11656 TRACE_IRQS_OFF
11657 - testl %edi,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11658 + testl %edi,TI_flags(%r11)
11659 jz \exit
11660 CLEAR_RREGS -ARGOFFSET
11661 jmp int_with_check
11662 @@ -237,7 +286,7 @@ sysexit_audit:
11663
11664 sysenter_tracesys:
11665 #ifdef CONFIG_AUDITSYSCALL
11666 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11667 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
11668 jz sysenter_auditsys
11669 #endif
11670 SAVE_REST
11671 @@ -249,6 +298,9 @@ sysenter_tracesys:
11672 RESTORE_REST
11673 cmpq $(IA32_NR_syscalls-1),%rax
11674 ja int_ret_from_sys_call /* sysenter_tracesys has set RAX(%rsp) */
11675 +
11676 + pax_erase_kstack
11677 +
11678 jmp sysenter_do_call
11679 CFI_ENDPROC
11680 ENDPROC(ia32_sysenter_target)
11681 @@ -276,19 +328,25 @@ ENDPROC(ia32_sysenter_target)
11682 ENTRY(ia32_cstar_target)
11683 CFI_STARTPROC32 simple
11684 CFI_SIGNAL_FRAME
11685 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
11686 + CFI_DEF_CFA rsp,0
11687 CFI_REGISTER rip,rcx
11688 /*CFI_REGISTER rflags,r11*/
11689 SWAPGS_UNSAFE_STACK
11690 movl %esp,%r8d
11691 CFI_REGISTER rsp,r8
11692 movq PER_CPU_VAR(kernel_stack),%rsp
11693 + SAVE_ARGS 8*6,0,0
11694 + pax_enter_kernel_user
11695 +
11696 +#ifdef CONFIG_PAX_RANDKSTACK
11697 + pax_erase_kstack
11698 +#endif
11699 +
11700 /*
11701 * No need to follow this irqs on/off section: the syscall
11702 * disabled irqs and here we enable it straight after entry:
11703 */
11704 ENABLE_INTERRUPTS(CLBR_NONE)
11705 - SAVE_ARGS 8,0,0
11706 movl %eax,%eax /* zero extension */
11707 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
11708 movq %rcx,RIP-ARGOFFSET(%rsp)
11709 @@ -304,12 +362,19 @@ ENTRY(ia32_cstar_target)
11710 /* no need to do an access_ok check here because r8 has been
11711 32bit zero extended */
11712 /* hardware stack frame is complete now */
11713 +
11714 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11715 + mov pax_user_shadow_base,%r11
11716 + add %r11,%r8
11717 +#endif
11718 +
11719 ASM_STAC
11720 1: movl (%r8),%r9d
11721 _ASM_EXTABLE(1b,ia32_badarg)
11722 ASM_CLAC
11723 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11724 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11725 + GET_THREAD_INFO(%r11)
11726 + orl $TS_COMPAT,TI_status(%r11)
11727 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
11728 CFI_REMEMBER_STATE
11729 jnz cstar_tracesys
11730 cmpq $IA32_NR_syscalls-1,%rax
11731 @@ -319,12 +384,15 @@ cstar_do_call:
11732 cstar_dispatch:
11733 call *ia32_sys_call_table(,%rax,8)
11734 movq %rax,RAX-ARGOFFSET(%rsp)
11735 + GET_THREAD_INFO(%r11)
11736 DISABLE_INTERRUPTS(CLBR_NONE)
11737 TRACE_IRQS_OFF
11738 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11739 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
11740 jnz sysretl_audit
11741 sysretl_from_sys_call:
11742 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11743 + pax_exit_kernel_user
11744 + pax_erase_kstack
11745 + andl $~TS_COMPAT,TI_status(%r11)
11746 RESTORE_ARGS 0,-ARG_SKIP,0,0,0
11747 movl RIP-ARGOFFSET(%rsp),%ecx
11748 CFI_REGISTER rip,rcx
11749 @@ -352,7 +420,7 @@ sysretl_audit:
11750
11751 cstar_tracesys:
11752 #ifdef CONFIG_AUDITSYSCALL
11753 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11754 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
11755 jz cstar_auditsys
11756 #endif
11757 xchgl %r9d,%ebp
11758 @@ -366,6 +434,9 @@ cstar_tracesys:
11759 xchgl %ebp,%r9d
11760 cmpq $(IA32_NR_syscalls-1),%rax
11761 ja int_ret_from_sys_call /* cstar_tracesys has set RAX(%rsp) */
11762 +
11763 + pax_erase_kstack
11764 +
11765 jmp cstar_do_call
11766 END(ia32_cstar_target)
11767
11768 @@ -407,19 +478,26 @@ ENTRY(ia32_syscall)
11769 CFI_REL_OFFSET rip,RIP-RIP
11770 PARAVIRT_ADJUST_EXCEPTION_FRAME
11771 SWAPGS
11772 - /*
11773 - * No need to follow this irqs on/off section: the syscall
11774 - * disabled irqs and here we enable it straight after entry:
11775 - */
11776 - ENABLE_INTERRUPTS(CLBR_NONE)
11777 movl %eax,%eax
11778 pushq_cfi %rax
11779 cld
11780 /* note the registers are not zero extended to the sf.
11781 this could be a problem. */
11782 SAVE_ARGS 0,1,0
11783 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11784 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11785 + pax_enter_kernel_user
11786 +
11787 +#ifdef CONFIG_PAX_RANDKSTACK
11788 + pax_erase_kstack
11789 +#endif
11790 +
11791 + /*
11792 + * No need to follow this irqs on/off section: the syscall
11793 + * disabled irqs and here we enable it straight after entry:
11794 + */
11795 + ENABLE_INTERRUPTS(CLBR_NONE)
11796 + GET_THREAD_INFO(%r11)
11797 + orl $TS_COMPAT,TI_status(%r11)
11798 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
11799 jnz ia32_tracesys
11800 cmpq $(IA32_NR_syscalls-1),%rax
11801 ja ia32_badsys
11802 @@ -442,6 +520,9 @@ ia32_tracesys:
11803 RESTORE_REST
11804 cmpq $(IA32_NR_syscalls-1),%rax
11805 ja int_ret_from_sys_call /* ia32_tracesys has set RAX(%rsp) */
11806 +
11807 + pax_erase_kstack
11808 +
11809 jmp ia32_do_call
11810 END(ia32_syscall)
11811
11812 diff --git a/arch/x86/ia32/sys_ia32.c b/arch/x86/ia32/sys_ia32.c
11813 index ad7a20c..1ffa3c1 100644
11814 --- a/arch/x86/ia32/sys_ia32.c
11815 +++ b/arch/x86/ia32/sys_ia32.c
11816 @@ -69,8 +69,8 @@ asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long offset_low,
11817 */
11818 static int cp_stat64(struct stat64 __user *ubuf, struct kstat *stat)
11819 {
11820 - typeof(ubuf->st_uid) uid = 0;
11821 - typeof(ubuf->st_gid) gid = 0;
11822 + typeof(((struct stat64 *)0)->st_uid) uid = 0;
11823 + typeof(((struct stat64 *)0)->st_gid) gid = 0;
11824 SET_UID(uid, from_kuid_munged(current_user_ns(), stat->uid));
11825 SET_GID(gid, from_kgid_munged(current_user_ns(), stat->gid));
11826 if (!access_ok(VERIFY_WRITE, ubuf, sizeof(struct stat64)) ||
11827 @@ -205,7 +205,7 @@ asmlinkage long sys32_sendfile(int out_fd, int in_fd,
11828 return -EFAULT;
11829
11830 set_fs(KERNEL_DS);
11831 - ret = sys_sendfile(out_fd, in_fd, offset ? (off_t __user *)&of : NULL,
11832 + ret = sys_sendfile(out_fd, in_fd, offset ? (off_t __force_user *)&of : NULL,
11833 count);
11834 set_fs(old_fs);
11835
11836 diff --git a/arch/x86/include/asm/alternative-asm.h b/arch/x86/include/asm/alternative-asm.h
11837 index 372231c..a5aa1a1 100644
11838 --- a/arch/x86/include/asm/alternative-asm.h
11839 +++ b/arch/x86/include/asm/alternative-asm.h
11840 @@ -18,6 +18,45 @@
11841 .endm
11842 #endif
11843
11844 +#ifdef KERNEXEC_PLUGIN
11845 + .macro pax_force_retaddr_bts rip=0
11846 + btsq $63,\rip(%rsp)
11847 + .endm
11848 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
11849 + .macro pax_force_retaddr rip=0, reload=0
11850 + btsq $63,\rip(%rsp)
11851 + .endm
11852 + .macro pax_force_fptr ptr
11853 + btsq $63,\ptr
11854 + .endm
11855 + .macro pax_set_fptr_mask
11856 + .endm
11857 +#endif
11858 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
11859 + .macro pax_force_retaddr rip=0, reload=0
11860 + .if \reload
11861 + pax_set_fptr_mask
11862 + .endif
11863 + orq %r10,\rip(%rsp)
11864 + .endm
11865 + .macro pax_force_fptr ptr
11866 + orq %r10,\ptr
11867 + .endm
11868 + .macro pax_set_fptr_mask
11869 + movabs $0x8000000000000000,%r10
11870 + .endm
11871 +#endif
11872 +#else
11873 + .macro pax_force_retaddr rip=0, reload=0
11874 + .endm
11875 + .macro pax_force_fptr ptr
11876 + .endm
11877 + .macro pax_force_retaddr_bts rip=0
11878 + .endm
11879 + .macro pax_set_fptr_mask
11880 + .endm
11881 +#endif
11882 +
11883 .macro altinstruction_entry orig alt feature orig_len alt_len
11884 .long \orig - .
11885 .long \alt - .
11886 diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h
11887 index 58ed6d9..f1cbe58 100644
11888 --- a/arch/x86/include/asm/alternative.h
11889 +++ b/arch/x86/include/asm/alternative.h
11890 @@ -105,7 +105,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
11891 ".pushsection .discard,\"aw\",@progbits\n" \
11892 DISCARD_ENTRY(1) \
11893 ".popsection\n" \
11894 - ".pushsection .altinstr_replacement, \"ax\"\n" \
11895 + ".pushsection .altinstr_replacement, \"a\"\n" \
11896 ALTINSTR_REPLACEMENT(newinstr, feature, 1) \
11897 ".popsection"
11898
11899 @@ -119,7 +119,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
11900 DISCARD_ENTRY(1) \
11901 DISCARD_ENTRY(2) \
11902 ".popsection\n" \
11903 - ".pushsection .altinstr_replacement, \"ax\"\n" \
11904 + ".pushsection .altinstr_replacement, \"a\"\n" \
11905 ALTINSTR_REPLACEMENT(newinstr1, feature1, 1) \
11906 ALTINSTR_REPLACEMENT(newinstr2, feature2, 2) \
11907 ".popsection"
11908 diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
11909 index 3388034..050f0b9 100644
11910 --- a/arch/x86/include/asm/apic.h
11911 +++ b/arch/x86/include/asm/apic.h
11912 @@ -44,7 +44,7 @@ static inline void generic_apic_probe(void)
11913
11914 #ifdef CONFIG_X86_LOCAL_APIC
11915
11916 -extern unsigned int apic_verbosity;
11917 +extern int apic_verbosity;
11918 extern int local_apic_timer_c2_ok;
11919
11920 extern int disable_apic;
11921 diff --git a/arch/x86/include/asm/apm.h b/arch/x86/include/asm/apm.h
11922 index 20370c6..a2eb9b0 100644
11923 --- a/arch/x86/include/asm/apm.h
11924 +++ b/arch/x86/include/asm/apm.h
11925 @@ -34,7 +34,7 @@ static inline void apm_bios_call_asm(u32 func, u32 ebx_in, u32 ecx_in,
11926 __asm__ __volatile__(APM_DO_ZERO_SEGS
11927 "pushl %%edi\n\t"
11928 "pushl %%ebp\n\t"
11929 - "lcall *%%cs:apm_bios_entry\n\t"
11930 + "lcall *%%ss:apm_bios_entry\n\t"
11931 "setc %%al\n\t"
11932 "popl %%ebp\n\t"
11933 "popl %%edi\n\t"
11934 @@ -58,7 +58,7 @@ static inline u8 apm_bios_call_simple_asm(u32 func, u32 ebx_in,
11935 __asm__ __volatile__(APM_DO_ZERO_SEGS
11936 "pushl %%edi\n\t"
11937 "pushl %%ebp\n\t"
11938 - "lcall *%%cs:apm_bios_entry\n\t"
11939 + "lcall *%%ss:apm_bios_entry\n\t"
11940 "setc %%bl\n\t"
11941 "popl %%ebp\n\t"
11942 "popl %%edi\n\t"
11943 diff --git a/arch/x86/include/asm/atomic.h b/arch/x86/include/asm/atomic.h
11944 index 722aa3b..3a0bb27 100644
11945 --- a/arch/x86/include/asm/atomic.h
11946 +++ b/arch/x86/include/asm/atomic.h
11947 @@ -22,7 +22,18 @@
11948 */
11949 static inline int atomic_read(const atomic_t *v)
11950 {
11951 - return (*(volatile int *)&(v)->counter);
11952 + return (*(volatile const int *)&(v)->counter);
11953 +}
11954 +
11955 +/**
11956 + * atomic_read_unchecked - read atomic variable
11957 + * @v: pointer of type atomic_unchecked_t
11958 + *
11959 + * Atomically reads the value of @v.
11960 + */
11961 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
11962 +{
11963 + return (*(volatile const int *)&(v)->counter);
11964 }
11965
11966 /**
11967 @@ -38,6 +49,18 @@ static inline void atomic_set(atomic_t *v, int i)
11968 }
11969
11970 /**
11971 + * atomic_set_unchecked - set atomic variable
11972 + * @v: pointer of type atomic_unchecked_t
11973 + * @i: required value
11974 + *
11975 + * Atomically sets the value of @v to @i.
11976 + */
11977 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
11978 +{
11979 + v->counter = i;
11980 +}
11981 +
11982 +/**
11983 * atomic_add - add integer to atomic variable
11984 * @i: integer value to add
11985 * @v: pointer of type atomic_t
11986 @@ -46,7 +69,29 @@ static inline void atomic_set(atomic_t *v, int i)
11987 */
11988 static inline void atomic_add(int i, atomic_t *v)
11989 {
11990 - asm volatile(LOCK_PREFIX "addl %1,%0"
11991 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
11992 +
11993 +#ifdef CONFIG_PAX_REFCOUNT
11994 + "jno 0f\n"
11995 + LOCK_PREFIX "subl %1,%0\n"
11996 + "int $4\n0:\n"
11997 + _ASM_EXTABLE(0b, 0b)
11998 +#endif
11999 +
12000 + : "+m" (v->counter)
12001 + : "ir" (i));
12002 +}
12003 +
12004 +/**
12005 + * atomic_add_unchecked - add integer to atomic variable
12006 + * @i: integer value to add
12007 + * @v: pointer of type atomic_unchecked_t
12008 + *
12009 + * Atomically adds @i to @v.
12010 + */
12011 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
12012 +{
12013 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
12014 : "+m" (v->counter)
12015 : "ir" (i));
12016 }
12017 @@ -60,7 +105,29 @@ static inline void atomic_add(int i, atomic_t *v)
12018 */
12019 static inline void atomic_sub(int i, atomic_t *v)
12020 {
12021 - asm volatile(LOCK_PREFIX "subl %1,%0"
12022 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
12023 +
12024 +#ifdef CONFIG_PAX_REFCOUNT
12025 + "jno 0f\n"
12026 + LOCK_PREFIX "addl %1,%0\n"
12027 + "int $4\n0:\n"
12028 + _ASM_EXTABLE(0b, 0b)
12029 +#endif
12030 +
12031 + : "+m" (v->counter)
12032 + : "ir" (i));
12033 +}
12034 +
12035 +/**
12036 + * atomic_sub_unchecked - subtract integer from atomic variable
12037 + * @i: integer value to subtract
12038 + * @v: pointer of type atomic_unchecked_t
12039 + *
12040 + * Atomically subtracts @i from @v.
12041 + */
12042 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
12043 +{
12044 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
12045 : "+m" (v->counter)
12046 : "ir" (i));
12047 }
12048 @@ -78,7 +145,16 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
12049 {
12050 unsigned char c;
12051
12052 - asm volatile(LOCK_PREFIX "subl %2,%0; sete %1"
12053 + asm volatile(LOCK_PREFIX "subl %2,%0\n"
12054 +
12055 +#ifdef CONFIG_PAX_REFCOUNT
12056 + "jno 0f\n"
12057 + LOCK_PREFIX "addl %2,%0\n"
12058 + "int $4\n0:\n"
12059 + _ASM_EXTABLE(0b, 0b)
12060 +#endif
12061 +
12062 + "sete %1\n"
12063 : "+m" (v->counter), "=qm" (c)
12064 : "ir" (i) : "memory");
12065 return c;
12066 @@ -92,7 +168,27 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
12067 */
12068 static inline void atomic_inc(atomic_t *v)
12069 {
12070 - asm volatile(LOCK_PREFIX "incl %0"
12071 + asm volatile(LOCK_PREFIX "incl %0\n"
12072 +
12073 +#ifdef CONFIG_PAX_REFCOUNT
12074 + "jno 0f\n"
12075 + LOCK_PREFIX "decl %0\n"
12076 + "int $4\n0:\n"
12077 + _ASM_EXTABLE(0b, 0b)
12078 +#endif
12079 +
12080 + : "+m" (v->counter));
12081 +}
12082 +
12083 +/**
12084 + * atomic_inc_unchecked - increment atomic variable
12085 + * @v: pointer of type atomic_unchecked_t
12086 + *
12087 + * Atomically increments @v by 1.
12088 + */
12089 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
12090 +{
12091 + asm volatile(LOCK_PREFIX "incl %0\n"
12092 : "+m" (v->counter));
12093 }
12094
12095 @@ -104,7 +200,27 @@ static inline void atomic_inc(atomic_t *v)
12096 */
12097 static inline void atomic_dec(atomic_t *v)
12098 {
12099 - asm volatile(LOCK_PREFIX "decl %0"
12100 + asm volatile(LOCK_PREFIX "decl %0\n"
12101 +
12102 +#ifdef CONFIG_PAX_REFCOUNT
12103 + "jno 0f\n"
12104 + LOCK_PREFIX "incl %0\n"
12105 + "int $4\n0:\n"
12106 + _ASM_EXTABLE(0b, 0b)
12107 +#endif
12108 +
12109 + : "+m" (v->counter));
12110 +}
12111 +
12112 +/**
12113 + * atomic_dec_unchecked - decrement atomic variable
12114 + * @v: pointer of type atomic_unchecked_t
12115 + *
12116 + * Atomically decrements @v by 1.
12117 + */
12118 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
12119 +{
12120 + asm volatile(LOCK_PREFIX "decl %0\n"
12121 : "+m" (v->counter));
12122 }
12123
12124 @@ -120,7 +236,16 @@ static inline int atomic_dec_and_test(atomic_t *v)
12125 {
12126 unsigned char c;
12127
12128 - asm volatile(LOCK_PREFIX "decl %0; sete %1"
12129 + asm volatile(LOCK_PREFIX "decl %0\n"
12130 +
12131 +#ifdef CONFIG_PAX_REFCOUNT
12132 + "jno 0f\n"
12133 + LOCK_PREFIX "incl %0\n"
12134 + "int $4\n0:\n"
12135 + _ASM_EXTABLE(0b, 0b)
12136 +#endif
12137 +
12138 + "sete %1\n"
12139 : "+m" (v->counter), "=qm" (c)
12140 : : "memory");
12141 return c != 0;
12142 @@ -138,7 +263,35 @@ static inline int atomic_inc_and_test(atomic_t *v)
12143 {
12144 unsigned char c;
12145
12146 - asm volatile(LOCK_PREFIX "incl %0; sete %1"
12147 + asm volatile(LOCK_PREFIX "incl %0\n"
12148 +
12149 +#ifdef CONFIG_PAX_REFCOUNT
12150 + "jno 0f\n"
12151 + LOCK_PREFIX "decl %0\n"
12152 + "int $4\n0:\n"
12153 + _ASM_EXTABLE(0b, 0b)
12154 +#endif
12155 +
12156 + "sete %1\n"
12157 + : "+m" (v->counter), "=qm" (c)
12158 + : : "memory");
12159 + return c != 0;
12160 +}
12161 +
12162 +/**
12163 + * atomic_inc_and_test_unchecked - increment and test
12164 + * @v: pointer of type atomic_unchecked_t
12165 + *
12166 + * Atomically increments @v by 1
12167 + * and returns true if the result is zero, or false for all
12168 + * other cases.
12169 + */
12170 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
12171 +{
12172 + unsigned char c;
12173 +
12174 + asm volatile(LOCK_PREFIX "incl %0\n"
12175 + "sete %1\n"
12176 : "+m" (v->counter), "=qm" (c)
12177 : : "memory");
12178 return c != 0;
12179 @@ -157,7 +310,16 @@ static inline int atomic_add_negative(int i, atomic_t *v)
12180 {
12181 unsigned char c;
12182
12183 - asm volatile(LOCK_PREFIX "addl %2,%0; sets %1"
12184 + asm volatile(LOCK_PREFIX "addl %2,%0\n"
12185 +
12186 +#ifdef CONFIG_PAX_REFCOUNT
12187 + "jno 0f\n"
12188 + LOCK_PREFIX "subl %2,%0\n"
12189 + "int $4\n0:\n"
12190 + _ASM_EXTABLE(0b, 0b)
12191 +#endif
12192 +
12193 + "sets %1\n"
12194 : "+m" (v->counter), "=qm" (c)
12195 : "ir" (i) : "memory");
12196 return c;
12197 @@ -172,6 +334,18 @@ static inline int atomic_add_negative(int i, atomic_t *v)
12198 */
12199 static inline int atomic_add_return(int i, atomic_t *v)
12200 {
12201 + return i + xadd_check_overflow(&v->counter, i);
12202 +}
12203 +
12204 +/**
12205 + * atomic_add_return_unchecked - add integer and return
12206 + * @i: integer value to add
12207 + * @v: pointer of type atomic_unchecked_t
12208 + *
12209 + * Atomically adds @i to @v and returns @i + @v
12210 + */
12211 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
12212 +{
12213 return i + xadd(&v->counter, i);
12214 }
12215
12216 @@ -188,6 +362,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
12217 }
12218
12219 #define atomic_inc_return(v) (atomic_add_return(1, v))
12220 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
12221 +{
12222 + return atomic_add_return_unchecked(1, v);
12223 +}
12224 #define atomic_dec_return(v) (atomic_sub_return(1, v))
12225
12226 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
12227 @@ -195,11 +373,21 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
12228 return cmpxchg(&v->counter, old, new);
12229 }
12230
12231 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
12232 +{
12233 + return cmpxchg(&v->counter, old, new);
12234 +}
12235 +
12236 static inline int atomic_xchg(atomic_t *v, int new)
12237 {
12238 return xchg(&v->counter, new);
12239 }
12240
12241 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
12242 +{
12243 + return xchg(&v->counter, new);
12244 +}
12245 +
12246 /**
12247 * __atomic_add_unless - add unless the number is already a given value
12248 * @v: pointer of type atomic_t
12249 @@ -211,12 +399,25 @@ static inline int atomic_xchg(atomic_t *v, int new)
12250 */
12251 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
12252 {
12253 - int c, old;
12254 + int c, old, new;
12255 c = atomic_read(v);
12256 for (;;) {
12257 - if (unlikely(c == (u)))
12258 + if (unlikely(c == u))
12259 break;
12260 - old = atomic_cmpxchg((v), c, c + (a));
12261 +
12262 + asm volatile("addl %2,%0\n"
12263 +
12264 +#ifdef CONFIG_PAX_REFCOUNT
12265 + "jno 0f\n"
12266 + "subl %2,%0\n"
12267 + "int $4\n0:\n"
12268 + _ASM_EXTABLE(0b, 0b)
12269 +#endif
12270 +
12271 + : "=r" (new)
12272 + : "0" (c), "ir" (a));
12273 +
12274 + old = atomic_cmpxchg(v, c, new);
12275 if (likely(old == c))
12276 break;
12277 c = old;
12278 @@ -225,6 +426,49 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
12279 }
12280
12281 /**
12282 + * atomic_inc_not_zero_hint - increment if not null
12283 + * @v: pointer of type atomic_t
12284 + * @hint: probable value of the atomic before the increment
12285 + *
12286 + * This version of atomic_inc_not_zero() gives a hint of probable
12287 + * value of the atomic. This helps processor to not read the memory
12288 + * before doing the atomic read/modify/write cycle, lowering
12289 + * number of bus transactions on some arches.
12290 + *
12291 + * Returns: 0 if increment was not done, 1 otherwise.
12292 + */
12293 +#define atomic_inc_not_zero_hint atomic_inc_not_zero_hint
12294 +static inline int atomic_inc_not_zero_hint(atomic_t *v, int hint)
12295 +{
12296 + int val, c = hint, new;
12297 +
12298 + /* sanity test, should be removed by compiler if hint is a constant */
12299 + if (!hint)
12300 + return __atomic_add_unless(v, 1, 0);
12301 +
12302 + do {
12303 + asm volatile("incl %0\n"
12304 +
12305 +#ifdef CONFIG_PAX_REFCOUNT
12306 + "jno 0f\n"
12307 + "decl %0\n"
12308 + "int $4\n0:\n"
12309 + _ASM_EXTABLE(0b, 0b)
12310 +#endif
12311 +
12312 + : "=r" (new)
12313 + : "0" (c));
12314 +
12315 + val = atomic_cmpxchg(v, c, new);
12316 + if (val == c)
12317 + return 1;
12318 + c = val;
12319 + } while (c);
12320 +
12321 + return 0;
12322 +}
12323 +
12324 +/**
12325 * atomic_inc_short - increment of a short integer
12326 * @v: pointer to type int
12327 *
12328 @@ -253,14 +497,37 @@ static inline void atomic_or_long(unsigned long *v1, unsigned long v2)
12329 #endif
12330
12331 /* These are x86-specific, used by some header files */
12332 -#define atomic_clear_mask(mask, addr) \
12333 - asm volatile(LOCK_PREFIX "andl %0,%1" \
12334 - : : "r" (~(mask)), "m" (*(addr)) : "memory")
12335 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
12336 +{
12337 + asm volatile(LOCK_PREFIX "andl %1,%0"
12338 + : "+m" (v->counter)
12339 + : "r" (~(mask))
12340 + : "memory");
12341 +}
12342
12343 -#define atomic_set_mask(mask, addr) \
12344 - asm volatile(LOCK_PREFIX "orl %0,%1" \
12345 - : : "r" ((unsigned)(mask)), "m" (*(addr)) \
12346 - : "memory")
12347 +static inline void atomic_clear_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
12348 +{
12349 + asm volatile(LOCK_PREFIX "andl %1,%0"
12350 + : "+m" (v->counter)
12351 + : "r" (~(mask))
12352 + : "memory");
12353 +}
12354 +
12355 +static inline void atomic_set_mask(unsigned int mask, atomic_t *v)
12356 +{
12357 + asm volatile(LOCK_PREFIX "orl %1,%0"
12358 + : "+m" (v->counter)
12359 + : "r" (mask)
12360 + : "memory");
12361 +}
12362 +
12363 +static inline void atomic_set_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
12364 +{
12365 + asm volatile(LOCK_PREFIX "orl %1,%0"
12366 + : "+m" (v->counter)
12367 + : "r" (mask)
12368 + : "memory");
12369 +}
12370
12371 /* Atomic operations are already serializing on x86 */
12372 #define smp_mb__before_atomic_dec() barrier()
12373 diff --git a/arch/x86/include/asm/atomic64_32.h b/arch/x86/include/asm/atomic64_32.h
12374 index b154de7..aadebd8 100644
12375 --- a/arch/x86/include/asm/atomic64_32.h
12376 +++ b/arch/x86/include/asm/atomic64_32.h
12377 @@ -12,6 +12,14 @@ typedef struct {
12378 u64 __aligned(8) counter;
12379 } atomic64_t;
12380
12381 +#ifdef CONFIG_PAX_REFCOUNT
12382 +typedef struct {
12383 + u64 __aligned(8) counter;
12384 +} atomic64_unchecked_t;
12385 +#else
12386 +typedef atomic64_t atomic64_unchecked_t;
12387 +#endif
12388 +
12389 #define ATOMIC64_INIT(val) { (val) }
12390
12391 #define __ATOMIC64_DECL(sym) void atomic64_##sym(atomic64_t *, ...)
12392 @@ -37,21 +45,31 @@ typedef struct {
12393 ATOMIC64_DECL_ONE(sym##_386)
12394
12395 ATOMIC64_DECL_ONE(add_386);
12396 +ATOMIC64_DECL_ONE(add_unchecked_386);
12397 ATOMIC64_DECL_ONE(sub_386);
12398 +ATOMIC64_DECL_ONE(sub_unchecked_386);
12399 ATOMIC64_DECL_ONE(inc_386);
12400 +ATOMIC64_DECL_ONE(inc_unchecked_386);
12401 ATOMIC64_DECL_ONE(dec_386);
12402 +ATOMIC64_DECL_ONE(dec_unchecked_386);
12403 #endif
12404
12405 #define alternative_atomic64(f, out, in...) \
12406 __alternative_atomic64(f, f, ASM_OUTPUT2(out), ## in)
12407
12408 ATOMIC64_DECL(read);
12409 +ATOMIC64_DECL(read_unchecked);
12410 ATOMIC64_DECL(set);
12411 +ATOMIC64_DECL(set_unchecked);
12412 ATOMIC64_DECL(xchg);
12413 ATOMIC64_DECL(add_return);
12414 +ATOMIC64_DECL(add_return_unchecked);
12415 ATOMIC64_DECL(sub_return);
12416 +ATOMIC64_DECL(sub_return_unchecked);
12417 ATOMIC64_DECL(inc_return);
12418 +ATOMIC64_DECL(inc_return_unchecked);
12419 ATOMIC64_DECL(dec_return);
12420 +ATOMIC64_DECL(dec_return_unchecked);
12421 ATOMIC64_DECL(dec_if_positive);
12422 ATOMIC64_DECL(inc_not_zero);
12423 ATOMIC64_DECL(add_unless);
12424 @@ -77,6 +95,21 @@ static inline long long atomic64_cmpxchg(atomic64_t *v, long long o, long long n
12425 }
12426
12427 /**
12428 + * atomic64_cmpxchg_unchecked - cmpxchg atomic64 variable
12429 + * @p: pointer to type atomic64_unchecked_t
12430 + * @o: expected value
12431 + * @n: new value
12432 + *
12433 + * Atomically sets @v to @n if it was equal to @o and returns
12434 + * the old value.
12435 + */
12436 +
12437 +static inline long long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long long o, long long n)
12438 +{
12439 + return cmpxchg64(&v->counter, o, n);
12440 +}
12441 +
12442 +/**
12443 * atomic64_xchg - xchg atomic64 variable
12444 * @v: pointer to type atomic64_t
12445 * @n: value to assign
12446 @@ -112,6 +145,22 @@ static inline void atomic64_set(atomic64_t *v, long long i)
12447 }
12448
12449 /**
12450 + * atomic64_set_unchecked - set atomic64 variable
12451 + * @v: pointer to type atomic64_unchecked_t
12452 + * @n: value to assign
12453 + *
12454 + * Atomically sets the value of @v to @n.
12455 + */
12456 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long long i)
12457 +{
12458 + unsigned high = (unsigned)(i >> 32);
12459 + unsigned low = (unsigned)i;
12460 + alternative_atomic64(set, /* no output */,
12461 + "S" (v), "b" (low), "c" (high)
12462 + : "eax", "edx", "memory");
12463 +}
12464 +
12465 +/**
12466 * atomic64_read - read atomic64 variable
12467 * @v: pointer to type atomic64_t
12468 *
12469 @@ -125,6 +174,19 @@ static inline long long atomic64_read(const atomic64_t *v)
12470 }
12471
12472 /**
12473 + * atomic64_read_unchecked - read atomic64 variable
12474 + * @v: pointer to type atomic64_unchecked_t
12475 + *
12476 + * Atomically reads the value of @v and returns it.
12477 + */
12478 +static inline long long atomic64_read_unchecked(atomic64_unchecked_t *v)
12479 +{
12480 + long long r;
12481 + alternative_atomic64(read, "=&A" (r), "c" (v) : "memory");
12482 + return r;
12483 + }
12484 +
12485 +/**
12486 * atomic64_add_return - add and return
12487 * @i: integer value to add
12488 * @v: pointer to type atomic64_t
12489 @@ -139,6 +201,21 @@ static inline long long atomic64_add_return(long long i, atomic64_t *v)
12490 return i;
12491 }
12492
12493 +/**
12494 + * atomic64_add_return_unchecked - add and return
12495 + * @i: integer value to add
12496 + * @v: pointer to type atomic64_unchecked_t
12497 + *
12498 + * Atomically adds @i to @v and returns @i + *@v
12499 + */
12500 +static inline long long atomic64_add_return_unchecked(long long i, atomic64_unchecked_t *v)
12501 +{
12502 + alternative_atomic64(add_return_unchecked,
12503 + ASM_OUTPUT2("+A" (i), "+c" (v)),
12504 + ASM_NO_INPUT_CLOBBER("memory"));
12505 + return i;
12506 +}
12507 +
12508 /*
12509 * Other variants with different arithmetic operators:
12510 */
12511 @@ -158,6 +235,14 @@ static inline long long atomic64_inc_return(atomic64_t *v)
12512 return a;
12513 }
12514
12515 +static inline long long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
12516 +{
12517 + long long a;
12518 + alternative_atomic64(inc_return_unchecked, "=&A" (a),
12519 + "S" (v) : "memory", "ecx");
12520 + return a;
12521 +}
12522 +
12523 static inline long long atomic64_dec_return(atomic64_t *v)
12524 {
12525 long long a;
12526 @@ -182,6 +267,21 @@ static inline long long atomic64_add(long long i, atomic64_t *v)
12527 }
12528
12529 /**
12530 + * atomic64_add_unchecked - add integer to atomic64 variable
12531 + * @i: integer value to add
12532 + * @v: pointer to type atomic64_unchecked_t
12533 + *
12534 + * Atomically adds @i to @v.
12535 + */
12536 +static inline long long atomic64_add_unchecked(long long i, atomic64_unchecked_t *v)
12537 +{
12538 + __alternative_atomic64(add_unchecked, add_return_unchecked,
12539 + ASM_OUTPUT2("+A" (i), "+c" (v)),
12540 + ASM_NO_INPUT_CLOBBER("memory"));
12541 + return i;
12542 +}
12543 +
12544 +/**
12545 * atomic64_sub - subtract the atomic64 variable
12546 * @i: integer value to subtract
12547 * @v: pointer to type atomic64_t
12548 diff --git a/arch/x86/include/asm/atomic64_64.h b/arch/x86/include/asm/atomic64_64.h
12549 index 0e1cbfc..5623683 100644
12550 --- a/arch/x86/include/asm/atomic64_64.h
12551 +++ b/arch/x86/include/asm/atomic64_64.h
12552 @@ -18,7 +18,19 @@
12553 */
12554 static inline long atomic64_read(const atomic64_t *v)
12555 {
12556 - return (*(volatile long *)&(v)->counter);
12557 + return (*(volatile const long *)&(v)->counter);
12558 +}
12559 +
12560 +/**
12561 + * atomic64_read_unchecked - read atomic64 variable
12562 + * @v: pointer of type atomic64_unchecked_t
12563 + *
12564 + * Atomically reads the value of @v.
12565 + * Doesn't imply a read memory barrier.
12566 + */
12567 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
12568 +{
12569 + return (*(volatile const long *)&(v)->counter);
12570 }
12571
12572 /**
12573 @@ -34,6 +46,18 @@ static inline void atomic64_set(atomic64_t *v, long i)
12574 }
12575
12576 /**
12577 + * atomic64_set_unchecked - set atomic64 variable
12578 + * @v: pointer to type atomic64_unchecked_t
12579 + * @i: required value
12580 + *
12581 + * Atomically sets the value of @v to @i.
12582 + */
12583 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
12584 +{
12585 + v->counter = i;
12586 +}
12587 +
12588 +/**
12589 * atomic64_add - add integer to atomic64 variable
12590 * @i: integer value to add
12591 * @v: pointer to type atomic64_t
12592 @@ -42,6 +66,28 @@ static inline void atomic64_set(atomic64_t *v, long i)
12593 */
12594 static inline void atomic64_add(long i, atomic64_t *v)
12595 {
12596 + asm volatile(LOCK_PREFIX "addq %1,%0\n"
12597 +
12598 +#ifdef CONFIG_PAX_REFCOUNT
12599 + "jno 0f\n"
12600 + LOCK_PREFIX "subq %1,%0\n"
12601 + "int $4\n0:\n"
12602 + _ASM_EXTABLE(0b, 0b)
12603 +#endif
12604 +
12605 + : "=m" (v->counter)
12606 + : "er" (i), "m" (v->counter));
12607 +}
12608 +
12609 +/**
12610 + * atomic64_add_unchecked - add integer to atomic64 variable
12611 + * @i: integer value to add
12612 + * @v: pointer to type atomic64_unchecked_t
12613 + *
12614 + * Atomically adds @i to @v.
12615 + */
12616 +static inline void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
12617 +{
12618 asm volatile(LOCK_PREFIX "addq %1,%0"
12619 : "=m" (v->counter)
12620 : "er" (i), "m" (v->counter));
12621 @@ -56,7 +102,29 @@ static inline void atomic64_add(long i, atomic64_t *v)
12622 */
12623 static inline void atomic64_sub(long i, atomic64_t *v)
12624 {
12625 - asm volatile(LOCK_PREFIX "subq %1,%0"
12626 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
12627 +
12628 +#ifdef CONFIG_PAX_REFCOUNT
12629 + "jno 0f\n"
12630 + LOCK_PREFIX "addq %1,%0\n"
12631 + "int $4\n0:\n"
12632 + _ASM_EXTABLE(0b, 0b)
12633 +#endif
12634 +
12635 + : "=m" (v->counter)
12636 + : "er" (i), "m" (v->counter));
12637 +}
12638 +
12639 +/**
12640 + * atomic64_sub_unchecked - subtract the atomic64 variable
12641 + * @i: integer value to subtract
12642 + * @v: pointer to type atomic64_unchecked_t
12643 + *
12644 + * Atomically subtracts @i from @v.
12645 + */
12646 +static inline void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
12647 +{
12648 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
12649 : "=m" (v->counter)
12650 : "er" (i), "m" (v->counter));
12651 }
12652 @@ -74,7 +142,16 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
12653 {
12654 unsigned char c;
12655
12656 - asm volatile(LOCK_PREFIX "subq %2,%0; sete %1"
12657 + asm volatile(LOCK_PREFIX "subq %2,%0\n"
12658 +
12659 +#ifdef CONFIG_PAX_REFCOUNT
12660 + "jno 0f\n"
12661 + LOCK_PREFIX "addq %2,%0\n"
12662 + "int $4\n0:\n"
12663 + _ASM_EXTABLE(0b, 0b)
12664 +#endif
12665 +
12666 + "sete %1\n"
12667 : "=m" (v->counter), "=qm" (c)
12668 : "er" (i), "m" (v->counter) : "memory");
12669 return c;
12670 @@ -88,6 +165,27 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
12671 */
12672 static inline void atomic64_inc(atomic64_t *v)
12673 {
12674 + asm volatile(LOCK_PREFIX "incq %0\n"
12675 +
12676 +#ifdef CONFIG_PAX_REFCOUNT
12677 + "jno 0f\n"
12678 + LOCK_PREFIX "decq %0\n"
12679 + "int $4\n0:\n"
12680 + _ASM_EXTABLE(0b, 0b)
12681 +#endif
12682 +
12683 + : "=m" (v->counter)
12684 + : "m" (v->counter));
12685 +}
12686 +
12687 +/**
12688 + * atomic64_inc_unchecked - increment atomic64 variable
12689 + * @v: pointer to type atomic64_unchecked_t
12690 + *
12691 + * Atomically increments @v by 1.
12692 + */
12693 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
12694 +{
12695 asm volatile(LOCK_PREFIX "incq %0"
12696 : "=m" (v->counter)
12697 : "m" (v->counter));
12698 @@ -101,7 +199,28 @@ static inline void atomic64_inc(atomic64_t *v)
12699 */
12700 static inline void atomic64_dec(atomic64_t *v)
12701 {
12702 - asm volatile(LOCK_PREFIX "decq %0"
12703 + asm volatile(LOCK_PREFIX "decq %0\n"
12704 +
12705 +#ifdef CONFIG_PAX_REFCOUNT
12706 + "jno 0f\n"
12707 + LOCK_PREFIX "incq %0\n"
12708 + "int $4\n0:\n"
12709 + _ASM_EXTABLE(0b, 0b)
12710 +#endif
12711 +
12712 + : "=m" (v->counter)
12713 + : "m" (v->counter));
12714 +}
12715 +
12716 +/**
12717 + * atomic64_dec_unchecked - decrement atomic64 variable
12718 + * @v: pointer to type atomic64_t
12719 + *
12720 + * Atomically decrements @v by 1.
12721 + */
12722 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
12723 +{
12724 + asm volatile(LOCK_PREFIX "decq %0\n"
12725 : "=m" (v->counter)
12726 : "m" (v->counter));
12727 }
12728 @@ -118,7 +237,16 @@ static inline int atomic64_dec_and_test(atomic64_t *v)
12729 {
12730 unsigned char c;
12731
12732 - asm volatile(LOCK_PREFIX "decq %0; sete %1"
12733 + asm volatile(LOCK_PREFIX "decq %0\n"
12734 +
12735 +#ifdef CONFIG_PAX_REFCOUNT
12736 + "jno 0f\n"
12737 + LOCK_PREFIX "incq %0\n"
12738 + "int $4\n0:\n"
12739 + _ASM_EXTABLE(0b, 0b)
12740 +#endif
12741 +
12742 + "sete %1\n"
12743 : "=m" (v->counter), "=qm" (c)
12744 : "m" (v->counter) : "memory");
12745 return c != 0;
12746 @@ -136,7 +264,16 @@ static inline int atomic64_inc_and_test(atomic64_t *v)
12747 {
12748 unsigned char c;
12749
12750 - asm volatile(LOCK_PREFIX "incq %0; sete %1"
12751 + asm volatile(LOCK_PREFIX "incq %0\n"
12752 +
12753 +#ifdef CONFIG_PAX_REFCOUNT
12754 + "jno 0f\n"
12755 + LOCK_PREFIX "decq %0\n"
12756 + "int $4\n0:\n"
12757 + _ASM_EXTABLE(0b, 0b)
12758 +#endif
12759 +
12760 + "sete %1\n"
12761 : "=m" (v->counter), "=qm" (c)
12762 : "m" (v->counter) : "memory");
12763 return c != 0;
12764 @@ -155,7 +292,16 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
12765 {
12766 unsigned char c;
12767
12768 - asm volatile(LOCK_PREFIX "addq %2,%0; sets %1"
12769 + asm volatile(LOCK_PREFIX "addq %2,%0\n"
12770 +
12771 +#ifdef CONFIG_PAX_REFCOUNT
12772 + "jno 0f\n"
12773 + LOCK_PREFIX "subq %2,%0\n"
12774 + "int $4\n0:\n"
12775 + _ASM_EXTABLE(0b, 0b)
12776 +#endif
12777 +
12778 + "sets %1\n"
12779 : "=m" (v->counter), "=qm" (c)
12780 : "er" (i), "m" (v->counter) : "memory");
12781 return c;
12782 @@ -170,6 +316,18 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
12783 */
12784 static inline long atomic64_add_return(long i, atomic64_t *v)
12785 {
12786 + return i + xadd_check_overflow(&v->counter, i);
12787 +}
12788 +
12789 +/**
12790 + * atomic64_add_return_unchecked - add and return
12791 + * @i: integer value to add
12792 + * @v: pointer to type atomic64_unchecked_t
12793 + *
12794 + * Atomically adds @i to @v and returns @i + @v
12795 + */
12796 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
12797 +{
12798 return i + xadd(&v->counter, i);
12799 }
12800
12801 @@ -179,6 +337,10 @@ static inline long atomic64_sub_return(long i, atomic64_t *v)
12802 }
12803
12804 #define atomic64_inc_return(v) (atomic64_add_return(1, (v)))
12805 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
12806 +{
12807 + return atomic64_add_return_unchecked(1, v);
12808 +}
12809 #define atomic64_dec_return(v) (atomic64_sub_return(1, (v)))
12810
12811 static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
12812 @@ -186,6 +348,11 @@ static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
12813 return cmpxchg(&v->counter, old, new);
12814 }
12815
12816 +static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old, long new)
12817 +{
12818 + return cmpxchg(&v->counter, old, new);
12819 +}
12820 +
12821 static inline long atomic64_xchg(atomic64_t *v, long new)
12822 {
12823 return xchg(&v->counter, new);
12824 @@ -202,17 +369,30 @@ static inline long atomic64_xchg(atomic64_t *v, long new)
12825 */
12826 static inline int atomic64_add_unless(atomic64_t *v, long a, long u)
12827 {
12828 - long c, old;
12829 + long c, old, new;
12830 c = atomic64_read(v);
12831 for (;;) {
12832 - if (unlikely(c == (u)))
12833 + if (unlikely(c == u))
12834 break;
12835 - old = atomic64_cmpxchg((v), c, c + (a));
12836 +
12837 + asm volatile("add %2,%0\n"
12838 +
12839 +#ifdef CONFIG_PAX_REFCOUNT
12840 + "jno 0f\n"
12841 + "sub %2,%0\n"
12842 + "int $4\n0:\n"
12843 + _ASM_EXTABLE(0b, 0b)
12844 +#endif
12845 +
12846 + : "=r" (new)
12847 + : "0" (c), "ir" (a));
12848 +
12849 + old = atomic64_cmpxchg(v, c, new);
12850 if (likely(old == c))
12851 break;
12852 c = old;
12853 }
12854 - return c != (u);
12855 + return c != u;
12856 }
12857
12858 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
12859 diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
12860 index 6dfd019..28e188d 100644
12861 --- a/arch/x86/include/asm/bitops.h
12862 +++ b/arch/x86/include/asm/bitops.h
12863 @@ -40,7 +40,7 @@
12864 * a mask operation on a byte.
12865 */
12866 #define IS_IMMEDIATE(nr) (__builtin_constant_p(nr))
12867 -#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((void *)(addr) + ((nr)>>3))
12868 +#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((volatile void *)(addr) + ((nr)>>3))
12869 #define CONST_MASK(nr) (1 << ((nr) & 7))
12870
12871 /**
12872 @@ -486,7 +486,7 @@ static inline int fls(int x)
12873 * at position 64.
12874 */
12875 #ifdef CONFIG_X86_64
12876 -static __always_inline int fls64(__u64 x)
12877 +static __always_inline long fls64(__u64 x)
12878 {
12879 int bitpos = -1;
12880 /*
12881 diff --git a/arch/x86/include/asm/boot.h b/arch/x86/include/asm/boot.h
12882 index 4fa687a..60f2d39 100644
12883 --- a/arch/x86/include/asm/boot.h
12884 +++ b/arch/x86/include/asm/boot.h
12885 @@ -6,10 +6,15 @@
12886 #include <uapi/asm/boot.h>
12887
12888 /* Physical address where kernel should be loaded. */
12889 -#define LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
12890 +#define ____LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
12891 + (CONFIG_PHYSICAL_ALIGN - 1)) \
12892 & ~(CONFIG_PHYSICAL_ALIGN - 1))
12893
12894 +#ifndef __ASSEMBLY__
12895 +extern unsigned char __LOAD_PHYSICAL_ADDR[];
12896 +#define LOAD_PHYSICAL_ADDR ((unsigned long)__LOAD_PHYSICAL_ADDR)
12897 +#endif
12898 +
12899 /* Minimum kernel alignment, as a power of two */
12900 #ifdef CONFIG_X86_64
12901 #define MIN_KERNEL_ALIGN_LG2 PMD_SHIFT
12902 diff --git a/arch/x86/include/asm/cache.h b/arch/x86/include/asm/cache.h
12903 index 48f99f1..d78ebf9 100644
12904 --- a/arch/x86/include/asm/cache.h
12905 +++ b/arch/x86/include/asm/cache.h
12906 @@ -5,12 +5,13 @@
12907
12908 /* L1 cache line size */
12909 #define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
12910 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
12911 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
12912
12913 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
12914 +#define __read_only __attribute__((__section__(".data..read_only")))
12915
12916 #define INTERNODE_CACHE_SHIFT CONFIG_X86_INTERNODE_CACHE_SHIFT
12917 -#define INTERNODE_CACHE_BYTES (1 << INTERNODE_CACHE_SHIFT)
12918 +#define INTERNODE_CACHE_BYTES (_AC(1,UL) << INTERNODE_CACHE_SHIFT)
12919
12920 #ifdef CONFIG_X86_VSMP
12921 #ifdef CONFIG_SMP
12922 diff --git a/arch/x86/include/asm/cacheflush.h b/arch/x86/include/asm/cacheflush.h
12923 index 9863ee3..4a1f8e1 100644
12924 --- a/arch/x86/include/asm/cacheflush.h
12925 +++ b/arch/x86/include/asm/cacheflush.h
12926 @@ -27,7 +27,7 @@ static inline unsigned long get_page_memtype(struct page *pg)
12927 unsigned long pg_flags = pg->flags & _PGMT_MASK;
12928
12929 if (pg_flags == _PGMT_DEFAULT)
12930 - return -1;
12931 + return ~0UL;
12932 else if (pg_flags == _PGMT_WC)
12933 return _PAGE_CACHE_WC;
12934 else if (pg_flags == _PGMT_UC_MINUS)
12935 diff --git a/arch/x86/include/asm/checksum_32.h b/arch/x86/include/asm/checksum_32.h
12936 index 46fc474..b02b0f9 100644
12937 --- a/arch/x86/include/asm/checksum_32.h
12938 +++ b/arch/x86/include/asm/checksum_32.h
12939 @@ -31,6 +31,14 @@ asmlinkage __wsum csum_partial_copy_generic(const void *src, void *dst,
12940 int len, __wsum sum,
12941 int *src_err_ptr, int *dst_err_ptr);
12942
12943 +asmlinkage __wsum csum_partial_copy_generic_to_user(const void *src, void *dst,
12944 + int len, __wsum sum,
12945 + int *src_err_ptr, int *dst_err_ptr);
12946 +
12947 +asmlinkage __wsum csum_partial_copy_generic_from_user(const void *src, void *dst,
12948 + int len, __wsum sum,
12949 + int *src_err_ptr, int *dst_err_ptr);
12950 +
12951 /*
12952 * Note: when you get a NULL pointer exception here this means someone
12953 * passed in an incorrect kernel address to one of these functions.
12954 @@ -50,7 +58,7 @@ static inline __wsum csum_partial_copy_from_user(const void __user *src,
12955 int *err_ptr)
12956 {
12957 might_sleep();
12958 - return csum_partial_copy_generic((__force void *)src, dst,
12959 + return csum_partial_copy_generic_from_user((__force void *)src, dst,
12960 len, sum, err_ptr, NULL);
12961 }
12962
12963 @@ -178,7 +186,7 @@ static inline __wsum csum_and_copy_to_user(const void *src,
12964 {
12965 might_sleep();
12966 if (access_ok(VERIFY_WRITE, dst, len))
12967 - return csum_partial_copy_generic(src, (__force void *)dst,
12968 + return csum_partial_copy_generic_to_user(src, (__force void *)dst,
12969 len, sum, NULL, err_ptr);
12970
12971 if (len)
12972 diff --git a/arch/x86/include/asm/cmpxchg.h b/arch/x86/include/asm/cmpxchg.h
12973 index 8d871ea..c1a0dc9 100644
12974 --- a/arch/x86/include/asm/cmpxchg.h
12975 +++ b/arch/x86/include/asm/cmpxchg.h
12976 @@ -14,8 +14,12 @@ extern void __cmpxchg_wrong_size(void)
12977 __compiletime_error("Bad argument size for cmpxchg");
12978 extern void __xadd_wrong_size(void)
12979 __compiletime_error("Bad argument size for xadd");
12980 +extern void __xadd_check_overflow_wrong_size(void)
12981 + __compiletime_error("Bad argument size for xadd_check_overflow");
12982 extern void __add_wrong_size(void)
12983 __compiletime_error("Bad argument size for add");
12984 +extern void __add_check_overflow_wrong_size(void)
12985 + __compiletime_error("Bad argument size for add_check_overflow");
12986
12987 /*
12988 * Constants for operation sizes. On 32-bit, the 64-bit size it set to
12989 @@ -67,6 +71,34 @@ extern void __add_wrong_size(void)
12990 __ret; \
12991 })
12992
12993 +#define __xchg_op_check_overflow(ptr, arg, op, lock) \
12994 + ({ \
12995 + __typeof__ (*(ptr)) __ret = (arg); \
12996 + switch (sizeof(*(ptr))) { \
12997 + case __X86_CASE_L: \
12998 + asm volatile (lock #op "l %0, %1\n" \
12999 + "jno 0f\n" \
13000 + "mov %0,%1\n" \
13001 + "int $4\n0:\n" \
13002 + _ASM_EXTABLE(0b, 0b) \
13003 + : "+r" (__ret), "+m" (*(ptr)) \
13004 + : : "memory", "cc"); \
13005 + break; \
13006 + case __X86_CASE_Q: \
13007 + asm volatile (lock #op "q %q0, %1\n" \
13008 + "jno 0f\n" \
13009 + "mov %0,%1\n" \
13010 + "int $4\n0:\n" \
13011 + _ASM_EXTABLE(0b, 0b) \
13012 + : "+r" (__ret), "+m" (*(ptr)) \
13013 + : : "memory", "cc"); \
13014 + break; \
13015 + default: \
13016 + __ ## op ## _check_overflow_wrong_size(); \
13017 + } \
13018 + __ret; \
13019 + })
13020 +
13021 /*
13022 * Note: no "lock" prefix even on SMP: xchg always implies lock anyway.
13023 * Since this is generally used to protect other memory information, we
13024 @@ -167,6 +199,9 @@ extern void __add_wrong_size(void)
13025 #define xadd_sync(ptr, inc) __xadd((ptr), (inc), "lock; ")
13026 #define xadd_local(ptr, inc) __xadd((ptr), (inc), "")
13027
13028 +#define __xadd_check_overflow(ptr, inc, lock) __xchg_op_check_overflow((ptr), (inc), xadd, lock)
13029 +#define xadd_check_overflow(ptr, inc) __xadd_check_overflow((ptr), (inc), LOCK_PREFIX)
13030 +
13031 #define __add(ptr, inc, lock) \
13032 ({ \
13033 __typeof__ (*(ptr)) __ret = (inc); \
13034 diff --git a/arch/x86/include/asm/compat.h b/arch/x86/include/asm/compat.h
13035 index 59c6c40..5e0b22c 100644
13036 --- a/arch/x86/include/asm/compat.h
13037 +++ b/arch/x86/include/asm/compat.h
13038 @@ -41,7 +41,7 @@ typedef s64 __attribute__((aligned(4))) compat_s64;
13039 typedef u32 compat_uint_t;
13040 typedef u32 compat_ulong_t;
13041 typedef u64 __attribute__((aligned(4))) compat_u64;
13042 -typedef u32 compat_uptr_t;
13043 +typedef u32 __user compat_uptr_t;
13044
13045 struct compat_timespec {
13046 compat_time_t tv_sec;
13047 diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
13048 index 93fe929..90858b7 100644
13049 --- a/arch/x86/include/asm/cpufeature.h
13050 +++ b/arch/x86/include/asm/cpufeature.h
13051 @@ -207,7 +207,7 @@
13052 #define X86_FEATURE_BMI1 (9*32+ 3) /* 1st group bit manipulation extensions */
13053 #define X86_FEATURE_HLE (9*32+ 4) /* Hardware Lock Elision */
13054 #define X86_FEATURE_AVX2 (9*32+ 5) /* AVX2 instructions */
13055 -#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Protection */
13056 +#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Prevention */
13057 #define X86_FEATURE_BMI2 (9*32+ 8) /* 2nd group bit manipulation extensions */
13058 #define X86_FEATURE_ERMS (9*32+ 9) /* Enhanced REP MOVSB/STOSB */
13059 #define X86_FEATURE_INVPCID (9*32+10) /* Invalidate Processor Context ID */
13060 @@ -377,7 +377,7 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
13061 ".section .discard,\"aw\",@progbits\n"
13062 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
13063 ".previous\n"
13064 - ".section .altinstr_replacement,\"ax\"\n"
13065 + ".section .altinstr_replacement,\"a\"\n"
13066 "3: movb $1,%0\n"
13067 "4:\n"
13068 ".previous\n"
13069 diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h
13070 index 8bf1c06..b6ae785 100644
13071 --- a/arch/x86/include/asm/desc.h
13072 +++ b/arch/x86/include/asm/desc.h
13073 @@ -4,6 +4,7 @@
13074 #include <asm/desc_defs.h>
13075 #include <asm/ldt.h>
13076 #include <asm/mmu.h>
13077 +#include <asm/pgtable.h>
13078
13079 #include <linux/smp.h>
13080 #include <linux/percpu.h>
13081 @@ -17,6 +18,7 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
13082
13083 desc->type = (info->read_exec_only ^ 1) << 1;
13084 desc->type |= info->contents << 2;
13085 + desc->type |= info->seg_not_present ^ 1;
13086
13087 desc->s = 1;
13088 desc->dpl = 0x3;
13089 @@ -35,19 +37,14 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
13090 }
13091
13092 extern struct desc_ptr idt_descr;
13093 -extern gate_desc idt_table[];
13094 extern struct desc_ptr nmi_idt_descr;
13095 -extern gate_desc nmi_idt_table[];
13096 -
13097 -struct gdt_page {
13098 - struct desc_struct gdt[GDT_ENTRIES];
13099 -} __attribute__((aligned(PAGE_SIZE)));
13100 -
13101 -DECLARE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page);
13102 +extern gate_desc idt_table[256];
13103 +extern gate_desc nmi_idt_table[256];
13104
13105 +extern struct desc_struct cpu_gdt_table[NR_CPUS][PAGE_SIZE / sizeof(struct desc_struct)];
13106 static inline struct desc_struct *get_cpu_gdt_table(unsigned int cpu)
13107 {
13108 - return per_cpu(gdt_page, cpu).gdt;
13109 + return cpu_gdt_table[cpu];
13110 }
13111
13112 #ifdef CONFIG_X86_64
13113 @@ -72,8 +69,14 @@ static inline void pack_gate(gate_desc *gate, unsigned char type,
13114 unsigned long base, unsigned dpl, unsigned flags,
13115 unsigned short seg)
13116 {
13117 - gate->a = (seg << 16) | (base & 0xffff);
13118 - gate->b = (base & 0xffff0000) | (((0x80 | type | (dpl << 5)) & 0xff) << 8);
13119 + gate->gate.offset_low = base;
13120 + gate->gate.seg = seg;
13121 + gate->gate.reserved = 0;
13122 + gate->gate.type = type;
13123 + gate->gate.s = 0;
13124 + gate->gate.dpl = dpl;
13125 + gate->gate.p = 1;
13126 + gate->gate.offset_high = base >> 16;
13127 }
13128
13129 #endif
13130 @@ -118,12 +121,16 @@ static inline void paravirt_free_ldt(struct desc_struct *ldt, unsigned entries)
13131
13132 static inline void native_write_idt_entry(gate_desc *idt, int entry, const gate_desc *gate)
13133 {
13134 + pax_open_kernel();
13135 memcpy(&idt[entry], gate, sizeof(*gate));
13136 + pax_close_kernel();
13137 }
13138
13139 static inline void native_write_ldt_entry(struct desc_struct *ldt, int entry, const void *desc)
13140 {
13141 + pax_open_kernel();
13142 memcpy(&ldt[entry], desc, 8);
13143 + pax_close_kernel();
13144 }
13145
13146 static inline void
13147 @@ -137,7 +144,9 @@ native_write_gdt_entry(struct desc_struct *gdt, int entry, const void *desc, int
13148 default: size = sizeof(*gdt); break;
13149 }
13150
13151 + pax_open_kernel();
13152 memcpy(&gdt[entry], desc, size);
13153 + pax_close_kernel();
13154 }
13155
13156 static inline void pack_descriptor(struct desc_struct *desc, unsigned long base,
13157 @@ -210,7 +219,9 @@ static inline void native_set_ldt(const void *addr, unsigned int entries)
13158
13159 static inline void native_load_tr_desc(void)
13160 {
13161 + pax_open_kernel();
13162 asm volatile("ltr %w0"::"q" (GDT_ENTRY_TSS*8));
13163 + pax_close_kernel();
13164 }
13165
13166 static inline void native_load_gdt(const struct desc_ptr *dtr)
13167 @@ -247,8 +258,10 @@ static inline void native_load_tls(struct thread_struct *t, unsigned int cpu)
13168 struct desc_struct *gdt = get_cpu_gdt_table(cpu);
13169 unsigned int i;
13170
13171 + pax_open_kernel();
13172 for (i = 0; i < GDT_ENTRY_TLS_ENTRIES; i++)
13173 gdt[GDT_ENTRY_TLS_MIN + i] = t->tls_array[i];
13174 + pax_close_kernel();
13175 }
13176
13177 #define _LDT_empty(info) \
13178 @@ -287,7 +300,7 @@ static inline void load_LDT(mm_context_t *pc)
13179 preempt_enable();
13180 }
13181
13182 -static inline unsigned long get_desc_base(const struct desc_struct *desc)
13183 +static inline unsigned long __intentional_overflow(-1) get_desc_base(const struct desc_struct *desc)
13184 {
13185 return (unsigned)(desc->base0 | ((desc->base1) << 16) | ((desc->base2) << 24));
13186 }
13187 @@ -311,7 +324,7 @@ static inline void set_desc_limit(struct desc_struct *desc, unsigned long limit)
13188 }
13189
13190 #ifdef CONFIG_X86_64
13191 -static inline void set_nmi_gate(int gate, void *addr)
13192 +static inline void set_nmi_gate(int gate, const void *addr)
13193 {
13194 gate_desc s;
13195
13196 @@ -320,7 +333,7 @@ static inline void set_nmi_gate(int gate, void *addr)
13197 }
13198 #endif
13199
13200 -static inline void _set_gate(int gate, unsigned type, void *addr,
13201 +static inline void _set_gate(int gate, unsigned type, const void *addr,
13202 unsigned dpl, unsigned ist, unsigned seg)
13203 {
13204 gate_desc s;
13205 @@ -339,7 +352,7 @@ static inline void _set_gate(int gate, unsigned type, void *addr,
13206 * Pentium F0 0F bugfix can have resulted in the mapped
13207 * IDT being write-protected.
13208 */
13209 -static inline void set_intr_gate(unsigned int n, void *addr)
13210 +static inline void set_intr_gate(unsigned int n, const void *addr)
13211 {
13212 BUG_ON((unsigned)n > 0xFF);
13213 _set_gate(n, GATE_INTERRUPT, addr, 0, 0, __KERNEL_CS);
13214 @@ -369,19 +382,19 @@ static inline void alloc_intr_gate(unsigned int n, void *addr)
13215 /*
13216 * This routine sets up an interrupt gate at directory privilege level 3.
13217 */
13218 -static inline void set_system_intr_gate(unsigned int n, void *addr)
13219 +static inline void set_system_intr_gate(unsigned int n, const void *addr)
13220 {
13221 BUG_ON((unsigned)n > 0xFF);
13222 _set_gate(n, GATE_INTERRUPT, addr, 0x3, 0, __KERNEL_CS);
13223 }
13224
13225 -static inline void set_system_trap_gate(unsigned int n, void *addr)
13226 +static inline void set_system_trap_gate(unsigned int n, const void *addr)
13227 {
13228 BUG_ON((unsigned)n > 0xFF);
13229 _set_gate(n, GATE_TRAP, addr, 0x3, 0, __KERNEL_CS);
13230 }
13231
13232 -static inline void set_trap_gate(unsigned int n, void *addr)
13233 +static inline void set_trap_gate(unsigned int n, const void *addr)
13234 {
13235 BUG_ON((unsigned)n > 0xFF);
13236 _set_gate(n, GATE_TRAP, addr, 0, 0, __KERNEL_CS);
13237 @@ -390,19 +403,31 @@ static inline void set_trap_gate(unsigned int n, void *addr)
13238 static inline void set_task_gate(unsigned int n, unsigned int gdt_entry)
13239 {
13240 BUG_ON((unsigned)n > 0xFF);
13241 - _set_gate(n, GATE_TASK, (void *)0, 0, 0, (gdt_entry<<3));
13242 + _set_gate(n, GATE_TASK, (const void *)0, 0, 0, (gdt_entry<<3));
13243 }
13244
13245 -static inline void set_intr_gate_ist(int n, void *addr, unsigned ist)
13246 +static inline void set_intr_gate_ist(int n, const void *addr, unsigned ist)
13247 {
13248 BUG_ON((unsigned)n > 0xFF);
13249 _set_gate(n, GATE_INTERRUPT, addr, 0, ist, __KERNEL_CS);
13250 }
13251
13252 -static inline void set_system_intr_gate_ist(int n, void *addr, unsigned ist)
13253 +static inline void set_system_intr_gate_ist(int n, const void *addr, unsigned ist)
13254 {
13255 BUG_ON((unsigned)n > 0xFF);
13256 _set_gate(n, GATE_INTERRUPT, addr, 0x3, ist, __KERNEL_CS);
13257 }
13258
13259 +#ifdef CONFIG_X86_32
13260 +static inline void set_user_cs(unsigned long base, unsigned long limit, int cpu)
13261 +{
13262 + struct desc_struct d;
13263 +
13264 + if (likely(limit))
13265 + limit = (limit - 1UL) >> PAGE_SHIFT;
13266 + pack_descriptor(&d, base, limit, 0xFB, 0xC);
13267 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_DEFAULT_USER_CS, &d, DESCTYPE_S);
13268 +}
13269 +#endif
13270 +
13271 #endif /* _ASM_X86_DESC_H */
13272 diff --git a/arch/x86/include/asm/desc_defs.h b/arch/x86/include/asm/desc_defs.h
13273 index 278441f..b95a174 100644
13274 --- a/arch/x86/include/asm/desc_defs.h
13275 +++ b/arch/x86/include/asm/desc_defs.h
13276 @@ -31,6 +31,12 @@ struct desc_struct {
13277 unsigned base1: 8, type: 4, s: 1, dpl: 2, p: 1;
13278 unsigned limit: 4, avl: 1, l: 1, d: 1, g: 1, base2: 8;
13279 };
13280 + struct {
13281 + u16 offset_low;
13282 + u16 seg;
13283 + unsigned reserved: 8, type: 4, s: 1, dpl: 2, p: 1;
13284 + unsigned offset_high: 16;
13285 + } gate;
13286 };
13287 } __attribute__((packed));
13288
13289 diff --git a/arch/x86/include/asm/div64.h b/arch/x86/include/asm/div64.h
13290 index ced283a..ffe04cc 100644
13291 --- a/arch/x86/include/asm/div64.h
13292 +++ b/arch/x86/include/asm/div64.h
13293 @@ -39,7 +39,7 @@
13294 __mod; \
13295 })
13296
13297 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
13298 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
13299 {
13300 union {
13301 u64 v64;
13302 diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
13303 index 9c999c1..3860cb8 100644
13304 --- a/arch/x86/include/asm/elf.h
13305 +++ b/arch/x86/include/asm/elf.h
13306 @@ -243,7 +243,25 @@ extern int force_personality32;
13307 the loader. We need to make sure that it is out of the way of the program
13308 that it will "exec", and that there is sufficient room for the brk. */
13309
13310 +#ifdef CONFIG_PAX_SEGMEXEC
13311 +#define ELF_ET_DYN_BASE ((current->mm->pax_flags & MF_PAX_SEGMEXEC) ? SEGMEXEC_TASK_SIZE/3*2 : TASK_SIZE/3*2)
13312 +#else
13313 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
13314 +#endif
13315 +
13316 +#ifdef CONFIG_PAX_ASLR
13317 +#ifdef CONFIG_X86_32
13318 +#define PAX_ELF_ET_DYN_BASE 0x10000000UL
13319 +
13320 +#define PAX_DELTA_MMAP_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
13321 +#define PAX_DELTA_STACK_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
13322 +#else
13323 +#define PAX_ELF_ET_DYN_BASE 0x400000UL
13324 +
13325 +#define PAX_DELTA_MMAP_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
13326 +#define PAX_DELTA_STACK_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
13327 +#endif
13328 +#endif
13329
13330 /* This yields a mask that user programs can use to figure out what
13331 instruction set this CPU supports. This could be done in user space,
13332 @@ -296,16 +314,12 @@ do { \
13333
13334 #define ARCH_DLINFO \
13335 do { \
13336 - if (vdso_enabled) \
13337 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
13338 - (unsigned long)current->mm->context.vdso); \
13339 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
13340 } while (0)
13341
13342 #define ARCH_DLINFO_X32 \
13343 do { \
13344 - if (vdso_enabled) \
13345 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
13346 - (unsigned long)current->mm->context.vdso); \
13347 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
13348 } while (0)
13349
13350 #define AT_SYSINFO 32
13351 @@ -320,7 +334,7 @@ else \
13352
13353 #endif /* !CONFIG_X86_32 */
13354
13355 -#define VDSO_CURRENT_BASE ((unsigned long)current->mm->context.vdso)
13356 +#define VDSO_CURRENT_BASE (current->mm->context.vdso)
13357
13358 #define VDSO_ENTRY \
13359 ((unsigned long)VDSO32_SYMBOL(VDSO_CURRENT_BASE, vsyscall))
13360 @@ -336,9 +350,6 @@ extern int x32_setup_additional_pages(struct linux_binprm *bprm,
13361 extern int syscall32_setup_pages(struct linux_binprm *, int exstack);
13362 #define compat_arch_setup_additional_pages syscall32_setup_pages
13363
13364 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
13365 -#define arch_randomize_brk arch_randomize_brk
13366 -
13367 /*
13368 * True on X86_32 or when emulating IA32 on X86_64
13369 */
13370 diff --git a/arch/x86/include/asm/emergency-restart.h b/arch/x86/include/asm/emergency-restart.h
13371 index 75ce3f4..882e801 100644
13372 --- a/arch/x86/include/asm/emergency-restart.h
13373 +++ b/arch/x86/include/asm/emergency-restart.h
13374 @@ -13,6 +13,6 @@ enum reboot_type {
13375
13376 extern enum reboot_type reboot_type;
13377
13378 -extern void machine_emergency_restart(void);
13379 +extern void machine_emergency_restart(void) __noreturn;
13380
13381 #endif /* _ASM_X86_EMERGENCY_RESTART_H */
13382 diff --git a/arch/x86/include/asm/fpu-internal.h b/arch/x86/include/asm/fpu-internal.h
13383 index e25cc33..425d099 100644
13384 --- a/arch/x86/include/asm/fpu-internal.h
13385 +++ b/arch/x86/include/asm/fpu-internal.h
13386 @@ -127,7 +127,9 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
13387 ({ \
13388 int err; \
13389 asm volatile(ASM_STAC "\n" \
13390 - "1:" #insn "\n\t" \
13391 + "1:" \
13392 + __copyuser_seg \
13393 + #insn "\n\t" \
13394 "2: " ASM_CLAC "\n" \
13395 ".section .fixup,\"ax\"\n" \
13396 "3: movl $-1,%[err]\n" \
13397 @@ -300,7 +302,7 @@ static inline int restore_fpu_checking(struct task_struct *tsk)
13398 "emms\n\t" /* clear stack tags */
13399 "fildl %P[addr]", /* set F?P to defined value */
13400 X86_FEATURE_FXSAVE_LEAK,
13401 - [addr] "m" (tsk->thread.fpu.has_fpu));
13402 + [addr] "m" (init_tss[raw_smp_processor_id()].x86_tss.sp0));
13403
13404 return fpu_restore_checking(&tsk->thread.fpu);
13405 }
13406 diff --git a/arch/x86/include/asm/futex.h b/arch/x86/include/asm/futex.h
13407 index be27ba1..8f13ff9 100644
13408 --- a/arch/x86/include/asm/futex.h
13409 +++ b/arch/x86/include/asm/futex.h
13410 @@ -12,6 +12,7 @@
13411 #include <asm/smap.h>
13412
13413 #define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \
13414 + typecheck(u32 __user *, uaddr); \
13415 asm volatile("\t" ASM_STAC "\n" \
13416 "1:\t" insn "\n" \
13417 "2:\t" ASM_CLAC "\n" \
13418 @@ -20,15 +21,16 @@
13419 "\tjmp\t2b\n" \
13420 "\t.previous\n" \
13421 _ASM_EXTABLE(1b, 3b) \
13422 - : "=r" (oldval), "=r" (ret), "+m" (*uaddr) \
13423 + : "=r" (oldval), "=r" (ret), "+m" (*(u32 __user *)____m(uaddr)) \
13424 : "i" (-EFAULT), "0" (oparg), "1" (0))
13425
13426 #define __futex_atomic_op2(insn, ret, oldval, uaddr, oparg) \
13427 + typecheck(u32 __user *, uaddr); \
13428 asm volatile("\t" ASM_STAC "\n" \
13429 "1:\tmovl %2, %0\n" \
13430 "\tmovl\t%0, %3\n" \
13431 "\t" insn "\n" \
13432 - "2:\t" LOCK_PREFIX "cmpxchgl %3, %2\n" \
13433 + "2:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %3, %2\n" \
13434 "\tjnz\t1b\n" \
13435 "3:\t" ASM_CLAC "\n" \
13436 "\t.section .fixup,\"ax\"\n" \
13437 @@ -38,7 +40,7 @@
13438 _ASM_EXTABLE(1b, 4b) \
13439 _ASM_EXTABLE(2b, 4b) \
13440 : "=&a" (oldval), "=&r" (ret), \
13441 - "+m" (*uaddr), "=&r" (tem) \
13442 + "+m" (*(u32 __user *)____m(uaddr)), "=&r" (tem) \
13443 : "r" (oparg), "i" (-EFAULT), "1" (0))
13444
13445 static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
13446 @@ -59,10 +61,10 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
13447
13448 switch (op) {
13449 case FUTEX_OP_SET:
13450 - __futex_atomic_op1("xchgl %0, %2", ret, oldval, uaddr, oparg);
13451 + __futex_atomic_op1(__copyuser_seg"xchgl %0, %2", ret, oldval, uaddr, oparg);
13452 break;
13453 case FUTEX_OP_ADD:
13454 - __futex_atomic_op1(LOCK_PREFIX "xaddl %0, %2", ret, oldval,
13455 + __futex_atomic_op1(LOCK_PREFIX __copyuser_seg"xaddl %0, %2", ret, oldval,
13456 uaddr, oparg);
13457 break;
13458 case FUTEX_OP_OR:
13459 @@ -116,14 +118,14 @@ static inline int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
13460 return -EFAULT;
13461
13462 asm volatile("\t" ASM_STAC "\n"
13463 - "1:\t" LOCK_PREFIX "cmpxchgl %4, %2\n"
13464 + "1:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %4, %2\n"
13465 "2:\t" ASM_CLAC "\n"
13466 "\t.section .fixup, \"ax\"\n"
13467 "3:\tmov %3, %0\n"
13468 "\tjmp 2b\n"
13469 "\t.previous\n"
13470 _ASM_EXTABLE(1b, 3b)
13471 - : "+r" (ret), "=a" (oldval), "+m" (*uaddr)
13472 + : "+r" (ret), "=a" (oldval), "+m" (*(u32 __user *)____m(uaddr))
13473 : "i" (-EFAULT), "r" (newval), "1" (oldval)
13474 : "memory"
13475 );
13476 diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h
13477 index 10a78c3..cc77143 100644
13478 --- a/arch/x86/include/asm/hw_irq.h
13479 +++ b/arch/x86/include/asm/hw_irq.h
13480 @@ -147,8 +147,8 @@ extern void setup_ioapic_dest(void);
13481 extern void enable_IO_APIC(void);
13482
13483 /* Statistics */
13484 -extern atomic_t irq_err_count;
13485 -extern atomic_t irq_mis_count;
13486 +extern atomic_unchecked_t irq_err_count;
13487 +extern atomic_unchecked_t irq_mis_count;
13488
13489 /* EISA */
13490 extern void eisa_set_level_irq(unsigned int irq);
13491 diff --git a/arch/x86/include/asm/i8259.h b/arch/x86/include/asm/i8259.h
13492 index a203659..9889f1c 100644
13493 --- a/arch/x86/include/asm/i8259.h
13494 +++ b/arch/x86/include/asm/i8259.h
13495 @@ -62,7 +62,7 @@ struct legacy_pic {
13496 void (*init)(int auto_eoi);
13497 int (*irq_pending)(unsigned int irq);
13498 void (*make_irq)(unsigned int irq);
13499 -};
13500 +} __do_const;
13501
13502 extern struct legacy_pic *legacy_pic;
13503 extern struct legacy_pic null_legacy_pic;
13504 diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
13505 index d8e8eef..1765f78 100644
13506 --- a/arch/x86/include/asm/io.h
13507 +++ b/arch/x86/include/asm/io.h
13508 @@ -51,12 +51,12 @@ static inline void name(type val, volatile void __iomem *addr) \
13509 "m" (*(volatile type __force *)addr) barrier); }
13510
13511 build_mmio_read(readb, "b", unsigned char, "=q", :"memory")
13512 -build_mmio_read(readw, "w", unsigned short, "=r", :"memory")
13513 -build_mmio_read(readl, "l", unsigned int, "=r", :"memory")
13514 +build_mmio_read(__intentional_overflow(-1) readw, "w", unsigned short, "=r", :"memory")
13515 +build_mmio_read(__intentional_overflow(-1) readl, "l", unsigned int, "=r", :"memory")
13516
13517 build_mmio_read(__readb, "b", unsigned char, "=q", )
13518 -build_mmio_read(__readw, "w", unsigned short, "=r", )
13519 -build_mmio_read(__readl, "l", unsigned int, "=r", )
13520 +build_mmio_read(__intentional_overflow(-1) __readw, "w", unsigned short, "=r", )
13521 +build_mmio_read(__intentional_overflow(-1) __readl, "l", unsigned int, "=r", )
13522
13523 build_mmio_write(writeb, "b", unsigned char, "q", :"memory")
13524 build_mmio_write(writew, "w", unsigned short, "r", :"memory")
13525 @@ -184,7 +184,7 @@ static inline void __iomem *ioremap(resource_size_t offset, unsigned long size)
13526 return ioremap_nocache(offset, size);
13527 }
13528
13529 -extern void iounmap(volatile void __iomem *addr);
13530 +extern void iounmap(const volatile void __iomem *addr);
13531
13532 extern void set_iounmap_nonlazy(void);
13533
13534 @@ -194,6 +194,17 @@ extern void set_iounmap_nonlazy(void);
13535
13536 #include <linux/vmalloc.h>
13537
13538 +#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
13539 +static inline int valid_phys_addr_range(unsigned long addr, size_t count)
13540 +{
13541 + return ((addr + count + PAGE_SIZE - 1) >> PAGE_SHIFT) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
13542 +}
13543 +
13544 +static inline int valid_mmap_phys_addr_range(unsigned long pfn, size_t count)
13545 +{
13546 + return (pfn + (count >> PAGE_SHIFT)) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
13547 +}
13548 +
13549 /*
13550 * Convert a virtual cached pointer to an uncached pointer
13551 */
13552 diff --git a/arch/x86/include/asm/irqflags.h b/arch/x86/include/asm/irqflags.h
13553 index bba3cf8..06bc8da 100644
13554 --- a/arch/x86/include/asm/irqflags.h
13555 +++ b/arch/x86/include/asm/irqflags.h
13556 @@ -141,6 +141,11 @@ static inline notrace unsigned long arch_local_irq_save(void)
13557 sti; \
13558 sysexit
13559
13560 +#define GET_CR0_INTO_RDI mov %cr0, %rdi
13561 +#define SET_RDI_INTO_CR0 mov %rdi, %cr0
13562 +#define GET_CR3_INTO_RDI mov %cr3, %rdi
13563 +#define SET_RDI_INTO_CR3 mov %rdi, %cr3
13564 +
13565 #else
13566 #define INTERRUPT_RETURN iret
13567 #define ENABLE_INTERRUPTS_SYSEXIT sti; sysexit
13568 diff --git a/arch/x86/include/asm/kprobes.h b/arch/x86/include/asm/kprobes.h
13569 index 5a6d287..f815789 100644
13570 --- a/arch/x86/include/asm/kprobes.h
13571 +++ b/arch/x86/include/asm/kprobes.h
13572 @@ -38,13 +38,8 @@ typedef u8 kprobe_opcode_t;
13573 #define RELATIVEJUMP_SIZE 5
13574 #define RELATIVECALL_OPCODE 0xe8
13575 #define RELATIVE_ADDR_SIZE 4
13576 -#define MAX_STACK_SIZE 64
13577 -#define MIN_STACK_SIZE(ADDR) \
13578 - (((MAX_STACK_SIZE) < (((unsigned long)current_thread_info()) + \
13579 - THREAD_SIZE - (unsigned long)(ADDR))) \
13580 - ? (MAX_STACK_SIZE) \
13581 - : (((unsigned long)current_thread_info()) + \
13582 - THREAD_SIZE - (unsigned long)(ADDR)))
13583 +#define MAX_STACK_SIZE 64UL
13584 +#define MIN_STACK_SIZE(ADDR) min(MAX_STACK_SIZE, current->thread.sp0 - (unsigned long)(ADDR))
13585
13586 #define flush_insn_slot(p) do { } while (0)
13587
13588 diff --git a/arch/x86/include/asm/local.h b/arch/x86/include/asm/local.h
13589 index 2d89e39..baee879 100644
13590 --- a/arch/x86/include/asm/local.h
13591 +++ b/arch/x86/include/asm/local.h
13592 @@ -10,33 +10,97 @@ typedef struct {
13593 atomic_long_t a;
13594 } local_t;
13595
13596 +typedef struct {
13597 + atomic_long_unchecked_t a;
13598 +} local_unchecked_t;
13599 +
13600 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
13601
13602 #define local_read(l) atomic_long_read(&(l)->a)
13603 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
13604 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
13605 +#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
13606
13607 static inline void local_inc(local_t *l)
13608 {
13609 - asm volatile(_ASM_INC "%0"
13610 + asm volatile(_ASM_INC "%0\n"
13611 +
13612 +#ifdef CONFIG_PAX_REFCOUNT
13613 + "jno 0f\n"
13614 + _ASM_DEC "%0\n"
13615 + "int $4\n0:\n"
13616 + _ASM_EXTABLE(0b, 0b)
13617 +#endif
13618 +
13619 + : "+m" (l->a.counter));
13620 +}
13621 +
13622 +static inline void local_inc_unchecked(local_unchecked_t *l)
13623 +{
13624 + asm volatile(_ASM_INC "%0\n"
13625 : "+m" (l->a.counter));
13626 }
13627
13628 static inline void local_dec(local_t *l)
13629 {
13630 - asm volatile(_ASM_DEC "%0"
13631 + asm volatile(_ASM_DEC "%0\n"
13632 +
13633 +#ifdef CONFIG_PAX_REFCOUNT
13634 + "jno 0f\n"
13635 + _ASM_INC "%0\n"
13636 + "int $4\n0:\n"
13637 + _ASM_EXTABLE(0b, 0b)
13638 +#endif
13639 +
13640 + : "+m" (l->a.counter));
13641 +}
13642 +
13643 +static inline void local_dec_unchecked(local_unchecked_t *l)
13644 +{
13645 + asm volatile(_ASM_DEC "%0\n"
13646 : "+m" (l->a.counter));
13647 }
13648
13649 static inline void local_add(long i, local_t *l)
13650 {
13651 - asm volatile(_ASM_ADD "%1,%0"
13652 + asm volatile(_ASM_ADD "%1,%0\n"
13653 +
13654 +#ifdef CONFIG_PAX_REFCOUNT
13655 + "jno 0f\n"
13656 + _ASM_SUB "%1,%0\n"
13657 + "int $4\n0:\n"
13658 + _ASM_EXTABLE(0b, 0b)
13659 +#endif
13660 +
13661 + : "+m" (l->a.counter)
13662 + : "ir" (i));
13663 +}
13664 +
13665 +static inline void local_add_unchecked(long i, local_unchecked_t *l)
13666 +{
13667 + asm volatile(_ASM_ADD "%1,%0\n"
13668 : "+m" (l->a.counter)
13669 : "ir" (i));
13670 }
13671
13672 static inline void local_sub(long i, local_t *l)
13673 {
13674 - asm volatile(_ASM_SUB "%1,%0"
13675 + asm volatile(_ASM_SUB "%1,%0\n"
13676 +
13677 +#ifdef CONFIG_PAX_REFCOUNT
13678 + "jno 0f\n"
13679 + _ASM_ADD "%1,%0\n"
13680 + "int $4\n0:\n"
13681 + _ASM_EXTABLE(0b, 0b)
13682 +#endif
13683 +
13684 + : "+m" (l->a.counter)
13685 + : "ir" (i));
13686 +}
13687 +
13688 +static inline void local_sub_unchecked(long i, local_unchecked_t *l)
13689 +{
13690 + asm volatile(_ASM_SUB "%1,%0\n"
13691 : "+m" (l->a.counter)
13692 : "ir" (i));
13693 }
13694 @@ -54,7 +118,16 @@ static inline int local_sub_and_test(long i, local_t *l)
13695 {
13696 unsigned char c;
13697
13698 - asm volatile(_ASM_SUB "%2,%0; sete %1"
13699 + asm volatile(_ASM_SUB "%2,%0\n"
13700 +
13701 +#ifdef CONFIG_PAX_REFCOUNT
13702 + "jno 0f\n"
13703 + _ASM_ADD "%2,%0\n"
13704 + "int $4\n0:\n"
13705 + _ASM_EXTABLE(0b, 0b)
13706 +#endif
13707 +
13708 + "sete %1\n"
13709 : "+m" (l->a.counter), "=qm" (c)
13710 : "ir" (i) : "memory");
13711 return c;
13712 @@ -72,7 +145,16 @@ static inline int local_dec_and_test(local_t *l)
13713 {
13714 unsigned char c;
13715
13716 - asm volatile(_ASM_DEC "%0; sete %1"
13717 + asm volatile(_ASM_DEC "%0\n"
13718 +
13719 +#ifdef CONFIG_PAX_REFCOUNT
13720 + "jno 0f\n"
13721 + _ASM_INC "%0\n"
13722 + "int $4\n0:\n"
13723 + _ASM_EXTABLE(0b, 0b)
13724 +#endif
13725 +
13726 + "sete %1\n"
13727 : "+m" (l->a.counter), "=qm" (c)
13728 : : "memory");
13729 return c != 0;
13730 @@ -90,7 +172,16 @@ static inline int local_inc_and_test(local_t *l)
13731 {
13732 unsigned char c;
13733
13734 - asm volatile(_ASM_INC "%0; sete %1"
13735 + asm volatile(_ASM_INC "%0\n"
13736 +
13737 +#ifdef CONFIG_PAX_REFCOUNT
13738 + "jno 0f\n"
13739 + _ASM_DEC "%0\n"
13740 + "int $4\n0:\n"
13741 + _ASM_EXTABLE(0b, 0b)
13742 +#endif
13743 +
13744 + "sete %1\n"
13745 : "+m" (l->a.counter), "=qm" (c)
13746 : : "memory");
13747 return c != 0;
13748 @@ -109,7 +200,16 @@ static inline int local_add_negative(long i, local_t *l)
13749 {
13750 unsigned char c;
13751
13752 - asm volatile(_ASM_ADD "%2,%0; sets %1"
13753 + asm volatile(_ASM_ADD "%2,%0\n"
13754 +
13755 +#ifdef CONFIG_PAX_REFCOUNT
13756 + "jno 0f\n"
13757 + _ASM_SUB "%2,%0\n"
13758 + "int $4\n0:\n"
13759 + _ASM_EXTABLE(0b, 0b)
13760 +#endif
13761 +
13762 + "sets %1\n"
13763 : "+m" (l->a.counter), "=qm" (c)
13764 : "ir" (i) : "memory");
13765 return c;
13766 @@ -125,6 +225,30 @@ static inline int local_add_negative(long i, local_t *l)
13767 static inline long local_add_return(long i, local_t *l)
13768 {
13769 long __i = i;
13770 + asm volatile(_ASM_XADD "%0, %1\n"
13771 +
13772 +#ifdef CONFIG_PAX_REFCOUNT
13773 + "jno 0f\n"
13774 + _ASM_MOV "%0,%1\n"
13775 + "int $4\n0:\n"
13776 + _ASM_EXTABLE(0b, 0b)
13777 +#endif
13778 +
13779 + : "+r" (i), "+m" (l->a.counter)
13780 + : : "memory");
13781 + return i + __i;
13782 +}
13783 +
13784 +/**
13785 + * local_add_return_unchecked - add and return
13786 + * @i: integer value to add
13787 + * @l: pointer to type local_unchecked_t
13788 + *
13789 + * Atomically adds @i to @l and returns @i + @l
13790 + */
13791 +static inline long local_add_return_unchecked(long i, local_unchecked_t *l)
13792 +{
13793 + long __i = i;
13794 asm volatile(_ASM_XADD "%0, %1;"
13795 : "+r" (i), "+m" (l->a.counter)
13796 : : "memory");
13797 @@ -141,6 +265,8 @@ static inline long local_sub_return(long i, local_t *l)
13798
13799 #define local_cmpxchg(l, o, n) \
13800 (cmpxchg_local(&((l)->a.counter), (o), (n)))
13801 +#define local_cmpxchg_unchecked(l, o, n) \
13802 + (cmpxchg_local(&((l)->a.counter), (o), (n)))
13803 /* Always has a lock prefix */
13804 #define local_xchg(l, n) (xchg(&((l)->a.counter), (n)))
13805
13806 diff --git a/arch/x86/include/asm/mman.h b/arch/x86/include/asm/mman.h
13807 new file mode 100644
13808 index 0000000..2bfd3ba
13809 --- /dev/null
13810 +++ b/arch/x86/include/asm/mman.h
13811 @@ -0,0 +1,15 @@
13812 +#ifndef _X86_MMAN_H
13813 +#define _X86_MMAN_H
13814 +
13815 +#include <uapi/asm/mman.h>
13816 +
13817 +#ifdef __KERNEL__
13818 +#ifndef __ASSEMBLY__
13819 +#ifdef CONFIG_X86_32
13820 +#define arch_mmap_check i386_mmap_check
13821 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags);
13822 +#endif
13823 +#endif
13824 +#endif
13825 +
13826 +#endif /* X86_MMAN_H */
13827 diff --git a/arch/x86/include/asm/mmu.h b/arch/x86/include/asm/mmu.h
13828 index 5f55e69..e20bfb1 100644
13829 --- a/arch/x86/include/asm/mmu.h
13830 +++ b/arch/x86/include/asm/mmu.h
13831 @@ -9,7 +9,7 @@
13832 * we put the segment information here.
13833 */
13834 typedef struct {
13835 - void *ldt;
13836 + struct desc_struct *ldt;
13837 int size;
13838
13839 #ifdef CONFIG_X86_64
13840 @@ -18,7 +18,19 @@ typedef struct {
13841 #endif
13842
13843 struct mutex lock;
13844 - void *vdso;
13845 + unsigned long vdso;
13846 +
13847 +#ifdef CONFIG_X86_32
13848 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
13849 + unsigned long user_cs_base;
13850 + unsigned long user_cs_limit;
13851 +
13852 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
13853 + cpumask_t cpu_user_cs_mask;
13854 +#endif
13855 +
13856 +#endif
13857 +#endif
13858 } mm_context_t;
13859
13860 #ifdef CONFIG_SMP
13861 diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h
13862 index cdbf367..adb37ac 100644
13863 --- a/arch/x86/include/asm/mmu_context.h
13864 +++ b/arch/x86/include/asm/mmu_context.h
13865 @@ -24,6 +24,18 @@ void destroy_context(struct mm_struct *mm);
13866
13867 static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
13868 {
13869 +
13870 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
13871 + unsigned int i;
13872 + pgd_t *pgd;
13873 +
13874 + pax_open_kernel();
13875 + pgd = get_cpu_pgd(smp_processor_id());
13876 + for (i = USER_PGD_PTRS; i < 2 * USER_PGD_PTRS; ++i)
13877 + set_pgd_batched(pgd+i, native_make_pgd(0));
13878 + pax_close_kernel();
13879 +#endif
13880 +
13881 #ifdef CONFIG_SMP
13882 if (this_cpu_read(cpu_tlbstate.state) == TLBSTATE_OK)
13883 this_cpu_write(cpu_tlbstate.state, TLBSTATE_LAZY);
13884 @@ -34,16 +46,30 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
13885 struct task_struct *tsk)
13886 {
13887 unsigned cpu = smp_processor_id();
13888 +#if defined(CONFIG_X86_32) && defined(CONFIG_SMP) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
13889 + int tlbstate = TLBSTATE_OK;
13890 +#endif
13891
13892 if (likely(prev != next)) {
13893 #ifdef CONFIG_SMP
13894 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
13895 + tlbstate = this_cpu_read(cpu_tlbstate.state);
13896 +#endif
13897 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
13898 this_cpu_write(cpu_tlbstate.active_mm, next);
13899 #endif
13900 cpumask_set_cpu(cpu, mm_cpumask(next));
13901
13902 /* Re-load page tables */
13903 +#ifdef CONFIG_PAX_PER_CPU_PGD
13904 + pax_open_kernel();
13905 + __clone_user_pgds(get_cpu_pgd(cpu), next->pgd);
13906 + __shadow_user_pgds(get_cpu_pgd(cpu) + USER_PGD_PTRS, next->pgd);
13907 + pax_close_kernel();
13908 + load_cr3(get_cpu_pgd(cpu));
13909 +#else
13910 load_cr3(next->pgd);
13911 +#endif
13912
13913 /* stop flush ipis for the previous mm */
13914 cpumask_clear_cpu(cpu, mm_cpumask(prev));
13915 @@ -53,9 +79,38 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
13916 */
13917 if (unlikely(prev->context.ldt != next->context.ldt))
13918 load_LDT_nolock(&next->context);
13919 - }
13920 +
13921 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
13922 + if (!(__supported_pte_mask & _PAGE_NX)) {
13923 + smp_mb__before_clear_bit();
13924 + cpu_clear(cpu, prev->context.cpu_user_cs_mask);
13925 + smp_mb__after_clear_bit();
13926 + cpu_set(cpu, next->context.cpu_user_cs_mask);
13927 + }
13928 +#endif
13929 +
13930 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
13931 + if (unlikely(prev->context.user_cs_base != next->context.user_cs_base ||
13932 + prev->context.user_cs_limit != next->context.user_cs_limit))
13933 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
13934 #ifdef CONFIG_SMP
13935 + else if (unlikely(tlbstate != TLBSTATE_OK))
13936 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
13937 +#endif
13938 +#endif
13939 +
13940 + }
13941 else {
13942 +
13943 +#ifdef CONFIG_PAX_PER_CPU_PGD
13944 + pax_open_kernel();
13945 + __clone_user_pgds(get_cpu_pgd(cpu), next->pgd);
13946 + __shadow_user_pgds(get_cpu_pgd(cpu) + USER_PGD_PTRS, next->pgd);
13947 + pax_close_kernel();
13948 + load_cr3(get_cpu_pgd(cpu));
13949 +#endif
13950 +
13951 +#ifdef CONFIG_SMP
13952 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
13953 BUG_ON(this_cpu_read(cpu_tlbstate.active_mm) != next);
13954
13955 @@ -64,11 +119,28 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
13956 * tlb flush IPI delivery. We must reload CR3
13957 * to make sure to use no freed page tables.
13958 */
13959 +
13960 +#ifndef CONFIG_PAX_PER_CPU_PGD
13961 load_cr3(next->pgd);
13962 +#endif
13963 +
13964 load_LDT_nolock(&next->context);
13965 +
13966 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
13967 + if (!(__supported_pte_mask & _PAGE_NX))
13968 + cpu_set(cpu, next->context.cpu_user_cs_mask);
13969 +#endif
13970 +
13971 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
13972 +#ifdef CONFIG_PAX_PAGEEXEC
13973 + if (!((next->pax_flags & MF_PAX_PAGEEXEC) && (__supported_pte_mask & _PAGE_NX)))
13974 +#endif
13975 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
13976 +#endif
13977 +
13978 }
13979 +#endif
13980 }
13981 -#endif
13982 }
13983
13984 #define activate_mm(prev, next) \
13985 diff --git a/arch/x86/include/asm/module.h b/arch/x86/include/asm/module.h
13986 index e3b7819..b257c64 100644
13987 --- a/arch/x86/include/asm/module.h
13988 +++ b/arch/x86/include/asm/module.h
13989 @@ -5,6 +5,7 @@
13990
13991 #ifdef CONFIG_X86_64
13992 /* X86_64 does not define MODULE_PROC_FAMILY */
13993 +#define MODULE_PROC_FAMILY ""
13994 #elif defined CONFIG_M486
13995 #define MODULE_PROC_FAMILY "486 "
13996 #elif defined CONFIG_M586
13997 @@ -57,8 +58,20 @@
13998 #error unknown processor family
13999 #endif
14000
14001 -#ifdef CONFIG_X86_32
14002 -# define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY
14003 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
14004 +#define MODULE_PAX_KERNEXEC "KERNEXEC_BTS "
14005 +#elif defined(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR)
14006 +#define MODULE_PAX_KERNEXEC "KERNEXEC_OR "
14007 +#else
14008 +#define MODULE_PAX_KERNEXEC ""
14009 #endif
14010
14011 +#ifdef CONFIG_PAX_MEMORY_UDEREF
14012 +#define MODULE_PAX_UDEREF "UDEREF "
14013 +#else
14014 +#define MODULE_PAX_UDEREF ""
14015 +#endif
14016 +
14017 +#define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY MODULE_PAX_KERNEXEC MODULE_PAX_UDEREF
14018 +
14019 #endif /* _ASM_X86_MODULE_H */
14020 diff --git a/arch/x86/include/asm/nmi.h b/arch/x86/include/asm/nmi.h
14021 index c0fa356..07a498a 100644
14022 --- a/arch/x86/include/asm/nmi.h
14023 +++ b/arch/x86/include/asm/nmi.h
14024 @@ -42,11 +42,11 @@ struct nmiaction {
14025 nmi_handler_t handler;
14026 unsigned long flags;
14027 const char *name;
14028 -};
14029 +} __do_const;
14030
14031 #define register_nmi_handler(t, fn, fg, n, init...) \
14032 ({ \
14033 - static struct nmiaction init fn##_na = { \
14034 + static const struct nmiaction init fn##_na = { \
14035 .handler = (fn), \
14036 .name = (n), \
14037 .flags = (fg), \
14038 @@ -54,7 +54,7 @@ struct nmiaction {
14039 __register_nmi_handler((t), &fn##_na); \
14040 })
14041
14042 -int __register_nmi_handler(unsigned int, struct nmiaction *);
14043 +int __register_nmi_handler(unsigned int, const struct nmiaction *);
14044
14045 void unregister_nmi_handler(unsigned int, const char *);
14046
14047 diff --git a/arch/x86/include/asm/page_64.h b/arch/x86/include/asm/page_64.h
14048 index 0f1ddee..e2fc3d1 100644
14049 --- a/arch/x86/include/asm/page_64.h
14050 +++ b/arch/x86/include/asm/page_64.h
14051 @@ -7,9 +7,9 @@
14052
14053 /* duplicated to the one in bootmem.h */
14054 extern unsigned long max_pfn;
14055 -extern unsigned long phys_base;
14056 +extern const unsigned long phys_base;
14057
14058 -static inline unsigned long __phys_addr_nodebug(unsigned long x)
14059 +static inline unsigned long __intentional_overflow(-1) __phys_addr_nodebug(unsigned long x)
14060 {
14061 unsigned long y = x - __START_KERNEL_map;
14062
14063 diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
14064 index 7361e47..16dc226 100644
14065 --- a/arch/x86/include/asm/paravirt.h
14066 +++ b/arch/x86/include/asm/paravirt.h
14067 @@ -564,7 +564,7 @@ static inline pmd_t __pmd(pmdval_t val)
14068 return (pmd_t) { ret };
14069 }
14070
14071 -static inline pmdval_t pmd_val(pmd_t pmd)
14072 +static inline __intentional_overflow(-1) pmdval_t pmd_val(pmd_t pmd)
14073 {
14074 pmdval_t ret;
14075
14076 @@ -630,6 +630,18 @@ static inline void set_pgd(pgd_t *pgdp, pgd_t pgd)
14077 val);
14078 }
14079
14080 +static inline void set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
14081 +{
14082 + pgdval_t val = native_pgd_val(pgd);
14083 +
14084 + if (sizeof(pgdval_t) > sizeof(long))
14085 + PVOP_VCALL3(pv_mmu_ops.set_pgd_batched, pgdp,
14086 + val, (u64)val >> 32);
14087 + else
14088 + PVOP_VCALL2(pv_mmu_ops.set_pgd_batched, pgdp,
14089 + val);
14090 +}
14091 +
14092 static inline void pgd_clear(pgd_t *pgdp)
14093 {
14094 set_pgd(pgdp, __pgd(0));
14095 @@ -714,6 +726,21 @@ static inline void __set_fixmap(unsigned /* enum fixed_addresses */ idx,
14096 pv_mmu_ops.set_fixmap(idx, phys, flags);
14097 }
14098
14099 +#ifdef CONFIG_PAX_KERNEXEC
14100 +static inline unsigned long pax_open_kernel(void)
14101 +{
14102 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_open_kernel);
14103 +}
14104 +
14105 +static inline unsigned long pax_close_kernel(void)
14106 +{
14107 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_close_kernel);
14108 +}
14109 +#else
14110 +static inline unsigned long pax_open_kernel(void) { return 0; }
14111 +static inline unsigned long pax_close_kernel(void) { return 0; }
14112 +#endif
14113 +
14114 #if defined(CONFIG_SMP) && defined(CONFIG_PARAVIRT_SPINLOCKS)
14115
14116 static inline int arch_spin_is_locked(struct arch_spinlock *lock)
14117 @@ -930,7 +957,7 @@ extern void default_banner(void);
14118
14119 #define PARA_PATCH(struct, off) ((PARAVIRT_PATCH_##struct + (off)) / 4)
14120 #define PARA_SITE(ptype, clobbers, ops) _PVSITE(ptype, clobbers, ops, .long, 4)
14121 -#define PARA_INDIRECT(addr) *%cs:addr
14122 +#define PARA_INDIRECT(addr) *%ss:addr
14123 #endif
14124
14125 #define INTERRUPT_RETURN \
14126 @@ -1005,6 +1032,21 @@ extern void default_banner(void);
14127 PARA_SITE(PARA_PATCH(pv_cpu_ops, PV_CPU_irq_enable_sysexit), \
14128 CLBR_NONE, \
14129 jmp PARA_INDIRECT(pv_cpu_ops+PV_CPU_irq_enable_sysexit))
14130 +
14131 +#define GET_CR0_INTO_RDI \
14132 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0); \
14133 + mov %rax,%rdi
14134 +
14135 +#define SET_RDI_INTO_CR0 \
14136 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
14137 +
14138 +#define GET_CR3_INTO_RDI \
14139 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_read_cr3); \
14140 + mov %rax,%rdi
14141 +
14142 +#define SET_RDI_INTO_CR3 \
14143 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_write_cr3)
14144 +
14145 #endif /* CONFIG_X86_32 */
14146
14147 #endif /* __ASSEMBLY__ */
14148 diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
14149 index b3b0ec1..b1cd3eb 100644
14150 --- a/arch/x86/include/asm/paravirt_types.h
14151 +++ b/arch/x86/include/asm/paravirt_types.h
14152 @@ -84,7 +84,7 @@ struct pv_init_ops {
14153 */
14154 unsigned (*patch)(u8 type, u16 clobber, void *insnbuf,
14155 unsigned long addr, unsigned len);
14156 -};
14157 +} __no_const;
14158
14159
14160 struct pv_lazy_ops {
14161 @@ -98,7 +98,7 @@ struct pv_time_ops {
14162 unsigned long long (*sched_clock)(void);
14163 unsigned long long (*steal_clock)(int cpu);
14164 unsigned long (*get_tsc_khz)(void);
14165 -};
14166 +} __no_const;
14167
14168 struct pv_cpu_ops {
14169 /* hooks for various privileged instructions */
14170 @@ -192,7 +192,7 @@ struct pv_cpu_ops {
14171
14172 void (*start_context_switch)(struct task_struct *prev);
14173 void (*end_context_switch)(struct task_struct *next);
14174 -};
14175 +} __no_const;
14176
14177 struct pv_irq_ops {
14178 /*
14179 @@ -223,7 +223,7 @@ struct pv_apic_ops {
14180 unsigned long start_eip,
14181 unsigned long start_esp);
14182 #endif
14183 -};
14184 +} __no_const;
14185
14186 struct pv_mmu_ops {
14187 unsigned long (*read_cr2)(void);
14188 @@ -313,6 +313,7 @@ struct pv_mmu_ops {
14189 struct paravirt_callee_save make_pud;
14190
14191 void (*set_pgd)(pgd_t *pudp, pgd_t pgdval);
14192 + void (*set_pgd_batched)(pgd_t *pudp, pgd_t pgdval);
14193 #endif /* PAGETABLE_LEVELS == 4 */
14194 #endif /* PAGETABLE_LEVELS >= 3 */
14195
14196 @@ -324,6 +325,12 @@ struct pv_mmu_ops {
14197 an mfn. We can tell which is which from the index. */
14198 void (*set_fixmap)(unsigned /* enum fixed_addresses */ idx,
14199 phys_addr_t phys, pgprot_t flags);
14200 +
14201 +#ifdef CONFIG_PAX_KERNEXEC
14202 + unsigned long (*pax_open_kernel)(void);
14203 + unsigned long (*pax_close_kernel)(void);
14204 +#endif
14205 +
14206 };
14207
14208 struct arch_spinlock;
14209 @@ -334,7 +341,7 @@ struct pv_lock_ops {
14210 void (*spin_lock_flags)(struct arch_spinlock *lock, unsigned long flags);
14211 int (*spin_trylock)(struct arch_spinlock *lock);
14212 void (*spin_unlock)(struct arch_spinlock *lock);
14213 -};
14214 +} __no_const;
14215
14216 /* This contains all the paravirt structures: we get a convenient
14217 * number for each function using the offset which we use to indicate
14218 diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h
14219 index b4389a4..7024269 100644
14220 --- a/arch/x86/include/asm/pgalloc.h
14221 +++ b/arch/x86/include/asm/pgalloc.h
14222 @@ -63,6 +63,13 @@ static inline void pmd_populate_kernel(struct mm_struct *mm,
14223 pmd_t *pmd, pte_t *pte)
14224 {
14225 paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
14226 + set_pmd(pmd, __pmd(__pa(pte) | _KERNPG_TABLE));
14227 +}
14228 +
14229 +static inline void pmd_populate_user(struct mm_struct *mm,
14230 + pmd_t *pmd, pte_t *pte)
14231 +{
14232 + paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
14233 set_pmd(pmd, __pmd(__pa(pte) | _PAGE_TABLE));
14234 }
14235
14236 @@ -99,12 +106,22 @@ static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd,
14237
14238 #ifdef CONFIG_X86_PAE
14239 extern void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd);
14240 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
14241 +{
14242 + pud_populate(mm, pudp, pmd);
14243 +}
14244 #else /* !CONFIG_X86_PAE */
14245 static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
14246 {
14247 paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
14248 set_pud(pud, __pud(_PAGE_TABLE | __pa(pmd)));
14249 }
14250 +
14251 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
14252 +{
14253 + paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
14254 + set_pud(pud, __pud(_KERNPG_TABLE | __pa(pmd)));
14255 +}
14256 #endif /* CONFIG_X86_PAE */
14257
14258 #if PAGETABLE_LEVELS > 3
14259 @@ -114,6 +131,12 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
14260 set_pgd(pgd, __pgd(_PAGE_TABLE | __pa(pud)));
14261 }
14262
14263 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
14264 +{
14265 + paravirt_alloc_pud(mm, __pa(pud) >> PAGE_SHIFT);
14266 + set_pgd(pgd, __pgd(_KERNPG_TABLE | __pa(pud)));
14267 +}
14268 +
14269 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
14270 {
14271 return (pud_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
14272 diff --git a/arch/x86/include/asm/pgtable-2level.h b/arch/x86/include/asm/pgtable-2level.h
14273 index f2b489c..4f7e2e5 100644
14274 --- a/arch/x86/include/asm/pgtable-2level.h
14275 +++ b/arch/x86/include/asm/pgtable-2level.h
14276 @@ -18,7 +18,9 @@ static inline void native_set_pte(pte_t *ptep , pte_t pte)
14277
14278 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
14279 {
14280 + pax_open_kernel();
14281 *pmdp = pmd;
14282 + pax_close_kernel();
14283 }
14284
14285 static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
14286 diff --git a/arch/x86/include/asm/pgtable-3level.h b/arch/x86/include/asm/pgtable-3level.h
14287 index 4cc9f2b..5fd9226 100644
14288 --- a/arch/x86/include/asm/pgtable-3level.h
14289 +++ b/arch/x86/include/asm/pgtable-3level.h
14290 @@ -92,12 +92,16 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
14291
14292 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
14293 {
14294 + pax_open_kernel();
14295 set_64bit((unsigned long long *)(pmdp), native_pmd_val(pmd));
14296 + pax_close_kernel();
14297 }
14298
14299 static inline void native_set_pud(pud_t *pudp, pud_t pud)
14300 {
14301 + pax_open_kernel();
14302 set_64bit((unsigned long long *)(pudp), native_pud_val(pud));
14303 + pax_close_kernel();
14304 }
14305
14306 /*
14307 diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
14308 index 1e67223..dd6e7ea 100644
14309 --- a/arch/x86/include/asm/pgtable.h
14310 +++ b/arch/x86/include/asm/pgtable.h
14311 @@ -44,6 +44,7 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
14312
14313 #ifndef __PAGETABLE_PUD_FOLDED
14314 #define set_pgd(pgdp, pgd) native_set_pgd(pgdp, pgd)
14315 +#define set_pgd_batched(pgdp, pgd) native_set_pgd_batched(pgdp, pgd)
14316 #define pgd_clear(pgd) native_pgd_clear(pgd)
14317 #endif
14318
14319 @@ -81,12 +82,51 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
14320
14321 #define arch_end_context_switch(prev) do {} while(0)
14322
14323 +#define pax_open_kernel() native_pax_open_kernel()
14324 +#define pax_close_kernel() native_pax_close_kernel()
14325 #endif /* CONFIG_PARAVIRT */
14326
14327 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
14328 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
14329 +
14330 +#ifdef CONFIG_PAX_KERNEXEC
14331 +static inline unsigned long native_pax_open_kernel(void)
14332 +{
14333 + unsigned long cr0;
14334 +
14335 + preempt_disable();
14336 + barrier();
14337 + cr0 = read_cr0() ^ X86_CR0_WP;
14338 + BUG_ON(cr0 & X86_CR0_WP);
14339 + write_cr0(cr0);
14340 + return cr0 ^ X86_CR0_WP;
14341 +}
14342 +
14343 +static inline unsigned long native_pax_close_kernel(void)
14344 +{
14345 + unsigned long cr0;
14346 +
14347 + cr0 = read_cr0() ^ X86_CR0_WP;
14348 + BUG_ON(!(cr0 & X86_CR0_WP));
14349 + write_cr0(cr0);
14350 + barrier();
14351 + preempt_enable_no_resched();
14352 + return cr0 ^ X86_CR0_WP;
14353 +}
14354 +#else
14355 +static inline unsigned long native_pax_open_kernel(void) { return 0; }
14356 +static inline unsigned long native_pax_close_kernel(void) { return 0; }
14357 +#endif
14358 +
14359 /*
14360 * The following only work if pte_present() is true.
14361 * Undefined behaviour if not..
14362 */
14363 +static inline int pte_user(pte_t pte)
14364 +{
14365 + return pte_val(pte) & _PAGE_USER;
14366 +}
14367 +
14368 static inline int pte_dirty(pte_t pte)
14369 {
14370 return pte_flags(pte) & _PAGE_DIRTY;
14371 @@ -147,6 +187,11 @@ static inline unsigned long pud_pfn(pud_t pud)
14372 return (pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT;
14373 }
14374
14375 +static inline unsigned long pgd_pfn(pgd_t pgd)
14376 +{
14377 + return (pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT;
14378 +}
14379 +
14380 #define pte_page(pte) pfn_to_page(pte_pfn(pte))
14381
14382 static inline int pmd_large(pmd_t pte)
14383 @@ -200,9 +245,29 @@ static inline pte_t pte_wrprotect(pte_t pte)
14384 return pte_clear_flags(pte, _PAGE_RW);
14385 }
14386
14387 +static inline pte_t pte_mkread(pte_t pte)
14388 +{
14389 + return __pte(pte_val(pte) | _PAGE_USER);
14390 +}
14391 +
14392 static inline pte_t pte_mkexec(pte_t pte)
14393 {
14394 - return pte_clear_flags(pte, _PAGE_NX);
14395 +#ifdef CONFIG_X86_PAE
14396 + if (__supported_pte_mask & _PAGE_NX)
14397 + return pte_clear_flags(pte, _PAGE_NX);
14398 + else
14399 +#endif
14400 + return pte_set_flags(pte, _PAGE_USER);
14401 +}
14402 +
14403 +static inline pte_t pte_exprotect(pte_t pte)
14404 +{
14405 +#ifdef CONFIG_X86_PAE
14406 + if (__supported_pte_mask & _PAGE_NX)
14407 + return pte_set_flags(pte, _PAGE_NX);
14408 + else
14409 +#endif
14410 + return pte_clear_flags(pte, _PAGE_USER);
14411 }
14412
14413 static inline pte_t pte_mkdirty(pte_t pte)
14414 @@ -394,6 +459,15 @@ pte_t *populate_extra_pte(unsigned long vaddr);
14415 #endif
14416
14417 #ifndef __ASSEMBLY__
14418 +
14419 +#ifdef CONFIG_PAX_PER_CPU_PGD
14420 +extern pgd_t cpu_pgd[NR_CPUS][PTRS_PER_PGD];
14421 +static inline pgd_t *get_cpu_pgd(unsigned int cpu)
14422 +{
14423 + return cpu_pgd[cpu];
14424 +}
14425 +#endif
14426 +
14427 #include <linux/mm_types.h>
14428 #include <linux/log2.h>
14429
14430 @@ -529,7 +603,7 @@ static inline unsigned long pud_page_vaddr(pud_t pud)
14431 * Currently stuck as a macro due to indirect forward reference to
14432 * linux/mmzone.h's __section_mem_map_addr() definition:
14433 */
14434 -#define pud_page(pud) pfn_to_page(pud_val(pud) >> PAGE_SHIFT)
14435 +#define pud_page(pud) pfn_to_page((pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT)
14436
14437 /* Find an entry in the second-level page table.. */
14438 static inline pmd_t *pmd_offset(pud_t *pud, unsigned long address)
14439 @@ -569,7 +643,7 @@ static inline unsigned long pgd_page_vaddr(pgd_t pgd)
14440 * Currently stuck as a macro due to indirect forward reference to
14441 * linux/mmzone.h's __section_mem_map_addr() definition:
14442 */
14443 -#define pgd_page(pgd) pfn_to_page(pgd_val(pgd) >> PAGE_SHIFT)
14444 +#define pgd_page(pgd) pfn_to_page((pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT)
14445
14446 /* to find an entry in a page-table-directory. */
14447 static inline unsigned long pud_index(unsigned long address)
14448 @@ -584,7 +658,7 @@ static inline pud_t *pud_offset(pgd_t *pgd, unsigned long address)
14449
14450 static inline int pgd_bad(pgd_t pgd)
14451 {
14452 - return (pgd_flags(pgd) & ~_PAGE_USER) != _KERNPG_TABLE;
14453 + return (pgd_flags(pgd) & ~(_PAGE_USER | _PAGE_NX)) != _KERNPG_TABLE;
14454 }
14455
14456 static inline int pgd_none(pgd_t pgd)
14457 @@ -607,7 +681,12 @@ static inline int pgd_none(pgd_t pgd)
14458 * pgd_offset() returns a (pgd_t *)
14459 * pgd_index() is used get the offset into the pgd page's array of pgd_t's;
14460 */
14461 -#define pgd_offset(mm, address) ((mm)->pgd + pgd_index((address)))
14462 +#define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))
14463 +
14464 +#ifdef CONFIG_PAX_PER_CPU_PGD
14465 +#define pgd_offset_cpu(cpu, address) (get_cpu_pgd(cpu) + pgd_index(address))
14466 +#endif
14467 +
14468 /*
14469 * a shortcut which implies the use of the kernel's pgd, instead
14470 * of a process's
14471 @@ -618,6 +697,22 @@ static inline int pgd_none(pgd_t pgd)
14472 #define KERNEL_PGD_BOUNDARY pgd_index(PAGE_OFFSET)
14473 #define KERNEL_PGD_PTRS (PTRS_PER_PGD - KERNEL_PGD_BOUNDARY)
14474
14475 +#ifdef CONFIG_X86_32
14476 +#define USER_PGD_PTRS KERNEL_PGD_BOUNDARY
14477 +#else
14478 +#define TASK_SIZE_MAX_SHIFT CONFIG_TASK_SIZE_MAX_SHIFT
14479 +#define USER_PGD_PTRS (_AC(1,UL) << (TASK_SIZE_MAX_SHIFT - PGDIR_SHIFT))
14480 +
14481 +#ifdef CONFIG_PAX_MEMORY_UDEREF
14482 +#ifdef __ASSEMBLY__
14483 +#define pax_user_shadow_base pax_user_shadow_base(%rip)
14484 +#else
14485 +extern unsigned long pax_user_shadow_base;
14486 +#endif
14487 +#endif
14488 +
14489 +#endif
14490 +
14491 #ifndef __ASSEMBLY__
14492
14493 extern int direct_gbpages;
14494 @@ -784,11 +879,24 @@ static inline void pmdp_set_wrprotect(struct mm_struct *mm,
14495 * dst and src can be on the same page, but the range must not overlap,
14496 * and must not cross a page boundary.
14497 */
14498 -static inline void clone_pgd_range(pgd_t *dst, pgd_t *src, int count)
14499 +static inline void clone_pgd_range(pgd_t *dst, const pgd_t *src, int count)
14500 {
14501 - memcpy(dst, src, count * sizeof(pgd_t));
14502 + pax_open_kernel();
14503 + while (count--)
14504 + *dst++ = *src++;
14505 + pax_close_kernel();
14506 }
14507
14508 +#ifdef CONFIG_PAX_PER_CPU_PGD
14509 +extern void __clone_user_pgds(pgd_t *dst, const pgd_t *src);
14510 +#endif
14511 +
14512 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
14513 +extern void __shadow_user_pgds(pgd_t *dst, const pgd_t *src);
14514 +#else
14515 +static inline void __shadow_user_pgds(pgd_t *dst, const pgd_t *src) {}
14516 +#endif
14517 +
14518 #define PTE_SHIFT ilog2(PTRS_PER_PTE)
14519 static inline int page_level_shift(enum pg_level level)
14520 {
14521 diff --git a/arch/x86/include/asm/pgtable_32.h b/arch/x86/include/asm/pgtable_32.h
14522 index 9ee3221..b979c6b 100644
14523 --- a/arch/x86/include/asm/pgtable_32.h
14524 +++ b/arch/x86/include/asm/pgtable_32.h
14525 @@ -25,9 +25,6 @@
14526 struct mm_struct;
14527 struct vm_area_struct;
14528
14529 -extern pgd_t swapper_pg_dir[1024];
14530 -extern pgd_t initial_page_table[1024];
14531 -
14532 static inline void pgtable_cache_init(void) { }
14533 static inline void check_pgt_cache(void) { }
14534 void paging_init(void);
14535 @@ -48,6 +45,12 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
14536 # include <asm/pgtable-2level.h>
14537 #endif
14538
14539 +extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
14540 +extern pgd_t initial_page_table[PTRS_PER_PGD];
14541 +#ifdef CONFIG_X86_PAE
14542 +extern pmd_t swapper_pm_dir[PTRS_PER_PGD][PTRS_PER_PMD];
14543 +#endif
14544 +
14545 #if defined(CONFIG_HIGHPTE)
14546 #define pte_offset_map(dir, address) \
14547 ((pte_t *)kmap_atomic(pmd_page(*(dir))) + \
14548 @@ -62,12 +65,17 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
14549 /* Clear a kernel PTE and flush it from the TLB */
14550 #define kpte_clear_flush(ptep, vaddr) \
14551 do { \
14552 + pax_open_kernel(); \
14553 pte_clear(&init_mm, (vaddr), (ptep)); \
14554 + pax_close_kernel(); \
14555 __flush_tlb_one((vaddr)); \
14556 } while (0)
14557
14558 #endif /* !__ASSEMBLY__ */
14559
14560 +#define HAVE_ARCH_UNMAPPED_AREA
14561 +#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
14562 +
14563 /*
14564 * kern_addr_valid() is (1) for FLATMEM and (0) for
14565 * SPARSEMEM and DISCONTIGMEM
14566 diff --git a/arch/x86/include/asm/pgtable_32_types.h b/arch/x86/include/asm/pgtable_32_types.h
14567 index ed5903b..c7fe163 100644
14568 --- a/arch/x86/include/asm/pgtable_32_types.h
14569 +++ b/arch/x86/include/asm/pgtable_32_types.h
14570 @@ -8,7 +8,7 @@
14571 */
14572 #ifdef CONFIG_X86_PAE
14573 # include <asm/pgtable-3level_types.h>
14574 -# define PMD_SIZE (1UL << PMD_SHIFT)
14575 +# define PMD_SIZE (_AC(1, UL) << PMD_SHIFT)
14576 # define PMD_MASK (~(PMD_SIZE - 1))
14577 #else
14578 # include <asm/pgtable-2level_types.h>
14579 @@ -46,6 +46,19 @@ extern bool __vmalloc_start_set; /* set once high_memory is set */
14580 # define VMALLOC_END (FIXADDR_START - 2 * PAGE_SIZE)
14581 #endif
14582
14583 +#ifdef CONFIG_PAX_KERNEXEC
14584 +#ifndef __ASSEMBLY__
14585 +extern unsigned char MODULES_EXEC_VADDR[];
14586 +extern unsigned char MODULES_EXEC_END[];
14587 +#endif
14588 +#include <asm/boot.h>
14589 +#define ktla_ktva(addr) (addr + LOAD_PHYSICAL_ADDR + PAGE_OFFSET)
14590 +#define ktva_ktla(addr) (addr - LOAD_PHYSICAL_ADDR - PAGE_OFFSET)
14591 +#else
14592 +#define ktla_ktva(addr) (addr)
14593 +#define ktva_ktla(addr) (addr)
14594 +#endif
14595 +
14596 #define MODULES_VADDR VMALLOC_START
14597 #define MODULES_END VMALLOC_END
14598 #define MODULES_LEN (MODULES_VADDR - MODULES_END)
14599 diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
14600 index e22c1db..23a625a 100644
14601 --- a/arch/x86/include/asm/pgtable_64.h
14602 +++ b/arch/x86/include/asm/pgtable_64.h
14603 @@ -16,10 +16,14 @@
14604
14605 extern pud_t level3_kernel_pgt[512];
14606 extern pud_t level3_ident_pgt[512];
14607 +extern pud_t level3_vmalloc_start_pgt[512];
14608 +extern pud_t level3_vmalloc_end_pgt[512];
14609 +extern pud_t level3_vmemmap_pgt[512];
14610 +extern pud_t level2_vmemmap_pgt[512];
14611 extern pmd_t level2_kernel_pgt[512];
14612 extern pmd_t level2_fixmap_pgt[512];
14613 -extern pmd_t level2_ident_pgt[512];
14614 -extern pgd_t init_level4_pgt[];
14615 +extern pmd_t level2_ident_pgt[512*2];
14616 +extern pgd_t init_level4_pgt[512];
14617
14618 #define swapper_pg_dir init_level4_pgt
14619
14620 @@ -61,7 +65,9 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
14621
14622 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
14623 {
14624 + pax_open_kernel();
14625 *pmdp = pmd;
14626 + pax_close_kernel();
14627 }
14628
14629 static inline void native_pmd_clear(pmd_t *pmd)
14630 @@ -97,7 +103,9 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *xp)
14631
14632 static inline void native_set_pud(pud_t *pudp, pud_t pud)
14633 {
14634 + pax_open_kernel();
14635 *pudp = pud;
14636 + pax_close_kernel();
14637 }
14638
14639 static inline void native_pud_clear(pud_t *pud)
14640 @@ -107,6 +115,13 @@ static inline void native_pud_clear(pud_t *pud)
14641
14642 static inline void native_set_pgd(pgd_t *pgdp, pgd_t pgd)
14643 {
14644 + pax_open_kernel();
14645 + *pgdp = pgd;
14646 + pax_close_kernel();
14647 +}
14648 +
14649 +static inline void native_set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
14650 +{
14651 *pgdp = pgd;
14652 }
14653
14654 diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h
14655 index 2d88344..4679fc3 100644
14656 --- a/arch/x86/include/asm/pgtable_64_types.h
14657 +++ b/arch/x86/include/asm/pgtable_64_types.h
14658 @@ -61,6 +61,11 @@ typedef struct { pteval_t pte; } pte_t;
14659 #define MODULES_VADDR _AC(0xffffffffa0000000, UL)
14660 #define MODULES_END _AC(0xffffffffff000000, UL)
14661 #define MODULES_LEN (MODULES_END - MODULES_VADDR)
14662 +#define MODULES_EXEC_VADDR MODULES_VADDR
14663 +#define MODULES_EXEC_END MODULES_END
14664 +
14665 +#define ktla_ktva(addr) (addr)
14666 +#define ktva_ktla(addr) (addr)
14667
14668 #define EARLY_DYNAMIC_PAGE_TABLES 64
14669
14670 diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h
14671 index 567b5d0..bd91d64 100644
14672 --- a/arch/x86/include/asm/pgtable_types.h
14673 +++ b/arch/x86/include/asm/pgtable_types.h
14674 @@ -16,13 +16,12 @@
14675 #define _PAGE_BIT_PSE 7 /* 4 MB (or 2MB) page */
14676 #define _PAGE_BIT_PAT 7 /* on 4KB pages */
14677 #define _PAGE_BIT_GLOBAL 8 /* Global TLB entry PPro+ */
14678 -#define _PAGE_BIT_UNUSED1 9 /* available for programmer */
14679 +#define _PAGE_BIT_SPECIAL 9 /* special mappings, no associated struct page */
14680 #define _PAGE_BIT_IOMAP 10 /* flag used to indicate IO mapping */
14681 #define _PAGE_BIT_HIDDEN 11 /* hidden by kmemcheck */
14682 #define _PAGE_BIT_PAT_LARGE 12 /* On 2MB or 1GB pages */
14683 -#define _PAGE_BIT_SPECIAL _PAGE_BIT_UNUSED1
14684 -#define _PAGE_BIT_CPA_TEST _PAGE_BIT_UNUSED1
14685 -#define _PAGE_BIT_SPLITTING _PAGE_BIT_UNUSED1 /* only valid on a PSE pmd */
14686 +#define _PAGE_BIT_CPA_TEST _PAGE_BIT_SPECIAL
14687 +#define _PAGE_BIT_SPLITTING _PAGE_BIT_SPECIAL /* only valid on a PSE pmd */
14688 #define _PAGE_BIT_NX 63 /* No execute: only valid after cpuid check */
14689
14690 /* If _PAGE_BIT_PRESENT is clear, we use these: */
14691 @@ -40,7 +39,6 @@
14692 #define _PAGE_DIRTY (_AT(pteval_t, 1) << _PAGE_BIT_DIRTY)
14693 #define _PAGE_PSE (_AT(pteval_t, 1) << _PAGE_BIT_PSE)
14694 #define _PAGE_GLOBAL (_AT(pteval_t, 1) << _PAGE_BIT_GLOBAL)
14695 -#define _PAGE_UNUSED1 (_AT(pteval_t, 1) << _PAGE_BIT_UNUSED1)
14696 #define _PAGE_IOMAP (_AT(pteval_t, 1) << _PAGE_BIT_IOMAP)
14697 #define _PAGE_PAT (_AT(pteval_t, 1) << _PAGE_BIT_PAT)
14698 #define _PAGE_PAT_LARGE (_AT(pteval_t, 1) << _PAGE_BIT_PAT_LARGE)
14699 @@ -57,8 +55,10 @@
14700
14701 #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
14702 #define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX)
14703 -#else
14704 +#elif defined(CONFIG_KMEMCHECK)
14705 #define _PAGE_NX (_AT(pteval_t, 0))
14706 +#else
14707 +#define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_HIDDEN)
14708 #endif
14709
14710 #define _PAGE_FILE (_AT(pteval_t, 1) << _PAGE_BIT_FILE)
14711 @@ -116,6 +116,9 @@
14712 #define PAGE_READONLY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | \
14713 _PAGE_ACCESSED)
14714
14715 +#define PAGE_READONLY_NOEXEC PAGE_READONLY
14716 +#define PAGE_SHARED_NOEXEC PAGE_SHARED
14717 +
14718 #define __PAGE_KERNEL_EXEC \
14719 (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_GLOBAL)
14720 #define __PAGE_KERNEL (__PAGE_KERNEL_EXEC | _PAGE_NX)
14721 @@ -126,7 +129,7 @@
14722 #define __PAGE_KERNEL_WC (__PAGE_KERNEL | _PAGE_CACHE_WC)
14723 #define __PAGE_KERNEL_NOCACHE (__PAGE_KERNEL | _PAGE_PCD | _PAGE_PWT)
14724 #define __PAGE_KERNEL_UC_MINUS (__PAGE_KERNEL | _PAGE_PCD)
14725 -#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RX | _PAGE_USER)
14726 +#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RO | _PAGE_USER)
14727 #define __PAGE_KERNEL_VVAR (__PAGE_KERNEL_RO | _PAGE_USER)
14728 #define __PAGE_KERNEL_VVAR_NOCACHE (__PAGE_KERNEL_VVAR | _PAGE_PCD | _PAGE_PWT)
14729 #define __PAGE_KERNEL_LARGE (__PAGE_KERNEL | _PAGE_PSE)
14730 @@ -188,8 +191,8 @@
14731 * bits are combined, this will alow user to access the high address mapped
14732 * VDSO in the presence of CONFIG_COMPAT_VDSO
14733 */
14734 -#define PTE_IDENT_ATTR 0x003 /* PRESENT+RW */
14735 -#define PDE_IDENT_ATTR 0x067 /* PRESENT+RW+USER+DIRTY+ACCESSED */
14736 +#define PTE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
14737 +#define PDE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
14738 #define PGD_IDENT_ATTR 0x001 /* PRESENT (no other attributes) */
14739 #endif
14740
14741 @@ -227,7 +230,17 @@ static inline pgdval_t pgd_flags(pgd_t pgd)
14742 {
14743 return native_pgd_val(pgd) & PTE_FLAGS_MASK;
14744 }
14745 +#endif
14746
14747 +#if PAGETABLE_LEVELS == 3
14748 +#include <asm-generic/pgtable-nopud.h>
14749 +#endif
14750 +
14751 +#if PAGETABLE_LEVELS == 2
14752 +#include <asm-generic/pgtable-nopmd.h>
14753 +#endif
14754 +
14755 +#ifndef __ASSEMBLY__
14756 #if PAGETABLE_LEVELS > 3
14757 typedef struct { pudval_t pud; } pud_t;
14758
14759 @@ -241,8 +254,6 @@ static inline pudval_t native_pud_val(pud_t pud)
14760 return pud.pud;
14761 }
14762 #else
14763 -#include <asm-generic/pgtable-nopud.h>
14764 -
14765 static inline pudval_t native_pud_val(pud_t pud)
14766 {
14767 return native_pgd_val(pud.pgd);
14768 @@ -262,8 +273,6 @@ static inline pmdval_t native_pmd_val(pmd_t pmd)
14769 return pmd.pmd;
14770 }
14771 #else
14772 -#include <asm-generic/pgtable-nopmd.h>
14773 -
14774 static inline pmdval_t native_pmd_val(pmd_t pmd)
14775 {
14776 return native_pgd_val(pmd.pud.pgd);
14777 @@ -303,7 +312,6 @@ typedef struct page *pgtable_t;
14778
14779 extern pteval_t __supported_pte_mask;
14780 extern void set_nx(void);
14781 -extern int nx_enabled;
14782
14783 #define pgprot_writecombine pgprot_writecombine
14784 extern pgprot_t pgprot_writecombine(pgprot_t prot);
14785 diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
14786 index 3270116..8d99d82 100644
14787 --- a/arch/x86/include/asm/processor.h
14788 +++ b/arch/x86/include/asm/processor.h
14789 @@ -285,7 +285,7 @@ struct tss_struct {
14790
14791 } ____cacheline_aligned;
14792
14793 -DECLARE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss);
14794 +extern struct tss_struct init_tss[NR_CPUS];
14795
14796 /*
14797 * Save the original ist values for checking stack pointers during debugging
14798 @@ -826,11 +826,18 @@ static inline void spin_lock_prefetch(const void *x)
14799 */
14800 #define TASK_SIZE PAGE_OFFSET
14801 #define TASK_SIZE_MAX TASK_SIZE
14802 +
14803 +#ifdef CONFIG_PAX_SEGMEXEC
14804 +#define SEGMEXEC_TASK_SIZE (TASK_SIZE / 2)
14805 +#define STACK_TOP ((current->mm->pax_flags & MF_PAX_SEGMEXEC)?SEGMEXEC_TASK_SIZE:TASK_SIZE)
14806 +#else
14807 #define STACK_TOP TASK_SIZE
14808 -#define STACK_TOP_MAX STACK_TOP
14809 +#endif
14810 +
14811 +#define STACK_TOP_MAX TASK_SIZE
14812
14813 #define INIT_THREAD { \
14814 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
14815 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
14816 .vm86_info = NULL, \
14817 .sysenter_cs = __KERNEL_CS, \
14818 .io_bitmap_ptr = NULL, \
14819 @@ -844,7 +851,7 @@ static inline void spin_lock_prefetch(const void *x)
14820 */
14821 #define INIT_TSS { \
14822 .x86_tss = { \
14823 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
14824 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
14825 .ss0 = __KERNEL_DS, \
14826 .ss1 = __KERNEL_CS, \
14827 .io_bitmap_base = INVALID_IO_BITMAP_OFFSET, \
14828 @@ -855,11 +862,7 @@ static inline void spin_lock_prefetch(const void *x)
14829 extern unsigned long thread_saved_pc(struct task_struct *tsk);
14830
14831 #define THREAD_SIZE_LONGS (THREAD_SIZE/sizeof(unsigned long))
14832 -#define KSTK_TOP(info) \
14833 -({ \
14834 - unsigned long *__ptr = (unsigned long *)(info); \
14835 - (unsigned long)(&__ptr[THREAD_SIZE_LONGS]); \
14836 -})
14837 +#define KSTK_TOP(info) ((container_of(info, struct task_struct, tinfo))->thread.sp0)
14838
14839 /*
14840 * The below -8 is to reserve 8 bytes on top of the ring0 stack.
14841 @@ -874,7 +877,7 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
14842 #define task_pt_regs(task) \
14843 ({ \
14844 struct pt_regs *__regs__; \
14845 - __regs__ = (struct pt_regs *)(KSTK_TOP(task_stack_page(task))-8); \
14846 + __regs__ = (struct pt_regs *)((task)->thread.sp0); \
14847 __regs__ - 1; \
14848 })
14849
14850 @@ -884,13 +887,13 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
14851 /*
14852 * User space process size. 47bits minus one guard page.
14853 */
14854 -#define TASK_SIZE_MAX ((1UL << 47) - PAGE_SIZE)
14855 +#define TASK_SIZE_MAX ((1UL << TASK_SIZE_MAX_SHIFT) - PAGE_SIZE)
14856
14857 /* This decides where the kernel will search for a free chunk of vm
14858 * space during mmap's.
14859 */
14860 #define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? \
14861 - 0xc0000000 : 0xFFFFe000)
14862 + 0xc0000000 : 0xFFFFf000)
14863
14864 #define TASK_SIZE (test_thread_flag(TIF_ADDR32) ? \
14865 IA32_PAGE_OFFSET : TASK_SIZE_MAX)
14866 @@ -901,11 +904,11 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
14867 #define STACK_TOP_MAX TASK_SIZE_MAX
14868
14869 #define INIT_THREAD { \
14870 - .sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
14871 + .sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
14872 }
14873
14874 #define INIT_TSS { \
14875 - .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
14876 + .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
14877 }
14878
14879 /*
14880 @@ -933,6 +936,10 @@ extern void start_thread(struct pt_regs *regs, unsigned long new_ip,
14881 */
14882 #define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3))
14883
14884 +#ifdef CONFIG_PAX_SEGMEXEC
14885 +#define SEGMEXEC_TASK_UNMAPPED_BASE (PAGE_ALIGN(SEGMEXEC_TASK_SIZE / 3))
14886 +#endif
14887 +
14888 #define KSTK_EIP(task) (task_pt_regs(task)->ip)
14889
14890 /* Get/set a process' ability to use the timestamp counter instruction */
14891 @@ -993,7 +1000,7 @@ extern bool cpu_has_amd_erratum(const int *);
14892 #define cpu_has_amd_erratum(x) (false)
14893 #endif /* CONFIG_CPU_SUP_AMD */
14894
14895 -extern unsigned long arch_align_stack(unsigned long sp);
14896 +#define arch_align_stack(x) ((x) & ~0xfUL)
14897 extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
14898
14899 void default_idle(void);
14900 @@ -1003,6 +1010,6 @@ bool xen_set_default_idle(void);
14901 #define xen_set_default_idle 0
14902 #endif
14903
14904 -void stop_this_cpu(void *dummy);
14905 +void stop_this_cpu(void *dummy) __noreturn;
14906
14907 #endif /* _ASM_X86_PROCESSOR_H */
14908 diff --git a/arch/x86/include/asm/ptrace.h b/arch/x86/include/asm/ptrace.h
14909 index 942a086..6c26446 100644
14910 --- a/arch/x86/include/asm/ptrace.h
14911 +++ b/arch/x86/include/asm/ptrace.h
14912 @@ -85,28 +85,29 @@ static inline unsigned long regs_return_value(struct pt_regs *regs)
14913 }
14914
14915 /*
14916 - * user_mode_vm(regs) determines whether a register set came from user mode.
14917 + * user_mode(regs) determines whether a register set came from user mode.
14918 * This is true if V8086 mode was enabled OR if the register set was from
14919 * protected mode with RPL-3 CS value. This tricky test checks that with
14920 * one comparison. Many places in the kernel can bypass this full check
14921 - * if they have already ruled out V8086 mode, so user_mode(regs) can be used.
14922 + * if they have already ruled out V8086 mode, so user_mode_novm(regs) can
14923 + * be used.
14924 */
14925 -static inline int user_mode(struct pt_regs *regs)
14926 +static inline int user_mode_novm(struct pt_regs *regs)
14927 {
14928 #ifdef CONFIG_X86_32
14929 return (regs->cs & SEGMENT_RPL_MASK) == USER_RPL;
14930 #else
14931 - return !!(regs->cs & 3);
14932 + return !!(regs->cs & SEGMENT_RPL_MASK);
14933 #endif
14934 }
14935
14936 -static inline int user_mode_vm(struct pt_regs *regs)
14937 +static inline int user_mode(struct pt_regs *regs)
14938 {
14939 #ifdef CONFIG_X86_32
14940 return ((regs->cs & SEGMENT_RPL_MASK) | (regs->flags & X86_VM_MASK)) >=
14941 USER_RPL;
14942 #else
14943 - return user_mode(regs);
14944 + return user_mode_novm(regs);
14945 #endif
14946 }
14947
14948 @@ -122,15 +123,16 @@ static inline int v8086_mode(struct pt_regs *regs)
14949 #ifdef CONFIG_X86_64
14950 static inline bool user_64bit_mode(struct pt_regs *regs)
14951 {
14952 + unsigned long cs = regs->cs & 0xffff;
14953 #ifndef CONFIG_PARAVIRT
14954 /*
14955 * On non-paravirt systems, this is the only long mode CPL 3
14956 * selector. We do not allow long mode selectors in the LDT.
14957 */
14958 - return regs->cs == __USER_CS;
14959 + return cs == __USER_CS;
14960 #else
14961 /* Headers are too twisted for this to go in paravirt.h. */
14962 - return regs->cs == __USER_CS || regs->cs == pv_info.extra_user_64bit_cs;
14963 + return cs == __USER_CS || cs == pv_info.extra_user_64bit_cs;
14964 #endif
14965 }
14966
14967 @@ -181,9 +183,11 @@ static inline unsigned long regs_get_register(struct pt_regs *regs,
14968 * Traps from the kernel do not save sp and ss.
14969 * Use the helper function to retrieve sp.
14970 */
14971 - if (offset == offsetof(struct pt_regs, sp) &&
14972 - regs->cs == __KERNEL_CS)
14973 - return kernel_stack_pointer(regs);
14974 + if (offset == offsetof(struct pt_regs, sp)) {
14975 + unsigned long cs = regs->cs & 0xffff;
14976 + if (cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS)
14977 + return kernel_stack_pointer(regs);
14978 + }
14979 #endif
14980 return *(unsigned long *)((unsigned long)regs + offset);
14981 }
14982 diff --git a/arch/x86/include/asm/realmode.h b/arch/x86/include/asm/realmode.h
14983 index 9c6b890..5305f53 100644
14984 --- a/arch/x86/include/asm/realmode.h
14985 +++ b/arch/x86/include/asm/realmode.h
14986 @@ -22,16 +22,14 @@ struct real_mode_header {
14987 #endif
14988 /* APM/BIOS reboot */
14989 u32 machine_real_restart_asm;
14990 -#ifdef CONFIG_X86_64
14991 u32 machine_real_restart_seg;
14992 -#endif
14993 };
14994
14995 /* This must match data at trampoline_32/64.S */
14996 struct trampoline_header {
14997 #ifdef CONFIG_X86_32
14998 u32 start;
14999 - u16 gdt_pad;
15000 + u16 boot_cs;
15001 u16 gdt_limit;
15002 u32 gdt_base;
15003 #else
15004 diff --git a/arch/x86/include/asm/reboot.h b/arch/x86/include/asm/reboot.h
15005 index a82c4f1..ac45053 100644
15006 --- a/arch/x86/include/asm/reboot.h
15007 +++ b/arch/x86/include/asm/reboot.h
15008 @@ -6,13 +6,13 @@
15009 struct pt_regs;
15010
15011 struct machine_ops {
15012 - void (*restart)(char *cmd);
15013 - void (*halt)(void);
15014 - void (*power_off)(void);
15015 + void (* __noreturn restart)(char *cmd);
15016 + void (* __noreturn halt)(void);
15017 + void (* __noreturn power_off)(void);
15018 void (*shutdown)(void);
15019 void (*crash_shutdown)(struct pt_regs *);
15020 - void (*emergency_restart)(void);
15021 -};
15022 + void (* __noreturn emergency_restart)(void);
15023 +} __no_const;
15024
15025 extern struct machine_ops machine_ops;
15026
15027 diff --git a/arch/x86/include/asm/rwsem.h b/arch/x86/include/asm/rwsem.h
15028 index 2dbe4a7..ce1db00 100644
15029 --- a/arch/x86/include/asm/rwsem.h
15030 +++ b/arch/x86/include/asm/rwsem.h
15031 @@ -64,6 +64,14 @@ static inline void __down_read(struct rw_semaphore *sem)
15032 {
15033 asm volatile("# beginning down_read\n\t"
15034 LOCK_PREFIX _ASM_INC "(%1)\n\t"
15035 +
15036 +#ifdef CONFIG_PAX_REFCOUNT
15037 + "jno 0f\n"
15038 + LOCK_PREFIX _ASM_DEC "(%1)\n"
15039 + "int $4\n0:\n"
15040 + _ASM_EXTABLE(0b, 0b)
15041 +#endif
15042 +
15043 /* adds 0x00000001 */
15044 " jns 1f\n"
15045 " call call_rwsem_down_read_failed\n"
15046 @@ -85,6 +93,14 @@ static inline int __down_read_trylock(struct rw_semaphore *sem)
15047 "1:\n\t"
15048 " mov %1,%2\n\t"
15049 " add %3,%2\n\t"
15050 +
15051 +#ifdef CONFIG_PAX_REFCOUNT
15052 + "jno 0f\n"
15053 + "sub %3,%2\n"
15054 + "int $4\n0:\n"
15055 + _ASM_EXTABLE(0b, 0b)
15056 +#endif
15057 +
15058 " jle 2f\n\t"
15059 LOCK_PREFIX " cmpxchg %2,%0\n\t"
15060 " jnz 1b\n\t"
15061 @@ -104,6 +120,14 @@ static inline void __down_write_nested(struct rw_semaphore *sem, int subclass)
15062 long tmp;
15063 asm volatile("# beginning down_write\n\t"
15064 LOCK_PREFIX " xadd %1,(%2)\n\t"
15065 +
15066 +#ifdef CONFIG_PAX_REFCOUNT
15067 + "jno 0f\n"
15068 + "mov %1,(%2)\n"
15069 + "int $4\n0:\n"
15070 + _ASM_EXTABLE(0b, 0b)
15071 +#endif
15072 +
15073 /* adds 0xffff0001, returns the old value */
15074 " test %1,%1\n\t"
15075 /* was the count 0 before? */
15076 @@ -141,6 +165,14 @@ static inline void __up_read(struct rw_semaphore *sem)
15077 long tmp;
15078 asm volatile("# beginning __up_read\n\t"
15079 LOCK_PREFIX " xadd %1,(%2)\n\t"
15080 +
15081 +#ifdef CONFIG_PAX_REFCOUNT
15082 + "jno 0f\n"
15083 + "mov %1,(%2)\n"
15084 + "int $4\n0:\n"
15085 + _ASM_EXTABLE(0b, 0b)
15086 +#endif
15087 +
15088 /* subtracts 1, returns the old value */
15089 " jns 1f\n\t"
15090 " call call_rwsem_wake\n" /* expects old value in %edx */
15091 @@ -159,6 +191,14 @@ static inline void __up_write(struct rw_semaphore *sem)
15092 long tmp;
15093 asm volatile("# beginning __up_write\n\t"
15094 LOCK_PREFIX " xadd %1,(%2)\n\t"
15095 +
15096 +#ifdef CONFIG_PAX_REFCOUNT
15097 + "jno 0f\n"
15098 + "mov %1,(%2)\n"
15099 + "int $4\n0:\n"
15100 + _ASM_EXTABLE(0b, 0b)
15101 +#endif
15102 +
15103 /* subtracts 0xffff0001, returns the old value */
15104 " jns 1f\n\t"
15105 " call call_rwsem_wake\n" /* expects old value in %edx */
15106 @@ -176,6 +216,14 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
15107 {
15108 asm volatile("# beginning __downgrade_write\n\t"
15109 LOCK_PREFIX _ASM_ADD "%2,(%1)\n\t"
15110 +
15111 +#ifdef CONFIG_PAX_REFCOUNT
15112 + "jno 0f\n"
15113 + LOCK_PREFIX _ASM_SUB "%2,(%1)\n"
15114 + "int $4\n0:\n"
15115 + _ASM_EXTABLE(0b, 0b)
15116 +#endif
15117 +
15118 /*
15119 * transitions 0xZZZZ0001 -> 0xYYYY0001 (i386)
15120 * 0xZZZZZZZZ00000001 -> 0xYYYYYYYY00000001 (x86_64)
15121 @@ -194,7 +242,15 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
15122 */
15123 static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
15124 {
15125 - asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0"
15126 + asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0\n"
15127 +
15128 +#ifdef CONFIG_PAX_REFCOUNT
15129 + "jno 0f\n"
15130 + LOCK_PREFIX _ASM_SUB "%1,%0\n"
15131 + "int $4\n0:\n"
15132 + _ASM_EXTABLE(0b, 0b)
15133 +#endif
15134 +
15135 : "+m" (sem->count)
15136 : "er" (delta));
15137 }
15138 @@ -204,7 +260,7 @@ static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
15139 */
15140 static inline long rwsem_atomic_update(long delta, struct rw_semaphore *sem)
15141 {
15142 - return delta + xadd(&sem->count, delta);
15143 + return delta + xadd_check_overflow(&sem->count, delta);
15144 }
15145
15146 #endif /* __KERNEL__ */
15147 diff --git a/arch/x86/include/asm/segment.h b/arch/x86/include/asm/segment.h
15148 index c48a950..c6d7468 100644
15149 --- a/arch/x86/include/asm/segment.h
15150 +++ b/arch/x86/include/asm/segment.h
15151 @@ -64,10 +64,15 @@
15152 * 26 - ESPFIX small SS
15153 * 27 - per-cpu [ offset to per-cpu data area ]
15154 * 28 - stack_canary-20 [ for stack protector ]
15155 - * 29 - unused
15156 - * 30 - unused
15157 + * 29 - PCI BIOS CS
15158 + * 30 - PCI BIOS DS
15159 * 31 - TSS for double fault handler
15160 */
15161 +#define GDT_ENTRY_KERNEXEC_EFI_CS (1)
15162 +#define GDT_ENTRY_KERNEXEC_EFI_DS (2)
15163 +#define __KERNEXEC_EFI_CS (GDT_ENTRY_KERNEXEC_EFI_CS*8)
15164 +#define __KERNEXEC_EFI_DS (GDT_ENTRY_KERNEXEC_EFI_DS*8)
15165 +
15166 #define GDT_ENTRY_TLS_MIN 6
15167 #define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1)
15168
15169 @@ -79,6 +84,8 @@
15170
15171 #define GDT_ENTRY_KERNEL_CS (GDT_ENTRY_KERNEL_BASE+0)
15172
15173 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS (4)
15174 +
15175 #define GDT_ENTRY_KERNEL_DS (GDT_ENTRY_KERNEL_BASE+1)
15176
15177 #define GDT_ENTRY_TSS (GDT_ENTRY_KERNEL_BASE+4)
15178 @@ -104,6 +111,12 @@
15179 #define __KERNEL_STACK_CANARY 0
15180 #endif
15181
15182 +#define GDT_ENTRY_PCIBIOS_CS (GDT_ENTRY_KERNEL_BASE+17)
15183 +#define __PCIBIOS_CS (GDT_ENTRY_PCIBIOS_CS * 8)
15184 +
15185 +#define GDT_ENTRY_PCIBIOS_DS (GDT_ENTRY_KERNEL_BASE+18)
15186 +#define __PCIBIOS_DS (GDT_ENTRY_PCIBIOS_DS * 8)
15187 +
15188 #define GDT_ENTRY_DOUBLEFAULT_TSS 31
15189
15190 /*
15191 @@ -141,7 +154,7 @@
15192 */
15193
15194 /* Matches PNP_CS32 and PNP_CS16 (they must be consecutive) */
15195 -#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xf4) == GDT_ENTRY_PNPBIOS_BASE * 8)
15196 +#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xFFFCU) == PNP_CS32 || ((x) & 0xFFFCU) == PNP_CS16)
15197
15198
15199 #else
15200 @@ -165,6 +178,8 @@
15201 #define __USER32_CS (GDT_ENTRY_DEFAULT_USER32_CS*8+3)
15202 #define __USER32_DS __USER_DS
15203
15204 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS 7
15205 +
15206 #define GDT_ENTRY_TSS 8 /* needs two entries */
15207 #define GDT_ENTRY_LDT 10 /* needs two entries */
15208 #define GDT_ENTRY_TLS_MIN 12
15209 @@ -185,6 +200,7 @@
15210 #endif
15211
15212 #define __KERNEL_CS (GDT_ENTRY_KERNEL_CS*8)
15213 +#define __KERNEXEC_KERNEL_CS (GDT_ENTRY_KERNEXEC_KERNEL_CS*8)
15214 #define __KERNEL_DS (GDT_ENTRY_KERNEL_DS*8)
15215 #define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS*8+3)
15216 #define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS*8+3)
15217 @@ -265,7 +281,7 @@ static inline unsigned long get_limit(unsigned long segment)
15218 {
15219 unsigned long __limit;
15220 asm("lsll %1,%0" : "=r" (__limit) : "r" (segment));
15221 - return __limit + 1;
15222 + return __limit;
15223 }
15224
15225 #endif /* !__ASSEMBLY__ */
15226 diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
15227 index b073aae..39f9bdd 100644
15228 --- a/arch/x86/include/asm/smp.h
15229 +++ b/arch/x86/include/asm/smp.h
15230 @@ -36,7 +36,7 @@ DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_map);
15231 /* cpus sharing the last level cache: */
15232 DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_llc_shared_map);
15233 DECLARE_PER_CPU_READ_MOSTLY(u16, cpu_llc_id);
15234 -DECLARE_PER_CPU_READ_MOSTLY(int, cpu_number);
15235 +DECLARE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
15236
15237 static inline struct cpumask *cpu_sibling_mask(int cpu)
15238 {
15239 @@ -79,7 +79,7 @@ struct smp_ops {
15240
15241 void (*send_call_func_ipi)(const struct cpumask *mask);
15242 void (*send_call_func_single_ipi)(int cpu);
15243 -};
15244 +} __no_const;
15245
15246 /* Globals due to paravirt */
15247 extern void set_cpu_sibling_map(int cpu);
15248 @@ -191,14 +191,8 @@ extern unsigned disabled_cpus __cpuinitdata;
15249 extern int safe_smp_processor_id(void);
15250
15251 #elif defined(CONFIG_X86_64_SMP)
15252 -#define raw_smp_processor_id() (this_cpu_read(cpu_number))
15253 -
15254 -#define stack_smp_processor_id() \
15255 -({ \
15256 - struct thread_info *ti; \
15257 - __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \
15258 - ti->cpu; \
15259 -})
15260 +#define raw_smp_processor_id() (this_cpu_read(cpu_number))
15261 +#define stack_smp_processor_id() raw_smp_processor_id()
15262 #define safe_smp_processor_id() smp_processor_id()
15263
15264 #endif
15265 diff --git a/arch/x86/include/asm/spinlock.h b/arch/x86/include/asm/spinlock.h
15266 index 33692ea..350a534 100644
15267 --- a/arch/x86/include/asm/spinlock.h
15268 +++ b/arch/x86/include/asm/spinlock.h
15269 @@ -172,6 +172,14 @@ static inline int arch_write_can_lock(arch_rwlock_t *lock)
15270 static inline void arch_read_lock(arch_rwlock_t *rw)
15271 {
15272 asm volatile(LOCK_PREFIX READ_LOCK_SIZE(dec) " (%0)\n\t"
15273 +
15274 +#ifdef CONFIG_PAX_REFCOUNT
15275 + "jno 0f\n"
15276 + LOCK_PREFIX READ_LOCK_SIZE(inc) " (%0)\n"
15277 + "int $4\n0:\n"
15278 + _ASM_EXTABLE(0b, 0b)
15279 +#endif
15280 +
15281 "jns 1f\n"
15282 "call __read_lock_failed\n\t"
15283 "1:\n"
15284 @@ -181,6 +189,14 @@ static inline void arch_read_lock(arch_rwlock_t *rw)
15285 static inline void arch_write_lock(arch_rwlock_t *rw)
15286 {
15287 asm volatile(LOCK_PREFIX WRITE_LOCK_SUB(%1) "(%0)\n\t"
15288 +
15289 +#ifdef CONFIG_PAX_REFCOUNT
15290 + "jno 0f\n"
15291 + LOCK_PREFIX WRITE_LOCK_ADD(%1) "(%0)\n"
15292 + "int $4\n0:\n"
15293 + _ASM_EXTABLE(0b, 0b)
15294 +#endif
15295 +
15296 "jz 1f\n"
15297 "call __write_lock_failed\n\t"
15298 "1:\n"
15299 @@ -210,13 +226,29 @@ static inline int arch_write_trylock(arch_rwlock_t *lock)
15300
15301 static inline void arch_read_unlock(arch_rwlock_t *rw)
15302 {
15303 - asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0"
15304 + asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0\n"
15305 +
15306 +#ifdef CONFIG_PAX_REFCOUNT
15307 + "jno 0f\n"
15308 + LOCK_PREFIX READ_LOCK_SIZE(dec) " %0\n"
15309 + "int $4\n0:\n"
15310 + _ASM_EXTABLE(0b, 0b)
15311 +#endif
15312 +
15313 :"+m" (rw->lock) : : "memory");
15314 }
15315
15316 static inline void arch_write_unlock(arch_rwlock_t *rw)
15317 {
15318 - asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0"
15319 + asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0\n"
15320 +
15321 +#ifdef CONFIG_PAX_REFCOUNT
15322 + "jno 0f\n"
15323 + LOCK_PREFIX WRITE_LOCK_SUB(%1) "%0\n"
15324 + "int $4\n0:\n"
15325 + _ASM_EXTABLE(0b, 0b)
15326 +#endif
15327 +
15328 : "+m" (rw->write) : "i" (RW_LOCK_BIAS) : "memory");
15329 }
15330
15331 diff --git a/arch/x86/include/asm/stackprotector.h b/arch/x86/include/asm/stackprotector.h
15332 index 6a99859..03cb807 100644
15333 --- a/arch/x86/include/asm/stackprotector.h
15334 +++ b/arch/x86/include/asm/stackprotector.h
15335 @@ -47,7 +47,7 @@
15336 * head_32 for boot CPU and setup_per_cpu_areas() for others.
15337 */
15338 #define GDT_STACK_CANARY_INIT \
15339 - [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x18),
15340 + [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x17),
15341
15342 /*
15343 * Initialize the stackprotector canary value.
15344 @@ -112,7 +112,7 @@ static inline void setup_stack_canary_segment(int cpu)
15345
15346 static inline void load_stack_canary_segment(void)
15347 {
15348 -#ifdef CONFIG_X86_32
15349 +#if defined(CONFIG_X86_32) && !defined(CONFIG_PAX_MEMORY_UDEREF)
15350 asm volatile ("mov %0, %%gs" : : "r" (0));
15351 #endif
15352 }
15353 diff --git a/arch/x86/include/asm/stacktrace.h b/arch/x86/include/asm/stacktrace.h
15354 index 70bbe39..4ae2bd4 100644
15355 --- a/arch/x86/include/asm/stacktrace.h
15356 +++ b/arch/x86/include/asm/stacktrace.h
15357 @@ -11,28 +11,20 @@
15358
15359 extern int kstack_depth_to_print;
15360
15361 -struct thread_info;
15362 +struct task_struct;
15363 struct stacktrace_ops;
15364
15365 -typedef unsigned long (*walk_stack_t)(struct thread_info *tinfo,
15366 - unsigned long *stack,
15367 - unsigned long bp,
15368 - const struct stacktrace_ops *ops,
15369 - void *data,
15370 - unsigned long *end,
15371 - int *graph);
15372 +typedef unsigned long walk_stack_t(struct task_struct *task,
15373 + void *stack_start,
15374 + unsigned long *stack,
15375 + unsigned long bp,
15376 + const struct stacktrace_ops *ops,
15377 + void *data,
15378 + unsigned long *end,
15379 + int *graph);
15380
15381 -extern unsigned long
15382 -print_context_stack(struct thread_info *tinfo,
15383 - unsigned long *stack, unsigned long bp,
15384 - const struct stacktrace_ops *ops, void *data,
15385 - unsigned long *end, int *graph);
15386 -
15387 -extern unsigned long
15388 -print_context_stack_bp(struct thread_info *tinfo,
15389 - unsigned long *stack, unsigned long bp,
15390 - const struct stacktrace_ops *ops, void *data,
15391 - unsigned long *end, int *graph);
15392 +extern walk_stack_t print_context_stack;
15393 +extern walk_stack_t print_context_stack_bp;
15394
15395 /* Generic stack tracer with callbacks */
15396
15397 @@ -40,7 +32,7 @@ struct stacktrace_ops {
15398 void (*address)(void *data, unsigned long address, int reliable);
15399 /* On negative return stop dumping */
15400 int (*stack)(void *data, char *name);
15401 - walk_stack_t walk_stack;
15402 + walk_stack_t *walk_stack;
15403 };
15404
15405 void dump_trace(struct task_struct *tsk, struct pt_regs *regs,
15406 diff --git a/arch/x86/include/asm/switch_to.h b/arch/x86/include/asm/switch_to.h
15407 index 4ec45b3..a4f0a8a 100644
15408 --- a/arch/x86/include/asm/switch_to.h
15409 +++ b/arch/x86/include/asm/switch_to.h
15410 @@ -108,7 +108,7 @@ do { \
15411 "call __switch_to\n\t" \
15412 "movq "__percpu_arg([current_task])",%%rsi\n\t" \
15413 __switch_canary \
15414 - "movq %P[thread_info](%%rsi),%%r8\n\t" \
15415 + "movq "__percpu_arg([thread_info])",%%r8\n\t" \
15416 "movq %%rax,%%rdi\n\t" \
15417 "testl %[_tif_fork],%P[ti_flags](%%r8)\n\t" \
15418 "jnz ret_from_fork\n\t" \
15419 @@ -119,7 +119,7 @@ do { \
15420 [threadrsp] "i" (offsetof(struct task_struct, thread.sp)), \
15421 [ti_flags] "i" (offsetof(struct thread_info, flags)), \
15422 [_tif_fork] "i" (_TIF_FORK), \
15423 - [thread_info] "i" (offsetof(struct task_struct, stack)), \
15424 + [thread_info] "m" (current_tinfo), \
15425 [current_task] "m" (current_task) \
15426 __switch_canary_iparam \
15427 : "memory", "cc" __EXTRA_CLOBBER)
15428 diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h
15429 index 2cd056e..0224df8 100644
15430 --- a/arch/x86/include/asm/thread_info.h
15431 +++ b/arch/x86/include/asm/thread_info.h
15432 @@ -10,6 +10,7 @@
15433 #include <linux/compiler.h>
15434 #include <asm/page.h>
15435 #include <asm/types.h>
15436 +#include <asm/percpu.h>
15437
15438 /*
15439 * low level task data that entry.S needs immediate access to
15440 @@ -23,7 +24,6 @@ struct exec_domain;
15441 #include <linux/atomic.h>
15442
15443 struct thread_info {
15444 - struct task_struct *task; /* main task structure */
15445 struct exec_domain *exec_domain; /* execution domain */
15446 __u32 flags; /* low level flags */
15447 __u32 status; /* thread synchronous flags */
15448 @@ -33,19 +33,13 @@ struct thread_info {
15449 mm_segment_t addr_limit;
15450 struct restart_block restart_block;
15451 void __user *sysenter_return;
15452 -#ifdef CONFIG_X86_32
15453 - unsigned long previous_esp; /* ESP of the previous stack in
15454 - case of nested (IRQ) stacks
15455 - */
15456 - __u8 supervisor_stack[0];
15457 -#endif
15458 + unsigned long lowest_stack;
15459 unsigned int sig_on_uaccess_error:1;
15460 unsigned int uaccess_err:1; /* uaccess failed */
15461 };
15462
15463 -#define INIT_THREAD_INFO(tsk) \
15464 +#define INIT_THREAD_INFO \
15465 { \
15466 - .task = &tsk, \
15467 .exec_domain = &default_exec_domain, \
15468 .flags = 0, \
15469 .cpu = 0, \
15470 @@ -56,7 +50,7 @@ struct thread_info {
15471 }, \
15472 }
15473
15474 -#define init_thread_info (init_thread_union.thread_info)
15475 +#define init_thread_info (init_thread_union.stack)
15476 #define init_stack (init_thread_union.stack)
15477
15478 #else /* !__ASSEMBLY__ */
15479 @@ -97,6 +91,7 @@ struct thread_info {
15480 #define TIF_SYSCALL_TRACEPOINT 28 /* syscall tracepoint instrumentation */
15481 #define TIF_ADDR32 29 /* 32-bit address space on 64 bits */
15482 #define TIF_X32 30 /* 32-bit native x86-64 binary */
15483 +#define TIF_GRSEC_SETXID 31 /* update credentials on syscall entry/exit */
15484
15485 #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
15486 #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
15487 @@ -121,17 +116,18 @@ struct thread_info {
15488 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
15489 #define _TIF_ADDR32 (1 << TIF_ADDR32)
15490 #define _TIF_X32 (1 << TIF_X32)
15491 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
15492
15493 /* work to do in syscall_trace_enter() */
15494 #define _TIF_WORK_SYSCALL_ENTRY \
15495 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_EMU | _TIF_SYSCALL_AUDIT | \
15496 _TIF_SECCOMP | _TIF_SINGLESTEP | _TIF_SYSCALL_TRACEPOINT | \
15497 - _TIF_NOHZ)
15498 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
15499
15500 /* work to do in syscall_trace_leave() */
15501 #define _TIF_WORK_SYSCALL_EXIT \
15502 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP | \
15503 - _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ)
15504 + _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ | _TIF_GRSEC_SETXID)
15505
15506 /* work to do on interrupt/exception return */
15507 #define _TIF_WORK_MASK \
15508 @@ -142,7 +138,7 @@ struct thread_info {
15509 /* work to do on any return to user space */
15510 #define _TIF_ALLWORK_MASK \
15511 ((0x0000FFFF & ~_TIF_SECCOMP) | _TIF_SYSCALL_TRACEPOINT | \
15512 - _TIF_NOHZ)
15513 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
15514
15515 /* Only used for 64 bit */
15516 #define _TIF_DO_NOTIFY_MASK \
15517 @@ -158,45 +154,40 @@ struct thread_info {
15518
15519 #define PREEMPT_ACTIVE 0x10000000
15520
15521 -#ifdef CONFIG_X86_32
15522 -
15523 -#define STACK_WARN (THREAD_SIZE/8)
15524 -/*
15525 - * macros/functions for gaining access to the thread information structure
15526 - *
15527 - * preempt_count needs to be 1 initially, until the scheduler is functional.
15528 - */
15529 -#ifndef __ASSEMBLY__
15530 -
15531 -
15532 -/* how to get the current stack pointer from C */
15533 -register unsigned long current_stack_pointer asm("esp") __used;
15534 -
15535 -/* how to get the thread information struct from C */
15536 -static inline struct thread_info *current_thread_info(void)
15537 -{
15538 - return (struct thread_info *)
15539 - (current_stack_pointer & ~(THREAD_SIZE - 1));
15540 -}
15541 -
15542 -#else /* !__ASSEMBLY__ */
15543 -
15544 +#ifdef __ASSEMBLY__
15545 /* how to get the thread information struct from ASM */
15546 #define GET_THREAD_INFO(reg) \
15547 - movl $-THREAD_SIZE, reg; \
15548 - andl %esp, reg
15549 + mov PER_CPU_VAR(current_tinfo), reg
15550
15551 /* use this one if reg already contains %esp */
15552 -#define GET_THREAD_INFO_WITH_ESP(reg) \
15553 - andl $-THREAD_SIZE, reg
15554 +#define GET_THREAD_INFO_WITH_ESP(reg) GET_THREAD_INFO(reg)
15555 +#else
15556 +/* how to get the thread information struct from C */
15557 +DECLARE_PER_CPU(struct thread_info *, current_tinfo);
15558 +
15559 +static __always_inline struct thread_info *current_thread_info(void)
15560 +{
15561 + return this_cpu_read_stable(current_tinfo);
15562 +}
15563 +#endif
15564 +
15565 +#ifdef CONFIG_X86_32
15566 +
15567 +#define STACK_WARN (THREAD_SIZE/8)
15568 +/*
15569 + * macros/functions for gaining access to the thread information structure
15570 + *
15571 + * preempt_count needs to be 1 initially, until the scheduler is functional.
15572 + */
15573 +#ifndef __ASSEMBLY__
15574 +
15575 +/* how to get the current stack pointer from C */
15576 +register unsigned long current_stack_pointer asm("esp") __used;
15577
15578 #endif
15579
15580 #else /* X86_32 */
15581
15582 -#include <asm/percpu.h>
15583 -#define KERNEL_STACK_OFFSET (5*8)
15584 -
15585 /*
15586 * macros/functions for gaining access to the thread information structure
15587 * preempt_count needs to be 1 initially, until the scheduler is functional.
15588 @@ -204,27 +195,8 @@ static inline struct thread_info *current_thread_info(void)
15589 #ifndef __ASSEMBLY__
15590 DECLARE_PER_CPU(unsigned long, kernel_stack);
15591
15592 -static inline struct thread_info *current_thread_info(void)
15593 -{
15594 - struct thread_info *ti;
15595 - ti = (void *)(this_cpu_read_stable(kernel_stack) +
15596 - KERNEL_STACK_OFFSET - THREAD_SIZE);
15597 - return ti;
15598 -}
15599 -
15600 -#else /* !__ASSEMBLY__ */
15601 -
15602 -/* how to get the thread information struct from ASM */
15603 -#define GET_THREAD_INFO(reg) \
15604 - movq PER_CPU_VAR(kernel_stack),reg ; \
15605 - subq $(THREAD_SIZE-KERNEL_STACK_OFFSET),reg
15606 -
15607 -/*
15608 - * Same if PER_CPU_VAR(kernel_stack) is, perhaps with some offset, already in
15609 - * a certain register (to be used in assembler memory operands).
15610 - */
15611 -#define THREAD_INFO(reg, off) KERNEL_STACK_OFFSET+(off)-THREAD_SIZE(reg)
15612 -
15613 +/* how to get the current stack pointer from C */
15614 +register unsigned long current_stack_pointer asm("rsp") __used;
15615 #endif
15616
15617 #endif /* !X86_32 */
15618 @@ -285,5 +257,12 @@ static inline bool is_ia32_task(void)
15619 extern void arch_task_cache_init(void);
15620 extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src);
15621 extern void arch_release_task_struct(struct task_struct *tsk);
15622 +
15623 +#define __HAVE_THREAD_FUNCTIONS
15624 +#define task_thread_info(task) (&(task)->tinfo)
15625 +#define task_stack_page(task) ((task)->stack)
15626 +#define setup_thread_stack(p, org) do {} while (0)
15627 +#define end_of_stack(p) ((unsigned long *)task_stack_page(p) + 1)
15628 +
15629 #endif
15630 #endif /* _ASM_X86_THREAD_INFO_H */
15631 diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
15632 index 5ee2687..70d5895 100644
15633 --- a/arch/x86/include/asm/uaccess.h
15634 +++ b/arch/x86/include/asm/uaccess.h
15635 @@ -7,6 +7,7 @@
15636 #include <linux/compiler.h>
15637 #include <linux/thread_info.h>
15638 #include <linux/string.h>
15639 +#include <linux/sched.h>
15640 #include <asm/asm.h>
15641 #include <asm/page.h>
15642 #include <asm/smap.h>
15643 @@ -29,7 +30,12 @@
15644
15645 #define get_ds() (KERNEL_DS)
15646 #define get_fs() (current_thread_info()->addr_limit)
15647 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
15648 +void __set_fs(mm_segment_t x);
15649 +void set_fs(mm_segment_t x);
15650 +#else
15651 #define set_fs(x) (current_thread_info()->addr_limit = (x))
15652 +#endif
15653
15654 #define segment_eq(a, b) ((a).seg == (b).seg)
15655
15656 @@ -77,8 +83,33 @@
15657 * checks that the pointer is in the user space range - after calling
15658 * this function, memory access functions may still return -EFAULT.
15659 */
15660 -#define access_ok(type, addr, size) \
15661 - (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
15662 +#define __access_ok(type, addr, size) (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
15663 +#define access_ok(type, addr, size) \
15664 +({ \
15665 + long __size = size; \
15666 + unsigned long __addr = (unsigned long)addr; \
15667 + unsigned long __addr_ao = __addr & PAGE_MASK; \
15668 + unsigned long __end_ao = __addr + __size - 1; \
15669 + bool __ret_ao = __range_not_ok(__addr, __size, user_addr_max()) == 0;\
15670 + if (__ret_ao && unlikely((__end_ao ^ __addr_ao) & PAGE_MASK)) { \
15671 + while(__addr_ao <= __end_ao) { \
15672 + char __c_ao; \
15673 + __addr_ao += PAGE_SIZE; \
15674 + if (__size > PAGE_SIZE) \
15675 + cond_resched(); \
15676 + if (__get_user(__c_ao, (char __user *)__addr)) \
15677 + break; \
15678 + if (type != VERIFY_WRITE) { \
15679 + __addr = __addr_ao; \
15680 + continue; \
15681 + } \
15682 + if (__put_user(__c_ao, (char __user *)__addr)) \
15683 + break; \
15684 + __addr = __addr_ao; \
15685 + } \
15686 + } \
15687 + __ret_ao; \
15688 +})
15689
15690 /*
15691 * The exception table consists of pairs of addresses relative to the
15692 @@ -176,13 +207,21 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
15693 asm volatile("call __put_user_" #size : "=a" (__ret_pu) \
15694 : "0" ((typeof(*(ptr)))(x)), "c" (ptr) : "ebx")
15695
15696 -
15697 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
15698 +#define __copyuser_seg "gs;"
15699 +#define __COPYUSER_SET_ES "pushl %%gs; popl %%es\n"
15700 +#define __COPYUSER_RESTORE_ES "pushl %%ss; popl %%es\n"
15701 +#else
15702 +#define __copyuser_seg
15703 +#define __COPYUSER_SET_ES
15704 +#define __COPYUSER_RESTORE_ES
15705 +#endif
15706
15707 #ifdef CONFIG_X86_32
15708 #define __put_user_asm_u64(x, addr, err, errret) \
15709 asm volatile(ASM_STAC "\n" \
15710 - "1: movl %%eax,0(%2)\n" \
15711 - "2: movl %%edx,4(%2)\n" \
15712 + "1: "__copyuser_seg"movl %%eax,0(%2)\n" \
15713 + "2: "__copyuser_seg"movl %%edx,4(%2)\n" \
15714 "3: " ASM_CLAC "\n" \
15715 ".section .fixup,\"ax\"\n" \
15716 "4: movl %3,%0\n" \
15717 @@ -195,8 +234,8 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
15718
15719 #define __put_user_asm_ex_u64(x, addr) \
15720 asm volatile(ASM_STAC "\n" \
15721 - "1: movl %%eax,0(%1)\n" \
15722 - "2: movl %%edx,4(%1)\n" \
15723 + "1: "__copyuser_seg"movl %%eax,0(%1)\n" \
15724 + "2: "__copyuser_seg"movl %%edx,4(%1)\n" \
15725 "3: " ASM_CLAC "\n" \
15726 _ASM_EXTABLE_EX(1b, 2b) \
15727 _ASM_EXTABLE_EX(2b, 3b) \
15728 @@ -246,7 +285,7 @@ extern void __put_user_8(void);
15729 __typeof__(*(ptr)) __pu_val; \
15730 __chk_user_ptr(ptr); \
15731 might_fault(); \
15732 - __pu_val = x; \
15733 + __pu_val = (x); \
15734 switch (sizeof(*(ptr))) { \
15735 case 1: \
15736 __put_user_x(1, __pu_val, ptr, __ret_pu); \
15737 @@ -345,7 +384,7 @@ do { \
15738
15739 #define __get_user_asm(x, addr, err, itype, rtype, ltype, errret) \
15740 asm volatile(ASM_STAC "\n" \
15741 - "1: mov"itype" %2,%"rtype"1\n" \
15742 + "1: "__copyuser_seg"mov"itype" %2,%"rtype"1\n"\
15743 "2: " ASM_CLAC "\n" \
15744 ".section .fixup,\"ax\"\n" \
15745 "3: mov %3,%0\n" \
15746 @@ -353,7 +392,7 @@ do { \
15747 " jmp 2b\n" \
15748 ".previous\n" \
15749 _ASM_EXTABLE(1b, 3b) \
15750 - : "=r" (err), ltype(x) \
15751 + : "=r" (err), ltype (x) \
15752 : "m" (__m(addr)), "i" (errret), "0" (err))
15753
15754 #define __get_user_size_ex(x, ptr, size) \
15755 @@ -378,7 +417,7 @@ do { \
15756 } while (0)
15757
15758 #define __get_user_asm_ex(x, addr, itype, rtype, ltype) \
15759 - asm volatile("1: mov"itype" %1,%"rtype"0\n" \
15760 + asm volatile("1: "__copyuser_seg"mov"itype" %1,%"rtype"0\n"\
15761 "2:\n" \
15762 _ASM_EXTABLE_EX(1b, 2b) \
15763 : ltype(x) : "m" (__m(addr)))
15764 @@ -395,13 +434,24 @@ do { \
15765 int __gu_err; \
15766 unsigned long __gu_val; \
15767 __get_user_size(__gu_val, (ptr), (size), __gu_err, -EFAULT); \
15768 - (x) = (__force __typeof__(*(ptr)))__gu_val; \
15769 + (x) = (__typeof__(*(ptr)))__gu_val; \
15770 __gu_err; \
15771 })
15772
15773 /* FIXME: this hack is definitely wrong -AK */
15774 struct __large_struct { unsigned long buf[100]; };
15775 -#define __m(x) (*(struct __large_struct __user *)(x))
15776 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15777 +#define ____m(x) \
15778 +({ \
15779 + unsigned long ____x = (unsigned long)(x); \
15780 + if (____x < pax_user_shadow_base) \
15781 + ____x += pax_user_shadow_base; \
15782 + (typeof(x))____x; \
15783 +})
15784 +#else
15785 +#define ____m(x) (x)
15786 +#endif
15787 +#define __m(x) (*(struct __large_struct __user *)____m(x))
15788
15789 /*
15790 * Tell gcc we read from memory instead of writing: this is because
15791 @@ -410,7 +460,7 @@ struct __large_struct { unsigned long buf[100]; };
15792 */
15793 #define __put_user_asm(x, addr, err, itype, rtype, ltype, errret) \
15794 asm volatile(ASM_STAC "\n" \
15795 - "1: mov"itype" %"rtype"1,%2\n" \
15796 + "1: "__copyuser_seg"mov"itype" %"rtype"1,%2\n"\
15797 "2: " ASM_CLAC "\n" \
15798 ".section .fixup,\"ax\"\n" \
15799 "3: mov %3,%0\n" \
15800 @@ -418,10 +468,10 @@ struct __large_struct { unsigned long buf[100]; };
15801 ".previous\n" \
15802 _ASM_EXTABLE(1b, 3b) \
15803 : "=r"(err) \
15804 - : ltype(x), "m" (__m(addr)), "i" (errret), "0" (err))
15805 + : ltype (x), "m" (__m(addr)), "i" (errret), "0" (err))
15806
15807 #define __put_user_asm_ex(x, addr, itype, rtype, ltype) \
15808 - asm volatile("1: mov"itype" %"rtype"0,%1\n" \
15809 + asm volatile("1: "__copyuser_seg"mov"itype" %"rtype"0,%1\n"\
15810 "2:\n" \
15811 _ASM_EXTABLE_EX(1b, 2b) \
15812 : : ltype(x), "m" (__m(addr)))
15813 @@ -460,8 +510,12 @@ struct __large_struct { unsigned long buf[100]; };
15814 * On error, the variable @x is set to zero.
15815 */
15816
15817 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15818 +#define __get_user(x, ptr) get_user((x), (ptr))
15819 +#else
15820 #define __get_user(x, ptr) \
15821 __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
15822 +#endif
15823
15824 /**
15825 * __put_user: - Write a simple value into user space, with less checking.
15826 @@ -483,8 +537,12 @@ struct __large_struct { unsigned long buf[100]; };
15827 * Returns zero on success, or -EFAULT on error.
15828 */
15829
15830 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15831 +#define __put_user(x, ptr) put_user((x), (ptr))
15832 +#else
15833 #define __put_user(x, ptr) \
15834 __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))
15835 +#endif
15836
15837 #define __get_user_unaligned __get_user
15838 #define __put_user_unaligned __put_user
15839 @@ -502,7 +560,7 @@ struct __large_struct { unsigned long buf[100]; };
15840 #define get_user_ex(x, ptr) do { \
15841 unsigned long __gue_val; \
15842 __get_user_size_ex((__gue_val), (ptr), (sizeof(*(ptr)))); \
15843 - (x) = (__force __typeof__(*(ptr)))__gue_val; \
15844 + (x) = (__typeof__(*(ptr)))__gue_val; \
15845 } while (0)
15846
15847 #define put_user_try uaccess_try
15848 @@ -519,8 +577,8 @@ strncpy_from_user(char *dst, const char __user *src, long count);
15849 extern __must_check long strlen_user(const char __user *str);
15850 extern __must_check long strnlen_user(const char __user *str, long n);
15851
15852 -unsigned long __must_check clear_user(void __user *mem, unsigned long len);
15853 -unsigned long __must_check __clear_user(void __user *mem, unsigned long len);
15854 +unsigned long __must_check clear_user(void __user *mem, unsigned long len) __size_overflow(2);
15855 +unsigned long __must_check __clear_user(void __user *mem, unsigned long len) __size_overflow(2);
15856
15857 /*
15858 * movsl can be slow when source and dest are not both 8-byte aligned
15859 diff --git a/arch/x86/include/asm/uaccess_32.h b/arch/x86/include/asm/uaccess_32.h
15860 index 7f760a9..04b1c65 100644
15861 --- a/arch/x86/include/asm/uaccess_32.h
15862 +++ b/arch/x86/include/asm/uaccess_32.h
15863 @@ -11,15 +11,15 @@
15864 #include <asm/page.h>
15865
15866 unsigned long __must_check __copy_to_user_ll
15867 - (void __user *to, const void *from, unsigned long n);
15868 + (void __user *to, const void *from, unsigned long n) __size_overflow(3);
15869 unsigned long __must_check __copy_from_user_ll
15870 - (void *to, const void __user *from, unsigned long n);
15871 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
15872 unsigned long __must_check __copy_from_user_ll_nozero
15873 - (void *to, const void __user *from, unsigned long n);
15874 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
15875 unsigned long __must_check __copy_from_user_ll_nocache
15876 - (void *to, const void __user *from, unsigned long n);
15877 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
15878 unsigned long __must_check __copy_from_user_ll_nocache_nozero
15879 - (void *to, const void __user *from, unsigned long n);
15880 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
15881
15882 /**
15883 * __copy_to_user_inatomic: - Copy a block of data into user space, with less checking.
15884 @@ -43,6 +43,11 @@ unsigned long __must_check __copy_from_user_ll_nocache_nozero
15885 static __always_inline unsigned long __must_check
15886 __copy_to_user_inatomic(void __user *to, const void *from, unsigned long n)
15887 {
15888 + if ((long)n < 0)
15889 + return n;
15890 +
15891 + check_object_size(from, n, true);
15892 +
15893 if (__builtin_constant_p(n)) {
15894 unsigned long ret;
15895
15896 @@ -82,12 +87,16 @@ static __always_inline unsigned long __must_check
15897 __copy_to_user(void __user *to, const void *from, unsigned long n)
15898 {
15899 might_fault();
15900 +
15901 return __copy_to_user_inatomic(to, from, n);
15902 }
15903
15904 static __always_inline unsigned long
15905 __copy_from_user_inatomic(void *to, const void __user *from, unsigned long n)
15906 {
15907 + if ((long)n < 0)
15908 + return n;
15909 +
15910 /* Avoid zeroing the tail if the copy fails..
15911 * If 'n' is constant and 1, 2, or 4, we do still zero on a failure,
15912 * but as the zeroing behaviour is only significant when n is not
15913 @@ -137,6 +146,12 @@ static __always_inline unsigned long
15914 __copy_from_user(void *to, const void __user *from, unsigned long n)
15915 {
15916 might_fault();
15917 +
15918 + if ((long)n < 0)
15919 + return n;
15920 +
15921 + check_object_size(to, n, false);
15922 +
15923 if (__builtin_constant_p(n)) {
15924 unsigned long ret;
15925
15926 @@ -159,6 +174,10 @@ static __always_inline unsigned long __copy_from_user_nocache(void *to,
15927 const void __user *from, unsigned long n)
15928 {
15929 might_fault();
15930 +
15931 + if ((long)n < 0)
15932 + return n;
15933 +
15934 if (__builtin_constant_p(n)) {
15935 unsigned long ret;
15936
15937 @@ -181,15 +200,19 @@ static __always_inline unsigned long
15938 __copy_from_user_inatomic_nocache(void *to, const void __user *from,
15939 unsigned long n)
15940 {
15941 - return __copy_from_user_ll_nocache_nozero(to, from, n);
15942 + if ((long)n < 0)
15943 + return n;
15944 +
15945 + return __copy_from_user_ll_nocache_nozero(to, from, n);
15946 }
15947
15948 -unsigned long __must_check copy_to_user(void __user *to,
15949 - const void *from, unsigned long n);
15950 -unsigned long __must_check _copy_from_user(void *to,
15951 - const void __user *from,
15952 - unsigned long n);
15953 -
15954 +extern void copy_to_user_overflow(void)
15955 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
15956 + __compiletime_error("copy_to_user() buffer size is not provably correct")
15957 +#else
15958 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
15959 +#endif
15960 +;
15961
15962 extern void copy_from_user_overflow(void)
15963 #ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
15964 @@ -199,17 +222,60 @@ extern void copy_from_user_overflow(void)
15965 #endif
15966 ;
15967
15968 -static inline unsigned long __must_check copy_from_user(void *to,
15969 - const void __user *from,
15970 - unsigned long n)
15971 +/**
15972 + * copy_to_user: - Copy a block of data into user space.
15973 + * @to: Destination address, in user space.
15974 + * @from: Source address, in kernel space.
15975 + * @n: Number of bytes to copy.
15976 + *
15977 + * Context: User context only. This function may sleep.
15978 + *
15979 + * Copy data from kernel space to user space.
15980 + *
15981 + * Returns number of bytes that could not be copied.
15982 + * On success, this will be zero.
15983 + */
15984 +static inline unsigned long __must_check
15985 +copy_to_user(void __user *to, const void *from, unsigned long n)
15986 {
15987 - int sz = __compiletime_object_size(to);
15988 + size_t sz = __compiletime_object_size(from);
15989
15990 - if (likely(sz == -1 || sz >= n))
15991 - n = _copy_from_user(to, from, n);
15992 - else
15993 + if (unlikely(sz != (size_t)-1 && sz < n))
15994 + copy_to_user_overflow();
15995 + else if (access_ok(VERIFY_WRITE, to, n))
15996 + n = __copy_to_user(to, from, n);
15997 + return n;
15998 +}
15999 +
16000 +/**
16001 + * copy_from_user: - Copy a block of data from user space.
16002 + * @to: Destination address, in kernel space.
16003 + * @from: Source address, in user space.
16004 + * @n: Number of bytes to copy.
16005 + *
16006 + * Context: User context only. This function may sleep.
16007 + *
16008 + * Copy data from user space to kernel space.
16009 + *
16010 + * Returns number of bytes that could not be copied.
16011 + * On success, this will be zero.
16012 + *
16013 + * If some data could not be copied, this function will pad the copied
16014 + * data to the requested size using zero bytes.
16015 + */
16016 +static inline unsigned long __must_check
16017 +copy_from_user(void *to, const void __user *from, unsigned long n)
16018 +{
16019 + size_t sz = __compiletime_object_size(to);
16020 +
16021 + check_object_size(to, n, false);
16022 +
16023 + if (unlikely(sz != (size_t)-1 && sz < n))
16024 copy_from_user_overflow();
16025 -
16026 + else if (access_ok(VERIFY_READ, from, n))
16027 + n = __copy_from_user(to, from, n);
16028 + else if ((long)n > 0)
16029 + memset(to, 0, n);
16030 return n;
16031 }
16032
16033 diff --git a/arch/x86/include/asm/uaccess_64.h b/arch/x86/include/asm/uaccess_64.h
16034 index 142810c..1f2a0a7 100644
16035 --- a/arch/x86/include/asm/uaccess_64.h
16036 +++ b/arch/x86/include/asm/uaccess_64.h
16037 @@ -10,6 +10,9 @@
16038 #include <asm/alternative.h>
16039 #include <asm/cpufeature.h>
16040 #include <asm/page.h>
16041 +#include <asm/pgtable.h>
16042 +
16043 +#define set_fs(x) (current_thread_info()->addr_limit = (x))
16044
16045 /*
16046 * Copy To/From Userspace
16047 @@ -17,13 +20,13 @@
16048
16049 /* Handles exceptions in both to and from, but doesn't do access_ok */
16050 __must_check unsigned long
16051 -copy_user_enhanced_fast_string(void *to, const void *from, unsigned len);
16052 +copy_user_enhanced_fast_string(void *to, const void *from, unsigned len) __size_overflow(3);
16053 __must_check unsigned long
16054 -copy_user_generic_string(void *to, const void *from, unsigned len);
16055 +copy_user_generic_string(void *to, const void *from, unsigned len) __size_overflow(3);
16056 __must_check unsigned long
16057 -copy_user_generic_unrolled(void *to, const void *from, unsigned len);
16058 +copy_user_generic_unrolled(void *to, const void *from, unsigned len) __size_overflow(3);
16059
16060 -static __always_inline __must_check unsigned long
16061 +static __always_inline __must_check __size_overflow(3) unsigned long
16062 copy_user_generic(void *to, const void *from, unsigned len)
16063 {
16064 unsigned ret;
16065 @@ -41,142 +44,204 @@ copy_user_generic(void *to, const void *from, unsigned len)
16066 ASM_OUTPUT2("=a" (ret), "=D" (to), "=S" (from),
16067 "=d" (len)),
16068 "1" (to), "2" (from), "3" (len)
16069 - : "memory", "rcx", "r8", "r9", "r10", "r11");
16070 + : "memory", "rcx", "r8", "r9", "r11");
16071 return ret;
16072 }
16073
16074 +static __always_inline __must_check unsigned long
16075 +__copy_to_user(void __user *to, const void *from, unsigned long len);
16076 +static __always_inline __must_check unsigned long
16077 +__copy_from_user(void *to, const void __user *from, unsigned long len);
16078 __must_check unsigned long
16079 -_copy_to_user(void __user *to, const void *from, unsigned len);
16080 -__must_check unsigned long
16081 -_copy_from_user(void *to, const void __user *from, unsigned len);
16082 -__must_check unsigned long
16083 -copy_in_user(void __user *to, const void __user *from, unsigned len);
16084 +copy_in_user(void __user *to, const void __user *from, unsigned long len);
16085 +
16086 +extern void copy_to_user_overflow(void)
16087 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16088 + __compiletime_error("copy_to_user() buffer size is not provably correct")
16089 +#else
16090 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
16091 +#endif
16092 +;
16093 +
16094 +extern void copy_from_user_overflow(void)
16095 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16096 + __compiletime_error("copy_from_user() buffer size is not provably correct")
16097 +#else
16098 + __compiletime_warning("copy_from_user() buffer size is not provably correct")
16099 +#endif
16100 +;
16101
16102 static inline unsigned long __must_check copy_from_user(void *to,
16103 const void __user *from,
16104 unsigned long n)
16105 {
16106 - int sz = __compiletime_object_size(to);
16107 -
16108 might_fault();
16109 - if (likely(sz == -1 || sz >= n))
16110 - n = _copy_from_user(to, from, n);
16111 -#ifdef CONFIG_DEBUG_VM
16112 - else
16113 - WARN(1, "Buffer overflow detected!\n");
16114 -#endif
16115 +
16116 + check_object_size(to, n, false);
16117 +
16118 + if (access_ok(VERIFY_READ, from, n))
16119 + n = __copy_from_user(to, from, n);
16120 + else if (n < INT_MAX)
16121 + memset(to, 0, n);
16122 return n;
16123 }
16124
16125 static __always_inline __must_check
16126 -int copy_to_user(void __user *dst, const void *src, unsigned size)
16127 +int copy_to_user(void __user *dst, const void *src, unsigned long size)
16128 {
16129 might_fault();
16130
16131 - return _copy_to_user(dst, src, size);
16132 + if (access_ok(VERIFY_WRITE, dst, size))
16133 + size = __copy_to_user(dst, src, size);
16134 + return size;
16135 }
16136
16137 static __always_inline __must_check
16138 -int __copy_from_user(void *dst, const void __user *src, unsigned size)
16139 +unsigned long __copy_from_user(void *dst, const void __user *src, unsigned long size)
16140 {
16141 - int ret = 0;
16142 + size_t sz = __compiletime_object_size(dst);
16143 + unsigned ret = 0;
16144
16145 might_fault();
16146 +
16147 + if (size > INT_MAX)
16148 + return size;
16149 +
16150 + check_object_size(dst, size, false);
16151 +
16152 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16153 + if (!__access_ok(VERIFY_READ, src, size))
16154 + return size;
16155 +#endif
16156 +
16157 + if (unlikely(sz != (size_t)-1 && sz < size)) {
16158 + copy_from_user_overflow();
16159 + return size;
16160 + }
16161 +
16162 if (!__builtin_constant_p(size))
16163 - return copy_user_generic(dst, (__force void *)src, size);
16164 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16165 switch (size) {
16166 - case 1:__get_user_asm(*(u8 *)dst, (u8 __user *)src,
16167 + case 1:__get_user_asm(*(u8 *)dst, (const u8 __user *)src,
16168 ret, "b", "b", "=q", 1);
16169 return ret;
16170 - case 2:__get_user_asm(*(u16 *)dst, (u16 __user *)src,
16171 + case 2:__get_user_asm(*(u16 *)dst, (const u16 __user *)src,
16172 ret, "w", "w", "=r", 2);
16173 return ret;
16174 - case 4:__get_user_asm(*(u32 *)dst, (u32 __user *)src,
16175 + case 4:__get_user_asm(*(u32 *)dst, (const u32 __user *)src,
16176 ret, "l", "k", "=r", 4);
16177 return ret;
16178 - case 8:__get_user_asm(*(u64 *)dst, (u64 __user *)src,
16179 + case 8:__get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16180 ret, "q", "", "=r", 8);
16181 return ret;
16182 case 10:
16183 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
16184 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16185 ret, "q", "", "=r", 10);
16186 if (unlikely(ret))
16187 return ret;
16188 __get_user_asm(*(u16 *)(8 + (char *)dst),
16189 - (u16 __user *)(8 + (char __user *)src),
16190 + (const u16 __user *)(8 + (const char __user *)src),
16191 ret, "w", "w", "=r", 2);
16192 return ret;
16193 case 16:
16194 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
16195 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16196 ret, "q", "", "=r", 16);
16197 if (unlikely(ret))
16198 return ret;
16199 __get_user_asm(*(u64 *)(8 + (char *)dst),
16200 - (u64 __user *)(8 + (char __user *)src),
16201 + (const u64 __user *)(8 + (const char __user *)src),
16202 ret, "q", "", "=r", 8);
16203 return ret;
16204 default:
16205 - return copy_user_generic(dst, (__force void *)src, size);
16206 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16207 }
16208 }
16209
16210 static __always_inline __must_check
16211 -int __copy_to_user(void __user *dst, const void *src, unsigned size)
16212 +unsigned long __copy_to_user(void __user *dst, const void *src, unsigned long size)
16213 {
16214 - int ret = 0;
16215 + size_t sz = __compiletime_object_size(src);
16216 + unsigned ret = 0;
16217
16218 might_fault();
16219 +
16220 + if (size > INT_MAX)
16221 + return size;
16222 +
16223 + check_object_size(src, size, true);
16224 +
16225 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16226 + if (!__access_ok(VERIFY_WRITE, dst, size))
16227 + return size;
16228 +#endif
16229 +
16230 + if (unlikely(sz != (size_t)-1 && sz < size)) {
16231 + copy_to_user_overflow();
16232 + return size;
16233 + }
16234 +
16235 if (!__builtin_constant_p(size))
16236 - return copy_user_generic((__force void *)dst, src, size);
16237 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16238 switch (size) {
16239 - case 1:__put_user_asm(*(u8 *)src, (u8 __user *)dst,
16240 + case 1:__put_user_asm(*(const u8 *)src, (u8 __user *)dst,
16241 ret, "b", "b", "iq", 1);
16242 return ret;
16243 - case 2:__put_user_asm(*(u16 *)src, (u16 __user *)dst,
16244 + case 2:__put_user_asm(*(const u16 *)src, (u16 __user *)dst,
16245 ret, "w", "w", "ir", 2);
16246 return ret;
16247 - case 4:__put_user_asm(*(u32 *)src, (u32 __user *)dst,
16248 + case 4:__put_user_asm(*(const u32 *)src, (u32 __user *)dst,
16249 ret, "l", "k", "ir", 4);
16250 return ret;
16251 - case 8:__put_user_asm(*(u64 *)src, (u64 __user *)dst,
16252 + case 8:__put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16253 ret, "q", "", "er", 8);
16254 return ret;
16255 case 10:
16256 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
16257 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16258 ret, "q", "", "er", 10);
16259 if (unlikely(ret))
16260 return ret;
16261 asm("":::"memory");
16262 - __put_user_asm(4[(u16 *)src], 4 + (u16 __user *)dst,
16263 + __put_user_asm(4[(const u16 *)src], 4 + (u16 __user *)dst,
16264 ret, "w", "w", "ir", 2);
16265 return ret;
16266 case 16:
16267 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
16268 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16269 ret, "q", "", "er", 16);
16270 if (unlikely(ret))
16271 return ret;
16272 asm("":::"memory");
16273 - __put_user_asm(1[(u64 *)src], 1 + (u64 __user *)dst,
16274 + __put_user_asm(1[(const u64 *)src], 1 + (u64 __user *)dst,
16275 ret, "q", "", "er", 8);
16276 return ret;
16277 default:
16278 - return copy_user_generic((__force void *)dst, src, size);
16279 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16280 }
16281 }
16282
16283 static __always_inline __must_check
16284 -int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16285 +unsigned long __copy_in_user(void __user *dst, const void __user *src, unsigned long size)
16286 {
16287 - int ret = 0;
16288 + unsigned ret = 0;
16289
16290 might_fault();
16291 +
16292 + if (size > INT_MAX)
16293 + return size;
16294 +
16295 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16296 + if (!__access_ok(VERIFY_READ, src, size))
16297 + return size;
16298 + if (!__access_ok(VERIFY_WRITE, dst, size))
16299 + return size;
16300 +#endif
16301 +
16302 if (!__builtin_constant_p(size))
16303 - return copy_user_generic((__force void *)dst,
16304 - (__force void *)src, size);
16305 + return copy_user_generic((__force_kernel void *)____m(dst),
16306 + (__force_kernel const void *)____m(src), size);
16307 switch (size) {
16308 case 1: {
16309 u8 tmp;
16310 - __get_user_asm(tmp, (u8 __user *)src,
16311 + __get_user_asm(tmp, (const u8 __user *)src,
16312 ret, "b", "b", "=q", 1);
16313 if (likely(!ret))
16314 __put_user_asm(tmp, (u8 __user *)dst,
16315 @@ -185,7 +250,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16316 }
16317 case 2: {
16318 u16 tmp;
16319 - __get_user_asm(tmp, (u16 __user *)src,
16320 + __get_user_asm(tmp, (const u16 __user *)src,
16321 ret, "w", "w", "=r", 2);
16322 if (likely(!ret))
16323 __put_user_asm(tmp, (u16 __user *)dst,
16324 @@ -195,7 +260,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16325
16326 case 4: {
16327 u32 tmp;
16328 - __get_user_asm(tmp, (u32 __user *)src,
16329 + __get_user_asm(tmp, (const u32 __user *)src,
16330 ret, "l", "k", "=r", 4);
16331 if (likely(!ret))
16332 __put_user_asm(tmp, (u32 __user *)dst,
16333 @@ -204,7 +269,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16334 }
16335 case 8: {
16336 u64 tmp;
16337 - __get_user_asm(tmp, (u64 __user *)src,
16338 + __get_user_asm(tmp, (const u64 __user *)src,
16339 ret, "q", "", "=r", 8);
16340 if (likely(!ret))
16341 __put_user_asm(tmp, (u64 __user *)dst,
16342 @@ -212,41 +277,72 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16343 return ret;
16344 }
16345 default:
16346 - return copy_user_generic((__force void *)dst,
16347 - (__force void *)src, size);
16348 + return copy_user_generic((__force_kernel void *)____m(dst),
16349 + (__force_kernel const void *)____m(src), size);
16350 }
16351 }
16352
16353 static __must_check __always_inline int
16354 -__copy_from_user_inatomic(void *dst, const void __user *src, unsigned size)
16355 +__copy_from_user_inatomic(void *dst, const void __user *src, unsigned long size)
16356 {
16357 - return copy_user_generic(dst, (__force const void *)src, size);
16358 + if (size > INT_MAX)
16359 + return size;
16360 +
16361 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16362 + if (!__access_ok(VERIFY_READ, src, size))
16363 + return size;
16364 +#endif
16365 +
16366 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16367 }
16368
16369 -static __must_check __always_inline int
16370 -__copy_to_user_inatomic(void __user *dst, const void *src, unsigned size)
16371 +static __must_check __always_inline unsigned long
16372 +__copy_to_user_inatomic(void __user *dst, const void *src, unsigned long size)
16373 {
16374 - return copy_user_generic((__force void *)dst, src, size);
16375 + if (size > INT_MAX)
16376 + return size;
16377 +
16378 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16379 + if (!__access_ok(VERIFY_WRITE, dst, size))
16380 + return size;
16381 +#endif
16382 +
16383 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16384 }
16385
16386 -extern long __copy_user_nocache(void *dst, const void __user *src,
16387 - unsigned size, int zerorest);
16388 +extern unsigned long __copy_user_nocache(void *dst, const void __user *src,
16389 + unsigned long size, int zerorest) __size_overflow(3);
16390
16391 -static inline int
16392 -__copy_from_user_nocache(void *dst, const void __user *src, unsigned size)
16393 +static inline unsigned long __copy_from_user_nocache(void *dst, const void __user *src, unsigned long size)
16394 {
16395 might_sleep();
16396 +
16397 + if (size > INT_MAX)
16398 + return size;
16399 +
16400 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16401 + if (!__access_ok(VERIFY_READ, src, size))
16402 + return size;
16403 +#endif
16404 +
16405 return __copy_user_nocache(dst, src, size, 1);
16406 }
16407
16408 -static inline int
16409 -__copy_from_user_inatomic_nocache(void *dst, const void __user *src,
16410 - unsigned size)
16411 +static inline unsigned long __copy_from_user_inatomic_nocache(void *dst, const void __user *src,
16412 + unsigned long size)
16413 {
16414 + if (size > INT_MAX)
16415 + return size;
16416 +
16417 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16418 + if (!__access_ok(VERIFY_READ, src, size))
16419 + return size;
16420 +#endif
16421 +
16422 return __copy_user_nocache(dst, src, size, 0);
16423 }
16424
16425 -unsigned long
16426 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest);
16427 +extern unsigned long
16428 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest) __size_overflow(3);
16429
16430 #endif /* _ASM_X86_UACCESS_64_H */
16431 diff --git a/arch/x86/include/asm/word-at-a-time.h b/arch/x86/include/asm/word-at-a-time.h
16432 index 5b238981..77fdd78 100644
16433 --- a/arch/x86/include/asm/word-at-a-time.h
16434 +++ b/arch/x86/include/asm/word-at-a-time.h
16435 @@ -11,7 +11,7 @@
16436 * and shift, for example.
16437 */
16438 struct word_at_a_time {
16439 - const unsigned long one_bits, high_bits;
16440 + unsigned long one_bits, high_bits;
16441 };
16442
16443 #define WORD_AT_A_TIME_CONSTANTS { REPEAT_BYTE(0x01), REPEAT_BYTE(0x80) }
16444 diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h
16445 index d8d9922..bf6cecb 100644
16446 --- a/arch/x86/include/asm/x86_init.h
16447 +++ b/arch/x86/include/asm/x86_init.h
16448 @@ -129,7 +129,7 @@ struct x86_init_ops {
16449 struct x86_init_timers timers;
16450 struct x86_init_iommu iommu;
16451 struct x86_init_pci pci;
16452 -};
16453 +} __no_const;
16454
16455 /**
16456 * struct x86_cpuinit_ops - platform specific cpu hotplug setups
16457 @@ -140,7 +140,7 @@ struct x86_cpuinit_ops {
16458 void (*setup_percpu_clockev)(void);
16459 void (*early_percpu_clock_init)(void);
16460 void (*fixup_cpu_id)(struct cpuinfo_x86 *c, int node);
16461 -};
16462 +} __no_const;
16463
16464 /**
16465 * struct x86_platform_ops - platform specific runtime functions
16466 @@ -166,7 +166,7 @@ struct x86_platform_ops {
16467 void (*save_sched_clock_state)(void);
16468 void (*restore_sched_clock_state)(void);
16469 void (*apic_post_init)(void);
16470 -};
16471 +} __no_const;
16472
16473 struct pci_dev;
16474 struct msi_msg;
16475 @@ -180,7 +180,7 @@ struct x86_msi_ops {
16476 void (*teardown_msi_irqs)(struct pci_dev *dev);
16477 void (*restore_msi_irqs)(struct pci_dev *dev, int irq);
16478 int (*setup_hpet_msi)(unsigned int irq, unsigned int id);
16479 -};
16480 +} __no_const;
16481
16482 struct IO_APIC_route_entry;
16483 struct io_apic_irq_attr;
16484 @@ -201,7 +201,7 @@ struct x86_io_apic_ops {
16485 unsigned int destination, int vector,
16486 struct io_apic_irq_attr *attr);
16487 void (*eoi_ioapic_pin)(int apic, int pin, int vector);
16488 -};
16489 +} __no_const;
16490
16491 extern struct x86_init_ops x86_init;
16492 extern struct x86_cpuinit_ops x86_cpuinit;
16493 diff --git a/arch/x86/include/asm/xsave.h b/arch/x86/include/asm/xsave.h
16494 index 0415cda..b43d877 100644
16495 --- a/arch/x86/include/asm/xsave.h
16496 +++ b/arch/x86/include/asm/xsave.h
16497 @@ -71,7 +71,9 @@ static inline int xsave_user(struct xsave_struct __user *buf)
16498 return -EFAULT;
16499
16500 __asm__ __volatile__(ASM_STAC "\n"
16501 - "1: .byte " REX_PREFIX "0x0f,0xae,0x27\n"
16502 + "1:"
16503 + __copyuser_seg
16504 + ".byte " REX_PREFIX "0x0f,0xae,0x27\n"
16505 "2: " ASM_CLAC "\n"
16506 ".section .fixup,\"ax\"\n"
16507 "3: movl $-1,%[err]\n"
16508 @@ -87,12 +89,14 @@ static inline int xsave_user(struct xsave_struct __user *buf)
16509 static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
16510 {
16511 int err;
16512 - struct xsave_struct *xstate = ((__force struct xsave_struct *)buf);
16513 + struct xsave_struct *xstate = ((__force_kernel struct xsave_struct *)buf);
16514 u32 lmask = mask;
16515 u32 hmask = mask >> 32;
16516
16517 __asm__ __volatile__(ASM_STAC "\n"
16518 - "1: .byte " REX_PREFIX "0x0f,0xae,0x2f\n"
16519 + "1:"
16520 + __copyuser_seg
16521 + ".byte " REX_PREFIX "0x0f,0xae,0x2f\n"
16522 "2: " ASM_CLAC "\n"
16523 ".section .fixup,\"ax\"\n"
16524 "3: movl $-1,%[err]\n"
16525 diff --git a/arch/x86/include/uapi/asm/e820.h b/arch/x86/include/uapi/asm/e820.h
16526 index bbae024..e1528f9 100644
16527 --- a/arch/x86/include/uapi/asm/e820.h
16528 +++ b/arch/x86/include/uapi/asm/e820.h
16529 @@ -63,7 +63,7 @@ struct e820map {
16530 #define ISA_START_ADDRESS 0xa0000
16531 #define ISA_END_ADDRESS 0x100000
16532
16533 -#define BIOS_BEGIN 0x000a0000
16534 +#define BIOS_BEGIN 0x000c0000
16535 #define BIOS_END 0x00100000
16536
16537 #define BIOS_ROM_BASE 0xffe00000
16538 diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
16539 index 7bd3bd3..5dac791 100644
16540 --- a/arch/x86/kernel/Makefile
16541 +++ b/arch/x86/kernel/Makefile
16542 @@ -22,7 +22,7 @@ obj-y += time.o ioport.o ldt.o dumpstack.o nmi.o
16543 obj-y += setup.o x86_init.o i8259.o irqinit.o jump_label.o
16544 obj-$(CONFIG_IRQ_WORK) += irq_work.o
16545 obj-y += probe_roms.o
16546 -obj-$(CONFIG_X86_32) += i386_ksyms_32.o
16547 +obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o
16548 obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o
16549 obj-y += syscall_$(BITS).o
16550 obj-$(CONFIG_X86_64) += vsyscall_64.o
16551 diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
16552 index 230c8ea..f915130 100644
16553 --- a/arch/x86/kernel/acpi/boot.c
16554 +++ b/arch/x86/kernel/acpi/boot.c
16555 @@ -1361,7 +1361,7 @@ static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d)
16556 * If your system is blacklisted here, but you find that acpi=force
16557 * works for you, please contact linux-acpi@vger.kernel.org
16558 */
16559 -static struct dmi_system_id __initdata acpi_dmi_table[] = {
16560 +static const struct dmi_system_id __initconst acpi_dmi_table[] = {
16561 /*
16562 * Boxes that need ACPI disabled
16563 */
16564 @@ -1436,7 +1436,7 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = {
16565 };
16566
16567 /* second table for DMI checks that should run after early-quirks */
16568 -static struct dmi_system_id __initdata acpi_dmi_table_late[] = {
16569 +static const struct dmi_system_id __initconst acpi_dmi_table_late[] = {
16570 /*
16571 * HP laptops which use a DSDT reporting as HP/SB400/10000,
16572 * which includes some code which overrides all temperature
16573 diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c
16574 index 0532f5d..36afc0a 100644
16575 --- a/arch/x86/kernel/acpi/sleep.c
16576 +++ b/arch/x86/kernel/acpi/sleep.c
16577 @@ -74,8 +74,12 @@ int acpi_suspend_lowlevel(void)
16578 #else /* CONFIG_64BIT */
16579 #ifdef CONFIG_SMP
16580 stack_start = (unsigned long)temp_stack + sizeof(temp_stack);
16581 +
16582 + pax_open_kernel();
16583 early_gdt_descr.address =
16584 (unsigned long)get_cpu_gdt_table(smp_processor_id());
16585 + pax_close_kernel();
16586 +
16587 initial_gs = per_cpu_offset(smp_processor_id());
16588 #endif
16589 initial_code = (unsigned long)wakeup_long64;
16590 diff --git a/arch/x86/kernel/acpi/wakeup_32.S b/arch/x86/kernel/acpi/wakeup_32.S
16591 index 13ab720..95d5442 100644
16592 --- a/arch/x86/kernel/acpi/wakeup_32.S
16593 +++ b/arch/x86/kernel/acpi/wakeup_32.S
16594 @@ -30,13 +30,11 @@ wakeup_pmode_return:
16595 # and restore the stack ... but you need gdt for this to work
16596 movl saved_context_esp, %esp
16597
16598 - movl %cs:saved_magic, %eax
16599 - cmpl $0x12345678, %eax
16600 + cmpl $0x12345678, saved_magic
16601 jne bogus_magic
16602
16603 # jump to place where we left off
16604 - movl saved_eip, %eax
16605 - jmp *%eax
16606 + jmp *(saved_eip)
16607
16608 bogus_magic:
16609 jmp bogus_magic
16610 diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
16611 index ef5ccca..bd83949 100644
16612 --- a/arch/x86/kernel/alternative.c
16613 +++ b/arch/x86/kernel/alternative.c
16614 @@ -268,6 +268,13 @@ void __init_or_module apply_alternatives(struct alt_instr *start,
16615 */
16616 for (a = start; a < end; a++) {
16617 instr = (u8 *)&a->instr_offset + a->instr_offset;
16618 +
16619 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16620 + instr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16621 + if (instr < (u8 *)_text || (u8 *)_einittext <= instr)
16622 + instr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16623 +#endif
16624 +
16625 replacement = (u8 *)&a->repl_offset + a->repl_offset;
16626 BUG_ON(a->replacementlen > a->instrlen);
16627 BUG_ON(a->instrlen > sizeof(insnbuf));
16628 @@ -299,10 +306,16 @@ static void alternatives_smp_lock(const s32 *start, const s32 *end,
16629 for (poff = start; poff < end; poff++) {
16630 u8 *ptr = (u8 *)poff + *poff;
16631
16632 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16633 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16634 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
16635 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16636 +#endif
16637 +
16638 if (!*poff || ptr < text || ptr >= text_end)
16639 continue;
16640 /* turn DS segment override prefix into lock prefix */
16641 - if (*ptr == 0x3e)
16642 + if (*ktla_ktva(ptr) == 0x3e)
16643 text_poke(ptr, ((unsigned char []){0xf0}), 1);
16644 }
16645 mutex_unlock(&text_mutex);
16646 @@ -317,10 +330,16 @@ static void alternatives_smp_unlock(const s32 *start, const s32 *end,
16647 for (poff = start; poff < end; poff++) {
16648 u8 *ptr = (u8 *)poff + *poff;
16649
16650 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16651 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16652 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
16653 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16654 +#endif
16655 +
16656 if (!*poff || ptr < text || ptr >= text_end)
16657 continue;
16658 /* turn lock prefix into DS segment override prefix */
16659 - if (*ptr == 0xf0)
16660 + if (*ktla_ktva(ptr) == 0xf0)
16661 text_poke(ptr, ((unsigned char []){0x3E}), 1);
16662 }
16663 mutex_unlock(&text_mutex);
16664 @@ -468,7 +487,7 @@ void __init_or_module apply_paravirt(struct paravirt_patch_site *start,
16665
16666 BUG_ON(p->len > MAX_PATCH_LEN);
16667 /* prep the buffer with the original instructions */
16668 - memcpy(insnbuf, p->instr, p->len);
16669 + memcpy(insnbuf, ktla_ktva(p->instr), p->len);
16670 used = pv_init_ops.patch(p->instrtype, p->clobbers, insnbuf,
16671 (unsigned long)p->instr, p->len);
16672
16673 @@ -515,7 +534,7 @@ void __init alternative_instructions(void)
16674 if (!uniproc_patched || num_possible_cpus() == 1)
16675 free_init_pages("SMP alternatives",
16676 (unsigned long)__smp_locks,
16677 - (unsigned long)__smp_locks_end);
16678 + PAGE_ALIGN((unsigned long)__smp_locks_end));
16679 #endif
16680
16681 apply_paravirt(__parainstructions, __parainstructions_end);
16682 @@ -535,13 +554,17 @@ void __init alternative_instructions(void)
16683 * instructions. And on the local CPU you need to be protected again NMI or MCE
16684 * handlers seeing an inconsistent instruction while you patch.
16685 */
16686 -void *__init_or_module text_poke_early(void *addr, const void *opcode,
16687 +void *__kprobes text_poke_early(void *addr, const void *opcode,
16688 size_t len)
16689 {
16690 unsigned long flags;
16691 local_irq_save(flags);
16692 - memcpy(addr, opcode, len);
16693 +
16694 + pax_open_kernel();
16695 + memcpy(ktla_ktva(addr), opcode, len);
16696 sync_core();
16697 + pax_close_kernel();
16698 +
16699 local_irq_restore(flags);
16700 /* Could also do a CLFLUSH here to speed up CPU recovery; but
16701 that causes hangs on some VIA CPUs. */
16702 @@ -563,36 +586,22 @@ void *__init_or_module text_poke_early(void *addr, const void *opcode,
16703 */
16704 void *__kprobes text_poke(void *addr, const void *opcode, size_t len)
16705 {
16706 - unsigned long flags;
16707 - char *vaddr;
16708 + unsigned char *vaddr = ktla_ktva(addr);
16709 struct page *pages[2];
16710 - int i;
16711 + size_t i;
16712
16713 if (!core_kernel_text((unsigned long)addr)) {
16714 - pages[0] = vmalloc_to_page(addr);
16715 - pages[1] = vmalloc_to_page(addr + PAGE_SIZE);
16716 + pages[0] = vmalloc_to_page(vaddr);
16717 + pages[1] = vmalloc_to_page(vaddr + PAGE_SIZE);
16718 } else {
16719 - pages[0] = virt_to_page(addr);
16720 + pages[0] = virt_to_page(vaddr);
16721 WARN_ON(!PageReserved(pages[0]));
16722 - pages[1] = virt_to_page(addr + PAGE_SIZE);
16723 + pages[1] = virt_to_page(vaddr + PAGE_SIZE);
16724 }
16725 BUG_ON(!pages[0]);
16726 - local_irq_save(flags);
16727 - set_fixmap(FIX_TEXT_POKE0, page_to_phys(pages[0]));
16728 - if (pages[1])
16729 - set_fixmap(FIX_TEXT_POKE1, page_to_phys(pages[1]));
16730 - vaddr = (char *)fix_to_virt(FIX_TEXT_POKE0);
16731 - memcpy(&vaddr[(unsigned long)addr & ~PAGE_MASK], opcode, len);
16732 - clear_fixmap(FIX_TEXT_POKE0);
16733 - if (pages[1])
16734 - clear_fixmap(FIX_TEXT_POKE1);
16735 - local_flush_tlb();
16736 - sync_core();
16737 - /* Could also do a CLFLUSH here to speed up CPU recovery; but
16738 - that causes hangs on some VIA CPUs. */
16739 + text_poke_early(addr, opcode, len);
16740 for (i = 0; i < len; i++)
16741 - BUG_ON(((char *)addr)[i] != ((char *)opcode)[i]);
16742 - local_irq_restore(flags);
16743 + BUG_ON((vaddr)[i] != ((const unsigned char *)opcode)[i]);
16744 return addr;
16745 }
16746
16747 diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
16748 index 904611b..004dde6 100644
16749 --- a/arch/x86/kernel/apic/apic.c
16750 +++ b/arch/x86/kernel/apic/apic.c
16751 @@ -189,7 +189,7 @@ int first_system_vector = 0xfe;
16752 /*
16753 * Debug level, exported for io_apic.c
16754 */
16755 -unsigned int apic_verbosity;
16756 +int apic_verbosity;
16757
16758 int pic_mode;
16759
16760 @@ -1955,7 +1955,7 @@ void smp_error_interrupt(struct pt_regs *regs)
16761 apic_write(APIC_ESR, 0);
16762 v1 = apic_read(APIC_ESR);
16763 ack_APIC_irq();
16764 - atomic_inc(&irq_err_count);
16765 + atomic_inc_unchecked(&irq_err_count);
16766
16767 apic_printk(APIC_DEBUG, KERN_DEBUG "APIC error on CPU%d: %02x(%02x)",
16768 smp_processor_id(), v0 , v1);
16769 diff --git a/arch/x86/kernel/apic/apic_flat_64.c b/arch/x86/kernel/apic/apic_flat_64.c
16770 index 00c77cf..2dc6a2d 100644
16771 --- a/arch/x86/kernel/apic/apic_flat_64.c
16772 +++ b/arch/x86/kernel/apic/apic_flat_64.c
16773 @@ -157,7 +157,7 @@ static int flat_probe(void)
16774 return 1;
16775 }
16776
16777 -static struct apic apic_flat = {
16778 +static struct apic apic_flat __read_only = {
16779 .name = "flat",
16780 .probe = flat_probe,
16781 .acpi_madt_oem_check = flat_acpi_madt_oem_check,
16782 @@ -271,7 +271,7 @@ static int physflat_probe(void)
16783 return 0;
16784 }
16785
16786 -static struct apic apic_physflat = {
16787 +static struct apic apic_physflat __read_only = {
16788
16789 .name = "physical flat",
16790 .probe = physflat_probe,
16791 diff --git a/arch/x86/kernel/apic/apic_noop.c b/arch/x86/kernel/apic/apic_noop.c
16792 index e145f28..2752888 100644
16793 --- a/arch/x86/kernel/apic/apic_noop.c
16794 +++ b/arch/x86/kernel/apic/apic_noop.c
16795 @@ -119,7 +119,7 @@ static void noop_apic_write(u32 reg, u32 v)
16796 WARN_ON_ONCE(cpu_has_apic && !disable_apic);
16797 }
16798
16799 -struct apic apic_noop = {
16800 +struct apic apic_noop __read_only = {
16801 .name = "noop",
16802 .probe = noop_probe,
16803 .acpi_madt_oem_check = NULL,
16804 diff --git a/arch/x86/kernel/apic/bigsmp_32.c b/arch/x86/kernel/apic/bigsmp_32.c
16805 index d50e364..543bee3 100644
16806 --- a/arch/x86/kernel/apic/bigsmp_32.c
16807 +++ b/arch/x86/kernel/apic/bigsmp_32.c
16808 @@ -152,7 +152,7 @@ static int probe_bigsmp(void)
16809 return dmi_bigsmp;
16810 }
16811
16812 -static struct apic apic_bigsmp = {
16813 +static struct apic apic_bigsmp __read_only = {
16814
16815 .name = "bigsmp",
16816 .probe = probe_bigsmp,
16817 diff --git a/arch/x86/kernel/apic/es7000_32.c b/arch/x86/kernel/apic/es7000_32.c
16818 index 0874799..a7a7892 100644
16819 --- a/arch/x86/kernel/apic/es7000_32.c
16820 +++ b/arch/x86/kernel/apic/es7000_32.c
16821 @@ -608,8 +608,7 @@ static int es7000_mps_oem_check_cluster(struct mpc_table *mpc, char *oem,
16822 return ret && es7000_apic_is_cluster();
16823 }
16824
16825 -/* We've been warned by a false positive warning.Use __refdata to keep calm. */
16826 -static struct apic __refdata apic_es7000_cluster = {
16827 +static struct apic apic_es7000_cluster __read_only = {
16828
16829 .name = "es7000",
16830 .probe = probe_es7000,
16831 @@ -675,7 +674,7 @@ static struct apic __refdata apic_es7000_cluster = {
16832 .x86_32_early_logical_apicid = es7000_early_logical_apicid,
16833 };
16834
16835 -static struct apic __refdata apic_es7000 = {
16836 +static struct apic apic_es7000 __read_only = {
16837
16838 .name = "es7000",
16839 .probe = probe_es7000,
16840 diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
16841 index 9ed796c..e930fe4 100644
16842 --- a/arch/x86/kernel/apic/io_apic.c
16843 +++ b/arch/x86/kernel/apic/io_apic.c
16844 @@ -1060,7 +1060,7 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin,
16845 }
16846 EXPORT_SYMBOL(IO_APIC_get_PCI_irq_vector);
16847
16848 -void lock_vector_lock(void)
16849 +void lock_vector_lock(void) __acquires(vector_lock)
16850 {
16851 /* Used to the online set of cpus does not change
16852 * during assign_irq_vector.
16853 @@ -1068,7 +1068,7 @@ void lock_vector_lock(void)
16854 raw_spin_lock(&vector_lock);
16855 }
16856
16857 -void unlock_vector_lock(void)
16858 +void unlock_vector_lock(void) __releases(vector_lock)
16859 {
16860 raw_spin_unlock(&vector_lock);
16861 }
16862 @@ -2362,7 +2362,7 @@ static void ack_apic_edge(struct irq_data *data)
16863 ack_APIC_irq();
16864 }
16865
16866 -atomic_t irq_mis_count;
16867 +atomic_unchecked_t irq_mis_count;
16868
16869 #ifdef CONFIG_GENERIC_PENDING_IRQ
16870 static bool io_apic_level_ack_pending(struct irq_cfg *cfg)
16871 @@ -2503,7 +2503,7 @@ static void ack_apic_level(struct irq_data *data)
16872 * at the cpu.
16873 */
16874 if (!(v & (1 << (i & 0x1f)))) {
16875 - atomic_inc(&irq_mis_count);
16876 + atomic_inc_unchecked(&irq_mis_count);
16877
16878 eoi_ioapic_irq(irq, cfg);
16879 }
16880 diff --git a/arch/x86/kernel/apic/numaq_32.c b/arch/x86/kernel/apic/numaq_32.c
16881 index d661ee9..791fd33 100644
16882 --- a/arch/x86/kernel/apic/numaq_32.c
16883 +++ b/arch/x86/kernel/apic/numaq_32.c
16884 @@ -455,8 +455,7 @@ static void numaq_setup_portio_remap(void)
16885 (u_long) xquad_portio, (u_long) num_quads*XQUAD_PORTIO_QUAD);
16886 }
16887
16888 -/* Use __refdata to keep false positive warning calm. */
16889 -static struct apic __refdata apic_numaq = {
16890 +static struct apic apic_numaq __read_only = {
16891
16892 .name = "NUMAQ",
16893 .probe = probe_numaq,
16894 diff --git a/arch/x86/kernel/apic/probe_32.c b/arch/x86/kernel/apic/probe_32.c
16895 index eb35ef9..f184a21 100644
16896 --- a/arch/x86/kernel/apic/probe_32.c
16897 +++ b/arch/x86/kernel/apic/probe_32.c
16898 @@ -72,7 +72,7 @@ static int probe_default(void)
16899 return 1;
16900 }
16901
16902 -static struct apic apic_default = {
16903 +static struct apic apic_default __read_only = {
16904
16905 .name = "default",
16906 .probe = probe_default,
16907 diff --git a/arch/x86/kernel/apic/summit_32.c b/arch/x86/kernel/apic/summit_32.c
16908 index 77c95c0..434f8a4 100644
16909 --- a/arch/x86/kernel/apic/summit_32.c
16910 +++ b/arch/x86/kernel/apic/summit_32.c
16911 @@ -486,7 +486,7 @@ void setup_summit(void)
16912 }
16913 #endif
16914
16915 -static struct apic apic_summit = {
16916 +static struct apic apic_summit __read_only = {
16917
16918 .name = "summit",
16919 .probe = probe_summit,
16920 diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c
16921 index c88baa4..757aee1 100644
16922 --- a/arch/x86/kernel/apic/x2apic_cluster.c
16923 +++ b/arch/x86/kernel/apic/x2apic_cluster.c
16924 @@ -183,7 +183,7 @@ update_clusterinfo(struct notifier_block *nfb, unsigned long action, void *hcpu)
16925 return notifier_from_errno(err);
16926 }
16927
16928 -static struct notifier_block __refdata x2apic_cpu_notifier = {
16929 +static struct notifier_block x2apic_cpu_notifier = {
16930 .notifier_call = update_clusterinfo,
16931 };
16932
16933 @@ -235,7 +235,7 @@ static void cluster_vector_allocation_domain(int cpu, struct cpumask *retmask,
16934 cpumask_and(retmask, mask, per_cpu(cpus_in_cluster, cpu));
16935 }
16936
16937 -static struct apic apic_x2apic_cluster = {
16938 +static struct apic apic_x2apic_cluster __read_only = {
16939
16940 .name = "cluster x2apic",
16941 .probe = x2apic_cluster_probe,
16942 diff --git a/arch/x86/kernel/apic/x2apic_phys.c b/arch/x86/kernel/apic/x2apic_phys.c
16943 index 562a76d..a003c0f 100644
16944 --- a/arch/x86/kernel/apic/x2apic_phys.c
16945 +++ b/arch/x86/kernel/apic/x2apic_phys.c
16946 @@ -89,7 +89,7 @@ static int x2apic_phys_probe(void)
16947 return apic == &apic_x2apic_phys;
16948 }
16949
16950 -static struct apic apic_x2apic_phys = {
16951 +static struct apic apic_x2apic_phys __read_only = {
16952
16953 .name = "physical x2apic",
16954 .probe = x2apic_phys_probe,
16955 diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
16956 index 794f6eb..67e1db2 100644
16957 --- a/arch/x86/kernel/apic/x2apic_uv_x.c
16958 +++ b/arch/x86/kernel/apic/x2apic_uv_x.c
16959 @@ -342,7 +342,7 @@ static int uv_probe(void)
16960 return apic == &apic_x2apic_uv_x;
16961 }
16962
16963 -static struct apic __refdata apic_x2apic_uv_x = {
16964 +static struct apic apic_x2apic_uv_x __read_only = {
16965
16966 .name = "UV large system",
16967 .probe = uv_probe,
16968 diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
16969 index 66b5faf..3442423 100644
16970 --- a/arch/x86/kernel/apm_32.c
16971 +++ b/arch/x86/kernel/apm_32.c
16972 @@ -434,7 +434,7 @@ static DEFINE_MUTEX(apm_mutex);
16973 * This is for buggy BIOS's that refer to (real mode) segment 0x40
16974 * even though they are called in protected mode.
16975 */
16976 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
16977 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
16978 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
16979
16980 static const char driver_version[] = "1.16ac"; /* no spaces */
16981 @@ -612,7 +612,10 @@ static long __apm_bios_call(void *_call)
16982 BUG_ON(cpu != 0);
16983 gdt = get_cpu_gdt_table(cpu);
16984 save_desc_40 = gdt[0x40 / 8];
16985 +
16986 + pax_open_kernel();
16987 gdt[0x40 / 8] = bad_bios_desc;
16988 + pax_close_kernel();
16989
16990 apm_irq_save(flags);
16991 APM_DO_SAVE_SEGS;
16992 @@ -621,7 +624,11 @@ static long __apm_bios_call(void *_call)
16993 &call->esi);
16994 APM_DO_RESTORE_SEGS;
16995 apm_irq_restore(flags);
16996 +
16997 + pax_open_kernel();
16998 gdt[0x40 / 8] = save_desc_40;
16999 + pax_close_kernel();
17000 +
17001 put_cpu();
17002
17003 return call->eax & 0xff;
17004 @@ -688,7 +695,10 @@ static long __apm_bios_call_simple(void *_call)
17005 BUG_ON(cpu != 0);
17006 gdt = get_cpu_gdt_table(cpu);
17007 save_desc_40 = gdt[0x40 / 8];
17008 +
17009 + pax_open_kernel();
17010 gdt[0x40 / 8] = bad_bios_desc;
17011 + pax_close_kernel();
17012
17013 apm_irq_save(flags);
17014 APM_DO_SAVE_SEGS;
17015 @@ -696,7 +706,11 @@ static long __apm_bios_call_simple(void *_call)
17016 &call->eax);
17017 APM_DO_RESTORE_SEGS;
17018 apm_irq_restore(flags);
17019 +
17020 + pax_open_kernel();
17021 gdt[0x40 / 8] = save_desc_40;
17022 + pax_close_kernel();
17023 +
17024 put_cpu();
17025 return error;
17026 }
17027 @@ -2363,12 +2377,15 @@ static int __init apm_init(void)
17028 * code to that CPU.
17029 */
17030 gdt = get_cpu_gdt_table(0);
17031 +
17032 + pax_open_kernel();
17033 set_desc_base(&gdt[APM_CS >> 3],
17034 (unsigned long)__va((unsigned long)apm_info.bios.cseg << 4));
17035 set_desc_base(&gdt[APM_CS_16 >> 3],
17036 (unsigned long)__va((unsigned long)apm_info.bios.cseg_16 << 4));
17037 set_desc_base(&gdt[APM_DS >> 3],
17038 (unsigned long)__va((unsigned long)apm_info.bios.dseg << 4));
17039 + pax_close_kernel();
17040
17041 proc_create("apm", 0, NULL, &apm_file_ops);
17042
17043 diff --git a/arch/x86/kernel/asm-offsets.c b/arch/x86/kernel/asm-offsets.c
17044 index 2861082..6d4718e 100644
17045 --- a/arch/x86/kernel/asm-offsets.c
17046 +++ b/arch/x86/kernel/asm-offsets.c
17047 @@ -33,6 +33,8 @@ void common(void) {
17048 OFFSET(TI_status, thread_info, status);
17049 OFFSET(TI_addr_limit, thread_info, addr_limit);
17050 OFFSET(TI_preempt_count, thread_info, preempt_count);
17051 + OFFSET(TI_lowest_stack, thread_info, lowest_stack);
17052 + DEFINE(TI_task_thread_sp0, offsetof(struct task_struct, thread.sp0) - offsetof(struct task_struct, tinfo));
17053
17054 BLANK();
17055 OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
17056 @@ -53,8 +55,26 @@ void common(void) {
17057 OFFSET(PV_CPU_irq_enable_sysexit, pv_cpu_ops, irq_enable_sysexit);
17058 OFFSET(PV_CPU_read_cr0, pv_cpu_ops, read_cr0);
17059 OFFSET(PV_MMU_read_cr2, pv_mmu_ops, read_cr2);
17060 +
17061 +#ifdef CONFIG_PAX_KERNEXEC
17062 + OFFSET(PV_CPU_write_cr0, pv_cpu_ops, write_cr0);
17063 #endif
17064
17065 +#ifdef CONFIG_PAX_MEMORY_UDEREF
17066 + OFFSET(PV_MMU_read_cr3, pv_mmu_ops, read_cr3);
17067 + OFFSET(PV_MMU_write_cr3, pv_mmu_ops, write_cr3);
17068 +#ifdef CONFIG_X86_64
17069 + OFFSET(PV_MMU_set_pgd_batched, pv_mmu_ops, set_pgd_batched);
17070 +#endif
17071 +#endif
17072 +
17073 +#endif
17074 +
17075 + BLANK();
17076 + DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
17077 + DEFINE(PAGE_SHIFT_asm, PAGE_SHIFT);
17078 + DEFINE(THREAD_SIZE_asm, THREAD_SIZE);
17079 +
17080 #ifdef CONFIG_XEN
17081 BLANK();
17082 OFFSET(XEN_vcpu_info_mask, vcpu_info, evtchn_upcall_mask);
17083 diff --git a/arch/x86/kernel/asm-offsets_64.c b/arch/x86/kernel/asm-offsets_64.c
17084 index 1b4754f..fbb4227 100644
17085 --- a/arch/x86/kernel/asm-offsets_64.c
17086 +++ b/arch/x86/kernel/asm-offsets_64.c
17087 @@ -76,6 +76,7 @@ int main(void)
17088 BLANK();
17089 #undef ENTRY
17090
17091 + DEFINE(TSS_size, sizeof(struct tss_struct));
17092 OFFSET(TSS_ist, tss_struct, x86_tss.ist);
17093 BLANK();
17094
17095 diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
17096 index a0e067d..9c7db16 100644
17097 --- a/arch/x86/kernel/cpu/Makefile
17098 +++ b/arch/x86/kernel/cpu/Makefile
17099 @@ -8,10 +8,6 @@ CFLAGS_REMOVE_common.o = -pg
17100 CFLAGS_REMOVE_perf_event.o = -pg
17101 endif
17102
17103 -# Make sure load_percpu_segment has no stackprotector
17104 -nostackp := $(call cc-option, -fno-stack-protector)
17105 -CFLAGS_common.o := $(nostackp)
17106 -
17107 obj-y := intel_cacheinfo.o scattered.o topology.o
17108 obj-y += proc.o capflags.o powerflags.o common.o
17109 obj-y += vmware.o hypervisor.o mshyperv.o
17110 diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
17111 index fa96eb0..03efe73 100644
17112 --- a/arch/x86/kernel/cpu/amd.c
17113 +++ b/arch/x86/kernel/cpu/amd.c
17114 @@ -737,7 +737,7 @@ static unsigned int __cpuinit amd_size_cache(struct cpuinfo_x86 *c,
17115 unsigned int size)
17116 {
17117 /* AMD errata T13 (order #21922) */
17118 - if ((c->x86 == 6)) {
17119 + if (c->x86 == 6) {
17120 /* Duron Rev A0 */
17121 if (c->x86_model == 3 && c->x86_mask == 0)
17122 size = 64;
17123 diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
17124 index d814772..c615653 100644
17125 --- a/arch/x86/kernel/cpu/common.c
17126 +++ b/arch/x86/kernel/cpu/common.c
17127 @@ -88,60 +88,6 @@ static const struct cpu_dev __cpuinitconst default_cpu = {
17128
17129 static const struct cpu_dev *this_cpu __cpuinitdata = &default_cpu;
17130
17131 -DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = {
17132 -#ifdef CONFIG_X86_64
17133 - /*
17134 - * We need valid kernel segments for data and code in long mode too
17135 - * IRET will check the segment types kkeil 2000/10/28
17136 - * Also sysret mandates a special GDT layout
17137 - *
17138 - * TLS descriptors are currently at a different place compared to i386.
17139 - * Hopefully nobody expects them at a fixed place (Wine?)
17140 - */
17141 - [GDT_ENTRY_KERNEL32_CS] = GDT_ENTRY_INIT(0xc09b, 0, 0xfffff),
17142 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xa09b, 0, 0xfffff),
17143 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc093, 0, 0xfffff),
17144 - [GDT_ENTRY_DEFAULT_USER32_CS] = GDT_ENTRY_INIT(0xc0fb, 0, 0xfffff),
17145 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f3, 0, 0xfffff),
17146 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xa0fb, 0, 0xfffff),
17147 -#else
17148 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xc09a, 0, 0xfffff),
17149 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17150 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xc0fa, 0, 0xfffff),
17151 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f2, 0, 0xfffff),
17152 - /*
17153 - * Segments used for calling PnP BIOS have byte granularity.
17154 - * They code segments and data segments have fixed 64k limits,
17155 - * the transfer segment sizes are set at run time.
17156 - */
17157 - /* 32-bit code */
17158 - [GDT_ENTRY_PNPBIOS_CS32] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
17159 - /* 16-bit code */
17160 - [GDT_ENTRY_PNPBIOS_CS16] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
17161 - /* 16-bit data */
17162 - [GDT_ENTRY_PNPBIOS_DS] = GDT_ENTRY_INIT(0x0092, 0, 0xffff),
17163 - /* 16-bit data */
17164 - [GDT_ENTRY_PNPBIOS_TS1] = GDT_ENTRY_INIT(0x0092, 0, 0),
17165 - /* 16-bit data */
17166 - [GDT_ENTRY_PNPBIOS_TS2] = GDT_ENTRY_INIT(0x0092, 0, 0),
17167 - /*
17168 - * The APM segments have byte granularity and their bases
17169 - * are set at run time. All have 64k limits.
17170 - */
17171 - /* 32-bit code */
17172 - [GDT_ENTRY_APMBIOS_BASE] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
17173 - /* 16-bit code */
17174 - [GDT_ENTRY_APMBIOS_BASE+1] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
17175 - /* data */
17176 - [GDT_ENTRY_APMBIOS_BASE+2] = GDT_ENTRY_INIT(0x4092, 0, 0xffff),
17177 -
17178 - [GDT_ENTRY_ESPFIX_SS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17179 - [GDT_ENTRY_PERCPU] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17180 - GDT_STACK_CANARY_INIT
17181 -#endif
17182 -} };
17183 -EXPORT_PER_CPU_SYMBOL_GPL(gdt_page);
17184 -
17185 static int __init x86_xsave_setup(char *s)
17186 {
17187 setup_clear_cpu_cap(X86_FEATURE_XSAVE);
17188 @@ -386,7 +332,7 @@ void switch_to_new_gdt(int cpu)
17189 {
17190 struct desc_ptr gdt_descr;
17191
17192 - gdt_descr.address = (long)get_cpu_gdt_table(cpu);
17193 + gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
17194 gdt_descr.size = GDT_SIZE - 1;
17195 load_gdt(&gdt_descr);
17196 /* Reload the per-cpu base */
17197 @@ -882,6 +828,10 @@ static void __cpuinit identify_cpu(struct cpuinfo_x86 *c)
17198 /* Filter out anything that depends on CPUID levels we don't have */
17199 filter_cpuid_features(c, true);
17200
17201 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
17202 + setup_clear_cpu_cap(X86_FEATURE_SEP);
17203 +#endif
17204 +
17205 /* If the model name is still unset, do table lookup. */
17206 if (!c->x86_model_id[0]) {
17207 const char *p;
17208 @@ -1065,10 +1015,12 @@ static __init int setup_disablecpuid(char *arg)
17209 }
17210 __setup("clearcpuid=", setup_disablecpuid);
17211
17212 +DEFINE_PER_CPU(struct thread_info *, current_tinfo) = &init_task.tinfo;
17213 +EXPORT_PER_CPU_SYMBOL(current_tinfo);
17214 +
17215 #ifdef CONFIG_X86_64
17216 struct desc_ptr idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
17217 -struct desc_ptr nmi_idt_descr = { NR_VECTORS * 16 - 1,
17218 - (unsigned long) nmi_idt_table };
17219 +struct desc_ptr nmi_idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) nmi_idt_table };
17220
17221 DEFINE_PER_CPU_FIRST(union irq_stack_union,
17222 irq_stack_union) __aligned(PAGE_SIZE);
17223 @@ -1082,7 +1034,7 @@ DEFINE_PER_CPU(struct task_struct *, current_task) ____cacheline_aligned =
17224 EXPORT_PER_CPU_SYMBOL(current_task);
17225
17226 DEFINE_PER_CPU(unsigned long, kernel_stack) =
17227 - (unsigned long)&init_thread_union - KERNEL_STACK_OFFSET + THREAD_SIZE;
17228 + (unsigned long)&init_thread_union - 16 + THREAD_SIZE;
17229 EXPORT_PER_CPU_SYMBOL(kernel_stack);
17230
17231 DEFINE_PER_CPU(char *, irq_stack_ptr) =
17232 @@ -1227,7 +1179,7 @@ void __cpuinit cpu_init(void)
17233 load_ucode_ap();
17234
17235 cpu = stack_smp_processor_id();
17236 - t = &per_cpu(init_tss, cpu);
17237 + t = init_tss + cpu;
17238 oist = &per_cpu(orig_ist, cpu);
17239
17240 #ifdef CONFIG_NUMA
17241 @@ -1253,7 +1205,7 @@ void __cpuinit cpu_init(void)
17242 switch_to_new_gdt(cpu);
17243 loadsegment(fs, 0);
17244
17245 - load_idt((const struct desc_ptr *)&idt_descr);
17246 + load_idt(&idt_descr);
17247
17248 memset(me->thread.tls_array, 0, GDT_ENTRY_TLS_ENTRIES * 8);
17249 syscall_init();
17250 @@ -1262,7 +1214,6 @@ void __cpuinit cpu_init(void)
17251 wrmsrl(MSR_KERNEL_GS_BASE, 0);
17252 barrier();
17253
17254 - x86_configure_nx();
17255 enable_x2apic();
17256
17257 /*
17258 @@ -1314,7 +1265,7 @@ void __cpuinit cpu_init(void)
17259 {
17260 int cpu = smp_processor_id();
17261 struct task_struct *curr = current;
17262 - struct tss_struct *t = &per_cpu(init_tss, cpu);
17263 + struct tss_struct *t = init_tss + cpu;
17264 struct thread_struct *thread = &curr->thread;
17265
17266 show_ucode_info_early();
17267 diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
17268 index 1905ce9..a7ac587 100644
17269 --- a/arch/x86/kernel/cpu/intel.c
17270 +++ b/arch/x86/kernel/cpu/intel.c
17271 @@ -173,7 +173,7 @@ static void __cpuinit trap_init_f00f_bug(void)
17272 * Update the IDT descriptor and reload the IDT so that
17273 * it uses the read-only mapped virtual address.
17274 */
17275 - idt_descr.address = fix_to_virt(FIX_F00F_IDT);
17276 + idt_descr.address = (struct desc_struct *)fix_to_virt(FIX_F00F_IDT);
17277 load_idt(&idt_descr);
17278 }
17279 #endif
17280 diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
17281 index 7c6f7d5..8cac382 100644
17282 --- a/arch/x86/kernel/cpu/intel_cacheinfo.c
17283 +++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
17284 @@ -1017,6 +1017,22 @@ static struct attribute *default_attrs[] = {
17285 };
17286
17287 #ifdef CONFIG_AMD_NB
17288 +static struct attribute *default_attrs_amd_nb[] = {
17289 + &type.attr,
17290 + &level.attr,
17291 + &coherency_line_size.attr,
17292 + &physical_line_partition.attr,
17293 + &ways_of_associativity.attr,
17294 + &number_of_sets.attr,
17295 + &size.attr,
17296 + &shared_cpu_map.attr,
17297 + &shared_cpu_list.attr,
17298 + NULL,
17299 + NULL,
17300 + NULL,
17301 + NULL
17302 +};
17303 +
17304 static struct attribute ** __cpuinit amd_l3_attrs(void)
17305 {
17306 static struct attribute **attrs;
17307 @@ -1027,18 +1043,7 @@ static struct attribute ** __cpuinit amd_l3_attrs(void)
17308
17309 n = ARRAY_SIZE(default_attrs);
17310
17311 - if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE))
17312 - n += 2;
17313 -
17314 - if (amd_nb_has_feature(AMD_NB_L3_PARTITIONING))
17315 - n += 1;
17316 -
17317 - attrs = kzalloc(n * sizeof (struct attribute *), GFP_KERNEL);
17318 - if (attrs == NULL)
17319 - return attrs = default_attrs;
17320 -
17321 - for (n = 0; default_attrs[n]; n++)
17322 - attrs[n] = default_attrs[n];
17323 + attrs = default_attrs_amd_nb;
17324
17325 if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE)) {
17326 attrs[n++] = &cache_disable_0.attr;
17327 @@ -1089,6 +1094,13 @@ static struct kobj_type ktype_cache = {
17328 .default_attrs = default_attrs,
17329 };
17330
17331 +#ifdef CONFIG_AMD_NB
17332 +static struct kobj_type ktype_cache_amd_nb = {
17333 + .sysfs_ops = &sysfs_ops,
17334 + .default_attrs = default_attrs_amd_nb,
17335 +};
17336 +#endif
17337 +
17338 static struct kobj_type ktype_percpu_entry = {
17339 .sysfs_ops = &sysfs_ops,
17340 };
17341 @@ -1154,20 +1166,26 @@ static int __cpuinit cache_add_dev(struct device *dev)
17342 return retval;
17343 }
17344
17345 +#ifdef CONFIG_AMD_NB
17346 + amd_l3_attrs();
17347 +#endif
17348 +
17349 for (i = 0; i < num_cache_leaves; i++) {
17350 + struct kobj_type *ktype;
17351 +
17352 this_object = INDEX_KOBJECT_PTR(cpu, i);
17353 this_object->cpu = cpu;
17354 this_object->index = i;
17355
17356 this_leaf = CPUID4_INFO_IDX(cpu, i);
17357
17358 - ktype_cache.default_attrs = default_attrs;
17359 + ktype = &ktype_cache;
17360 #ifdef CONFIG_AMD_NB
17361 if (this_leaf->base.nb)
17362 - ktype_cache.default_attrs = amd_l3_attrs();
17363 + ktype = &ktype_cache_amd_nb;
17364 #endif
17365 retval = kobject_init_and_add(&(this_object->kobj),
17366 - &ktype_cache,
17367 + ktype,
17368 per_cpu(ici_cache_kobject, cpu),
17369 "index%1lu", i);
17370 if (unlikely(retval)) {
17371 @@ -1222,7 +1240,7 @@ static int __cpuinit cacheinfo_cpu_callback(struct notifier_block *nfb,
17372 return NOTIFY_OK;
17373 }
17374
17375 -static struct notifier_block __cpuinitdata cacheinfo_cpu_notifier = {
17376 +static struct notifier_block cacheinfo_cpu_notifier = {
17377 .notifier_call = cacheinfo_cpu_callback,
17378 };
17379
17380 diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
17381 index 7bc1263..ce2cbfb 100644
17382 --- a/arch/x86/kernel/cpu/mcheck/mce.c
17383 +++ b/arch/x86/kernel/cpu/mcheck/mce.c
17384 @@ -45,6 +45,7 @@
17385 #include <asm/processor.h>
17386 #include <asm/mce.h>
17387 #include <asm/msr.h>
17388 +#include <asm/local.h>
17389
17390 #include "mce-internal.h"
17391
17392 @@ -246,7 +247,7 @@ static void print_mce(struct mce *m)
17393 !(m->mcgstatus & MCG_STATUS_EIPV) ? " !INEXACT!" : "",
17394 m->cs, m->ip);
17395
17396 - if (m->cs == __KERNEL_CS)
17397 + if (m->cs == __KERNEL_CS || m->cs == __KERNEXEC_KERNEL_CS)
17398 print_symbol("{%s}", m->ip);
17399 pr_cont("\n");
17400 }
17401 @@ -279,10 +280,10 @@ static void print_mce(struct mce *m)
17402
17403 #define PANIC_TIMEOUT 5 /* 5 seconds */
17404
17405 -static atomic_t mce_paniced;
17406 +static atomic_unchecked_t mce_paniced;
17407
17408 static int fake_panic;
17409 -static atomic_t mce_fake_paniced;
17410 +static atomic_unchecked_t mce_fake_paniced;
17411
17412 /* Panic in progress. Enable interrupts and wait for final IPI */
17413 static void wait_for_panic(void)
17414 @@ -306,7 +307,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
17415 /*
17416 * Make sure only one CPU runs in machine check panic
17417 */
17418 - if (atomic_inc_return(&mce_paniced) > 1)
17419 + if (atomic_inc_return_unchecked(&mce_paniced) > 1)
17420 wait_for_panic();
17421 barrier();
17422
17423 @@ -314,7 +315,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
17424 console_verbose();
17425 } else {
17426 /* Don't log too much for fake panic */
17427 - if (atomic_inc_return(&mce_fake_paniced) > 1)
17428 + if (atomic_inc_return_unchecked(&mce_fake_paniced) > 1)
17429 return;
17430 }
17431 /* First print corrected ones that are still unlogged */
17432 @@ -683,7 +684,7 @@ static int mce_timed_out(u64 *t)
17433 * might have been modified by someone else.
17434 */
17435 rmb();
17436 - if (atomic_read(&mce_paniced))
17437 + if (atomic_read_unchecked(&mce_paniced))
17438 wait_for_panic();
17439 if (!mca_cfg.monarch_timeout)
17440 goto out;
17441 @@ -1654,7 +1655,7 @@ static void unexpected_machine_check(struct pt_regs *regs, long error_code)
17442 }
17443
17444 /* Call the installed machine check handler for this CPU setup. */
17445 -void (*machine_check_vector)(struct pt_regs *, long error_code) =
17446 +void (*machine_check_vector)(struct pt_regs *, long error_code) __read_only =
17447 unexpected_machine_check;
17448
17449 /*
17450 @@ -1677,7 +1678,9 @@ void __cpuinit mcheck_cpu_init(struct cpuinfo_x86 *c)
17451 return;
17452 }
17453
17454 + pax_open_kernel();
17455 machine_check_vector = do_machine_check;
17456 + pax_close_kernel();
17457
17458 __mcheck_cpu_init_generic();
17459 __mcheck_cpu_init_vendor(c);
17460 @@ -1691,7 +1694,7 @@ void __cpuinit mcheck_cpu_init(struct cpuinfo_x86 *c)
17461 */
17462
17463 static DEFINE_SPINLOCK(mce_chrdev_state_lock);
17464 -static int mce_chrdev_open_count; /* #times opened */
17465 +static local_t mce_chrdev_open_count; /* #times opened */
17466 static int mce_chrdev_open_exclu; /* already open exclusive? */
17467
17468 static int mce_chrdev_open(struct inode *inode, struct file *file)
17469 @@ -1699,7 +1702,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
17470 spin_lock(&mce_chrdev_state_lock);
17471
17472 if (mce_chrdev_open_exclu ||
17473 - (mce_chrdev_open_count && (file->f_flags & O_EXCL))) {
17474 + (local_read(&mce_chrdev_open_count) && (file->f_flags & O_EXCL))) {
17475 spin_unlock(&mce_chrdev_state_lock);
17476
17477 return -EBUSY;
17478 @@ -1707,7 +1710,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
17479
17480 if (file->f_flags & O_EXCL)
17481 mce_chrdev_open_exclu = 1;
17482 - mce_chrdev_open_count++;
17483 + local_inc(&mce_chrdev_open_count);
17484
17485 spin_unlock(&mce_chrdev_state_lock);
17486
17487 @@ -1718,7 +1721,7 @@ static int mce_chrdev_release(struct inode *inode, struct file *file)
17488 {
17489 spin_lock(&mce_chrdev_state_lock);
17490
17491 - mce_chrdev_open_count--;
17492 + local_dec(&mce_chrdev_open_count);
17493 mce_chrdev_open_exclu = 0;
17494
17495 spin_unlock(&mce_chrdev_state_lock);
17496 @@ -2364,7 +2367,7 @@ mce_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
17497 return NOTIFY_OK;
17498 }
17499
17500 -static struct notifier_block mce_cpu_notifier __cpuinitdata = {
17501 +static struct notifier_block mce_cpu_notifier = {
17502 .notifier_call = mce_cpu_callback,
17503 };
17504
17505 @@ -2374,7 +2377,7 @@ static __init void mce_init_banks(void)
17506
17507 for (i = 0; i < mca_cfg.banks; i++) {
17508 struct mce_bank *b = &mce_banks[i];
17509 - struct device_attribute *a = &b->attr;
17510 + device_attribute_no_const *a = &b->attr;
17511
17512 sysfs_attr_init(&a->attr);
17513 a->attr.name = b->attrname;
17514 @@ -2442,7 +2445,7 @@ struct dentry *mce_get_debugfs_dir(void)
17515 static void mce_reset(void)
17516 {
17517 cpu_missing = 0;
17518 - atomic_set(&mce_fake_paniced, 0);
17519 + atomic_set_unchecked(&mce_fake_paniced, 0);
17520 atomic_set(&mce_executing, 0);
17521 atomic_set(&mce_callin, 0);
17522 atomic_set(&global_nwo, 0);
17523 diff --git a/arch/x86/kernel/cpu/mcheck/p5.c b/arch/x86/kernel/cpu/mcheck/p5.c
17524 index 1c044b1..37a2a43 100644
17525 --- a/arch/x86/kernel/cpu/mcheck/p5.c
17526 +++ b/arch/x86/kernel/cpu/mcheck/p5.c
17527 @@ -11,6 +11,7 @@
17528 #include <asm/processor.h>
17529 #include <asm/mce.h>
17530 #include <asm/msr.h>
17531 +#include <asm/pgtable.h>
17532
17533 /* By default disabled */
17534 int mce_p5_enabled __read_mostly;
17535 @@ -49,7 +50,9 @@ void intel_p5_mcheck_init(struct cpuinfo_x86 *c)
17536 if (!cpu_has(c, X86_FEATURE_MCE))
17537 return;
17538
17539 + pax_open_kernel();
17540 machine_check_vector = pentium_machine_check;
17541 + pax_close_kernel();
17542 /* Make sure the vector pointer is visible before we enable MCEs: */
17543 wmb();
17544
17545 diff --git a/arch/x86/kernel/cpu/mcheck/therm_throt.c b/arch/x86/kernel/cpu/mcheck/therm_throt.c
17546 index 47a1870..8c019a7 100644
17547 --- a/arch/x86/kernel/cpu/mcheck/therm_throt.c
17548 +++ b/arch/x86/kernel/cpu/mcheck/therm_throt.c
17549 @@ -288,7 +288,7 @@ thermal_throttle_cpu_callback(struct notifier_block *nfb,
17550 return notifier_from_errno(err);
17551 }
17552
17553 -static struct notifier_block thermal_throttle_cpu_notifier __cpuinitdata =
17554 +static struct notifier_block thermal_throttle_cpu_notifier =
17555 {
17556 .notifier_call = thermal_throttle_cpu_callback,
17557 };
17558 diff --git a/arch/x86/kernel/cpu/mcheck/winchip.c b/arch/x86/kernel/cpu/mcheck/winchip.c
17559 index e9a701a..35317d6 100644
17560 --- a/arch/x86/kernel/cpu/mcheck/winchip.c
17561 +++ b/arch/x86/kernel/cpu/mcheck/winchip.c
17562 @@ -10,6 +10,7 @@
17563 #include <asm/processor.h>
17564 #include <asm/mce.h>
17565 #include <asm/msr.h>
17566 +#include <asm/pgtable.h>
17567
17568 /* Machine check handler for WinChip C6: */
17569 static void winchip_machine_check(struct pt_regs *regs, long error_code)
17570 @@ -23,7 +24,9 @@ void winchip_mcheck_init(struct cpuinfo_x86 *c)
17571 {
17572 u32 lo, hi;
17573
17574 + pax_open_kernel();
17575 machine_check_vector = winchip_machine_check;
17576 + pax_close_kernel();
17577 /* Make sure the vector pointer is visible before we enable MCEs: */
17578 wmb();
17579
17580 diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
17581 index 726bf96..81f0526 100644
17582 --- a/arch/x86/kernel/cpu/mtrr/main.c
17583 +++ b/arch/x86/kernel/cpu/mtrr/main.c
17584 @@ -62,7 +62,7 @@ static DEFINE_MUTEX(mtrr_mutex);
17585 u64 size_or_mask, size_and_mask;
17586 static bool mtrr_aps_delayed_init;
17587
17588 -static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM];
17589 +static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM] __read_only;
17590
17591 const struct mtrr_ops *mtrr_if;
17592
17593 diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.h b/arch/x86/kernel/cpu/mtrr/mtrr.h
17594 index df5e41f..816c719 100644
17595 --- a/arch/x86/kernel/cpu/mtrr/mtrr.h
17596 +++ b/arch/x86/kernel/cpu/mtrr/mtrr.h
17597 @@ -25,7 +25,7 @@ struct mtrr_ops {
17598 int (*validate_add_page)(unsigned long base, unsigned long size,
17599 unsigned int type);
17600 int (*have_wrcomb)(void);
17601 -};
17602 +} __do_const;
17603
17604 extern int generic_get_free_region(unsigned long base, unsigned long size,
17605 int replace_reg);
17606 diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
17607 index bf0f01a..9adfee1 100644
17608 --- a/arch/x86/kernel/cpu/perf_event.c
17609 +++ b/arch/x86/kernel/cpu/perf_event.c
17610 @@ -1305,7 +1305,7 @@ static void __init pmu_check_apic(void)
17611 pr_info("no hardware sampling interrupt available.\n");
17612 }
17613
17614 -static struct attribute_group x86_pmu_format_group = {
17615 +static attribute_group_no_const x86_pmu_format_group = {
17616 .name = "format",
17617 .attrs = NULL,
17618 };
17619 @@ -1374,7 +1374,7 @@ static struct attribute *events_attr[] = {
17620 NULL,
17621 };
17622
17623 -static struct attribute_group x86_pmu_events_group = {
17624 +static attribute_group_no_const x86_pmu_events_group = {
17625 .name = "events",
17626 .attrs = events_attr,
17627 };
17628 @@ -1873,7 +1873,7 @@ static unsigned long get_segment_base(unsigned int segment)
17629 if (idx > GDT_ENTRIES)
17630 return 0;
17631
17632 - desc = __this_cpu_ptr(&gdt_page.gdt[0]);
17633 + desc = get_cpu_gdt_table(smp_processor_id());
17634 }
17635
17636 return get_desc_base(desc + idx);
17637 @@ -1963,7 +1963,7 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
17638 break;
17639
17640 perf_callchain_store(entry, frame.return_address);
17641 - fp = frame.next_frame;
17642 + fp = (const void __force_user *)frame.next_frame;
17643 }
17644 }
17645
17646 diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
17647 index 4a0a462..be3b204 100644
17648 --- a/arch/x86/kernel/cpu/perf_event_intel.c
17649 +++ b/arch/x86/kernel/cpu/perf_event_intel.c
17650 @@ -1994,10 +1994,10 @@ __init int intel_pmu_init(void)
17651 * v2 and above have a perf capabilities MSR
17652 */
17653 if (version > 1) {
17654 - u64 capabilities;
17655 + u64 capabilities = x86_pmu.intel_cap.capabilities;
17656
17657 - rdmsrl(MSR_IA32_PERF_CAPABILITIES, capabilities);
17658 - x86_pmu.intel_cap.capabilities = capabilities;
17659 + if (rdmsrl_safe(MSR_IA32_PERF_CAPABILITIES, &x86_pmu.intel_cap.capabilities))
17660 + x86_pmu.intel_cap.capabilities = capabilities;
17661 }
17662
17663 intel_ds_init();
17664 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
17665 index 3e091f0..d2dc8d6 100644
17666 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
17667 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
17668 @@ -2428,7 +2428,7 @@ static void __init uncore_types_exit(struct intel_uncore_type **types)
17669 static int __init uncore_type_init(struct intel_uncore_type *type)
17670 {
17671 struct intel_uncore_pmu *pmus;
17672 - struct attribute_group *attr_group;
17673 + attribute_group_no_const *attr_group;
17674 struct attribute **attrs;
17675 int i, j;
17676
17677 @@ -2826,7 +2826,7 @@ static int
17678 return NOTIFY_OK;
17679 }
17680
17681 -static struct notifier_block uncore_cpu_nb __cpuinitdata = {
17682 +static struct notifier_block uncore_cpu_nb = {
17683 .notifier_call = uncore_cpu_notifier,
17684 /*
17685 * to migrate uncore events, our notifier should be executed
17686 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.h b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
17687 index e68a455..975a932 100644
17688 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.h
17689 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
17690 @@ -428,7 +428,7 @@ struct intel_uncore_box {
17691 struct uncore_event_desc {
17692 struct kobj_attribute attr;
17693 const char *config;
17694 -};
17695 +} __do_const;
17696
17697 #define INTEL_UNCORE_EVENT_DESC(_name, _config) \
17698 { \
17699 diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
17700 index 1e4dbcf..b9a34c2 100644
17701 --- a/arch/x86/kernel/cpuid.c
17702 +++ b/arch/x86/kernel/cpuid.c
17703 @@ -171,7 +171,7 @@ static int __cpuinit cpuid_class_cpu_callback(struct notifier_block *nfb,
17704 return notifier_from_errno(err);
17705 }
17706
17707 -static struct notifier_block __refdata cpuid_class_cpu_notifier =
17708 +static struct notifier_block cpuid_class_cpu_notifier =
17709 {
17710 .notifier_call = cpuid_class_cpu_callback,
17711 };
17712 diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
17713 index 74467fe..18793d5 100644
17714 --- a/arch/x86/kernel/crash.c
17715 +++ b/arch/x86/kernel/crash.c
17716 @@ -58,10 +58,8 @@ static void kdump_nmi_callback(int cpu, struct pt_regs *regs)
17717 {
17718 #ifdef CONFIG_X86_32
17719 struct pt_regs fixed_regs;
17720 -#endif
17721
17722 -#ifdef CONFIG_X86_32
17723 - if (!user_mode_vm(regs)) {
17724 + if (!user_mode(regs)) {
17725 crash_fixup_ss_esp(&fixed_regs, regs);
17726 regs = &fixed_regs;
17727 }
17728 diff --git a/arch/x86/kernel/doublefault_32.c b/arch/x86/kernel/doublefault_32.c
17729 index 37250fe..bf2ec74 100644
17730 --- a/arch/x86/kernel/doublefault_32.c
17731 +++ b/arch/x86/kernel/doublefault_32.c
17732 @@ -11,7 +11,7 @@
17733
17734 #define DOUBLEFAULT_STACKSIZE (1024)
17735 static unsigned long doublefault_stack[DOUBLEFAULT_STACKSIZE];
17736 -#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE)
17737 +#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE-2)
17738
17739 #define ptr_ok(x) ((x) > PAGE_OFFSET && (x) < PAGE_OFFSET + MAXMEM)
17740
17741 @@ -21,7 +21,7 @@ static void doublefault_fn(void)
17742 unsigned long gdt, tss;
17743
17744 store_gdt(&gdt_desc);
17745 - gdt = gdt_desc.address;
17746 + gdt = (unsigned long)gdt_desc.address;
17747
17748 printk(KERN_EMERG "PANIC: double fault, gdt at %08lx [%d bytes]\n", gdt, gdt_desc.size);
17749
17750 @@ -58,10 +58,10 @@ struct tss_struct doublefault_tss __cacheline_aligned = {
17751 /* 0x2 bit is always set */
17752 .flags = X86_EFLAGS_SF | 0x2,
17753 .sp = STACK_START,
17754 - .es = __USER_DS,
17755 + .es = __KERNEL_DS,
17756 .cs = __KERNEL_CS,
17757 .ss = __KERNEL_DS,
17758 - .ds = __USER_DS,
17759 + .ds = __KERNEL_DS,
17760 .fs = __KERNEL_PERCPU,
17761
17762 .__cr3 = __pa_nodebug(swapper_pg_dir),
17763 diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
17764 index c8797d5..c605e53 100644
17765 --- a/arch/x86/kernel/dumpstack.c
17766 +++ b/arch/x86/kernel/dumpstack.c
17767 @@ -2,6 +2,9 @@
17768 * Copyright (C) 1991, 1992 Linus Torvalds
17769 * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
17770 */
17771 +#ifdef CONFIG_GRKERNSEC_HIDESYM
17772 +#define __INCLUDED_BY_HIDESYM 1
17773 +#endif
17774 #include <linux/kallsyms.h>
17775 #include <linux/kprobes.h>
17776 #include <linux/uaccess.h>
17777 @@ -35,16 +38,14 @@ void printk_address(unsigned long address, int reliable)
17778 static void
17779 print_ftrace_graph_addr(unsigned long addr, void *data,
17780 const struct stacktrace_ops *ops,
17781 - struct thread_info *tinfo, int *graph)
17782 + struct task_struct *task, int *graph)
17783 {
17784 - struct task_struct *task;
17785 unsigned long ret_addr;
17786 int index;
17787
17788 if (addr != (unsigned long)return_to_handler)
17789 return;
17790
17791 - task = tinfo->task;
17792 index = task->curr_ret_stack;
17793
17794 if (!task->ret_stack || index < *graph)
17795 @@ -61,7 +62,7 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
17796 static inline void
17797 print_ftrace_graph_addr(unsigned long addr, void *data,
17798 const struct stacktrace_ops *ops,
17799 - struct thread_info *tinfo, int *graph)
17800 + struct task_struct *task, int *graph)
17801 { }
17802 #endif
17803
17804 @@ -72,10 +73,8 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
17805 * severe exception (double fault, nmi, stack fault, debug, mce) hardware stack
17806 */
17807
17808 -static inline int valid_stack_ptr(struct thread_info *tinfo,
17809 - void *p, unsigned int size, void *end)
17810 +static inline int valid_stack_ptr(void *t, void *p, unsigned int size, void *end)
17811 {
17812 - void *t = tinfo;
17813 if (end) {
17814 if (p < end && p >= (end-THREAD_SIZE))
17815 return 1;
17816 @@ -86,14 +85,14 @@ static inline int valid_stack_ptr(struct thread_info *tinfo,
17817 }
17818
17819 unsigned long
17820 -print_context_stack(struct thread_info *tinfo,
17821 +print_context_stack(struct task_struct *task, void *stack_start,
17822 unsigned long *stack, unsigned long bp,
17823 const struct stacktrace_ops *ops, void *data,
17824 unsigned long *end, int *graph)
17825 {
17826 struct stack_frame *frame = (struct stack_frame *)bp;
17827
17828 - while (valid_stack_ptr(tinfo, stack, sizeof(*stack), end)) {
17829 + while (valid_stack_ptr(stack_start, stack, sizeof(*stack), end)) {
17830 unsigned long addr;
17831
17832 addr = *stack;
17833 @@ -105,7 +104,7 @@ print_context_stack(struct thread_info *tinfo,
17834 } else {
17835 ops->address(data, addr, 0);
17836 }
17837 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
17838 + print_ftrace_graph_addr(addr, data, ops, task, graph);
17839 }
17840 stack++;
17841 }
17842 @@ -114,7 +113,7 @@ print_context_stack(struct thread_info *tinfo,
17843 EXPORT_SYMBOL_GPL(print_context_stack);
17844
17845 unsigned long
17846 -print_context_stack_bp(struct thread_info *tinfo,
17847 +print_context_stack_bp(struct task_struct *task, void *stack_start,
17848 unsigned long *stack, unsigned long bp,
17849 const struct stacktrace_ops *ops, void *data,
17850 unsigned long *end, int *graph)
17851 @@ -122,7 +121,7 @@ print_context_stack_bp(struct thread_info *tinfo,
17852 struct stack_frame *frame = (struct stack_frame *)bp;
17853 unsigned long *ret_addr = &frame->return_address;
17854
17855 - while (valid_stack_ptr(tinfo, ret_addr, sizeof(*ret_addr), end)) {
17856 + while (valid_stack_ptr(stack_start, ret_addr, sizeof(*ret_addr), end)) {
17857 unsigned long addr = *ret_addr;
17858
17859 if (!__kernel_text_address(addr))
17860 @@ -131,7 +130,7 @@ print_context_stack_bp(struct thread_info *tinfo,
17861 ops->address(data, addr, 1);
17862 frame = frame->next_frame;
17863 ret_addr = &frame->return_address;
17864 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
17865 + print_ftrace_graph_addr(addr, data, ops, task, graph);
17866 }
17867
17868 return (unsigned long)frame;
17869 @@ -189,7 +188,7 @@ void dump_stack(void)
17870
17871 bp = stack_frame(current, NULL);
17872 printk("Pid: %d, comm: %.20s %s %s %.*s\n",
17873 - current->pid, current->comm, print_tainted(),
17874 + task_pid_nr(current), current->comm, print_tainted(),
17875 init_utsname()->release,
17876 (int)strcspn(init_utsname()->version, " "),
17877 init_utsname()->version);
17878 @@ -225,6 +224,8 @@ unsigned __kprobes long oops_begin(void)
17879 }
17880 EXPORT_SYMBOL_GPL(oops_begin);
17881
17882 +extern void gr_handle_kernel_exploit(void);
17883 +
17884 void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
17885 {
17886 if (regs && kexec_should_crash(current))
17887 @@ -246,7 +247,10 @@ void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
17888 panic("Fatal exception in interrupt");
17889 if (panic_on_oops)
17890 panic("Fatal exception");
17891 - do_exit(signr);
17892 +
17893 + gr_handle_kernel_exploit();
17894 +
17895 + do_group_exit(signr);
17896 }
17897
17898 int __kprobes __die(const char *str, struct pt_regs *regs, long err)
17899 @@ -274,7 +278,7 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err)
17900 print_modules();
17901 show_regs(regs);
17902 #ifdef CONFIG_X86_32
17903 - if (user_mode_vm(regs)) {
17904 + if (user_mode(regs)) {
17905 sp = regs->sp;
17906 ss = regs->ss & 0xffff;
17907 } else {
17908 @@ -302,7 +306,7 @@ void die(const char *str, struct pt_regs *regs, long err)
17909 unsigned long flags = oops_begin();
17910 int sig = SIGSEGV;
17911
17912 - if (!user_mode_vm(regs))
17913 + if (!user_mode(regs))
17914 report_bug(regs->ip, regs);
17915
17916 if (__die(str, regs, err))
17917 diff --git a/arch/x86/kernel/dumpstack_32.c b/arch/x86/kernel/dumpstack_32.c
17918 index 1038a41..db2c12b 100644
17919 --- a/arch/x86/kernel/dumpstack_32.c
17920 +++ b/arch/x86/kernel/dumpstack_32.c
17921 @@ -38,15 +38,13 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
17922 bp = stack_frame(task, regs);
17923
17924 for (;;) {
17925 - struct thread_info *context;
17926 + void *stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
17927
17928 - context = (struct thread_info *)
17929 - ((unsigned long)stack & (~(THREAD_SIZE - 1)));
17930 - bp = ops->walk_stack(context, stack, bp, ops, data, NULL, &graph);
17931 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
17932
17933 - stack = (unsigned long *)context->previous_esp;
17934 - if (!stack)
17935 + if (stack_start == task_stack_page(task))
17936 break;
17937 + stack = *(unsigned long **)stack_start;
17938 if (ops->stack(data, "IRQ") < 0)
17939 break;
17940 touch_nmi_watchdog();
17941 @@ -86,7 +84,7 @@ void show_regs(struct pt_regs *regs)
17942 {
17943 int i;
17944
17945 - __show_regs(regs, !user_mode_vm(regs));
17946 + __show_regs(regs, !user_mode(regs));
17947
17948 pr_emerg("Process %.*s (pid: %d, ti=%p task=%p task.ti=%p)\n",
17949 TASK_COMM_LEN, current->comm, task_pid_nr(current),
17950 @@ -95,21 +93,22 @@ void show_regs(struct pt_regs *regs)
17951 * When in-kernel, we also print out the stack and code at the
17952 * time of the fault..
17953 */
17954 - if (!user_mode_vm(regs)) {
17955 + if (!user_mode(regs)) {
17956 unsigned int code_prologue = code_bytes * 43 / 64;
17957 unsigned int code_len = code_bytes;
17958 unsigned char c;
17959 u8 *ip;
17960 + unsigned long cs_base = get_desc_base(&get_cpu_gdt_table(0)[(0xffff & regs->cs) >> 3]);
17961
17962 pr_emerg("Stack:\n");
17963 show_stack_log_lvl(NULL, regs, &regs->sp, 0, KERN_EMERG);
17964
17965 pr_emerg("Code:");
17966
17967 - ip = (u8 *)regs->ip - code_prologue;
17968 + ip = (u8 *)regs->ip - code_prologue + cs_base;
17969 if (ip < (u8 *)PAGE_OFFSET || probe_kernel_address(ip, c)) {
17970 /* try starting at IP */
17971 - ip = (u8 *)regs->ip;
17972 + ip = (u8 *)regs->ip + cs_base;
17973 code_len = code_len - code_prologue + 1;
17974 }
17975 for (i = 0; i < code_len; i++, ip++) {
17976 @@ -118,7 +117,7 @@ void show_regs(struct pt_regs *regs)
17977 pr_cont(" Bad EIP value.");
17978 break;
17979 }
17980 - if (ip == (u8 *)regs->ip)
17981 + if (ip == (u8 *)regs->ip + cs_base)
17982 pr_cont(" <%02x>", c);
17983 else
17984 pr_cont(" %02x", c);
17985 @@ -131,6 +130,7 @@ int is_valid_bugaddr(unsigned long ip)
17986 {
17987 unsigned short ud2;
17988
17989 + ip = ktla_ktva(ip);
17990 if (ip < PAGE_OFFSET)
17991 return 0;
17992 if (probe_kernel_address((unsigned short *)ip, ud2))
17993 @@ -138,3 +138,15 @@ int is_valid_bugaddr(unsigned long ip)
17994
17995 return ud2 == 0x0b0f;
17996 }
17997 +
17998 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
17999 +void pax_check_alloca(unsigned long size)
18000 +{
18001 + unsigned long sp = (unsigned long)&sp, stack_left;
18002 +
18003 + /* all kernel stacks are of the same size */
18004 + stack_left = sp & (THREAD_SIZE - 1);
18005 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18006 +}
18007 +EXPORT_SYMBOL(pax_check_alloca);
18008 +#endif
18009 diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
18010 index b653675..51cc8c0 100644
18011 --- a/arch/x86/kernel/dumpstack_64.c
18012 +++ b/arch/x86/kernel/dumpstack_64.c
18013 @@ -119,9 +119,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18014 unsigned long *irq_stack_end =
18015 (unsigned long *)per_cpu(irq_stack_ptr, cpu);
18016 unsigned used = 0;
18017 - struct thread_info *tinfo;
18018 int graph = 0;
18019 unsigned long dummy;
18020 + void *stack_start;
18021
18022 if (!task)
18023 task = current;
18024 @@ -142,10 +142,10 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18025 * current stack address. If the stacks consist of nested
18026 * exceptions
18027 */
18028 - tinfo = task_thread_info(task);
18029 for (;;) {
18030 char *id;
18031 unsigned long *estack_end;
18032 +
18033 estack_end = in_exception_stack(cpu, (unsigned long)stack,
18034 &used, &id);
18035
18036 @@ -153,7 +153,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18037 if (ops->stack(data, id) < 0)
18038 break;
18039
18040 - bp = ops->walk_stack(tinfo, stack, bp, ops,
18041 + bp = ops->walk_stack(task, estack_end - EXCEPTION_STKSZ, stack, bp, ops,
18042 data, estack_end, &graph);
18043 ops->stack(data, "<EOE>");
18044 /*
18045 @@ -161,6 +161,8 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18046 * second-to-last pointer (index -2 to end) in the
18047 * exception stack:
18048 */
18049 + if ((u16)estack_end[-1] != __KERNEL_DS)
18050 + goto out;
18051 stack = (unsigned long *) estack_end[-2];
18052 continue;
18053 }
18054 @@ -172,7 +174,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18055 if (in_irq_stack(stack, irq_stack, irq_stack_end)) {
18056 if (ops->stack(data, "IRQ") < 0)
18057 break;
18058 - bp = ops->walk_stack(tinfo, stack, bp,
18059 + bp = ops->walk_stack(task, irq_stack, stack, bp,
18060 ops, data, irq_stack_end, &graph);
18061 /*
18062 * We link to the next stack (which would be
18063 @@ -191,7 +193,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18064 /*
18065 * This handles the process stack:
18066 */
18067 - bp = ops->walk_stack(tinfo, stack, bp, ops, data, NULL, &graph);
18068 + stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
18069 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
18070 +out:
18071 put_cpu();
18072 }
18073 EXPORT_SYMBOL(dump_trace);
18074 @@ -249,7 +253,7 @@ void show_regs(struct pt_regs *regs)
18075 {
18076 int i;
18077 unsigned long sp;
18078 - const int cpu = smp_processor_id();
18079 + const int cpu = raw_smp_processor_id();
18080 struct task_struct *cur = current;
18081
18082 sp = regs->sp;
18083 @@ -304,3 +308,50 @@ int is_valid_bugaddr(unsigned long ip)
18084
18085 return ud2 == 0x0b0f;
18086 }
18087 +
18088 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18089 +void pax_check_alloca(unsigned long size)
18090 +{
18091 + unsigned long sp = (unsigned long)&sp, stack_start, stack_end;
18092 + unsigned cpu, used;
18093 + char *id;
18094 +
18095 + /* check the process stack first */
18096 + stack_start = (unsigned long)task_stack_page(current);
18097 + stack_end = stack_start + THREAD_SIZE;
18098 + if (likely(stack_start <= sp && sp < stack_end)) {
18099 + unsigned long stack_left = sp & (THREAD_SIZE - 1);
18100 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18101 + return;
18102 + }
18103 +
18104 + cpu = get_cpu();
18105 +
18106 + /* check the irq stacks */
18107 + stack_end = (unsigned long)per_cpu(irq_stack_ptr, cpu);
18108 + stack_start = stack_end - IRQ_STACK_SIZE;
18109 + if (stack_start <= sp && sp < stack_end) {
18110 + unsigned long stack_left = sp & (IRQ_STACK_SIZE - 1);
18111 + put_cpu();
18112 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18113 + return;
18114 + }
18115 +
18116 + /* check the exception stacks */
18117 + used = 0;
18118 + stack_end = (unsigned long)in_exception_stack(cpu, sp, &used, &id);
18119 + stack_start = stack_end - EXCEPTION_STKSZ;
18120 + if (stack_end && stack_start <= sp && sp < stack_end) {
18121 + unsigned long stack_left = sp & (EXCEPTION_STKSZ - 1);
18122 + put_cpu();
18123 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18124 + return;
18125 + }
18126 +
18127 + put_cpu();
18128 +
18129 + /* unknown stack */
18130 + BUG();
18131 +}
18132 +EXPORT_SYMBOL(pax_check_alloca);
18133 +#endif
18134 diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c
18135 index 9b9f18b..9fcaa04 100644
18136 --- a/arch/x86/kernel/early_printk.c
18137 +++ b/arch/x86/kernel/early_printk.c
18138 @@ -7,6 +7,7 @@
18139 #include <linux/pci_regs.h>
18140 #include <linux/pci_ids.h>
18141 #include <linux/errno.h>
18142 +#include <linux/sched.h>
18143 #include <asm/io.h>
18144 #include <asm/processor.h>
18145 #include <asm/fcntl.h>
18146 diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
18147 index 8f3e2de..934870f 100644
18148 --- a/arch/x86/kernel/entry_32.S
18149 +++ b/arch/x86/kernel/entry_32.S
18150 @@ -177,13 +177,153 @@
18151 /*CFI_REL_OFFSET gs, PT_GS*/
18152 .endm
18153 .macro SET_KERNEL_GS reg
18154 +
18155 +#ifdef CONFIG_CC_STACKPROTECTOR
18156 movl $(__KERNEL_STACK_CANARY), \reg
18157 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
18158 + movl $(__USER_DS), \reg
18159 +#else
18160 + xorl \reg, \reg
18161 +#endif
18162 +
18163 movl \reg, %gs
18164 .endm
18165
18166 #endif /* CONFIG_X86_32_LAZY_GS */
18167
18168 -.macro SAVE_ALL
18169 +.macro pax_enter_kernel
18170 +#ifdef CONFIG_PAX_KERNEXEC
18171 + call pax_enter_kernel
18172 +#endif
18173 +.endm
18174 +
18175 +.macro pax_exit_kernel
18176 +#ifdef CONFIG_PAX_KERNEXEC
18177 + call pax_exit_kernel
18178 +#endif
18179 +.endm
18180 +
18181 +#ifdef CONFIG_PAX_KERNEXEC
18182 +ENTRY(pax_enter_kernel)
18183 +#ifdef CONFIG_PARAVIRT
18184 + pushl %eax
18185 + pushl %ecx
18186 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0)
18187 + mov %eax, %esi
18188 +#else
18189 + mov %cr0, %esi
18190 +#endif
18191 + bts $16, %esi
18192 + jnc 1f
18193 + mov %cs, %esi
18194 + cmp $__KERNEL_CS, %esi
18195 + jz 3f
18196 + ljmp $__KERNEL_CS, $3f
18197 +1: ljmp $__KERNEXEC_KERNEL_CS, $2f
18198 +2:
18199 +#ifdef CONFIG_PARAVIRT
18200 + mov %esi, %eax
18201 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
18202 +#else
18203 + mov %esi, %cr0
18204 +#endif
18205 +3:
18206 +#ifdef CONFIG_PARAVIRT
18207 + popl %ecx
18208 + popl %eax
18209 +#endif
18210 + ret
18211 +ENDPROC(pax_enter_kernel)
18212 +
18213 +ENTRY(pax_exit_kernel)
18214 +#ifdef CONFIG_PARAVIRT
18215 + pushl %eax
18216 + pushl %ecx
18217 +#endif
18218 + mov %cs, %esi
18219 + cmp $__KERNEXEC_KERNEL_CS, %esi
18220 + jnz 2f
18221 +#ifdef CONFIG_PARAVIRT
18222 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0);
18223 + mov %eax, %esi
18224 +#else
18225 + mov %cr0, %esi
18226 +#endif
18227 + btr $16, %esi
18228 + ljmp $__KERNEL_CS, $1f
18229 +1:
18230 +#ifdef CONFIG_PARAVIRT
18231 + mov %esi, %eax
18232 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0);
18233 +#else
18234 + mov %esi, %cr0
18235 +#endif
18236 +2:
18237 +#ifdef CONFIG_PARAVIRT
18238 + popl %ecx
18239 + popl %eax
18240 +#endif
18241 + ret
18242 +ENDPROC(pax_exit_kernel)
18243 +#endif
18244 +
18245 +.macro pax_erase_kstack
18246 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18247 + call pax_erase_kstack
18248 +#endif
18249 +.endm
18250 +
18251 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18252 +/*
18253 + * ebp: thread_info
18254 + */
18255 +ENTRY(pax_erase_kstack)
18256 + pushl %edi
18257 + pushl %ecx
18258 + pushl %eax
18259 +
18260 + mov TI_lowest_stack(%ebp), %edi
18261 + mov $-0xBEEF, %eax
18262 + std
18263 +
18264 +1: mov %edi, %ecx
18265 + and $THREAD_SIZE_asm - 1, %ecx
18266 + shr $2, %ecx
18267 + repne scasl
18268 + jecxz 2f
18269 +
18270 + cmp $2*16, %ecx
18271 + jc 2f
18272 +
18273 + mov $2*16, %ecx
18274 + repe scasl
18275 + jecxz 2f
18276 + jne 1b
18277 +
18278 +2: cld
18279 + mov %esp, %ecx
18280 + sub %edi, %ecx
18281 +
18282 + cmp $THREAD_SIZE_asm, %ecx
18283 + jb 3f
18284 + ud2
18285 +3:
18286 +
18287 + shr $2, %ecx
18288 + rep stosl
18289 +
18290 + mov TI_task_thread_sp0(%ebp), %edi
18291 + sub $128, %edi
18292 + mov %edi, TI_lowest_stack(%ebp)
18293 +
18294 + popl %eax
18295 + popl %ecx
18296 + popl %edi
18297 + ret
18298 +ENDPROC(pax_erase_kstack)
18299 +#endif
18300 +
18301 +.macro __SAVE_ALL _DS
18302 cld
18303 PUSH_GS
18304 pushl_cfi %fs
18305 @@ -206,7 +346,7 @@
18306 CFI_REL_OFFSET ecx, 0
18307 pushl_cfi %ebx
18308 CFI_REL_OFFSET ebx, 0
18309 - movl $(__USER_DS), %edx
18310 + movl $\_DS, %edx
18311 movl %edx, %ds
18312 movl %edx, %es
18313 movl $(__KERNEL_PERCPU), %edx
18314 @@ -214,6 +354,15 @@
18315 SET_KERNEL_GS %edx
18316 .endm
18317
18318 +.macro SAVE_ALL
18319 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
18320 + __SAVE_ALL __KERNEL_DS
18321 + pax_enter_kernel
18322 +#else
18323 + __SAVE_ALL __USER_DS
18324 +#endif
18325 +.endm
18326 +
18327 .macro RESTORE_INT_REGS
18328 popl_cfi %ebx
18329 CFI_RESTORE ebx
18330 @@ -297,7 +446,7 @@ ENTRY(ret_from_fork)
18331 popfl_cfi
18332 jmp syscall_exit
18333 CFI_ENDPROC
18334 -END(ret_from_fork)
18335 +ENDPROC(ret_from_fork)
18336
18337 ENTRY(ret_from_kernel_thread)
18338 CFI_STARTPROC
18339 @@ -344,7 +493,15 @@ ret_from_intr:
18340 andl $SEGMENT_RPL_MASK, %eax
18341 #endif
18342 cmpl $USER_RPL, %eax
18343 +
18344 +#ifdef CONFIG_PAX_KERNEXEC
18345 + jae resume_userspace
18346 +
18347 + pax_exit_kernel
18348 + jmp resume_kernel
18349 +#else
18350 jb resume_kernel # not returning to v8086 or userspace
18351 +#endif
18352
18353 ENTRY(resume_userspace)
18354 LOCKDEP_SYS_EXIT
18355 @@ -356,8 +513,8 @@ ENTRY(resume_userspace)
18356 andl $_TIF_WORK_MASK, %ecx # is there any work to be done on
18357 # int/exception return?
18358 jne work_pending
18359 - jmp restore_all
18360 -END(ret_from_exception)
18361 + jmp restore_all_pax
18362 +ENDPROC(ret_from_exception)
18363
18364 #ifdef CONFIG_PREEMPT
18365 ENTRY(resume_kernel)
18366 @@ -372,7 +529,7 @@ need_resched:
18367 jz restore_all
18368 call preempt_schedule_irq
18369 jmp need_resched
18370 -END(resume_kernel)
18371 +ENDPROC(resume_kernel)
18372 #endif
18373 CFI_ENDPROC
18374 /*
18375 @@ -406,30 +563,45 @@ sysenter_past_esp:
18376 /*CFI_REL_OFFSET cs, 0*/
18377 /*
18378 * Push current_thread_info()->sysenter_return to the stack.
18379 - * A tiny bit of offset fixup is necessary - 4*4 means the 4 words
18380 - * pushed above; +8 corresponds to copy_thread's esp0 setting.
18381 */
18382 - pushl_cfi ((TI_sysenter_return)-THREAD_SIZE+8+4*4)(%esp)
18383 + pushl_cfi $0
18384 CFI_REL_OFFSET eip, 0
18385
18386 pushl_cfi %eax
18387 SAVE_ALL
18388 + GET_THREAD_INFO(%ebp)
18389 + movl TI_sysenter_return(%ebp),%ebp
18390 + movl %ebp,PT_EIP(%esp)
18391 ENABLE_INTERRUPTS(CLBR_NONE)
18392
18393 /*
18394 * Load the potential sixth argument from user stack.
18395 * Careful about security.
18396 */
18397 + movl PT_OLDESP(%esp),%ebp
18398 +
18399 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18400 + mov PT_OLDSS(%esp),%ds
18401 +1: movl %ds:(%ebp),%ebp
18402 + push %ss
18403 + pop %ds
18404 +#else
18405 cmpl $__PAGE_OFFSET-3,%ebp
18406 jae syscall_fault
18407 ASM_STAC
18408 1: movl (%ebp),%ebp
18409 ASM_CLAC
18410 +#endif
18411 +
18412 movl %ebp,PT_EBP(%esp)
18413 _ASM_EXTABLE(1b,syscall_fault)
18414
18415 GET_THREAD_INFO(%ebp)
18416
18417 +#ifdef CONFIG_PAX_RANDKSTACK
18418 + pax_erase_kstack
18419 +#endif
18420 +
18421 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
18422 jnz sysenter_audit
18423 sysenter_do_call:
18424 @@ -444,12 +616,24 @@ sysenter_do_call:
18425 testl $_TIF_ALLWORK_MASK, %ecx
18426 jne sysexit_audit
18427 sysenter_exit:
18428 +
18429 +#ifdef CONFIG_PAX_RANDKSTACK
18430 + pushl_cfi %eax
18431 + movl %esp, %eax
18432 + call pax_randomize_kstack
18433 + popl_cfi %eax
18434 +#endif
18435 +
18436 + pax_erase_kstack
18437 +
18438 /* if something modifies registers it must also disable sysexit */
18439 movl PT_EIP(%esp), %edx
18440 movl PT_OLDESP(%esp), %ecx
18441 xorl %ebp,%ebp
18442 TRACE_IRQS_ON
18443 1: mov PT_FS(%esp), %fs
18444 +2: mov PT_DS(%esp), %ds
18445 +3: mov PT_ES(%esp), %es
18446 PTGS_TO_GS
18447 ENABLE_INTERRUPTS_SYSEXIT
18448
18449 @@ -466,6 +650,9 @@ sysenter_audit:
18450 movl %eax,%edx /* 2nd arg: syscall number */
18451 movl $AUDIT_ARCH_I386,%eax /* 1st arg: audit arch */
18452 call __audit_syscall_entry
18453 +
18454 + pax_erase_kstack
18455 +
18456 pushl_cfi %ebx
18457 movl PT_EAX(%esp),%eax /* reload syscall number */
18458 jmp sysenter_do_call
18459 @@ -491,10 +678,16 @@ sysexit_audit:
18460
18461 CFI_ENDPROC
18462 .pushsection .fixup,"ax"
18463 -2: movl $0,PT_FS(%esp)
18464 +4: movl $0,PT_FS(%esp)
18465 + jmp 1b
18466 +5: movl $0,PT_DS(%esp)
18467 + jmp 1b
18468 +6: movl $0,PT_ES(%esp)
18469 jmp 1b
18470 .popsection
18471 - _ASM_EXTABLE(1b,2b)
18472 + _ASM_EXTABLE(1b,4b)
18473 + _ASM_EXTABLE(2b,5b)
18474 + _ASM_EXTABLE(3b,6b)
18475 PTGS_TO_GS_EX
18476 ENDPROC(ia32_sysenter_target)
18477
18478 @@ -509,6 +702,11 @@ ENTRY(system_call)
18479 pushl_cfi %eax # save orig_eax
18480 SAVE_ALL
18481 GET_THREAD_INFO(%ebp)
18482 +
18483 +#ifdef CONFIG_PAX_RANDKSTACK
18484 + pax_erase_kstack
18485 +#endif
18486 +
18487 # system call tracing in operation / emulation
18488 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
18489 jnz syscall_trace_entry
18490 @@ -527,6 +725,15 @@ syscall_exit:
18491 testl $_TIF_ALLWORK_MASK, %ecx # current->work
18492 jne syscall_exit_work
18493
18494 +restore_all_pax:
18495 +
18496 +#ifdef CONFIG_PAX_RANDKSTACK
18497 + movl %esp, %eax
18498 + call pax_randomize_kstack
18499 +#endif
18500 +
18501 + pax_erase_kstack
18502 +
18503 restore_all:
18504 TRACE_IRQS_IRET
18505 restore_all_notrace:
18506 @@ -583,14 +790,34 @@ ldt_ss:
18507 * compensating for the offset by changing to the ESPFIX segment with
18508 * a base address that matches for the difference.
18509 */
18510 -#define GDT_ESPFIX_SS PER_CPU_VAR(gdt_page) + (GDT_ENTRY_ESPFIX_SS * 8)
18511 +#define GDT_ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8)(%ebx)
18512 mov %esp, %edx /* load kernel esp */
18513 mov PT_OLDESP(%esp), %eax /* load userspace esp */
18514 mov %dx, %ax /* eax: new kernel esp */
18515 sub %eax, %edx /* offset (low word is 0) */
18516 +#ifdef CONFIG_SMP
18517 + movl PER_CPU_VAR(cpu_number), %ebx
18518 + shll $PAGE_SHIFT_asm, %ebx
18519 + addl $cpu_gdt_table, %ebx
18520 +#else
18521 + movl $cpu_gdt_table, %ebx
18522 +#endif
18523 shr $16, %edx
18524 - mov %dl, GDT_ESPFIX_SS + 4 /* bits 16..23 */
18525 - mov %dh, GDT_ESPFIX_SS + 7 /* bits 24..31 */
18526 +
18527 +#ifdef CONFIG_PAX_KERNEXEC
18528 + mov %cr0, %esi
18529 + btr $16, %esi
18530 + mov %esi, %cr0
18531 +#endif
18532 +
18533 + mov %dl, 4 + GDT_ESPFIX_SS /* bits 16..23 */
18534 + mov %dh, 7 + GDT_ESPFIX_SS /* bits 24..31 */
18535 +
18536 +#ifdef CONFIG_PAX_KERNEXEC
18537 + bts $16, %esi
18538 + mov %esi, %cr0
18539 +#endif
18540 +
18541 pushl_cfi $__ESPFIX_SS
18542 pushl_cfi %eax /* new kernel esp */
18543 /* Disable interrupts, but do not irqtrace this section: we
18544 @@ -619,20 +846,18 @@ work_resched:
18545 movl TI_flags(%ebp), %ecx
18546 andl $_TIF_WORK_MASK, %ecx # is there any work to be done other
18547 # than syscall tracing?
18548 - jz restore_all
18549 + jz restore_all_pax
18550 testb $_TIF_NEED_RESCHED, %cl
18551 jnz work_resched
18552
18553 work_notifysig: # deal with pending signals and
18554 # notify-resume requests
18555 + movl %esp, %eax
18556 #ifdef CONFIG_VM86
18557 testl $X86_EFLAGS_VM, PT_EFLAGS(%esp)
18558 - movl %esp, %eax
18559 jne work_notifysig_v86 # returning to kernel-space or
18560 # vm86-space
18561 1:
18562 -#else
18563 - movl %esp, %eax
18564 #endif
18565 TRACE_IRQS_ON
18566 ENABLE_INTERRUPTS(CLBR_NONE)
18567 @@ -653,7 +878,7 @@ work_notifysig_v86:
18568 movl %eax, %esp
18569 jmp 1b
18570 #endif
18571 -END(work_pending)
18572 +ENDPROC(work_pending)
18573
18574 # perform syscall exit tracing
18575 ALIGN
18576 @@ -661,11 +886,14 @@ syscall_trace_entry:
18577 movl $-ENOSYS,PT_EAX(%esp)
18578 movl %esp, %eax
18579 call syscall_trace_enter
18580 +
18581 + pax_erase_kstack
18582 +
18583 /* What it returned is what we'll actually use. */
18584 cmpl $(NR_syscalls), %eax
18585 jnae syscall_call
18586 jmp syscall_exit
18587 -END(syscall_trace_entry)
18588 +ENDPROC(syscall_trace_entry)
18589
18590 # perform syscall exit tracing
18591 ALIGN
18592 @@ -678,21 +906,25 @@ syscall_exit_work:
18593 movl %esp, %eax
18594 call syscall_trace_leave
18595 jmp resume_userspace
18596 -END(syscall_exit_work)
18597 +ENDPROC(syscall_exit_work)
18598 CFI_ENDPROC
18599
18600 RING0_INT_FRAME # can't unwind into user space anyway
18601 syscall_fault:
18602 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18603 + push %ss
18604 + pop %ds
18605 +#endif
18606 ASM_CLAC
18607 GET_THREAD_INFO(%ebp)
18608 movl $-EFAULT,PT_EAX(%esp)
18609 jmp resume_userspace
18610 -END(syscall_fault)
18611 +ENDPROC(syscall_fault)
18612
18613 syscall_badsys:
18614 movl $-ENOSYS,PT_EAX(%esp)
18615 jmp resume_userspace
18616 -END(syscall_badsys)
18617 +ENDPROC(syscall_badsys)
18618 CFI_ENDPROC
18619 /*
18620 * End of kprobes section
18621 @@ -708,8 +940,15 @@ END(syscall_badsys)
18622 * normal stack and adjusts ESP with the matching offset.
18623 */
18624 /* fixup the stack */
18625 - mov GDT_ESPFIX_SS + 4, %al /* bits 16..23 */
18626 - mov GDT_ESPFIX_SS + 7, %ah /* bits 24..31 */
18627 +#ifdef CONFIG_SMP
18628 + movl PER_CPU_VAR(cpu_number), %ebx
18629 + shll $PAGE_SHIFT_asm, %ebx
18630 + addl $cpu_gdt_table, %ebx
18631 +#else
18632 + movl $cpu_gdt_table, %ebx
18633 +#endif
18634 + mov 4 + GDT_ESPFIX_SS, %al /* bits 16..23 */
18635 + mov 7 + GDT_ESPFIX_SS, %ah /* bits 24..31 */
18636 shl $16, %eax
18637 addl %esp, %eax /* the adjusted stack pointer */
18638 pushl_cfi $__KERNEL_DS
18639 @@ -762,7 +1001,7 @@ vector=vector+1
18640 .endr
18641 2: jmp common_interrupt
18642 .endr
18643 -END(irq_entries_start)
18644 +ENDPROC(irq_entries_start)
18645
18646 .previous
18647 END(interrupt)
18648 @@ -813,7 +1052,7 @@ ENTRY(coprocessor_error)
18649 pushl_cfi $do_coprocessor_error
18650 jmp error_code
18651 CFI_ENDPROC
18652 -END(coprocessor_error)
18653 +ENDPROC(coprocessor_error)
18654
18655 ENTRY(simd_coprocessor_error)
18656 RING0_INT_FRAME
18657 @@ -835,7 +1074,7 @@ ENTRY(simd_coprocessor_error)
18658 #endif
18659 jmp error_code
18660 CFI_ENDPROC
18661 -END(simd_coprocessor_error)
18662 +ENDPROC(simd_coprocessor_error)
18663
18664 ENTRY(device_not_available)
18665 RING0_INT_FRAME
18666 @@ -844,18 +1083,18 @@ ENTRY(device_not_available)
18667 pushl_cfi $do_device_not_available
18668 jmp error_code
18669 CFI_ENDPROC
18670 -END(device_not_available)
18671 +ENDPROC(device_not_available)
18672
18673 #ifdef CONFIG_PARAVIRT
18674 ENTRY(native_iret)
18675 iret
18676 _ASM_EXTABLE(native_iret, iret_exc)
18677 -END(native_iret)
18678 +ENDPROC(native_iret)
18679
18680 ENTRY(native_irq_enable_sysexit)
18681 sti
18682 sysexit
18683 -END(native_irq_enable_sysexit)
18684 +ENDPROC(native_irq_enable_sysexit)
18685 #endif
18686
18687 ENTRY(overflow)
18688 @@ -865,7 +1104,7 @@ ENTRY(overflow)
18689 pushl_cfi $do_overflow
18690 jmp error_code
18691 CFI_ENDPROC
18692 -END(overflow)
18693 +ENDPROC(overflow)
18694
18695 ENTRY(bounds)
18696 RING0_INT_FRAME
18697 @@ -874,7 +1113,7 @@ ENTRY(bounds)
18698 pushl_cfi $do_bounds
18699 jmp error_code
18700 CFI_ENDPROC
18701 -END(bounds)
18702 +ENDPROC(bounds)
18703
18704 ENTRY(invalid_op)
18705 RING0_INT_FRAME
18706 @@ -883,7 +1122,7 @@ ENTRY(invalid_op)
18707 pushl_cfi $do_invalid_op
18708 jmp error_code
18709 CFI_ENDPROC
18710 -END(invalid_op)
18711 +ENDPROC(invalid_op)
18712
18713 ENTRY(coprocessor_segment_overrun)
18714 RING0_INT_FRAME
18715 @@ -892,7 +1131,7 @@ ENTRY(coprocessor_segment_overrun)
18716 pushl_cfi $do_coprocessor_segment_overrun
18717 jmp error_code
18718 CFI_ENDPROC
18719 -END(coprocessor_segment_overrun)
18720 +ENDPROC(coprocessor_segment_overrun)
18721
18722 ENTRY(invalid_TSS)
18723 RING0_EC_FRAME
18724 @@ -900,7 +1139,7 @@ ENTRY(invalid_TSS)
18725 pushl_cfi $do_invalid_TSS
18726 jmp error_code
18727 CFI_ENDPROC
18728 -END(invalid_TSS)
18729 +ENDPROC(invalid_TSS)
18730
18731 ENTRY(segment_not_present)
18732 RING0_EC_FRAME
18733 @@ -908,7 +1147,7 @@ ENTRY(segment_not_present)
18734 pushl_cfi $do_segment_not_present
18735 jmp error_code
18736 CFI_ENDPROC
18737 -END(segment_not_present)
18738 +ENDPROC(segment_not_present)
18739
18740 ENTRY(stack_segment)
18741 RING0_EC_FRAME
18742 @@ -916,7 +1155,7 @@ ENTRY(stack_segment)
18743 pushl_cfi $do_stack_segment
18744 jmp error_code
18745 CFI_ENDPROC
18746 -END(stack_segment)
18747 +ENDPROC(stack_segment)
18748
18749 ENTRY(alignment_check)
18750 RING0_EC_FRAME
18751 @@ -924,7 +1163,7 @@ ENTRY(alignment_check)
18752 pushl_cfi $do_alignment_check
18753 jmp error_code
18754 CFI_ENDPROC
18755 -END(alignment_check)
18756 +ENDPROC(alignment_check)
18757
18758 ENTRY(divide_error)
18759 RING0_INT_FRAME
18760 @@ -933,7 +1172,7 @@ ENTRY(divide_error)
18761 pushl_cfi $do_divide_error
18762 jmp error_code
18763 CFI_ENDPROC
18764 -END(divide_error)
18765 +ENDPROC(divide_error)
18766
18767 #ifdef CONFIG_X86_MCE
18768 ENTRY(machine_check)
18769 @@ -943,7 +1182,7 @@ ENTRY(machine_check)
18770 pushl_cfi machine_check_vector
18771 jmp error_code
18772 CFI_ENDPROC
18773 -END(machine_check)
18774 +ENDPROC(machine_check)
18775 #endif
18776
18777 ENTRY(spurious_interrupt_bug)
18778 @@ -953,7 +1192,7 @@ ENTRY(spurious_interrupt_bug)
18779 pushl_cfi $do_spurious_interrupt_bug
18780 jmp error_code
18781 CFI_ENDPROC
18782 -END(spurious_interrupt_bug)
18783 +ENDPROC(spurious_interrupt_bug)
18784 /*
18785 * End of kprobes section
18786 */
18787 @@ -1063,7 +1302,7 @@ BUILD_INTERRUPT3(hyperv_callback_vector, HYPERVISOR_CALLBACK_VECTOR,
18788
18789 ENTRY(mcount)
18790 ret
18791 -END(mcount)
18792 +ENDPROC(mcount)
18793
18794 ENTRY(ftrace_caller)
18795 cmpl $0, function_trace_stop
18796 @@ -1096,7 +1335,7 @@ ftrace_graph_call:
18797 .globl ftrace_stub
18798 ftrace_stub:
18799 ret
18800 -END(ftrace_caller)
18801 +ENDPROC(ftrace_caller)
18802
18803 ENTRY(ftrace_regs_caller)
18804 pushf /* push flags before compare (in cs location) */
18805 @@ -1197,7 +1436,7 @@ trace:
18806 popl %ecx
18807 popl %eax
18808 jmp ftrace_stub
18809 -END(mcount)
18810 +ENDPROC(mcount)
18811 #endif /* CONFIG_DYNAMIC_FTRACE */
18812 #endif /* CONFIG_FUNCTION_TRACER */
18813
18814 @@ -1215,7 +1454,7 @@ ENTRY(ftrace_graph_caller)
18815 popl %ecx
18816 popl %eax
18817 ret
18818 -END(ftrace_graph_caller)
18819 +ENDPROC(ftrace_graph_caller)
18820
18821 .globl return_to_handler
18822 return_to_handler:
18823 @@ -1271,15 +1510,18 @@ error_code:
18824 movl $-1, PT_ORIG_EAX(%esp) # no syscall to restart
18825 REG_TO_PTGS %ecx
18826 SET_KERNEL_GS %ecx
18827 - movl $(__USER_DS), %ecx
18828 + movl $(__KERNEL_DS), %ecx
18829 movl %ecx, %ds
18830 movl %ecx, %es
18831 +
18832 + pax_enter_kernel
18833 +
18834 TRACE_IRQS_OFF
18835 movl %esp,%eax # pt_regs pointer
18836 call *%edi
18837 jmp ret_from_exception
18838 CFI_ENDPROC
18839 -END(page_fault)
18840 +ENDPROC(page_fault)
18841
18842 /*
18843 * Debug traps and NMI can happen at the one SYSENTER instruction
18844 @@ -1322,7 +1564,7 @@ debug_stack_correct:
18845 call do_debug
18846 jmp ret_from_exception
18847 CFI_ENDPROC
18848 -END(debug)
18849 +ENDPROC(debug)
18850
18851 /*
18852 * NMI is doubly nasty. It can happen _while_ we're handling
18853 @@ -1360,6 +1602,9 @@ nmi_stack_correct:
18854 xorl %edx,%edx # zero error code
18855 movl %esp,%eax # pt_regs pointer
18856 call do_nmi
18857 +
18858 + pax_exit_kernel
18859 +
18860 jmp restore_all_notrace
18861 CFI_ENDPROC
18862
18863 @@ -1396,12 +1641,15 @@ nmi_espfix_stack:
18864 FIXUP_ESPFIX_STACK # %eax == %esp
18865 xorl %edx,%edx # zero error code
18866 call do_nmi
18867 +
18868 + pax_exit_kernel
18869 +
18870 RESTORE_REGS
18871 lss 12+4(%esp), %esp # back to espfix stack
18872 CFI_ADJUST_CFA_OFFSET -24
18873 jmp irq_return
18874 CFI_ENDPROC
18875 -END(nmi)
18876 +ENDPROC(nmi)
18877
18878 ENTRY(int3)
18879 RING0_INT_FRAME
18880 @@ -1414,14 +1662,14 @@ ENTRY(int3)
18881 call do_int3
18882 jmp ret_from_exception
18883 CFI_ENDPROC
18884 -END(int3)
18885 +ENDPROC(int3)
18886
18887 ENTRY(general_protection)
18888 RING0_EC_FRAME
18889 pushl_cfi $do_general_protection
18890 jmp error_code
18891 CFI_ENDPROC
18892 -END(general_protection)
18893 +ENDPROC(general_protection)
18894
18895 #ifdef CONFIG_KVM_GUEST
18896 ENTRY(async_page_fault)
18897 @@ -1430,7 +1678,7 @@ ENTRY(async_page_fault)
18898 pushl_cfi $do_async_page_fault
18899 jmp error_code
18900 CFI_ENDPROC
18901 -END(async_page_fault)
18902 +ENDPROC(async_page_fault)
18903 #endif
18904
18905 /*
18906 diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
18907 index c1d01e6..5625dce 100644
18908 --- a/arch/x86/kernel/entry_64.S
18909 +++ b/arch/x86/kernel/entry_64.S
18910 @@ -59,6 +59,8 @@
18911 #include <asm/context_tracking.h>
18912 #include <asm/smap.h>
18913 #include <linux/err.h>
18914 +#include <asm/pgtable.h>
18915 +#include <asm/alternative-asm.h>
18916
18917 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
18918 #include <linux/elf-em.h>
18919 @@ -80,8 +82,9 @@
18920 #ifdef CONFIG_DYNAMIC_FTRACE
18921
18922 ENTRY(function_hook)
18923 + pax_force_retaddr
18924 retq
18925 -END(function_hook)
18926 +ENDPROC(function_hook)
18927
18928 /* skip is set if stack has been adjusted */
18929 .macro ftrace_caller_setup skip=0
18930 @@ -122,8 +125,9 @@ GLOBAL(ftrace_graph_call)
18931 #endif
18932
18933 GLOBAL(ftrace_stub)
18934 + pax_force_retaddr
18935 retq
18936 -END(ftrace_caller)
18937 +ENDPROC(ftrace_caller)
18938
18939 ENTRY(ftrace_regs_caller)
18940 /* Save the current flags before compare (in SS location)*/
18941 @@ -191,7 +195,7 @@ ftrace_restore_flags:
18942 popfq
18943 jmp ftrace_stub
18944
18945 -END(ftrace_regs_caller)
18946 +ENDPROC(ftrace_regs_caller)
18947
18948
18949 #else /* ! CONFIG_DYNAMIC_FTRACE */
18950 @@ -212,6 +216,7 @@ ENTRY(function_hook)
18951 #endif
18952
18953 GLOBAL(ftrace_stub)
18954 + pax_force_retaddr
18955 retq
18956
18957 trace:
18958 @@ -225,12 +230,13 @@ trace:
18959 #endif
18960 subq $MCOUNT_INSN_SIZE, %rdi
18961
18962 + pax_force_fptr ftrace_trace_function
18963 call *ftrace_trace_function
18964
18965 MCOUNT_RESTORE_FRAME
18966
18967 jmp ftrace_stub
18968 -END(function_hook)
18969 +ENDPROC(function_hook)
18970 #endif /* CONFIG_DYNAMIC_FTRACE */
18971 #endif /* CONFIG_FUNCTION_TRACER */
18972
18973 @@ -252,8 +258,9 @@ ENTRY(ftrace_graph_caller)
18974
18975 MCOUNT_RESTORE_FRAME
18976
18977 + pax_force_retaddr
18978 retq
18979 -END(ftrace_graph_caller)
18980 +ENDPROC(ftrace_graph_caller)
18981
18982 GLOBAL(return_to_handler)
18983 subq $24, %rsp
18984 @@ -269,7 +276,9 @@ GLOBAL(return_to_handler)
18985 movq 8(%rsp), %rdx
18986 movq (%rsp), %rax
18987 addq $24, %rsp
18988 + pax_force_fptr %rdi
18989 jmp *%rdi
18990 +ENDPROC(return_to_handler)
18991 #endif
18992
18993
18994 @@ -284,6 +293,282 @@ ENTRY(native_usergs_sysret64)
18995 ENDPROC(native_usergs_sysret64)
18996 #endif /* CONFIG_PARAVIRT */
18997
18998 + .macro ljmpq sel, off
18999 +#if defined(CONFIG_MPSC) || defined(CONFIG_MCORE2) || defined (CONFIG_MATOM)
19000 + .byte 0x48; ljmp *1234f(%rip)
19001 + .pushsection .rodata
19002 + .align 16
19003 + 1234: .quad \off; .word \sel
19004 + .popsection
19005 +#else
19006 + pushq $\sel
19007 + pushq $\off
19008 + lretq
19009 +#endif
19010 + .endm
19011 +
19012 + .macro pax_enter_kernel
19013 + pax_set_fptr_mask
19014 +#ifdef CONFIG_PAX_KERNEXEC
19015 + call pax_enter_kernel
19016 +#endif
19017 + .endm
19018 +
19019 + .macro pax_exit_kernel
19020 +#ifdef CONFIG_PAX_KERNEXEC
19021 + call pax_exit_kernel
19022 +#endif
19023 + .endm
19024 +
19025 +#ifdef CONFIG_PAX_KERNEXEC
19026 +ENTRY(pax_enter_kernel)
19027 + pushq %rdi
19028 +
19029 +#ifdef CONFIG_PARAVIRT
19030 + PV_SAVE_REGS(CLBR_RDI)
19031 +#endif
19032 +
19033 + GET_CR0_INTO_RDI
19034 + bts $16,%rdi
19035 + jnc 3f
19036 + mov %cs,%edi
19037 + cmp $__KERNEL_CS,%edi
19038 + jnz 2f
19039 +1:
19040 +
19041 +#ifdef CONFIG_PARAVIRT
19042 + PV_RESTORE_REGS(CLBR_RDI)
19043 +#endif
19044 +
19045 + popq %rdi
19046 + pax_force_retaddr
19047 + retq
19048 +
19049 +2: ljmpq __KERNEL_CS,1b
19050 +3: ljmpq __KERNEXEC_KERNEL_CS,4f
19051 +4: SET_RDI_INTO_CR0
19052 + jmp 1b
19053 +ENDPROC(pax_enter_kernel)
19054 +
19055 +ENTRY(pax_exit_kernel)
19056 + pushq %rdi
19057 +
19058 +#ifdef CONFIG_PARAVIRT
19059 + PV_SAVE_REGS(CLBR_RDI)
19060 +#endif
19061 +
19062 + mov %cs,%rdi
19063 + cmp $__KERNEXEC_KERNEL_CS,%edi
19064 + jz 2f
19065 + GET_CR0_INTO_RDI
19066 + bts $16,%rdi
19067 + jnc 4f
19068 +1:
19069 +
19070 +#ifdef CONFIG_PARAVIRT
19071 + PV_RESTORE_REGS(CLBR_RDI);
19072 +#endif
19073 +
19074 + popq %rdi
19075 + pax_force_retaddr
19076 + retq
19077 +
19078 +2: GET_CR0_INTO_RDI
19079 + btr $16,%rdi
19080 + jnc 4f
19081 + ljmpq __KERNEL_CS,3f
19082 +3: SET_RDI_INTO_CR0
19083 + jmp 1b
19084 +4: ud2
19085 + jmp 4b
19086 +ENDPROC(pax_exit_kernel)
19087 +#endif
19088 +
19089 + .macro pax_enter_kernel_user
19090 + pax_set_fptr_mask
19091 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19092 + call pax_enter_kernel_user
19093 +#endif
19094 + .endm
19095 +
19096 + .macro pax_exit_kernel_user
19097 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19098 + call pax_exit_kernel_user
19099 +#endif
19100 +#ifdef CONFIG_PAX_RANDKSTACK
19101 + pushq %rax
19102 + call pax_randomize_kstack
19103 + popq %rax
19104 +#endif
19105 + .endm
19106 +
19107 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19108 +ENTRY(pax_enter_kernel_user)
19109 + pushq %rdi
19110 + pushq %rbx
19111 +
19112 +#ifdef CONFIG_PARAVIRT
19113 + PV_SAVE_REGS(CLBR_RDI)
19114 +#endif
19115 +
19116 + GET_CR3_INTO_RDI
19117 + mov %rdi,%rbx
19118 + add $__START_KERNEL_map,%rbx
19119 + sub phys_base(%rip),%rbx
19120 +
19121 +#ifdef CONFIG_PARAVIRT
19122 + pushq %rdi
19123 + cmpl $0, pv_info+PARAVIRT_enabled
19124 + jz 1f
19125 + i = 0
19126 + .rept USER_PGD_PTRS
19127 + mov i*8(%rbx),%rsi
19128 + mov $0,%sil
19129 + lea i*8(%rbx),%rdi
19130 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
19131 + i = i + 1
19132 + .endr
19133 + jmp 2f
19134 +1:
19135 +#endif
19136 +
19137 + i = 0
19138 + .rept USER_PGD_PTRS
19139 + movb $0,i*8(%rbx)
19140 + i = i + 1
19141 + .endr
19142 +
19143 +#ifdef CONFIG_PARAVIRT
19144 +2: popq %rdi
19145 +#endif
19146 + SET_RDI_INTO_CR3
19147 +
19148 +#ifdef CONFIG_PAX_KERNEXEC
19149 + GET_CR0_INTO_RDI
19150 + bts $16,%rdi
19151 + SET_RDI_INTO_CR0
19152 +#endif
19153 +
19154 +#ifdef CONFIG_PARAVIRT
19155 + PV_RESTORE_REGS(CLBR_RDI)
19156 +#endif
19157 +
19158 + popq %rbx
19159 + popq %rdi
19160 + pax_force_retaddr
19161 + retq
19162 +ENDPROC(pax_enter_kernel_user)
19163 +
19164 +ENTRY(pax_exit_kernel_user)
19165 + push %rdi
19166 +
19167 +#ifdef CONFIG_PARAVIRT
19168 + pushq %rbx
19169 + PV_SAVE_REGS(CLBR_RDI)
19170 +#endif
19171 +
19172 +#ifdef CONFIG_PAX_KERNEXEC
19173 + GET_CR0_INTO_RDI
19174 + btr $16,%rdi
19175 + jnc 3f
19176 + SET_RDI_INTO_CR0
19177 +#endif
19178 +
19179 + GET_CR3_INTO_RDI
19180 + add $__START_KERNEL_map,%rdi
19181 + sub phys_base(%rip),%rdi
19182 +
19183 +#ifdef CONFIG_PARAVIRT
19184 + cmpl $0, pv_info+PARAVIRT_enabled
19185 + jz 1f
19186 + mov %rdi,%rbx
19187 + i = 0
19188 + .rept USER_PGD_PTRS
19189 + mov i*8(%rbx),%rsi
19190 + mov $0x67,%sil
19191 + lea i*8(%rbx),%rdi
19192 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
19193 + i = i + 1
19194 + .endr
19195 + jmp 2f
19196 +1:
19197 +#endif
19198 +
19199 + i = 0
19200 + .rept USER_PGD_PTRS
19201 + movb $0x67,i*8(%rdi)
19202 + i = i + 1
19203 + .endr
19204 +
19205 +#ifdef CONFIG_PARAVIRT
19206 +2: PV_RESTORE_REGS(CLBR_RDI)
19207 + popq %rbx
19208 +#endif
19209 +
19210 + popq %rdi
19211 + pax_force_retaddr
19212 + retq
19213 +3: ud2
19214 + jmp 3b
19215 +ENDPROC(pax_exit_kernel_user)
19216 +#endif
19217 +
19218 +.macro pax_erase_kstack
19219 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
19220 + call pax_erase_kstack
19221 +#endif
19222 +.endm
19223 +
19224 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
19225 +ENTRY(pax_erase_kstack)
19226 + pushq %rdi
19227 + pushq %rcx
19228 + pushq %rax
19229 + pushq %r11
19230 +
19231 + GET_THREAD_INFO(%r11)
19232 + mov TI_lowest_stack(%r11), %rdi
19233 + mov $-0xBEEF, %rax
19234 + std
19235 +
19236 +1: mov %edi, %ecx
19237 + and $THREAD_SIZE_asm - 1, %ecx
19238 + shr $3, %ecx
19239 + repne scasq
19240 + jecxz 2f
19241 +
19242 + cmp $2*8, %ecx
19243 + jc 2f
19244 +
19245 + mov $2*8, %ecx
19246 + repe scasq
19247 + jecxz 2f
19248 + jne 1b
19249 +
19250 +2: cld
19251 + mov %esp, %ecx
19252 + sub %edi, %ecx
19253 +
19254 + cmp $THREAD_SIZE_asm, %rcx
19255 + jb 3f
19256 + ud2
19257 +3:
19258 +
19259 + shr $3, %ecx
19260 + rep stosq
19261 +
19262 + mov TI_task_thread_sp0(%r11), %rdi
19263 + sub $256, %rdi
19264 + mov %rdi, TI_lowest_stack(%r11)
19265 +
19266 + popq %r11
19267 + popq %rax
19268 + popq %rcx
19269 + popq %rdi
19270 + pax_force_retaddr
19271 + ret
19272 +ENDPROC(pax_erase_kstack)
19273 +#endif
19274
19275 .macro TRACE_IRQS_IRETQ offset=ARGOFFSET
19276 #ifdef CONFIG_TRACE_IRQFLAGS
19277 @@ -375,8 +660,8 @@ ENDPROC(native_usergs_sysret64)
19278 .endm
19279
19280 .macro UNFAKE_STACK_FRAME
19281 - addq $8*6, %rsp
19282 - CFI_ADJUST_CFA_OFFSET -(6*8)
19283 + addq $8*6 + ARG_SKIP, %rsp
19284 + CFI_ADJUST_CFA_OFFSET -(6*8 + ARG_SKIP)
19285 .endm
19286
19287 /*
19288 @@ -463,7 +748,7 @@ ENDPROC(native_usergs_sysret64)
19289 movq %rsp, %rsi
19290
19291 leaq -RBP(%rsp),%rdi /* arg1 for handler */
19292 - testl $3, CS-RBP(%rsi)
19293 + testb $3, CS-RBP(%rsi)
19294 je 1f
19295 SWAPGS
19296 /*
19297 @@ -498,9 +783,10 @@ ENTRY(save_rest)
19298 movq_cfi r15, R15+16
19299 movq %r11, 8(%rsp) /* return address */
19300 FIXUP_TOP_OF_STACK %r11, 16
19301 + pax_force_retaddr
19302 ret
19303 CFI_ENDPROC
19304 -END(save_rest)
19305 +ENDPROC(save_rest)
19306
19307 /* save complete stack frame */
19308 .pushsection .kprobes.text, "ax"
19309 @@ -529,9 +815,10 @@ ENTRY(save_paranoid)
19310 js 1f /* negative -> in kernel */
19311 SWAPGS
19312 xorl %ebx,%ebx
19313 -1: ret
19314 +1: pax_force_retaddr_bts
19315 + ret
19316 CFI_ENDPROC
19317 -END(save_paranoid)
19318 +ENDPROC(save_paranoid)
19319 .popsection
19320
19321 /*
19322 @@ -553,7 +840,7 @@ ENTRY(ret_from_fork)
19323
19324 RESTORE_REST
19325
19326 - testl $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
19327 + testb $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
19328 jz 1f
19329
19330 testl $_TIF_IA32, TI_flags(%rcx) # 32-bit compat task needs IRET
19331 @@ -571,7 +858,7 @@ ENTRY(ret_from_fork)
19332 RESTORE_REST
19333 jmp int_ret_from_sys_call
19334 CFI_ENDPROC
19335 -END(ret_from_fork)
19336 +ENDPROC(ret_from_fork)
19337
19338 /*
19339 * System call entry. Up to 6 arguments in registers are supported.
19340 @@ -608,7 +895,7 @@ END(ret_from_fork)
19341 ENTRY(system_call)
19342 CFI_STARTPROC simple
19343 CFI_SIGNAL_FRAME
19344 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
19345 + CFI_DEF_CFA rsp,0
19346 CFI_REGISTER rip,rcx
19347 /*CFI_REGISTER rflags,r11*/
19348 SWAPGS_UNSAFE_STACK
19349 @@ -621,16 +908,23 @@ GLOBAL(system_call_after_swapgs)
19350
19351 movq %rsp,PER_CPU_VAR(old_rsp)
19352 movq PER_CPU_VAR(kernel_stack),%rsp
19353 + SAVE_ARGS 8*6,0
19354 + pax_enter_kernel_user
19355 +
19356 +#ifdef CONFIG_PAX_RANDKSTACK
19357 + pax_erase_kstack
19358 +#endif
19359 +
19360 /*
19361 * No need to follow this irqs off/on section - it's straight
19362 * and short:
19363 */
19364 ENABLE_INTERRUPTS(CLBR_NONE)
19365 - SAVE_ARGS 8,0
19366 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
19367 movq %rcx,RIP-ARGOFFSET(%rsp)
19368 CFI_REL_OFFSET rip,RIP-ARGOFFSET
19369 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
19370 + GET_THREAD_INFO(%rcx)
19371 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%rcx)
19372 jnz tracesys
19373 system_call_fastpath:
19374 #if __SYSCALL_MASK == ~0
19375 @@ -640,7 +934,7 @@ system_call_fastpath:
19376 cmpl $__NR_syscall_max,%eax
19377 #endif
19378 ja badsys
19379 - movq %r10,%rcx
19380 + movq R10-ARGOFFSET(%rsp),%rcx
19381 call *sys_call_table(,%rax,8) # XXX: rip relative
19382 movq %rax,RAX-ARGOFFSET(%rsp)
19383 /*
19384 @@ -654,10 +948,13 @@ sysret_check:
19385 LOCKDEP_SYS_EXIT
19386 DISABLE_INTERRUPTS(CLBR_NONE)
19387 TRACE_IRQS_OFF
19388 - movl TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET),%edx
19389 + GET_THREAD_INFO(%rcx)
19390 + movl TI_flags(%rcx),%edx
19391 andl %edi,%edx
19392 jnz sysret_careful
19393 CFI_REMEMBER_STATE
19394 + pax_exit_kernel_user
19395 + pax_erase_kstack
19396 /*
19397 * sysretq will re-enable interrupts:
19398 */
19399 @@ -709,14 +1006,18 @@ badsys:
19400 * jump back to the normal fast path.
19401 */
19402 auditsys:
19403 - movq %r10,%r9 /* 6th arg: 4th syscall arg */
19404 + movq R10-ARGOFFSET(%rsp),%r9 /* 6th arg: 4th syscall arg */
19405 movq %rdx,%r8 /* 5th arg: 3rd syscall arg */
19406 movq %rsi,%rcx /* 4th arg: 2nd syscall arg */
19407 movq %rdi,%rdx /* 3rd arg: 1st syscall arg */
19408 movq %rax,%rsi /* 2nd arg: syscall number */
19409 movl $AUDIT_ARCH_X86_64,%edi /* 1st arg: audit arch */
19410 call __audit_syscall_entry
19411 +
19412 + pax_erase_kstack
19413 +
19414 LOAD_ARGS 0 /* reload call-clobbered registers */
19415 + pax_set_fptr_mask
19416 jmp system_call_fastpath
19417
19418 /*
19419 @@ -737,7 +1038,7 @@ sysret_audit:
19420 /* Do syscall tracing */
19421 tracesys:
19422 #ifdef CONFIG_AUDITSYSCALL
19423 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
19424 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%rcx)
19425 jz auditsys
19426 #endif
19427 SAVE_REST
19428 @@ -745,12 +1046,16 @@ tracesys:
19429 FIXUP_TOP_OF_STACK %rdi
19430 movq %rsp,%rdi
19431 call syscall_trace_enter
19432 +
19433 + pax_erase_kstack
19434 +
19435 /*
19436 * Reload arg registers from stack in case ptrace changed them.
19437 * We don't reload %rax because syscall_trace_enter() returned
19438 * the value it wants us to use in the table lookup.
19439 */
19440 LOAD_ARGS ARGOFFSET, 1
19441 + pax_set_fptr_mask
19442 RESTORE_REST
19443 #if __SYSCALL_MASK == ~0
19444 cmpq $__NR_syscall_max,%rax
19445 @@ -759,7 +1064,7 @@ tracesys:
19446 cmpl $__NR_syscall_max,%eax
19447 #endif
19448 ja int_ret_from_sys_call /* RAX(%rsp) set to -ENOSYS above */
19449 - movq %r10,%rcx /* fixup for C */
19450 + movq R10-ARGOFFSET(%rsp),%rcx /* fixup for C */
19451 call *sys_call_table(,%rax,8)
19452 movq %rax,RAX-ARGOFFSET(%rsp)
19453 /* Use IRET because user could have changed frame */
19454 @@ -780,7 +1085,9 @@ GLOBAL(int_with_check)
19455 andl %edi,%edx
19456 jnz int_careful
19457 andl $~TS_COMPAT,TI_status(%rcx)
19458 - jmp retint_swapgs
19459 + pax_exit_kernel_user
19460 + pax_erase_kstack
19461 + jmp retint_swapgs_pax
19462
19463 /* Either reschedule or signal or syscall exit tracking needed. */
19464 /* First do a reschedule test. */
19465 @@ -826,7 +1133,7 @@ int_restore_rest:
19466 TRACE_IRQS_OFF
19467 jmp int_with_check
19468 CFI_ENDPROC
19469 -END(system_call)
19470 +ENDPROC(system_call)
19471
19472 .macro FORK_LIKE func
19473 ENTRY(stub_\func)
19474 @@ -839,9 +1146,10 @@ ENTRY(stub_\func)
19475 DEFAULT_FRAME 0 8 /* offset 8: return address */
19476 call sys_\func
19477 RESTORE_TOP_OF_STACK %r11, 8
19478 + pax_force_retaddr
19479 ret $REST_SKIP /* pop extended registers */
19480 CFI_ENDPROC
19481 -END(stub_\func)
19482 +ENDPROC(stub_\func)
19483 .endm
19484
19485 .macro FIXED_FRAME label,func
19486 @@ -851,9 +1159,10 @@ ENTRY(\label)
19487 FIXUP_TOP_OF_STACK %r11, 8-ARGOFFSET
19488 call \func
19489 RESTORE_TOP_OF_STACK %r11, 8-ARGOFFSET
19490 + pax_force_retaddr
19491 ret
19492 CFI_ENDPROC
19493 -END(\label)
19494 +ENDPROC(\label)
19495 .endm
19496
19497 FORK_LIKE clone
19498 @@ -870,9 +1179,10 @@ ENTRY(ptregscall_common)
19499 movq_cfi_restore R12+8, r12
19500 movq_cfi_restore RBP+8, rbp
19501 movq_cfi_restore RBX+8, rbx
19502 + pax_force_retaddr
19503 ret $REST_SKIP /* pop extended registers */
19504 CFI_ENDPROC
19505 -END(ptregscall_common)
19506 +ENDPROC(ptregscall_common)
19507
19508 ENTRY(stub_execve)
19509 CFI_STARTPROC
19510 @@ -885,7 +1195,7 @@ ENTRY(stub_execve)
19511 RESTORE_REST
19512 jmp int_ret_from_sys_call
19513 CFI_ENDPROC
19514 -END(stub_execve)
19515 +ENDPROC(stub_execve)
19516
19517 /*
19518 * sigreturn is special because it needs to restore all registers on return.
19519 @@ -902,7 +1212,7 @@ ENTRY(stub_rt_sigreturn)
19520 RESTORE_REST
19521 jmp int_ret_from_sys_call
19522 CFI_ENDPROC
19523 -END(stub_rt_sigreturn)
19524 +ENDPROC(stub_rt_sigreturn)
19525
19526 #ifdef CONFIG_X86_X32_ABI
19527 ENTRY(stub_x32_rt_sigreturn)
19528 @@ -916,7 +1226,7 @@ ENTRY(stub_x32_rt_sigreturn)
19529 RESTORE_REST
19530 jmp int_ret_from_sys_call
19531 CFI_ENDPROC
19532 -END(stub_x32_rt_sigreturn)
19533 +ENDPROC(stub_x32_rt_sigreturn)
19534
19535 ENTRY(stub_x32_execve)
19536 CFI_STARTPROC
19537 @@ -930,7 +1240,7 @@ ENTRY(stub_x32_execve)
19538 RESTORE_REST
19539 jmp int_ret_from_sys_call
19540 CFI_ENDPROC
19541 -END(stub_x32_execve)
19542 +ENDPROC(stub_x32_execve)
19543
19544 #endif
19545
19546 @@ -967,7 +1277,7 @@ vector=vector+1
19547 2: jmp common_interrupt
19548 .endr
19549 CFI_ENDPROC
19550 -END(irq_entries_start)
19551 +ENDPROC(irq_entries_start)
19552
19553 .previous
19554 END(interrupt)
19555 @@ -987,6 +1297,16 @@ END(interrupt)
19556 subq $ORIG_RAX-RBP, %rsp
19557 CFI_ADJUST_CFA_OFFSET ORIG_RAX-RBP
19558 SAVE_ARGS_IRQ
19559 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19560 + testb $3, CS(%rdi)
19561 + jnz 1f
19562 + pax_enter_kernel
19563 + jmp 2f
19564 +1: pax_enter_kernel_user
19565 +2:
19566 +#else
19567 + pax_enter_kernel
19568 +#endif
19569 call \func
19570 .endm
19571
19572 @@ -1019,7 +1339,7 @@ ret_from_intr:
19573
19574 exit_intr:
19575 GET_THREAD_INFO(%rcx)
19576 - testl $3,CS-ARGOFFSET(%rsp)
19577 + testb $3,CS-ARGOFFSET(%rsp)
19578 je retint_kernel
19579
19580 /* Interrupt came from user space */
19581 @@ -1041,12 +1361,16 @@ retint_swapgs: /* return to user-space */
19582 * The iretq could re-enable interrupts:
19583 */
19584 DISABLE_INTERRUPTS(CLBR_ANY)
19585 + pax_exit_kernel_user
19586 +retint_swapgs_pax:
19587 TRACE_IRQS_IRETQ
19588 SWAPGS
19589 jmp restore_args
19590
19591 retint_restore_args: /* return to kernel space */
19592 DISABLE_INTERRUPTS(CLBR_ANY)
19593 + pax_exit_kernel
19594 + pax_force_retaddr (RIP-ARGOFFSET)
19595 /*
19596 * The iretq could re-enable interrupts:
19597 */
19598 @@ -1129,7 +1453,7 @@ ENTRY(retint_kernel)
19599 #endif
19600
19601 CFI_ENDPROC
19602 -END(common_interrupt)
19603 +ENDPROC(common_interrupt)
19604 /*
19605 * End of kprobes section
19606 */
19607 @@ -1147,7 +1471,7 @@ ENTRY(\sym)
19608 interrupt \do_sym
19609 jmp ret_from_intr
19610 CFI_ENDPROC
19611 -END(\sym)
19612 +ENDPROC(\sym)
19613 .endm
19614
19615 #ifdef CONFIG_SMP
19616 @@ -1203,12 +1527,22 @@ ENTRY(\sym)
19617 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19618 call error_entry
19619 DEFAULT_FRAME 0
19620 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19621 + testb $3, CS(%rsp)
19622 + jnz 1f
19623 + pax_enter_kernel
19624 + jmp 2f
19625 +1: pax_enter_kernel_user
19626 +2:
19627 +#else
19628 + pax_enter_kernel
19629 +#endif
19630 movq %rsp,%rdi /* pt_regs pointer */
19631 xorl %esi,%esi /* no error code */
19632 call \do_sym
19633 jmp error_exit /* %ebx: no swapgs flag */
19634 CFI_ENDPROC
19635 -END(\sym)
19636 +ENDPROC(\sym)
19637 .endm
19638
19639 .macro paranoidzeroentry sym do_sym
19640 @@ -1221,15 +1555,25 @@ ENTRY(\sym)
19641 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19642 call save_paranoid
19643 TRACE_IRQS_OFF
19644 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19645 + testb $3, CS(%rsp)
19646 + jnz 1f
19647 + pax_enter_kernel
19648 + jmp 2f
19649 +1: pax_enter_kernel_user
19650 +2:
19651 +#else
19652 + pax_enter_kernel
19653 +#endif
19654 movq %rsp,%rdi /* pt_regs pointer */
19655 xorl %esi,%esi /* no error code */
19656 call \do_sym
19657 jmp paranoid_exit /* %ebx: no swapgs flag */
19658 CFI_ENDPROC
19659 -END(\sym)
19660 +ENDPROC(\sym)
19661 .endm
19662
19663 -#define INIT_TSS_IST(x) PER_CPU_VAR(init_tss) + (TSS_ist + ((x) - 1) * 8)
19664 +#define INIT_TSS_IST(x) (TSS_ist + ((x) - 1) * 8)(%r12)
19665 .macro paranoidzeroentry_ist sym do_sym ist
19666 ENTRY(\sym)
19667 INTR_FRAME
19668 @@ -1240,14 +1584,30 @@ ENTRY(\sym)
19669 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19670 call save_paranoid
19671 TRACE_IRQS_OFF_DEBUG
19672 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19673 + testb $3, CS(%rsp)
19674 + jnz 1f
19675 + pax_enter_kernel
19676 + jmp 2f
19677 +1: pax_enter_kernel_user
19678 +2:
19679 +#else
19680 + pax_enter_kernel
19681 +#endif
19682 movq %rsp,%rdi /* pt_regs pointer */
19683 xorl %esi,%esi /* no error code */
19684 +#ifdef CONFIG_SMP
19685 + imul $TSS_size, PER_CPU_VAR(cpu_number), %r12d
19686 + lea init_tss(%r12), %r12
19687 +#else
19688 + lea init_tss(%rip), %r12
19689 +#endif
19690 subq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
19691 call \do_sym
19692 addq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
19693 jmp paranoid_exit /* %ebx: no swapgs flag */
19694 CFI_ENDPROC
19695 -END(\sym)
19696 +ENDPROC(\sym)
19697 .endm
19698
19699 .macro errorentry sym do_sym
19700 @@ -1259,13 +1619,23 @@ ENTRY(\sym)
19701 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19702 call error_entry
19703 DEFAULT_FRAME 0
19704 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19705 + testb $3, CS(%rsp)
19706 + jnz 1f
19707 + pax_enter_kernel
19708 + jmp 2f
19709 +1: pax_enter_kernel_user
19710 +2:
19711 +#else
19712 + pax_enter_kernel
19713 +#endif
19714 movq %rsp,%rdi /* pt_regs pointer */
19715 movq ORIG_RAX(%rsp),%rsi /* get error code */
19716 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
19717 call \do_sym
19718 jmp error_exit /* %ebx: no swapgs flag */
19719 CFI_ENDPROC
19720 -END(\sym)
19721 +ENDPROC(\sym)
19722 .endm
19723
19724 /* error code is on the stack already */
19725 @@ -1279,13 +1649,23 @@ ENTRY(\sym)
19726 call save_paranoid
19727 DEFAULT_FRAME 0
19728 TRACE_IRQS_OFF
19729 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19730 + testb $3, CS(%rsp)
19731 + jnz 1f
19732 + pax_enter_kernel
19733 + jmp 2f
19734 +1: pax_enter_kernel_user
19735 +2:
19736 +#else
19737 + pax_enter_kernel
19738 +#endif
19739 movq %rsp,%rdi /* pt_regs pointer */
19740 movq ORIG_RAX(%rsp),%rsi /* get error code */
19741 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
19742 call \do_sym
19743 jmp paranoid_exit /* %ebx: no swapgs flag */
19744 CFI_ENDPROC
19745 -END(\sym)
19746 +ENDPROC(\sym)
19747 .endm
19748
19749 zeroentry divide_error do_divide_error
19750 @@ -1315,9 +1695,10 @@ gs_change:
19751 2: mfence /* workaround */
19752 SWAPGS
19753 popfq_cfi
19754 + pax_force_retaddr
19755 ret
19756 CFI_ENDPROC
19757 -END(native_load_gs_index)
19758 +ENDPROC(native_load_gs_index)
19759
19760 _ASM_EXTABLE(gs_change,bad_gs)
19761 .section .fixup,"ax"
19762 @@ -1345,9 +1726,10 @@ ENTRY(call_softirq)
19763 CFI_DEF_CFA_REGISTER rsp
19764 CFI_ADJUST_CFA_OFFSET -8
19765 decl PER_CPU_VAR(irq_count)
19766 + pax_force_retaddr
19767 ret
19768 CFI_ENDPROC
19769 -END(call_softirq)
19770 +ENDPROC(call_softirq)
19771
19772 #ifdef CONFIG_XEN
19773 zeroentry xen_hypervisor_callback xen_do_hypervisor_callback
19774 @@ -1385,7 +1767,7 @@ ENTRY(xen_do_hypervisor_callback) # do_hypervisor_callback(struct *pt_regs)
19775 decl PER_CPU_VAR(irq_count)
19776 jmp error_exit
19777 CFI_ENDPROC
19778 -END(xen_do_hypervisor_callback)
19779 +ENDPROC(xen_do_hypervisor_callback)
19780
19781 /*
19782 * Hypervisor uses this for application faults while it executes.
19783 @@ -1444,7 +1826,7 @@ ENTRY(xen_failsafe_callback)
19784 SAVE_ALL
19785 jmp error_exit
19786 CFI_ENDPROC
19787 -END(xen_failsafe_callback)
19788 +ENDPROC(xen_failsafe_callback)
19789
19790 apicinterrupt HYPERVISOR_CALLBACK_VECTOR \
19791 xen_hvm_callback_vector xen_evtchn_do_upcall
19792 @@ -1498,16 +1880,31 @@ ENTRY(paranoid_exit)
19793 TRACE_IRQS_OFF_DEBUG
19794 testl %ebx,%ebx /* swapgs needed? */
19795 jnz paranoid_restore
19796 - testl $3,CS(%rsp)
19797 + testb $3,CS(%rsp)
19798 jnz paranoid_userspace
19799 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19800 + pax_exit_kernel
19801 + TRACE_IRQS_IRETQ 0
19802 + SWAPGS_UNSAFE_STACK
19803 + RESTORE_ALL 8
19804 + pax_force_retaddr_bts
19805 + jmp irq_return
19806 +#endif
19807 paranoid_swapgs:
19808 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19809 + pax_exit_kernel_user
19810 +#else
19811 + pax_exit_kernel
19812 +#endif
19813 TRACE_IRQS_IRETQ 0
19814 SWAPGS_UNSAFE_STACK
19815 RESTORE_ALL 8
19816 jmp irq_return
19817 paranoid_restore:
19818 + pax_exit_kernel
19819 TRACE_IRQS_IRETQ_DEBUG 0
19820 RESTORE_ALL 8
19821 + pax_force_retaddr_bts
19822 jmp irq_return
19823 paranoid_userspace:
19824 GET_THREAD_INFO(%rcx)
19825 @@ -1536,7 +1933,7 @@ paranoid_schedule:
19826 TRACE_IRQS_OFF
19827 jmp paranoid_userspace
19828 CFI_ENDPROC
19829 -END(paranoid_exit)
19830 +ENDPROC(paranoid_exit)
19831
19832 /*
19833 * Exception entry point. This expects an error code/orig_rax on the stack.
19834 @@ -1563,12 +1960,13 @@ ENTRY(error_entry)
19835 movq_cfi r14, R14+8
19836 movq_cfi r15, R15+8
19837 xorl %ebx,%ebx
19838 - testl $3,CS+8(%rsp)
19839 + testb $3,CS+8(%rsp)
19840 je error_kernelspace
19841 error_swapgs:
19842 SWAPGS
19843 error_sti:
19844 TRACE_IRQS_OFF
19845 + pax_force_retaddr_bts
19846 ret
19847
19848 /*
19849 @@ -1595,7 +1993,7 @@ bstep_iret:
19850 movq %rcx,RIP+8(%rsp)
19851 jmp error_swapgs
19852 CFI_ENDPROC
19853 -END(error_entry)
19854 +ENDPROC(error_entry)
19855
19856
19857 /* ebx: no swapgs flag (1: don't need swapgs, 0: need it) */
19858 @@ -1615,7 +2013,7 @@ ENTRY(error_exit)
19859 jnz retint_careful
19860 jmp retint_swapgs
19861 CFI_ENDPROC
19862 -END(error_exit)
19863 +ENDPROC(error_exit)
19864
19865 /*
19866 * Test if a given stack is an NMI stack or not.
19867 @@ -1673,9 +2071,11 @@ ENTRY(nmi)
19868 * If %cs was not the kernel segment, then the NMI triggered in user
19869 * space, which means it is definitely not nested.
19870 */
19871 + cmpl $__KERNEXEC_KERNEL_CS, 16(%rsp)
19872 + je 1f
19873 cmpl $__KERNEL_CS, 16(%rsp)
19874 jne first_nmi
19875 -
19876 +1:
19877 /*
19878 * Check the special variable on the stack to see if NMIs are
19879 * executing.
19880 @@ -1709,8 +2109,7 @@ nested_nmi:
19881
19882 1:
19883 /* Set up the interrupted NMIs stack to jump to repeat_nmi */
19884 - leaq -1*8(%rsp), %rdx
19885 - movq %rdx, %rsp
19886 + subq $8, %rsp
19887 CFI_ADJUST_CFA_OFFSET 1*8
19888 leaq -10*8(%rsp), %rdx
19889 pushq_cfi $__KERNEL_DS
19890 @@ -1728,6 +2127,7 @@ nested_nmi_out:
19891 CFI_RESTORE rdx
19892
19893 /* No need to check faults here */
19894 + pax_force_retaddr_bts
19895 INTERRUPT_RETURN
19896
19897 CFI_RESTORE_STATE
19898 @@ -1844,6 +2244,17 @@ end_repeat_nmi:
19899 */
19900 movq %cr2, %r12
19901
19902 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19903 + testb $3, CS(%rsp)
19904 + jnz 1f
19905 + pax_enter_kernel
19906 + jmp 2f
19907 +1: pax_enter_kernel_user
19908 +2:
19909 +#else
19910 + pax_enter_kernel
19911 +#endif
19912 +
19913 /* paranoidentry do_nmi, 0; without TRACE_IRQS_OFF */
19914 movq %rsp,%rdi
19915 movq $-1,%rsi
19916 @@ -1859,23 +2270,34 @@ end_repeat_nmi:
19917 testl %ebx,%ebx /* swapgs needed? */
19918 jnz nmi_restore
19919 nmi_swapgs:
19920 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19921 + pax_exit_kernel_user
19922 +#else
19923 + pax_exit_kernel
19924 +#endif
19925 SWAPGS_UNSAFE_STACK
19926 + RESTORE_ALL 6*8
19927 + /* Clear the NMI executing stack variable */
19928 + movq $0, 5*8(%rsp)
19929 + jmp irq_return
19930 nmi_restore:
19931 + pax_exit_kernel
19932 /* Pop the extra iret frame at once */
19933 RESTORE_ALL 6*8
19934 + pax_force_retaddr_bts
19935
19936 /* Clear the NMI executing stack variable */
19937 movq $0, 5*8(%rsp)
19938 jmp irq_return
19939 CFI_ENDPROC
19940 -END(nmi)
19941 +ENDPROC(nmi)
19942
19943 ENTRY(ignore_sysret)
19944 CFI_STARTPROC
19945 mov $-ENOSYS,%eax
19946 sysret
19947 CFI_ENDPROC
19948 -END(ignore_sysret)
19949 +ENDPROC(ignore_sysret)
19950
19951 /*
19952 * End of kprobes section
19953 diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
19954 index 42a392a..fbbd930 100644
19955 --- a/arch/x86/kernel/ftrace.c
19956 +++ b/arch/x86/kernel/ftrace.c
19957 @@ -105,6 +105,8 @@ ftrace_modify_code_direct(unsigned long ip, unsigned const char *old_code,
19958 {
19959 unsigned char replaced[MCOUNT_INSN_SIZE];
19960
19961 + ip = ktla_ktva(ip);
19962 +
19963 /*
19964 * Note: Due to modules and __init, code can
19965 * disappear and change, we need to protect against faulting
19966 @@ -227,7 +229,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
19967 unsigned char old[MCOUNT_INSN_SIZE], *new;
19968 int ret;
19969
19970 - memcpy(old, &ftrace_call, MCOUNT_INSN_SIZE);
19971 + memcpy(old, (void *)ktla_ktva((unsigned long)ftrace_call), MCOUNT_INSN_SIZE);
19972 new = ftrace_call_replace(ip, (unsigned long)func);
19973
19974 /* See comment above by declaration of modifying_ftrace_code */
19975 @@ -238,7 +240,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
19976 /* Also update the regs callback function */
19977 if (!ret) {
19978 ip = (unsigned long)(&ftrace_regs_call);
19979 - memcpy(old, &ftrace_regs_call, MCOUNT_INSN_SIZE);
19980 + memcpy(old, ktla_ktva((void *)&ftrace_regs_call), MCOUNT_INSN_SIZE);
19981 new = ftrace_call_replace(ip, (unsigned long)func);
19982 ret = ftrace_modify_code(ip, old, new);
19983 }
19984 @@ -279,7 +281,7 @@ static int ftrace_write(unsigned long ip, const char *val, int size)
19985 * kernel identity mapping to modify code.
19986 */
19987 if (within(ip, (unsigned long)_text, (unsigned long)_etext))
19988 - ip = (unsigned long)__va(__pa_symbol(ip));
19989 + ip = (unsigned long)__va(__pa_symbol(ktla_ktva(ip)));
19990
19991 return probe_kernel_write((void *)ip, val, size);
19992 }
19993 @@ -289,7 +291,7 @@ static int add_break(unsigned long ip, const char *old)
19994 unsigned char replaced[MCOUNT_INSN_SIZE];
19995 unsigned char brk = BREAKPOINT_INSTRUCTION;
19996
19997 - if (probe_kernel_read(replaced, (void *)ip, MCOUNT_INSN_SIZE))
19998 + if (probe_kernel_read(replaced, (void *)ktla_ktva(ip), MCOUNT_INSN_SIZE))
19999 return -EFAULT;
20000
20001 /* Make sure it is what we expect it to be */
20002 @@ -637,7 +639,7 @@ ftrace_modify_code(unsigned long ip, unsigned const char *old_code,
20003 return ret;
20004
20005 fail_update:
20006 - probe_kernel_write((void *)ip, &old_code[0], 1);
20007 + probe_kernel_write((void *)ktla_ktva(ip), &old_code[0], 1);
20008 goto out;
20009 }
20010
20011 @@ -670,6 +672,8 @@ static int ftrace_mod_jmp(unsigned long ip,
20012 {
20013 unsigned char code[MCOUNT_INSN_SIZE];
20014
20015 + ip = ktla_ktva(ip);
20016 +
20017 if (probe_kernel_read(code, (void *)ip, MCOUNT_INSN_SIZE))
20018 return -EFAULT;
20019
20020 diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
20021 index 8f3201d..aa860bf 100644
20022 --- a/arch/x86/kernel/head64.c
20023 +++ b/arch/x86/kernel/head64.c
20024 @@ -175,7 +175,6 @@ void __init x86_64_start_kernel(char * real_mode_data)
20025 if (console_loglevel == 10)
20026 early_printk("Kernel alive\n");
20027
20028 - clear_page(init_level4_pgt);
20029 /* set init_level4_pgt kernel high mapping*/
20030 init_level4_pgt[511] = early_level4_pgt[511];
20031
20032 diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
20033 index 73afd11..d1670f5 100644
20034 --- a/arch/x86/kernel/head_32.S
20035 +++ b/arch/x86/kernel/head_32.S
20036 @@ -26,6 +26,12 @@
20037 /* Physical address */
20038 #define pa(X) ((X) - __PAGE_OFFSET)
20039
20040 +#ifdef CONFIG_PAX_KERNEXEC
20041 +#define ta(X) (X)
20042 +#else
20043 +#define ta(X) ((X) - __PAGE_OFFSET)
20044 +#endif
20045 +
20046 /*
20047 * References to members of the new_cpu_data structure.
20048 */
20049 @@ -55,11 +61,7 @@
20050 * and small than max_low_pfn, otherwise will waste some page table entries
20051 */
20052
20053 -#if PTRS_PER_PMD > 1
20054 -#define PAGE_TABLE_SIZE(pages) (((pages) / PTRS_PER_PMD) + PTRS_PER_PGD)
20055 -#else
20056 -#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PGD)
20057 -#endif
20058 +#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PTE)
20059
20060 /* Number of possible pages in the lowmem region */
20061 LOWMEM_PAGES = (((1<<32) - __PAGE_OFFSET) >> PAGE_SHIFT)
20062 @@ -78,6 +80,12 @@ INIT_MAP_SIZE = PAGE_TABLE_SIZE(KERNEL_PAGES) * PAGE_SIZE
20063 RESERVE_BRK(pagetables, INIT_MAP_SIZE)
20064
20065 /*
20066 + * Real beginning of normal "text" segment
20067 + */
20068 +ENTRY(stext)
20069 +ENTRY(_stext)
20070 +
20071 +/*
20072 * 32-bit kernel entrypoint; only used by the boot CPU. On entry,
20073 * %esi points to the real-mode code as a 32-bit pointer.
20074 * CS and DS must be 4 GB flat segments, but we don't depend on
20075 @@ -85,6 +93,13 @@ RESERVE_BRK(pagetables, INIT_MAP_SIZE)
20076 * can.
20077 */
20078 __HEAD
20079 +
20080 +#ifdef CONFIG_PAX_KERNEXEC
20081 + jmp startup_32
20082 +/* PaX: fill first page in .text with int3 to catch NULL derefs in kernel mode */
20083 +.fill PAGE_SIZE-5,1,0xcc
20084 +#endif
20085 +
20086 ENTRY(startup_32)
20087 movl pa(stack_start),%ecx
20088
20089 @@ -106,6 +121,59 @@ ENTRY(startup_32)
20090 2:
20091 leal -__PAGE_OFFSET(%ecx),%esp
20092
20093 +#ifdef CONFIG_SMP
20094 + movl $pa(cpu_gdt_table),%edi
20095 + movl $__per_cpu_load,%eax
20096 + movw %ax,GDT_ENTRY_PERCPU * 8 + 2(%edi)
20097 + rorl $16,%eax
20098 + movb %al,GDT_ENTRY_PERCPU * 8 + 4(%edi)
20099 + movb %ah,GDT_ENTRY_PERCPU * 8 + 7(%edi)
20100 + movl $__per_cpu_end - 1,%eax
20101 + subl $__per_cpu_start,%eax
20102 + movw %ax,GDT_ENTRY_PERCPU * 8 + 0(%edi)
20103 +#endif
20104 +
20105 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20106 + movl $NR_CPUS,%ecx
20107 + movl $pa(cpu_gdt_table),%edi
20108 +1:
20109 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c09700),GDT_ENTRY_KERNEL_DS * 8 + 4(%edi)
20110 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0fb00),GDT_ENTRY_DEFAULT_USER_CS * 8 + 4(%edi)
20111 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0f300),GDT_ENTRY_DEFAULT_USER_DS * 8 + 4(%edi)
20112 + addl $PAGE_SIZE_asm,%edi
20113 + loop 1b
20114 +#endif
20115 +
20116 +#ifdef CONFIG_PAX_KERNEXEC
20117 + movl $pa(boot_gdt),%edi
20118 + movl $__LOAD_PHYSICAL_ADDR,%eax
20119 + movw %ax,GDT_ENTRY_BOOT_CS * 8 + 2(%edi)
20120 + rorl $16,%eax
20121 + movb %al,GDT_ENTRY_BOOT_CS * 8 + 4(%edi)
20122 + movb %ah,GDT_ENTRY_BOOT_CS * 8 + 7(%edi)
20123 + rorl $16,%eax
20124 +
20125 + ljmp $(__BOOT_CS),$1f
20126 +1:
20127 +
20128 + movl $NR_CPUS,%ecx
20129 + movl $pa(cpu_gdt_table),%edi
20130 + addl $__PAGE_OFFSET,%eax
20131 +1:
20132 + movb $0xc0,GDT_ENTRY_KERNEL_CS * 8 + 6(%edi)
20133 + movb $0xc0,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 6(%edi)
20134 + movw %ax,GDT_ENTRY_KERNEL_CS * 8 + 2(%edi)
20135 + movw %ax,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 2(%edi)
20136 + rorl $16,%eax
20137 + movb %al,GDT_ENTRY_KERNEL_CS * 8 + 4(%edi)
20138 + movb %al,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 4(%edi)
20139 + movb %ah,GDT_ENTRY_KERNEL_CS * 8 + 7(%edi)
20140 + movb %ah,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 7(%edi)
20141 + rorl $16,%eax
20142 + addl $PAGE_SIZE_asm,%edi
20143 + loop 1b
20144 +#endif
20145 +
20146 /*
20147 * Clear BSS first so that there are no surprises...
20148 */
20149 @@ -201,8 +269,11 @@ ENTRY(startup_32)
20150 movl %eax, pa(max_pfn_mapped)
20151
20152 /* Do early initialization of the fixmap area */
20153 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
20154 - movl %eax,pa(initial_pg_pmd+0x1000*KPMDS-8)
20155 +#ifdef CONFIG_COMPAT_VDSO
20156 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_pg_pmd+0x1000*KPMDS-8)
20157 +#else
20158 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_pg_pmd+0x1000*KPMDS-8)
20159 +#endif
20160 #else /* Not PAE */
20161
20162 page_pde_offset = (__PAGE_OFFSET >> 20);
20163 @@ -232,8 +303,11 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
20164 movl %eax, pa(max_pfn_mapped)
20165
20166 /* Do early initialization of the fixmap area */
20167 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
20168 - movl %eax,pa(initial_page_table+0xffc)
20169 +#ifdef CONFIG_COMPAT_VDSO
20170 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_page_table+0xffc)
20171 +#else
20172 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_page_table+0xffc)
20173 +#endif
20174 #endif
20175
20176 #ifdef CONFIG_PARAVIRT
20177 @@ -247,9 +321,7 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
20178 cmpl $num_subarch_entries, %eax
20179 jae bad_subarch
20180
20181 - movl pa(subarch_entries)(,%eax,4), %eax
20182 - subl $__PAGE_OFFSET, %eax
20183 - jmp *%eax
20184 + jmp *pa(subarch_entries)(,%eax,4)
20185
20186 bad_subarch:
20187 WEAK(lguest_entry)
20188 @@ -261,10 +333,10 @@ WEAK(xen_entry)
20189 __INITDATA
20190
20191 subarch_entries:
20192 - .long default_entry /* normal x86/PC */
20193 - .long lguest_entry /* lguest hypervisor */
20194 - .long xen_entry /* Xen hypervisor */
20195 - .long default_entry /* Moorestown MID */
20196 + .long ta(default_entry) /* normal x86/PC */
20197 + .long ta(lguest_entry) /* lguest hypervisor */
20198 + .long ta(xen_entry) /* Xen hypervisor */
20199 + .long ta(default_entry) /* Moorestown MID */
20200 num_subarch_entries = (. - subarch_entries) / 4
20201 .previous
20202 #else
20203 @@ -355,6 +427,7 @@ default_entry:
20204 movl pa(mmu_cr4_features),%eax
20205 movl %eax,%cr4
20206
20207 +#ifdef CONFIG_X86_PAE
20208 testb $X86_CR4_PAE, %al # check if PAE is enabled
20209 jz enable_paging
20210
20211 @@ -383,6 +456,9 @@ default_entry:
20212 /* Make changes effective */
20213 wrmsr
20214
20215 + btsl $_PAGE_BIT_NX-32,pa(__supported_pte_mask+4)
20216 +#endif
20217 +
20218 enable_paging:
20219
20220 /*
20221 @@ -451,14 +527,20 @@ is486:
20222 1: movl $(__KERNEL_DS),%eax # reload all the segment registers
20223 movl %eax,%ss # after changing gdt.
20224
20225 - movl $(__USER_DS),%eax # DS/ES contains default USER segment
20226 +# movl $(__KERNEL_DS),%eax # DS/ES contains default KERNEL segment
20227 movl %eax,%ds
20228 movl %eax,%es
20229
20230 movl $(__KERNEL_PERCPU), %eax
20231 movl %eax,%fs # set this cpu's percpu
20232
20233 +#ifdef CONFIG_CC_STACKPROTECTOR
20234 movl $(__KERNEL_STACK_CANARY),%eax
20235 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
20236 + movl $(__USER_DS),%eax
20237 +#else
20238 + xorl %eax,%eax
20239 +#endif
20240 movl %eax,%gs
20241
20242 xorl %eax,%eax # Clear LDT
20243 @@ -534,8 +616,11 @@ setup_once:
20244 * relocation. Manually set base address in stack canary
20245 * segment descriptor.
20246 */
20247 - movl $gdt_page,%eax
20248 + movl $cpu_gdt_table,%eax
20249 movl $stack_canary,%ecx
20250 +#ifdef CONFIG_SMP
20251 + addl $__per_cpu_load,%ecx
20252 +#endif
20253 movw %cx, 8 * GDT_ENTRY_STACK_CANARY + 2(%eax)
20254 shrl $16, %ecx
20255 movb %cl, 8 * GDT_ENTRY_STACK_CANARY + 4(%eax)
20256 @@ -566,7 +651,7 @@ ENDPROC(early_idt_handlers)
20257 /* This is global to keep gas from relaxing the jumps */
20258 ENTRY(early_idt_handler)
20259 cld
20260 - cmpl $2,%ss:early_recursion_flag
20261 + cmpl $1,%ss:early_recursion_flag
20262 je hlt_loop
20263 incl %ss:early_recursion_flag
20264
20265 @@ -604,8 +689,8 @@ ENTRY(early_idt_handler)
20266 pushl (20+6*4)(%esp) /* trapno */
20267 pushl $fault_msg
20268 call printk
20269 -#endif
20270 call dump_stack
20271 +#endif
20272 hlt_loop:
20273 hlt
20274 jmp hlt_loop
20275 @@ -624,8 +709,11 @@ ENDPROC(early_idt_handler)
20276 /* This is the default interrupt "handler" :-) */
20277 ALIGN
20278 ignore_int:
20279 - cld
20280 #ifdef CONFIG_PRINTK
20281 + cmpl $2,%ss:early_recursion_flag
20282 + je hlt_loop
20283 + incl %ss:early_recursion_flag
20284 + cld
20285 pushl %eax
20286 pushl %ecx
20287 pushl %edx
20288 @@ -634,9 +722,6 @@ ignore_int:
20289 movl $(__KERNEL_DS),%eax
20290 movl %eax,%ds
20291 movl %eax,%es
20292 - cmpl $2,early_recursion_flag
20293 - je hlt_loop
20294 - incl early_recursion_flag
20295 pushl 16(%esp)
20296 pushl 24(%esp)
20297 pushl 32(%esp)
20298 @@ -670,29 +755,43 @@ ENTRY(setup_once_ref)
20299 /*
20300 * BSS section
20301 */
20302 -__PAGE_ALIGNED_BSS
20303 - .align PAGE_SIZE
20304 #ifdef CONFIG_X86_PAE
20305 +.section .initial_pg_pmd,"a",@progbits
20306 initial_pg_pmd:
20307 .fill 1024*KPMDS,4,0
20308 #else
20309 +.section .initial_page_table,"a",@progbits
20310 ENTRY(initial_page_table)
20311 .fill 1024,4,0
20312 #endif
20313 +.section .initial_pg_fixmap,"a",@progbits
20314 initial_pg_fixmap:
20315 .fill 1024,4,0
20316 +.section .empty_zero_page,"a",@progbits
20317 ENTRY(empty_zero_page)
20318 .fill 4096,1,0
20319 +.section .swapper_pg_dir,"a",@progbits
20320 ENTRY(swapper_pg_dir)
20321 +#ifdef CONFIG_X86_PAE
20322 + .fill 4,8,0
20323 +#else
20324 .fill 1024,4,0
20325 +#endif
20326 +
20327 +/*
20328 + * The IDT has to be page-aligned to simplify the Pentium
20329 + * F0 0F bug workaround.. We have a special link segment
20330 + * for this.
20331 + */
20332 +.section .idt,"a",@progbits
20333 +ENTRY(idt_table)
20334 + .fill 256,8,0
20335
20336 /*
20337 * This starts the data section.
20338 */
20339 #ifdef CONFIG_X86_PAE
20340 -__PAGE_ALIGNED_DATA
20341 - /* Page-aligned for the benefit of paravirt? */
20342 - .align PAGE_SIZE
20343 +.section .initial_page_table,"a",@progbits
20344 ENTRY(initial_page_table)
20345 .long pa(initial_pg_pmd+PGD_IDENT_ATTR),0 /* low identity map */
20346 # if KPMDS == 3
20347 @@ -711,12 +810,20 @@ ENTRY(initial_page_table)
20348 # error "Kernel PMDs should be 1, 2 or 3"
20349 # endif
20350 .align PAGE_SIZE /* needs to be page-sized too */
20351 +
20352 +#ifdef CONFIG_PAX_PER_CPU_PGD
20353 +ENTRY(cpu_pgd)
20354 + .rept NR_CPUS
20355 + .fill 4,8,0
20356 + .endr
20357 +#endif
20358 +
20359 #endif
20360
20361 .data
20362 .balign 4
20363 ENTRY(stack_start)
20364 - .long init_thread_union+THREAD_SIZE
20365 + .long init_thread_union+THREAD_SIZE-8
20366
20367 __INITRODATA
20368 int_msg:
20369 @@ -744,7 +851,7 @@ fault_msg:
20370 * segment size, and 32-bit linear address value:
20371 */
20372
20373 - .data
20374 +.section .rodata,"a",@progbits
20375 .globl boot_gdt_descr
20376 .globl idt_descr
20377
20378 @@ -753,7 +860,7 @@ fault_msg:
20379 .word 0 # 32 bit align gdt_desc.address
20380 boot_gdt_descr:
20381 .word __BOOT_DS+7
20382 - .long boot_gdt - __PAGE_OFFSET
20383 + .long pa(boot_gdt)
20384
20385 .word 0 # 32-bit align idt_desc.address
20386 idt_descr:
20387 @@ -764,7 +871,7 @@ idt_descr:
20388 .word 0 # 32 bit align gdt_desc.address
20389 ENTRY(early_gdt_descr)
20390 .word GDT_ENTRIES*8-1
20391 - .long gdt_page /* Overwritten for secondary CPUs */
20392 + .long cpu_gdt_table /* Overwritten for secondary CPUs */
20393
20394 /*
20395 * The boot_gdt must mirror the equivalent in setup.S and is
20396 @@ -773,5 +880,65 @@ ENTRY(early_gdt_descr)
20397 .align L1_CACHE_BYTES
20398 ENTRY(boot_gdt)
20399 .fill GDT_ENTRY_BOOT_CS,8,0
20400 - .quad 0x00cf9a000000ffff /* kernel 4GB code at 0x00000000 */
20401 - .quad 0x00cf92000000ffff /* kernel 4GB data at 0x00000000 */
20402 + .quad 0x00cf9b000000ffff /* kernel 4GB code at 0x00000000 */
20403 + .quad 0x00cf93000000ffff /* kernel 4GB data at 0x00000000 */
20404 +
20405 + .align PAGE_SIZE_asm
20406 +ENTRY(cpu_gdt_table)
20407 + .rept NR_CPUS
20408 + .quad 0x0000000000000000 /* NULL descriptor */
20409 + .quad 0x0000000000000000 /* 0x0b reserved */
20410 + .quad 0x0000000000000000 /* 0x13 reserved */
20411 + .quad 0x0000000000000000 /* 0x1b reserved */
20412 +
20413 +#ifdef CONFIG_PAX_KERNEXEC
20414 + .quad 0x00cf9b000000ffff /* 0x20 alternate kernel 4GB code at 0x00000000 */
20415 +#else
20416 + .quad 0x0000000000000000 /* 0x20 unused */
20417 +#endif
20418 +
20419 + .quad 0x0000000000000000 /* 0x28 unused */
20420 + .quad 0x0000000000000000 /* 0x33 TLS entry 1 */
20421 + .quad 0x0000000000000000 /* 0x3b TLS entry 2 */
20422 + .quad 0x0000000000000000 /* 0x43 TLS entry 3 */
20423 + .quad 0x0000000000000000 /* 0x4b reserved */
20424 + .quad 0x0000000000000000 /* 0x53 reserved */
20425 + .quad 0x0000000000000000 /* 0x5b reserved */
20426 +
20427 + .quad 0x00cf9b000000ffff /* 0x60 kernel 4GB code at 0x00000000 */
20428 + .quad 0x00cf93000000ffff /* 0x68 kernel 4GB data at 0x00000000 */
20429 + .quad 0x00cffb000000ffff /* 0x73 user 4GB code at 0x00000000 */
20430 + .quad 0x00cff3000000ffff /* 0x7b user 4GB data at 0x00000000 */
20431 +
20432 + .quad 0x0000000000000000 /* 0x80 TSS descriptor */
20433 + .quad 0x0000000000000000 /* 0x88 LDT descriptor */
20434 +
20435 + /*
20436 + * Segments used for calling PnP BIOS have byte granularity.
20437 + * The code segments and data segments have fixed 64k limits,
20438 + * the transfer segment sizes are set at run time.
20439 + */
20440 + .quad 0x00409b000000ffff /* 0x90 32-bit code */
20441 + .quad 0x00009b000000ffff /* 0x98 16-bit code */
20442 + .quad 0x000093000000ffff /* 0xa0 16-bit data */
20443 + .quad 0x0000930000000000 /* 0xa8 16-bit data */
20444 + .quad 0x0000930000000000 /* 0xb0 16-bit data */
20445 +
20446 + /*
20447 + * The APM segments have byte granularity and their bases
20448 + * are set at run time. All have 64k limits.
20449 + */
20450 + .quad 0x00409b000000ffff /* 0xb8 APM CS code */
20451 + .quad 0x00009b000000ffff /* 0xc0 APM CS 16 code (16 bit) */
20452 + .quad 0x004093000000ffff /* 0xc8 APM DS data */
20453 +
20454 + .quad 0x00c0930000000000 /* 0xd0 - ESPFIX SS */
20455 + .quad 0x0040930000000000 /* 0xd8 - PERCPU */
20456 + .quad 0x0040910000000017 /* 0xe0 - STACK_CANARY */
20457 + .quad 0x0000000000000000 /* 0xe8 - PCIBIOS_CS */
20458 + .quad 0x0000000000000000 /* 0xf0 - PCIBIOS_DS */
20459 + .quad 0x0000000000000000 /* 0xf8 - GDT entry 31: double-fault TSS */
20460 +
20461 + /* Be sure this is zeroed to avoid false validations in Xen */
20462 + .fill PAGE_SIZE_asm - GDT_SIZE,1,0
20463 + .endr
20464 diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
20465 index 08f7e80..40cbed5 100644
20466 --- a/arch/x86/kernel/head_64.S
20467 +++ b/arch/x86/kernel/head_64.S
20468 @@ -20,6 +20,8 @@
20469 #include <asm/processor-flags.h>
20470 #include <asm/percpu.h>
20471 #include <asm/nops.h>
20472 +#include <asm/cpufeature.h>
20473 +#include <asm/alternative-asm.h>
20474
20475 #ifdef CONFIG_PARAVIRT
20476 #include <asm/asm-offsets.h>
20477 @@ -41,6 +43,12 @@ L4_PAGE_OFFSET = pgd_index(__PAGE_OFFSET)
20478 L3_PAGE_OFFSET = pud_index(__PAGE_OFFSET)
20479 L4_START_KERNEL = pgd_index(__START_KERNEL_map)
20480 L3_START_KERNEL = pud_index(__START_KERNEL_map)
20481 +L4_VMALLOC_START = pgd_index(VMALLOC_START)
20482 +L3_VMALLOC_START = pud_index(VMALLOC_START)
20483 +L4_VMALLOC_END = pgd_index(VMALLOC_END)
20484 +L3_VMALLOC_END = pud_index(VMALLOC_END)
20485 +L4_VMEMMAP_START = pgd_index(VMEMMAP_START)
20486 +L3_VMEMMAP_START = pud_index(VMEMMAP_START)
20487
20488 .text
20489 __HEAD
20490 @@ -89,11 +97,15 @@ startup_64:
20491 * Fixup the physical addresses in the page table
20492 */
20493 addq %rbp, early_level4_pgt + (L4_START_KERNEL*8)(%rip)
20494 + addq %rbp, init_level4_pgt + (L4_VMALLOC_START*8)(%rip)
20495 + addq %rbp, init_level4_pgt + (L4_VMALLOC_END*8)(%rip)
20496 + addq %rbp, init_level4_pgt + (L4_VMEMMAP_START*8)(%rip)
20497
20498 addq %rbp, level3_kernel_pgt + (510*8)(%rip)
20499 addq %rbp, level3_kernel_pgt + (511*8)(%rip)
20500
20501 addq %rbp, level2_fixmap_pgt + (506*8)(%rip)
20502 + addq %rbp, level2_fixmap_pgt + (507*8)(%rip)
20503
20504 /*
20505 * Set up the identity mapping for the switchover. These
20506 @@ -175,8 +187,8 @@ ENTRY(secondary_startup_64)
20507 movq $(init_level4_pgt - __START_KERNEL_map), %rax
20508 1:
20509
20510 - /* Enable PAE mode and PGE */
20511 - movl $(X86_CR4_PAE | X86_CR4_PGE), %ecx
20512 + /* Enable PAE mode and PSE/PGE */
20513 + movl $(X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE), %ecx
20514 movq %rcx, %cr4
20515
20516 /* Setup early boot stage 4 level pagetables. */
20517 @@ -197,10 +209,18 @@ ENTRY(secondary_startup_64)
20518 movl $MSR_EFER, %ecx
20519 rdmsr
20520 btsl $_EFER_SCE, %eax /* Enable System Call */
20521 - btl $20,%edi /* No Execute supported? */
20522 + btl $(X86_FEATURE_NX & 31),%edi /* No Execute supported? */
20523 jnc 1f
20524 btsl $_EFER_NX, %eax
20525 btsq $_PAGE_BIT_NX,early_pmd_flags(%rip)
20526 + leaq init_level4_pgt(%rip), %rdi
20527 +#ifndef CONFIG_EFI
20528 + btsq $_PAGE_BIT_NX, 8*L4_PAGE_OFFSET(%rdi)
20529 +#endif
20530 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_START(%rdi)
20531 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_END(%rdi)
20532 + btsq $_PAGE_BIT_NX, 8*L4_VMEMMAP_START(%rdi)
20533 + btsq $_PAGE_BIT_NX, __supported_pte_mask(%rip)
20534 1: wrmsr /* Make changes effective */
20535
20536 /* Setup cr0 */
20537 @@ -280,6 +300,7 @@ ENTRY(secondary_startup_64)
20538 * REX.W + FF /5 JMP m16:64 Jump far, absolute indirect,
20539 * address given in m16:64.
20540 */
20541 + pax_set_fptr_mask
20542 movq initial_code(%rip),%rax
20543 pushq $0 # fake return address to stop unwinder
20544 pushq $__KERNEL_CS # set correct cs
20545 @@ -386,7 +407,7 @@ ENTRY(early_idt_handler)
20546 call dump_stack
20547 #ifdef CONFIG_KALLSYMS
20548 leaq early_idt_ripmsg(%rip),%rdi
20549 - movq 40(%rsp),%rsi # %rip again
20550 + movq 88(%rsp),%rsi # %rip again
20551 call __print_symbol
20552 #endif
20553 #endif /* EARLY_PRINTK */
20554 @@ -414,6 +435,7 @@ ENDPROC(early_idt_handler)
20555 early_recursion_flag:
20556 .long 0
20557
20558 + .section .rodata,"a",@progbits
20559 #ifdef CONFIG_EARLY_PRINTK
20560 early_idt_msg:
20561 .asciz "PANIC: early exception %02lx rip %lx:%lx error %lx cr2 %lx\n"
20562 @@ -443,27 +465,50 @@ NEXT_PAGE(early_dynamic_pgts)
20563
20564 .data
20565
20566 -#ifndef CONFIG_XEN
20567 NEXT_PAGE(init_level4_pgt)
20568 - .fill 512,8,0
20569 -#else
20570 -NEXT_PAGE(init_level4_pgt)
20571 - .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
20572 .org init_level4_pgt + L4_PAGE_OFFSET*8, 0
20573 .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
20574 + .org init_level4_pgt + L4_VMALLOC_START*8, 0
20575 + .quad level3_vmalloc_start_pgt - __START_KERNEL_map + _KERNPG_TABLE
20576 + .org init_level4_pgt + L4_VMALLOC_END*8, 0
20577 + .quad level3_vmalloc_end_pgt - __START_KERNEL_map + _KERNPG_TABLE
20578 + .org init_level4_pgt + L4_VMEMMAP_START*8, 0
20579 + .quad level3_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
20580 .org init_level4_pgt + L4_START_KERNEL*8, 0
20581 /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */
20582 .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE
20583
20584 +#ifdef CONFIG_PAX_PER_CPU_PGD
20585 +NEXT_PAGE(cpu_pgd)
20586 + .rept NR_CPUS
20587 + .fill 512,8,0
20588 + .endr
20589 +#endif
20590 +
20591 NEXT_PAGE(level3_ident_pgt)
20592 .quad level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
20593 +#ifdef CONFIG_XEN
20594 .fill 511, 8, 0
20595 +#else
20596 + .quad level2_ident_pgt + PAGE_SIZE - __START_KERNEL_map + _KERNPG_TABLE
20597 + .fill 510,8,0
20598 +#endif
20599 +
20600 +NEXT_PAGE(level3_vmalloc_start_pgt)
20601 + .fill 512,8,0
20602 +
20603 +NEXT_PAGE(level3_vmalloc_end_pgt)
20604 + .fill 512,8,0
20605 +
20606 +NEXT_PAGE(level3_vmemmap_pgt)
20607 + .fill L3_VMEMMAP_START,8,0
20608 + .quad level2_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
20609 +
20610 NEXT_PAGE(level2_ident_pgt)
20611 - /* Since I easily can, map the first 1G.
20612 + /* Since I easily can, map the first 2G.
20613 * Don't set NX because code runs from these pages.
20614 */
20615 - PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, PTRS_PER_PMD)
20616 -#endif
20617 + PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, 2*PTRS_PER_PMD)
20618
20619 NEXT_PAGE(level3_kernel_pgt)
20620 .fill L3_START_KERNEL,8,0
20621 @@ -471,6 +516,9 @@ NEXT_PAGE(level3_kernel_pgt)
20622 .quad level2_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE
20623 .quad level2_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
20624
20625 +NEXT_PAGE(level2_vmemmap_pgt)
20626 + .fill 512,8,0
20627 +
20628 NEXT_PAGE(level2_kernel_pgt)
20629 /*
20630 * 512 MB kernel mapping. We spend a full page on this pagetable
20631 @@ -486,38 +534,64 @@ NEXT_PAGE(level2_kernel_pgt)
20632 KERNEL_IMAGE_SIZE/PMD_SIZE)
20633
20634 NEXT_PAGE(level2_fixmap_pgt)
20635 - .fill 506,8,0
20636 - .quad level1_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
20637 - /* 8MB reserved for vsyscalls + a 2MB hole = 4 + 1 entries */
20638 - .fill 5,8,0
20639 + .fill 507,8,0
20640 + .quad level1_vsyscall_pgt - __START_KERNEL_map + _PAGE_TABLE
20641 + /* 6MB reserved for vsyscalls + a 2MB hole = 3 + 1 entries */
20642 + .fill 4,8,0
20643
20644 -NEXT_PAGE(level1_fixmap_pgt)
20645 +NEXT_PAGE(level1_vsyscall_pgt)
20646 .fill 512,8,0
20647
20648 #undef PMDS
20649
20650 - .data
20651 + .align PAGE_SIZE
20652 +ENTRY(cpu_gdt_table)
20653 + .rept NR_CPUS
20654 + .quad 0x0000000000000000 /* NULL descriptor */
20655 + .quad 0x00cf9b000000ffff /* __KERNEL32_CS */
20656 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
20657 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
20658 + .quad 0x00cffb000000ffff /* __USER32_CS */
20659 + .quad 0x00cff3000000ffff /* __USER_DS, __USER32_DS */
20660 + .quad 0x00affb000000ffff /* __USER_CS */
20661 +
20662 +#ifdef CONFIG_PAX_KERNEXEC
20663 + .quad 0x00af9b000000ffff /* __KERNEXEC_KERNEL_CS */
20664 +#else
20665 + .quad 0x0 /* unused */
20666 +#endif
20667 +
20668 + .quad 0,0 /* TSS */
20669 + .quad 0,0 /* LDT */
20670 + .quad 0,0,0 /* three TLS descriptors */
20671 + .quad 0x0000f40000000000 /* node/CPU stored in limit */
20672 + /* asm/segment.h:GDT_ENTRIES must match this */
20673 +
20674 + /* zero the remaining page */
20675 + .fill PAGE_SIZE / 8 - GDT_ENTRIES,8,0
20676 + .endr
20677 +
20678 .align 16
20679 .globl early_gdt_descr
20680 early_gdt_descr:
20681 .word GDT_ENTRIES*8-1
20682 early_gdt_descr_base:
20683 - .quad INIT_PER_CPU_VAR(gdt_page)
20684 + .quad cpu_gdt_table
20685
20686 ENTRY(phys_base)
20687 /* This must match the first entry in level2_kernel_pgt */
20688 .quad 0x0000000000000000
20689
20690 #include "../../x86/xen/xen-head.S"
20691 -
20692 - .section .bss, "aw", @nobits
20693 +
20694 + .section .rodata,"a",@progbits
20695 .align L1_CACHE_BYTES
20696 ENTRY(idt_table)
20697 - .skip IDT_ENTRIES * 16
20698 + .fill 512,8,0
20699
20700 .align L1_CACHE_BYTES
20701 ENTRY(nmi_idt_table)
20702 - .skip IDT_ENTRIES * 16
20703 + .fill 512,8,0
20704
20705 __PAGE_ALIGNED_BSS
20706 NEXT_PAGE(empty_zero_page)
20707 diff --git a/arch/x86/kernel/i386_ksyms_32.c b/arch/x86/kernel/i386_ksyms_32.c
20708 index 0fa6912..37fce70 100644
20709 --- a/arch/x86/kernel/i386_ksyms_32.c
20710 +++ b/arch/x86/kernel/i386_ksyms_32.c
20711 @@ -20,8 +20,12 @@ extern void cmpxchg8b_emu(void);
20712 EXPORT_SYMBOL(cmpxchg8b_emu);
20713 #endif
20714
20715 +EXPORT_SYMBOL_GPL(cpu_gdt_table);
20716 +
20717 /* Networking helper routines. */
20718 EXPORT_SYMBOL(csum_partial_copy_generic);
20719 +EXPORT_SYMBOL(csum_partial_copy_generic_to_user);
20720 +EXPORT_SYMBOL(csum_partial_copy_generic_from_user);
20721
20722 EXPORT_SYMBOL(__get_user_1);
20723 EXPORT_SYMBOL(__get_user_2);
20724 @@ -37,3 +41,7 @@ EXPORT_SYMBOL(strstr);
20725
20726 EXPORT_SYMBOL(csum_partial);
20727 EXPORT_SYMBOL(empty_zero_page);
20728 +
20729 +#ifdef CONFIG_PAX_KERNEXEC
20730 +EXPORT_SYMBOL(__LOAD_PHYSICAL_ADDR);
20731 +#endif
20732 diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
20733 index 245a71d..89d9ce4 100644
20734 --- a/arch/x86/kernel/i387.c
20735 +++ b/arch/x86/kernel/i387.c
20736 @@ -55,7 +55,7 @@ static inline bool interrupted_kernel_fpu_idle(void)
20737 static inline bool interrupted_user_mode(void)
20738 {
20739 struct pt_regs *regs = get_irq_regs();
20740 - return regs && user_mode_vm(regs);
20741 + return regs && user_mode(regs);
20742 }
20743
20744 /*
20745 diff --git a/arch/x86/kernel/i8259.c b/arch/x86/kernel/i8259.c
20746 index 9a5c460..84868423 100644
20747 --- a/arch/x86/kernel/i8259.c
20748 +++ b/arch/x86/kernel/i8259.c
20749 @@ -110,7 +110,7 @@ static int i8259A_irq_pending(unsigned int irq)
20750 static void make_8259A_irq(unsigned int irq)
20751 {
20752 disable_irq_nosync(irq);
20753 - io_apic_irqs &= ~(1<<irq);
20754 + io_apic_irqs &= ~(1UL<<irq);
20755 irq_set_chip_and_handler_name(irq, &i8259A_chip, handle_level_irq,
20756 i8259A_chip.name);
20757 enable_irq(irq);
20758 @@ -209,7 +209,7 @@ spurious_8259A_irq:
20759 "spurious 8259A interrupt: IRQ%d.\n", irq);
20760 spurious_irq_mask |= irqmask;
20761 }
20762 - atomic_inc(&irq_err_count);
20763 + atomic_inc_unchecked(&irq_err_count);
20764 /*
20765 * Theoretically we do not have to handle this IRQ,
20766 * but in Linux this does not cause problems and is
20767 @@ -333,14 +333,16 @@ static void init_8259A(int auto_eoi)
20768 /* (slave's support for AEOI in flat mode is to be investigated) */
20769 outb_pic(SLAVE_ICW4_DEFAULT, PIC_SLAVE_IMR);
20770
20771 + pax_open_kernel();
20772 if (auto_eoi)
20773 /*
20774 * In AEOI mode we just have to mask the interrupt
20775 * when acking.
20776 */
20777 - i8259A_chip.irq_mask_ack = disable_8259A_irq;
20778 + *(void **)&i8259A_chip.irq_mask_ack = disable_8259A_irq;
20779 else
20780 - i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
20781 + *(void **)&i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
20782 + pax_close_kernel();
20783
20784 udelay(100); /* wait for 8259A to initialize */
20785
20786 diff --git a/arch/x86/kernel/io_delay.c b/arch/x86/kernel/io_delay.c
20787 index a979b5b..1d6db75 100644
20788 --- a/arch/x86/kernel/io_delay.c
20789 +++ b/arch/x86/kernel/io_delay.c
20790 @@ -58,7 +58,7 @@ static int __init dmi_io_delay_0xed_port(const struct dmi_system_id *id)
20791 * Quirk table for systems that misbehave (lock up, etc.) if port
20792 * 0x80 is used:
20793 */
20794 -static struct dmi_system_id __initdata io_delay_0xed_port_dmi_table[] = {
20795 +static const struct dmi_system_id __initconst io_delay_0xed_port_dmi_table[] = {
20796 {
20797 .callback = dmi_io_delay_0xed_port,
20798 .ident = "Compaq Presario V6000",
20799 diff --git a/arch/x86/kernel/ioport.c b/arch/x86/kernel/ioport.c
20800 index 4ddaf66..6292f4e 100644
20801 --- a/arch/x86/kernel/ioport.c
20802 +++ b/arch/x86/kernel/ioport.c
20803 @@ -6,6 +6,7 @@
20804 #include <linux/sched.h>
20805 #include <linux/kernel.h>
20806 #include <linux/capability.h>
20807 +#include <linux/security.h>
20808 #include <linux/errno.h>
20809 #include <linux/types.h>
20810 #include <linux/ioport.h>
20811 @@ -28,6 +29,12 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
20812
20813 if ((from + num <= from) || (from + num > IO_BITMAP_BITS))
20814 return -EINVAL;
20815 +#ifdef CONFIG_GRKERNSEC_IO
20816 + if (turn_on && grsec_disable_privio) {
20817 + gr_handle_ioperm();
20818 + return -EPERM;
20819 + }
20820 +#endif
20821 if (turn_on && !capable(CAP_SYS_RAWIO))
20822 return -EPERM;
20823
20824 @@ -54,7 +61,7 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
20825 * because the ->io_bitmap_max value must match the bitmap
20826 * contents:
20827 */
20828 - tss = &per_cpu(init_tss, get_cpu());
20829 + tss = init_tss + get_cpu();
20830
20831 if (turn_on)
20832 bitmap_clear(t->io_bitmap_ptr, from, num);
20833 @@ -103,6 +110,12 @@ SYSCALL_DEFINE1(iopl, unsigned int, level)
20834 return -EINVAL;
20835 /* Trying to gain more privileges? */
20836 if (level > old) {
20837 +#ifdef CONFIG_GRKERNSEC_IO
20838 + if (grsec_disable_privio) {
20839 + gr_handle_iopl();
20840 + return -EPERM;
20841 + }
20842 +#endif
20843 if (!capable(CAP_SYS_RAWIO))
20844 return -EPERM;
20845 }
20846 diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
20847 index 84b7789..e65e8be 100644
20848 --- a/arch/x86/kernel/irq.c
20849 +++ b/arch/x86/kernel/irq.c
20850 @@ -18,7 +18,7 @@
20851 #include <asm/mce.h>
20852 #include <asm/hw_irq.h>
20853
20854 -atomic_t irq_err_count;
20855 +atomic_unchecked_t irq_err_count;
20856
20857 /* Function pointer for generic interrupt vector handling */
20858 void (*x86_platform_ipi_callback)(void) = NULL;
20859 @@ -122,9 +122,9 @@ int arch_show_interrupts(struct seq_file *p, int prec)
20860 seq_printf(p, "%10u ", per_cpu(mce_poll_count, j));
20861 seq_printf(p, " Machine check polls\n");
20862 #endif
20863 - seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
20864 + seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
20865 #if defined(CONFIG_X86_IO_APIC)
20866 - seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read(&irq_mis_count));
20867 + seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read_unchecked(&irq_mis_count));
20868 #endif
20869 return 0;
20870 }
20871 @@ -164,7 +164,7 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
20872
20873 u64 arch_irq_stat(void)
20874 {
20875 - u64 sum = atomic_read(&irq_err_count);
20876 + u64 sum = atomic_read_unchecked(&irq_err_count);
20877 return sum;
20878 }
20879
20880 diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c
20881 index 344faf8..355f60d 100644
20882 --- a/arch/x86/kernel/irq_32.c
20883 +++ b/arch/x86/kernel/irq_32.c
20884 @@ -39,7 +39,7 @@ static int check_stack_overflow(void)
20885 __asm__ __volatile__("andl %%esp,%0" :
20886 "=r" (sp) : "0" (THREAD_SIZE - 1));
20887
20888 - return sp < (sizeof(struct thread_info) + STACK_WARN);
20889 + return sp < STACK_WARN;
20890 }
20891
20892 static void print_stack_overflow(void)
20893 @@ -59,8 +59,8 @@ static inline void print_stack_overflow(void) { }
20894 * per-CPU IRQ handling contexts (thread information and stack)
20895 */
20896 union irq_ctx {
20897 - struct thread_info tinfo;
20898 - u32 stack[THREAD_SIZE/sizeof(u32)];
20899 + unsigned long previous_esp;
20900 + u32 stack[THREAD_SIZE/sizeof(u32)];
20901 } __attribute__((aligned(THREAD_SIZE)));
20902
20903 static DEFINE_PER_CPU(union irq_ctx *, hardirq_ctx);
20904 @@ -80,10 +80,9 @@ static void call_on_stack(void *func, void *stack)
20905 static inline int
20906 execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
20907 {
20908 - union irq_ctx *curctx, *irqctx;
20909 + union irq_ctx *irqctx;
20910 u32 *isp, arg1, arg2;
20911
20912 - curctx = (union irq_ctx *) current_thread_info();
20913 irqctx = __this_cpu_read(hardirq_ctx);
20914
20915 /*
20916 @@ -92,16 +91,16 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
20917 * handler) we can't do that and just have to keep using the
20918 * current stack (which is the irq stack already after all)
20919 */
20920 - if (unlikely(curctx == irqctx))
20921 + if (unlikely((void *)current_stack_pointer - (void *)irqctx < THREAD_SIZE))
20922 return 0;
20923
20924 /* build the stack frame on the IRQ stack */
20925 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
20926 - irqctx->tinfo.task = curctx->tinfo.task;
20927 - irqctx->tinfo.previous_esp = current_stack_pointer;
20928 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
20929 + irqctx->previous_esp = current_stack_pointer;
20930
20931 - /* Copy the preempt_count so that the [soft]irq checks work. */
20932 - irqctx->tinfo.preempt_count = curctx->tinfo.preempt_count;
20933 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20934 + __set_fs(MAKE_MM_SEG(0));
20935 +#endif
20936
20937 if (unlikely(overflow))
20938 call_on_stack(print_stack_overflow, isp);
20939 @@ -113,6 +112,11 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
20940 : "0" (irq), "1" (desc), "2" (isp),
20941 "D" (desc->handle_irq)
20942 : "memory", "cc", "ecx");
20943 +
20944 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20945 + __set_fs(current_thread_info()->addr_limit);
20946 +#endif
20947 +
20948 return 1;
20949 }
20950
20951 @@ -121,29 +125,14 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
20952 */
20953 void __cpuinit irq_ctx_init(int cpu)
20954 {
20955 - union irq_ctx *irqctx;
20956 -
20957 if (per_cpu(hardirq_ctx, cpu))
20958 return;
20959
20960 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
20961 - THREADINFO_GFP,
20962 - THREAD_SIZE_ORDER));
20963 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
20964 - irqctx->tinfo.cpu = cpu;
20965 - irqctx->tinfo.preempt_count = HARDIRQ_OFFSET;
20966 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
20967 -
20968 - per_cpu(hardirq_ctx, cpu) = irqctx;
20969 -
20970 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
20971 - THREADINFO_GFP,
20972 - THREAD_SIZE_ORDER));
20973 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
20974 - irqctx->tinfo.cpu = cpu;
20975 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
20976 -
20977 - per_cpu(softirq_ctx, cpu) = irqctx;
20978 + per_cpu(hardirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
20979 + per_cpu(softirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
20980 +
20981 + printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
20982 + cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
20983
20984 printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
20985 cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
20986 @@ -152,7 +141,6 @@ void __cpuinit irq_ctx_init(int cpu)
20987 asmlinkage void do_softirq(void)
20988 {
20989 unsigned long flags;
20990 - struct thread_info *curctx;
20991 union irq_ctx *irqctx;
20992 u32 *isp;
20993
20994 @@ -162,15 +150,22 @@ asmlinkage void do_softirq(void)
20995 local_irq_save(flags);
20996
20997 if (local_softirq_pending()) {
20998 - curctx = current_thread_info();
20999 irqctx = __this_cpu_read(softirq_ctx);
21000 - irqctx->tinfo.task = curctx->task;
21001 - irqctx->tinfo.previous_esp = current_stack_pointer;
21002 + irqctx->previous_esp = current_stack_pointer;
21003
21004 /* build the stack frame on the softirq stack */
21005 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
21006 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
21007 +
21008 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21009 + __set_fs(MAKE_MM_SEG(0));
21010 +#endif
21011
21012 call_on_stack(__do_softirq, isp);
21013 +
21014 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21015 + __set_fs(current_thread_info()->addr_limit);
21016 +#endif
21017 +
21018 /*
21019 * Shouldn't happen, we returned above if in_interrupt():
21020 */
21021 @@ -191,7 +186,7 @@ bool handle_irq(unsigned irq, struct pt_regs *regs)
21022 if (unlikely(!desc))
21023 return false;
21024
21025 - if (user_mode_vm(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
21026 + if (user_mode(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
21027 if (unlikely(overflow))
21028 print_stack_overflow();
21029 desc->handle_irq(irq, desc);
21030 diff --git a/arch/x86/kernel/irq_64.c b/arch/x86/kernel/irq_64.c
21031 index d04d3ec..ea4b374 100644
21032 --- a/arch/x86/kernel/irq_64.c
21033 +++ b/arch/x86/kernel/irq_64.c
21034 @@ -44,7 +44,7 @@ static inline void stack_overflow_check(struct pt_regs *regs)
21035 u64 estack_top, estack_bottom;
21036 u64 curbase = (u64)task_stack_page(current);
21037
21038 - if (user_mode_vm(regs))
21039 + if (user_mode(regs))
21040 return;
21041
21042 if (regs->sp >= curbase + sizeof(struct thread_info) +
21043 diff --git a/arch/x86/kernel/kdebugfs.c b/arch/x86/kernel/kdebugfs.c
21044 index dc1404b..bbc43e7 100644
21045 --- a/arch/x86/kernel/kdebugfs.c
21046 +++ b/arch/x86/kernel/kdebugfs.c
21047 @@ -27,7 +27,7 @@ struct setup_data_node {
21048 u32 len;
21049 };
21050
21051 -static ssize_t setup_data_read(struct file *file, char __user *user_buf,
21052 +static ssize_t __size_overflow(3) setup_data_read(struct file *file, char __user *user_buf,
21053 size_t count, loff_t *ppos)
21054 {
21055 struct setup_data_node *node = file->private_data;
21056 diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
21057 index 836f832..a8bda67 100644
21058 --- a/arch/x86/kernel/kgdb.c
21059 +++ b/arch/x86/kernel/kgdb.c
21060 @@ -127,11 +127,11 @@ char *dbg_get_reg(int regno, void *mem, struct pt_regs *regs)
21061 #ifdef CONFIG_X86_32
21062 switch (regno) {
21063 case GDB_SS:
21064 - if (!user_mode_vm(regs))
21065 + if (!user_mode(regs))
21066 *(unsigned long *)mem = __KERNEL_DS;
21067 break;
21068 case GDB_SP:
21069 - if (!user_mode_vm(regs))
21070 + if (!user_mode(regs))
21071 *(unsigned long *)mem = kernel_stack_pointer(regs);
21072 break;
21073 case GDB_GS:
21074 @@ -229,7 +229,10 @@ static void kgdb_correct_hw_break(void)
21075 bp->attr.bp_addr = breakinfo[breakno].addr;
21076 bp->attr.bp_len = breakinfo[breakno].len;
21077 bp->attr.bp_type = breakinfo[breakno].type;
21078 - info->address = breakinfo[breakno].addr;
21079 + if (breakinfo[breakno].type == X86_BREAKPOINT_EXECUTE)
21080 + info->address = ktla_ktva(breakinfo[breakno].addr);
21081 + else
21082 + info->address = breakinfo[breakno].addr;
21083 info->len = breakinfo[breakno].len;
21084 info->type = breakinfo[breakno].type;
21085 val = arch_install_hw_breakpoint(bp);
21086 @@ -476,12 +479,12 @@ int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
21087 case 'k':
21088 /* clear the trace bit */
21089 linux_regs->flags &= ~X86_EFLAGS_TF;
21090 - atomic_set(&kgdb_cpu_doing_single_step, -1);
21091 + atomic_set_unchecked(&kgdb_cpu_doing_single_step, -1);
21092
21093 /* set the trace bit if we're stepping */
21094 if (remcomInBuffer[0] == 's') {
21095 linux_regs->flags |= X86_EFLAGS_TF;
21096 - atomic_set(&kgdb_cpu_doing_single_step,
21097 + atomic_set_unchecked(&kgdb_cpu_doing_single_step,
21098 raw_smp_processor_id());
21099 }
21100
21101 @@ -546,7 +549,7 @@ static int __kgdb_notify(struct die_args *args, unsigned long cmd)
21102
21103 switch (cmd) {
21104 case DIE_DEBUG:
21105 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
21106 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
21107 if (user_mode(regs))
21108 return single_step_cont(regs, args);
21109 break;
21110 @@ -751,11 +754,11 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
21111 #endif /* CONFIG_DEBUG_RODATA */
21112
21113 bpt->type = BP_BREAKPOINT;
21114 - err = probe_kernel_read(bpt->saved_instr, (char *)bpt->bpt_addr,
21115 + err = probe_kernel_read(bpt->saved_instr, ktla_ktva((char *)bpt->bpt_addr),
21116 BREAK_INSTR_SIZE);
21117 if (err)
21118 return err;
21119 - err = probe_kernel_write((char *)bpt->bpt_addr,
21120 + err = probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
21121 arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE);
21122 #ifdef CONFIG_DEBUG_RODATA
21123 if (!err)
21124 @@ -768,7 +771,7 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
21125 return -EBUSY;
21126 text_poke((void *)bpt->bpt_addr, arch_kgdb_ops.gdb_bpt_instr,
21127 BREAK_INSTR_SIZE);
21128 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
21129 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
21130 if (err)
21131 return err;
21132 if (memcmp(opc, arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE))
21133 @@ -793,13 +796,13 @@ int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt)
21134 if (mutex_is_locked(&text_mutex))
21135 goto knl_write;
21136 text_poke((void *)bpt->bpt_addr, bpt->saved_instr, BREAK_INSTR_SIZE);
21137 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
21138 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
21139 if (err || memcmp(opc, bpt->saved_instr, BREAK_INSTR_SIZE))
21140 goto knl_write;
21141 return err;
21142 knl_write:
21143 #endif /* CONFIG_DEBUG_RODATA */
21144 - return probe_kernel_write((char *)bpt->bpt_addr,
21145 + return probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
21146 (char *)bpt->saved_instr, BREAK_INSTR_SIZE);
21147 }
21148
21149 diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
21150 index 7bfe318..383d238 100644
21151 --- a/arch/x86/kernel/kprobes/core.c
21152 +++ b/arch/x86/kernel/kprobes/core.c
21153 @@ -119,9 +119,12 @@ static void __kprobes __synthesize_relative_insn(void *from, void *to, u8 op)
21154 s32 raddr;
21155 } __packed *insn;
21156
21157 - insn = (struct __arch_relative_insn *)from;
21158 + insn = (struct __arch_relative_insn *)ktla_ktva(from);
21159 +
21160 + pax_open_kernel();
21161 insn->raddr = (s32)((long)(to) - ((long)(from) + 5));
21162 insn->op = op;
21163 + pax_close_kernel();
21164 }
21165
21166 /* Insert a jump instruction at address 'from', which jumps to address 'to'.*/
21167 @@ -164,7 +167,7 @@ int __kprobes can_boost(kprobe_opcode_t *opcodes)
21168 kprobe_opcode_t opcode;
21169 kprobe_opcode_t *orig_opcodes = opcodes;
21170
21171 - if (search_exception_tables((unsigned long)opcodes))
21172 + if (search_exception_tables(ktva_ktla((unsigned long)opcodes)))
21173 return 0; /* Page fault may occur on this address. */
21174
21175 retry:
21176 @@ -238,9 +241,9 @@ __recover_probed_insn(kprobe_opcode_t *buf, unsigned long addr)
21177 * for the first byte, we can recover the original instruction
21178 * from it and kp->opcode.
21179 */
21180 - memcpy(buf, kp->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
21181 + memcpy(buf, ktla_ktva(kp->addr), MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
21182 buf[0] = kp->opcode;
21183 - return (unsigned long)buf;
21184 + return ktva_ktla((unsigned long)buf);
21185 }
21186
21187 /*
21188 @@ -332,7 +335,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
21189 /* Another subsystem puts a breakpoint, failed to recover */
21190 if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION)
21191 return 0;
21192 + pax_open_kernel();
21193 memcpy(dest, insn.kaddr, insn.length);
21194 + pax_close_kernel();
21195
21196 #ifdef CONFIG_X86_64
21197 if (insn_rip_relative(&insn)) {
21198 @@ -355,7 +360,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
21199 newdisp = (u8 *) src + (s64) insn.displacement.value - (u8 *) dest;
21200 BUG_ON((s64) (s32) newdisp != newdisp); /* Sanity check. */
21201 disp = (u8 *) dest + insn_offset_displacement(&insn);
21202 + pax_open_kernel();
21203 *(s32 *) disp = (s32) newdisp;
21204 + pax_close_kernel();
21205 }
21206 #endif
21207 return insn.length;
21208 @@ -488,7 +495,7 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
21209 * nor set current_kprobe, because it doesn't use single
21210 * stepping.
21211 */
21212 - regs->ip = (unsigned long)p->ainsn.insn;
21213 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
21214 preempt_enable_no_resched();
21215 return;
21216 }
21217 @@ -505,9 +512,9 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
21218 regs->flags &= ~X86_EFLAGS_IF;
21219 /* single step inline if the instruction is an int3 */
21220 if (p->opcode == BREAKPOINT_INSTRUCTION)
21221 - regs->ip = (unsigned long)p->addr;
21222 + regs->ip = ktla_ktva((unsigned long)p->addr);
21223 else
21224 - regs->ip = (unsigned long)p->ainsn.insn;
21225 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
21226 }
21227
21228 /*
21229 @@ -586,7 +593,7 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
21230 setup_singlestep(p, regs, kcb, 0);
21231 return 1;
21232 }
21233 - } else if (*addr != BREAKPOINT_INSTRUCTION) {
21234 + } else if (*(kprobe_opcode_t *)ktla_ktva((unsigned long)addr) != BREAKPOINT_INSTRUCTION) {
21235 /*
21236 * The breakpoint instruction was removed right
21237 * after we hit it. Another cpu has removed
21238 @@ -632,6 +639,9 @@ static void __used __kprobes kretprobe_trampoline_holder(void)
21239 " movq %rax, 152(%rsp)\n"
21240 RESTORE_REGS_STRING
21241 " popfq\n"
21242 +#ifdef KERNEXEC_PLUGIN
21243 + " btsq $63,(%rsp)\n"
21244 +#endif
21245 #else
21246 " pushf\n"
21247 SAVE_REGS_STRING
21248 @@ -769,7 +779,7 @@ static void __kprobes
21249 resume_execution(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *kcb)
21250 {
21251 unsigned long *tos = stack_addr(regs);
21252 - unsigned long copy_ip = (unsigned long)p->ainsn.insn;
21253 + unsigned long copy_ip = ktva_ktla((unsigned long)p->ainsn.insn);
21254 unsigned long orig_ip = (unsigned long)p->addr;
21255 kprobe_opcode_t *insn = p->ainsn.insn;
21256
21257 @@ -951,7 +961,7 @@ kprobe_exceptions_notify(struct notifier_block *self, unsigned long val, void *d
21258 struct die_args *args = data;
21259 int ret = NOTIFY_DONE;
21260
21261 - if (args->regs && user_mode_vm(args->regs))
21262 + if (args->regs && user_mode(args->regs))
21263 return ret;
21264
21265 switch (val) {
21266 diff --git a/arch/x86/kernel/kprobes/opt.c b/arch/x86/kernel/kprobes/opt.c
21267 index 76dc6f0..66bdfc3 100644
21268 --- a/arch/x86/kernel/kprobes/opt.c
21269 +++ b/arch/x86/kernel/kprobes/opt.c
21270 @@ -79,6 +79,7 @@ found:
21271 /* Insert a move instruction which sets a pointer to eax/rdi (1st arg). */
21272 static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long val)
21273 {
21274 + pax_open_kernel();
21275 #ifdef CONFIG_X86_64
21276 *addr++ = 0x48;
21277 *addr++ = 0xbf;
21278 @@ -86,6 +87,7 @@ static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long v
21279 *addr++ = 0xb8;
21280 #endif
21281 *(unsigned long *)addr = val;
21282 + pax_close_kernel();
21283 }
21284
21285 static void __used __kprobes kprobes_optinsn_template_holder(void)
21286 @@ -338,7 +340,7 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
21287 * Verify if the address gap is in 2GB range, because this uses
21288 * a relative jump.
21289 */
21290 - rel = (long)op->optinsn.insn - (long)op->kp.addr + RELATIVEJUMP_SIZE;
21291 + rel = (long)op->optinsn.insn - ktla_ktva((long)op->kp.addr) + RELATIVEJUMP_SIZE;
21292 if (abs(rel) > 0x7fffffff)
21293 return -ERANGE;
21294
21295 @@ -353,16 +355,18 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
21296 op->optinsn.size = ret;
21297
21298 /* Copy arch-dep-instance from template */
21299 - memcpy(buf, &optprobe_template_entry, TMPL_END_IDX);
21300 + pax_open_kernel();
21301 + memcpy(buf, ktla_ktva(&optprobe_template_entry), TMPL_END_IDX);
21302 + pax_close_kernel();
21303
21304 /* Set probe information */
21305 synthesize_set_arg1(buf + TMPL_MOVE_IDX, (unsigned long)op);
21306
21307 /* Set probe function call */
21308 - synthesize_relcall(buf + TMPL_CALL_IDX, optimized_callback);
21309 + synthesize_relcall(ktva_ktla(buf) + TMPL_CALL_IDX, optimized_callback);
21310
21311 /* Set returning jmp instruction at the tail of out-of-line buffer */
21312 - synthesize_reljump(buf + TMPL_END_IDX + op->optinsn.size,
21313 + synthesize_reljump(ktva_ktla(buf) + TMPL_END_IDX + op->optinsn.size,
21314 (u8 *)op->kp.addr + op->optinsn.size);
21315
21316 flush_icache_range((unsigned long) buf,
21317 @@ -385,7 +389,7 @@ static void __kprobes setup_optimize_kprobe(struct text_poke_param *tprm,
21318 ((long)op->kp.addr + RELATIVEJUMP_SIZE));
21319
21320 /* Backup instructions which will be replaced by jump address */
21321 - memcpy(op->optinsn.copied_insn, op->kp.addr + INT3_SIZE,
21322 + memcpy(op->optinsn.copied_insn, ktla_ktva(op->kp.addr) + INT3_SIZE,
21323 RELATIVE_ADDR_SIZE);
21324
21325 insn_buf[0] = RELATIVEJUMP_OPCODE;
21326 @@ -483,7 +487,7 @@ setup_detour_execution(struct kprobe *p, struct pt_regs *regs, int reenter)
21327 /* This kprobe is really able to run optimized path. */
21328 op = container_of(p, struct optimized_kprobe, kp);
21329 /* Detour through copied instructions */
21330 - regs->ip = (unsigned long)op->optinsn.insn + TMPL_END_IDX;
21331 + regs->ip = ktva_ktla((unsigned long)op->optinsn.insn) + TMPL_END_IDX;
21332 if (!reenter)
21333 reset_current_kprobe();
21334 preempt_enable_no_resched();
21335 diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
21336 index b686a90..60d36fb 100644
21337 --- a/arch/x86/kernel/kvm.c
21338 +++ b/arch/x86/kernel/kvm.c
21339 @@ -453,7 +453,7 @@ static int __cpuinit kvm_cpu_notify(struct notifier_block *self,
21340 return NOTIFY_OK;
21341 }
21342
21343 -static struct notifier_block __cpuinitdata kvm_cpu_notifier = {
21344 +static struct notifier_block kvm_cpu_notifier = {
21345 .notifier_call = kvm_cpu_notify,
21346 };
21347 #endif
21348 diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
21349 index ebc9873..1b9724b 100644
21350 --- a/arch/x86/kernel/ldt.c
21351 +++ b/arch/x86/kernel/ldt.c
21352 @@ -66,13 +66,13 @@ static int alloc_ldt(mm_context_t *pc, int mincount, int reload)
21353 if (reload) {
21354 #ifdef CONFIG_SMP
21355 preempt_disable();
21356 - load_LDT(pc);
21357 + load_LDT_nolock(pc);
21358 if (!cpumask_equal(mm_cpumask(current->mm),
21359 cpumask_of(smp_processor_id())))
21360 smp_call_function(flush_ldt, current->mm, 1);
21361 preempt_enable();
21362 #else
21363 - load_LDT(pc);
21364 + load_LDT_nolock(pc);
21365 #endif
21366 }
21367 if (oldsize) {
21368 @@ -94,7 +94,7 @@ static inline int copy_ldt(mm_context_t *new, mm_context_t *old)
21369 return err;
21370
21371 for (i = 0; i < old->size; i++)
21372 - write_ldt_entry(new->ldt, i, old->ldt + i * LDT_ENTRY_SIZE);
21373 + write_ldt_entry(new->ldt, i, old->ldt + i);
21374 return 0;
21375 }
21376
21377 @@ -115,6 +115,24 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
21378 retval = copy_ldt(&mm->context, &old_mm->context);
21379 mutex_unlock(&old_mm->context.lock);
21380 }
21381 +
21382 + if (tsk == current) {
21383 + mm->context.vdso = 0;
21384 +
21385 +#ifdef CONFIG_X86_32
21386 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
21387 + mm->context.user_cs_base = 0UL;
21388 + mm->context.user_cs_limit = ~0UL;
21389 +
21390 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
21391 + cpus_clear(mm->context.cpu_user_cs_mask);
21392 +#endif
21393 +
21394 +#endif
21395 +#endif
21396 +
21397 + }
21398 +
21399 return retval;
21400 }
21401
21402 @@ -229,6 +247,13 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
21403 }
21404 }
21405
21406 +#ifdef CONFIG_PAX_SEGMEXEC
21407 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (ldt_info.contents & MODIFY_LDT_CONTENTS_CODE)) {
21408 + error = -EINVAL;
21409 + goto out_unlock;
21410 + }
21411 +#endif
21412 +
21413 fill_ldt(&ldt, &ldt_info);
21414 if (oldmode)
21415 ldt.avl = 0;
21416 diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_kexec_32.c
21417 index 5b19e4d..6476a76 100644
21418 --- a/arch/x86/kernel/machine_kexec_32.c
21419 +++ b/arch/x86/kernel/machine_kexec_32.c
21420 @@ -26,7 +26,7 @@
21421 #include <asm/cacheflush.h>
21422 #include <asm/debugreg.h>
21423
21424 -static void set_idt(void *newidt, __u16 limit)
21425 +static void set_idt(struct desc_struct *newidt, __u16 limit)
21426 {
21427 struct desc_ptr curidt;
21428
21429 @@ -38,7 +38,7 @@ static void set_idt(void *newidt, __u16 limit)
21430 }
21431
21432
21433 -static void set_gdt(void *newgdt, __u16 limit)
21434 +static void set_gdt(struct desc_struct *newgdt, __u16 limit)
21435 {
21436 struct desc_ptr curgdt;
21437
21438 @@ -216,7 +216,7 @@ void machine_kexec(struct kimage *image)
21439 }
21440
21441 control_page = page_address(image->control_code_page);
21442 - memcpy(control_page, relocate_kernel, KEXEC_CONTROL_CODE_MAX_SIZE);
21443 + memcpy(control_page, (void *)ktla_ktva((unsigned long)relocate_kernel), KEXEC_CONTROL_CODE_MAX_SIZE);
21444
21445 relocate_kernel_ptr = control_page;
21446 page_list[PA_CONTROL_PAGE] = __pa(control_page);
21447 diff --git a/arch/x86/kernel/microcode_core.c b/arch/x86/kernel/microcode_core.c
21448 index 22db92b..d546bec 100644
21449 --- a/arch/x86/kernel/microcode_core.c
21450 +++ b/arch/x86/kernel/microcode_core.c
21451 @@ -513,7 +513,7 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
21452 return NOTIFY_OK;
21453 }
21454
21455 -static struct notifier_block __refdata mc_cpu_notifier = {
21456 +static struct notifier_block mc_cpu_notifier = {
21457 .notifier_call = mc_cpu_callback,
21458 };
21459
21460 diff --git a/arch/x86/kernel/microcode_intel.c b/arch/x86/kernel/microcode_intel.c
21461 index 5fb2ceb..3ae90bb 100644
21462 --- a/arch/x86/kernel/microcode_intel.c
21463 +++ b/arch/x86/kernel/microcode_intel.c
21464 @@ -293,13 +293,13 @@ static enum ucode_state request_microcode_fw(int cpu, struct device *device,
21465
21466 static int get_ucode_user(void *to, const void *from, size_t n)
21467 {
21468 - return copy_from_user(to, from, n);
21469 + return copy_from_user(to, (const void __force_user *)from, n);
21470 }
21471
21472 static enum ucode_state
21473 request_microcode_user(int cpu, const void __user *buf, size_t size)
21474 {
21475 - return generic_load_microcode(cpu, (void *)buf, size, &get_ucode_user);
21476 + return generic_load_microcode(cpu, (__force_kernel void *)buf, size, &get_ucode_user);
21477 }
21478
21479 static void microcode_fini_cpu(int cpu)
21480 diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
21481 index 216a4d7..228255a 100644
21482 --- a/arch/x86/kernel/module.c
21483 +++ b/arch/x86/kernel/module.c
21484 @@ -43,15 +43,60 @@ do { \
21485 } while (0)
21486 #endif
21487
21488 -void *module_alloc(unsigned long size)
21489 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
21490 {
21491 - if (PAGE_ALIGN(size) > MODULES_LEN)
21492 + if (!size || PAGE_ALIGN(size) > MODULES_LEN)
21493 return NULL;
21494 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
21495 - GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
21496 + GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, prot,
21497 -1, __builtin_return_address(0));
21498 }
21499
21500 +void *module_alloc(unsigned long size)
21501 +{
21502 +
21503 +#ifdef CONFIG_PAX_KERNEXEC
21504 + return __module_alloc(size, PAGE_KERNEL);
21505 +#else
21506 + return __module_alloc(size, PAGE_KERNEL_EXEC);
21507 +#endif
21508 +
21509 +}
21510 +
21511 +#ifdef CONFIG_PAX_KERNEXEC
21512 +#ifdef CONFIG_X86_32
21513 +void *module_alloc_exec(unsigned long size)
21514 +{
21515 + struct vm_struct *area;
21516 +
21517 + if (size == 0)
21518 + return NULL;
21519 +
21520 + area = __get_vm_area(size, VM_ALLOC, (unsigned long)&MODULES_EXEC_VADDR, (unsigned long)&MODULES_EXEC_END);
21521 + return area ? area->addr : NULL;
21522 +}
21523 +EXPORT_SYMBOL(module_alloc_exec);
21524 +
21525 +void module_free_exec(struct module *mod, void *module_region)
21526 +{
21527 + vunmap(module_region);
21528 +}
21529 +EXPORT_SYMBOL(module_free_exec);
21530 +#else
21531 +void module_free_exec(struct module *mod, void *module_region)
21532 +{
21533 + module_free(mod, module_region);
21534 +}
21535 +EXPORT_SYMBOL(module_free_exec);
21536 +
21537 +void *module_alloc_exec(unsigned long size)
21538 +{
21539 + return __module_alloc(size, PAGE_KERNEL_RX);
21540 +}
21541 +EXPORT_SYMBOL(module_alloc_exec);
21542 +#endif
21543 +#endif
21544 +
21545 #ifdef CONFIG_X86_32
21546 int apply_relocate(Elf32_Shdr *sechdrs,
21547 const char *strtab,
21548 @@ -62,14 +107,16 @@ int apply_relocate(Elf32_Shdr *sechdrs,
21549 unsigned int i;
21550 Elf32_Rel *rel = (void *)sechdrs[relsec].sh_addr;
21551 Elf32_Sym *sym;
21552 - uint32_t *location;
21553 + uint32_t *plocation, location;
21554
21555 DEBUGP("Applying relocate section %u to %u\n",
21556 relsec, sechdrs[relsec].sh_info);
21557 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
21558 /* This is where to make the change */
21559 - location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
21560 - + rel[i].r_offset;
21561 + plocation = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr + rel[i].r_offset;
21562 + location = (uint32_t)plocation;
21563 + if (sechdrs[sechdrs[relsec].sh_info].sh_flags & SHF_EXECINSTR)
21564 + plocation = ktla_ktva((void *)plocation);
21565 /* This is the symbol it is referring to. Note that all
21566 undefined symbols have been resolved. */
21567 sym = (Elf32_Sym *)sechdrs[symindex].sh_addr
21568 @@ -78,11 +125,15 @@ int apply_relocate(Elf32_Shdr *sechdrs,
21569 switch (ELF32_R_TYPE(rel[i].r_info)) {
21570 case R_386_32:
21571 /* We add the value into the location given */
21572 - *location += sym->st_value;
21573 + pax_open_kernel();
21574 + *plocation += sym->st_value;
21575 + pax_close_kernel();
21576 break;
21577 case R_386_PC32:
21578 /* Add the value, subtract its position */
21579 - *location += sym->st_value - (uint32_t)location;
21580 + pax_open_kernel();
21581 + *plocation += sym->st_value - location;
21582 + pax_close_kernel();
21583 break;
21584 default:
21585 pr_err("%s: Unknown relocation: %u\n",
21586 @@ -127,21 +178,30 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
21587 case R_X86_64_NONE:
21588 break;
21589 case R_X86_64_64:
21590 + pax_open_kernel();
21591 *(u64 *)loc = val;
21592 + pax_close_kernel();
21593 break;
21594 case R_X86_64_32:
21595 + pax_open_kernel();
21596 *(u32 *)loc = val;
21597 + pax_close_kernel();
21598 if (val != *(u32 *)loc)
21599 goto overflow;
21600 break;
21601 case R_X86_64_32S:
21602 + pax_open_kernel();
21603 *(s32 *)loc = val;
21604 + pax_close_kernel();
21605 if ((s64)val != *(s32 *)loc)
21606 goto overflow;
21607 break;
21608 case R_X86_64_PC32:
21609 val -= (u64)loc;
21610 + pax_open_kernel();
21611 *(u32 *)loc = val;
21612 + pax_close_kernel();
21613 +
21614 #if 0
21615 if ((s64)val != *(s32 *)loc)
21616 goto overflow;
21617 diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
21618 index ce13049..e2e9c3c 100644
21619 --- a/arch/x86/kernel/msr.c
21620 +++ b/arch/x86/kernel/msr.c
21621 @@ -233,7 +233,7 @@ static int __cpuinit msr_class_cpu_callback(struct notifier_block *nfb,
21622 return notifier_from_errno(err);
21623 }
21624
21625 -static struct notifier_block __refdata msr_class_cpu_notifier = {
21626 +static struct notifier_block msr_class_cpu_notifier = {
21627 .notifier_call = msr_class_cpu_callback,
21628 };
21629
21630 diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
21631 index 6030805..2d33f21 100644
21632 --- a/arch/x86/kernel/nmi.c
21633 +++ b/arch/x86/kernel/nmi.c
21634 @@ -105,7 +105,7 @@ static int __kprobes nmi_handle(unsigned int type, struct pt_regs *regs, bool b2
21635 return handled;
21636 }
21637
21638 -int __register_nmi_handler(unsigned int type, struct nmiaction *action)
21639 +int __register_nmi_handler(unsigned int type, const struct nmiaction *action)
21640 {
21641 struct nmi_desc *desc = nmi_to_desc(type);
21642 unsigned long flags;
21643 @@ -129,9 +129,9 @@ int __register_nmi_handler(unsigned int type, struct nmiaction *action)
21644 * event confuses some handlers (kdump uses this flag)
21645 */
21646 if (action->flags & NMI_FLAG_FIRST)
21647 - list_add_rcu(&action->list, &desc->head);
21648 + pax_list_add_rcu((struct list_head *)&action->list, &desc->head);
21649 else
21650 - list_add_tail_rcu(&action->list, &desc->head);
21651 + pax_list_add_tail_rcu((struct list_head *)&action->list, &desc->head);
21652
21653 spin_unlock_irqrestore(&desc->lock, flags);
21654 return 0;
21655 @@ -154,7 +154,7 @@ void unregister_nmi_handler(unsigned int type, const char *name)
21656 if (!strcmp(n->name, name)) {
21657 WARN(in_nmi(),
21658 "Trying to free NMI (%s) from NMI context!\n", n->name);
21659 - list_del_rcu(&n->list);
21660 + pax_list_del_rcu((struct list_head *)&n->list);
21661 break;
21662 }
21663 }
21664 @@ -479,6 +479,17 @@ static inline void nmi_nesting_postprocess(void)
21665 dotraplinkage notrace __kprobes void
21666 do_nmi(struct pt_regs *regs, long error_code)
21667 {
21668 +
21669 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
21670 + if (!user_mode(regs)) {
21671 + unsigned long cs = regs->cs & 0xFFFF;
21672 + unsigned long ip = ktva_ktla(regs->ip);
21673 +
21674 + if ((cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS) && ip <= (unsigned long)_etext)
21675 + regs->ip = ip;
21676 + }
21677 +#endif
21678 +
21679 nmi_nesting_preprocess(regs);
21680
21681 nmi_enter();
21682 diff --git a/arch/x86/kernel/nmi_selftest.c b/arch/x86/kernel/nmi_selftest.c
21683 index 6d9582e..f746287 100644
21684 --- a/arch/x86/kernel/nmi_selftest.c
21685 +++ b/arch/x86/kernel/nmi_selftest.c
21686 @@ -43,7 +43,7 @@ static void __init init_nmi_testsuite(void)
21687 {
21688 /* trap all the unknown NMIs we may generate */
21689 register_nmi_handler(NMI_UNKNOWN, nmi_unk_cb, 0, "nmi_selftest_unk",
21690 - __initdata);
21691 + __initconst);
21692 }
21693
21694 static void __init cleanup_nmi_testsuite(void)
21695 @@ -66,7 +66,7 @@ static void __init test_nmi_ipi(struct cpumask *mask)
21696 unsigned long timeout;
21697
21698 if (register_nmi_handler(NMI_LOCAL, test_nmi_ipi_callback,
21699 - NMI_FLAG_FIRST, "nmi_selftest", __initdata)) {
21700 + NMI_FLAG_FIRST, "nmi_selftest", __initconst)) {
21701 nmi_fail = FAILURE;
21702 return;
21703 }
21704 diff --git a/arch/x86/kernel/paravirt-spinlocks.c b/arch/x86/kernel/paravirt-spinlocks.c
21705 index 676b8c7..870ba04 100644
21706 --- a/arch/x86/kernel/paravirt-spinlocks.c
21707 +++ b/arch/x86/kernel/paravirt-spinlocks.c
21708 @@ -13,7 +13,7 @@ default_spin_lock_flags(arch_spinlock_t *lock, unsigned long flags)
21709 arch_spin_lock(lock);
21710 }
21711
21712 -struct pv_lock_ops pv_lock_ops = {
21713 +struct pv_lock_ops pv_lock_ops __read_only = {
21714 #ifdef CONFIG_SMP
21715 .spin_is_locked = __ticket_spin_is_locked,
21716 .spin_is_contended = __ticket_spin_is_contended,
21717 diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
21718 index 8bfb335..c1463c6 100644
21719 --- a/arch/x86/kernel/paravirt.c
21720 +++ b/arch/x86/kernel/paravirt.c
21721 @@ -55,6 +55,9 @@ u64 _paravirt_ident_64(u64 x)
21722 {
21723 return x;
21724 }
21725 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
21726 +PV_CALLEE_SAVE_REGS_THUNK(_paravirt_ident_64);
21727 +#endif
21728
21729 void __init default_banner(void)
21730 {
21731 @@ -147,15 +150,19 @@ unsigned paravirt_patch_default(u8 type, u16 clobbers, void *insnbuf,
21732 if (opfunc == NULL)
21733 /* If there's no function, patch it with a ud2a (BUG) */
21734 ret = paravirt_patch_insns(insnbuf, len, ud2a, ud2a+sizeof(ud2a));
21735 - else if (opfunc == _paravirt_nop)
21736 + else if (opfunc == (void *)_paravirt_nop)
21737 /* If the operation is a nop, then nop the callsite */
21738 ret = paravirt_patch_nop();
21739
21740 /* identity functions just return their single argument */
21741 - else if (opfunc == _paravirt_ident_32)
21742 + else if (opfunc == (void *)_paravirt_ident_32)
21743 ret = paravirt_patch_ident_32(insnbuf, len);
21744 - else if (opfunc == _paravirt_ident_64)
21745 + else if (opfunc == (void *)_paravirt_ident_64)
21746 ret = paravirt_patch_ident_64(insnbuf, len);
21747 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
21748 + else if (opfunc == (void *)__raw_callee_save__paravirt_ident_64)
21749 + ret = paravirt_patch_ident_64(insnbuf, len);
21750 +#endif
21751
21752 else if (type == PARAVIRT_PATCH(pv_cpu_ops.iret) ||
21753 type == PARAVIRT_PATCH(pv_cpu_ops.irq_enable_sysexit) ||
21754 @@ -180,7 +187,7 @@ unsigned paravirt_patch_insns(void *insnbuf, unsigned len,
21755 if (insn_len > len || start == NULL)
21756 insn_len = len;
21757 else
21758 - memcpy(insnbuf, start, insn_len);
21759 + memcpy(insnbuf, ktla_ktva(start), insn_len);
21760
21761 return insn_len;
21762 }
21763 @@ -304,7 +311,7 @@ enum paravirt_lazy_mode paravirt_get_lazy_mode(void)
21764 return this_cpu_read(paravirt_lazy_mode);
21765 }
21766
21767 -struct pv_info pv_info = {
21768 +struct pv_info pv_info __read_only = {
21769 .name = "bare hardware",
21770 .paravirt_enabled = 0,
21771 .kernel_rpl = 0,
21772 @@ -315,16 +322,16 @@ struct pv_info pv_info = {
21773 #endif
21774 };
21775
21776 -struct pv_init_ops pv_init_ops = {
21777 +struct pv_init_ops pv_init_ops __read_only = {
21778 .patch = native_patch,
21779 };
21780
21781 -struct pv_time_ops pv_time_ops = {
21782 +struct pv_time_ops pv_time_ops __read_only = {
21783 .sched_clock = native_sched_clock,
21784 .steal_clock = native_steal_clock,
21785 };
21786
21787 -struct pv_irq_ops pv_irq_ops = {
21788 +struct pv_irq_ops pv_irq_ops __read_only = {
21789 .save_fl = __PV_IS_CALLEE_SAVE(native_save_fl),
21790 .restore_fl = __PV_IS_CALLEE_SAVE(native_restore_fl),
21791 .irq_disable = __PV_IS_CALLEE_SAVE(native_irq_disable),
21792 @@ -336,7 +343,7 @@ struct pv_irq_ops pv_irq_ops = {
21793 #endif
21794 };
21795
21796 -struct pv_cpu_ops pv_cpu_ops = {
21797 +struct pv_cpu_ops pv_cpu_ops __read_only = {
21798 .cpuid = native_cpuid,
21799 .get_debugreg = native_get_debugreg,
21800 .set_debugreg = native_set_debugreg,
21801 @@ -395,21 +402,26 @@ struct pv_cpu_ops pv_cpu_ops = {
21802 .end_context_switch = paravirt_nop,
21803 };
21804
21805 -struct pv_apic_ops pv_apic_ops = {
21806 +struct pv_apic_ops pv_apic_ops __read_only= {
21807 #ifdef CONFIG_X86_LOCAL_APIC
21808 .startup_ipi_hook = paravirt_nop,
21809 #endif
21810 };
21811
21812 -#if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE)
21813 +#ifdef CONFIG_X86_32
21814 +#ifdef CONFIG_X86_PAE
21815 +/* 64-bit pagetable entries */
21816 +#define PTE_IDENT PV_CALLEE_SAVE(_paravirt_ident_64)
21817 +#else
21818 /* 32-bit pagetable entries */
21819 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_32)
21820 +#endif
21821 #else
21822 /* 64-bit pagetable entries */
21823 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_64)
21824 #endif
21825
21826 -struct pv_mmu_ops pv_mmu_ops = {
21827 +struct pv_mmu_ops pv_mmu_ops __read_only = {
21828
21829 .read_cr2 = native_read_cr2,
21830 .write_cr2 = native_write_cr2,
21831 @@ -459,6 +471,7 @@ struct pv_mmu_ops pv_mmu_ops = {
21832 .make_pud = PTE_IDENT,
21833
21834 .set_pgd = native_set_pgd,
21835 + .set_pgd_batched = native_set_pgd_batched,
21836 #endif
21837 #endif /* PAGETABLE_LEVELS >= 3 */
21838
21839 @@ -479,6 +492,12 @@ struct pv_mmu_ops pv_mmu_ops = {
21840 },
21841
21842 .set_fixmap = native_set_fixmap,
21843 +
21844 +#ifdef CONFIG_PAX_KERNEXEC
21845 + .pax_open_kernel = native_pax_open_kernel,
21846 + .pax_close_kernel = native_pax_close_kernel,
21847 +#endif
21848 +
21849 };
21850
21851 EXPORT_SYMBOL_GPL(pv_time_ops);
21852 diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c
21853 index 299d493..2ccb0ee 100644
21854 --- a/arch/x86/kernel/pci-calgary_64.c
21855 +++ b/arch/x86/kernel/pci-calgary_64.c
21856 @@ -1339,7 +1339,7 @@ static void __init get_tce_space_from_tar(void)
21857 tce_space = be64_to_cpu(readq(target));
21858 tce_space = tce_space & TAR_SW_BITS;
21859
21860 - tce_space = tce_space & (~specified_table_size);
21861 + tce_space = tce_space & (~(unsigned long)specified_table_size);
21862 info->tce_space = (u64 *)__va(tce_space);
21863 }
21864 }
21865 diff --git a/arch/x86/kernel/pci-iommu_table.c b/arch/x86/kernel/pci-iommu_table.c
21866 index 35ccf75..7a15747 100644
21867 --- a/arch/x86/kernel/pci-iommu_table.c
21868 +++ b/arch/x86/kernel/pci-iommu_table.c
21869 @@ -2,7 +2,7 @@
21870 #include <asm/iommu_table.h>
21871 #include <linux/string.h>
21872 #include <linux/kallsyms.h>
21873 -
21874 +#include <linux/sched.h>
21875
21876 #define DEBUG 1
21877
21878 diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
21879 index 6c483ba..d10ce2f 100644
21880 --- a/arch/x86/kernel/pci-swiotlb.c
21881 +++ b/arch/x86/kernel/pci-swiotlb.c
21882 @@ -32,7 +32,7 @@ static void x86_swiotlb_free_coherent(struct device *dev, size_t size,
21883 void *vaddr, dma_addr_t dma_addr,
21884 struct dma_attrs *attrs)
21885 {
21886 - swiotlb_free_coherent(dev, size, vaddr, dma_addr);
21887 + swiotlb_free_coherent(dev, size, vaddr, dma_addr, attrs);
21888 }
21889
21890 static struct dma_map_ops swiotlb_dma_ops = {
21891 diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
21892 index 14ae100..752a4f6 100644
21893 --- a/arch/x86/kernel/process.c
21894 +++ b/arch/x86/kernel/process.c
21895 @@ -36,7 +36,8 @@
21896 * section. Since TSS's are completely CPU-local, we want them
21897 * on exact cacheline boundaries, to eliminate cacheline ping-pong.
21898 */
21899 -DEFINE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss) = INIT_TSS;
21900 +struct tss_struct init_tss[NR_CPUS] ____cacheline_internodealigned_in_smp = { [0 ... NR_CPUS-1] = INIT_TSS };
21901 +EXPORT_SYMBOL(init_tss);
21902
21903 #ifdef CONFIG_X86_64
21904 static DEFINE_PER_CPU(unsigned char, is_idle);
21905 @@ -92,7 +93,7 @@ void arch_task_cache_init(void)
21906 task_xstate_cachep =
21907 kmem_cache_create("task_xstate", xstate_size,
21908 __alignof__(union thread_xstate),
21909 - SLAB_PANIC | SLAB_NOTRACK, NULL);
21910 + SLAB_PANIC | SLAB_NOTRACK | SLAB_USERCOPY, NULL);
21911 }
21912
21913 /*
21914 @@ -105,7 +106,7 @@ void exit_thread(void)
21915 unsigned long *bp = t->io_bitmap_ptr;
21916
21917 if (bp) {
21918 - struct tss_struct *tss = &per_cpu(init_tss, get_cpu());
21919 + struct tss_struct *tss = init_tss + get_cpu();
21920
21921 t->io_bitmap_ptr = NULL;
21922 clear_thread_flag(TIF_IO_BITMAP);
21923 @@ -136,7 +137,7 @@ void show_regs_common(void)
21924 board = dmi_get_system_info(DMI_BOARD_NAME);
21925
21926 printk(KERN_DEFAULT "Pid: %d, comm: %.20s %s %s %.*s %s %s%s%s\n",
21927 - current->pid, current->comm, print_tainted(),
21928 + task_pid_nr(current), current->comm, print_tainted(),
21929 init_utsname()->release,
21930 (int)strcspn(init_utsname()->version, " "),
21931 init_utsname()->version,
21932 @@ -149,6 +150,9 @@ void flush_thread(void)
21933 {
21934 struct task_struct *tsk = current;
21935
21936 +#if defined(CONFIG_X86_32) && !defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_PAX_MEMORY_UDEREF)
21937 + loadsegment(gs, 0);
21938 +#endif
21939 flush_ptrace_hw_breakpoint(tsk);
21940 memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array));
21941 drop_init_fpu(tsk);
21942 @@ -295,7 +299,7 @@ static void __exit_idle(void)
21943 void exit_idle(void)
21944 {
21945 /* idle loop has pid 0 */
21946 - if (current->pid)
21947 + if (task_pid_nr(current))
21948 return;
21949 __exit_idle();
21950 }
21951 @@ -398,7 +402,7 @@ bool xen_set_default_idle(void)
21952 return ret;
21953 }
21954 #endif
21955 -void stop_this_cpu(void *dummy)
21956 +__noreturn void stop_this_cpu(void *dummy)
21957 {
21958 local_irq_disable();
21959 /*
21960 @@ -544,16 +548,37 @@ static int __init idle_setup(char *str)
21961 }
21962 early_param("idle", idle_setup);
21963
21964 -unsigned long arch_align_stack(unsigned long sp)
21965 +#ifdef CONFIG_PAX_RANDKSTACK
21966 +void pax_randomize_kstack(struct pt_regs *regs)
21967 {
21968 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
21969 - sp -= get_random_int() % 8192;
21970 - return sp & ~0xf;
21971 -}
21972 + struct thread_struct *thread = &current->thread;
21973 + unsigned long time;
21974
21975 -unsigned long arch_randomize_brk(struct mm_struct *mm)
21976 -{
21977 - unsigned long range_end = mm->brk + 0x02000000;
21978 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
21979 -}
21980 + if (!randomize_va_space)
21981 + return;
21982 +
21983 + if (v8086_mode(regs))
21984 + return;
21985
21986 + rdtscl(time);
21987 +
21988 + /* P4 seems to return a 0 LSB, ignore it */
21989 +#ifdef CONFIG_MPENTIUM4
21990 + time &= 0x3EUL;
21991 + time <<= 2;
21992 +#elif defined(CONFIG_X86_64)
21993 + time &= 0xFUL;
21994 + time <<= 4;
21995 +#else
21996 + time &= 0x1FUL;
21997 + time <<= 3;
21998 +#endif
21999 +
22000 + thread->sp0 ^= time;
22001 + load_sp0(init_tss + smp_processor_id(), thread);
22002 +
22003 +#ifdef CONFIG_X86_64
22004 + this_cpu_write(kernel_stack, thread->sp0);
22005 +#endif
22006 +}
22007 +#endif
22008 diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
22009 index b5a8905..d9cacac 100644
22010 --- a/arch/x86/kernel/process_32.c
22011 +++ b/arch/x86/kernel/process_32.c
22012 @@ -65,6 +65,7 @@ asmlinkage void ret_from_kernel_thread(void) __asm__("ret_from_kernel_thread");
22013 unsigned long thread_saved_pc(struct task_struct *tsk)
22014 {
22015 return ((unsigned long *)tsk->thread.sp)[3];
22016 +//XXX return tsk->thread.eip;
22017 }
22018
22019 void __show_regs(struct pt_regs *regs, int all)
22020 @@ -74,21 +75,20 @@ void __show_regs(struct pt_regs *regs, int all)
22021 unsigned long sp;
22022 unsigned short ss, gs;
22023
22024 - if (user_mode_vm(regs)) {
22025 + if (user_mode(regs)) {
22026 sp = regs->sp;
22027 ss = regs->ss & 0xffff;
22028 - gs = get_user_gs(regs);
22029 } else {
22030 sp = kernel_stack_pointer(regs);
22031 savesegment(ss, ss);
22032 - savesegment(gs, gs);
22033 }
22034 + gs = get_user_gs(regs);
22035
22036 show_regs_common();
22037
22038 printk(KERN_DEFAULT "EIP: %04x:[<%08lx>] EFLAGS: %08lx CPU: %d\n",
22039 (u16)regs->cs, regs->ip, regs->flags,
22040 - smp_processor_id());
22041 + raw_smp_processor_id());
22042 print_symbol("EIP is at %s\n", regs->ip);
22043
22044 printk(KERN_DEFAULT "EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n",
22045 @@ -130,20 +130,21 @@ void release_thread(struct task_struct *dead_task)
22046 int copy_thread(unsigned long clone_flags, unsigned long sp,
22047 unsigned long arg, struct task_struct *p)
22048 {
22049 - struct pt_regs *childregs = task_pt_regs(p);
22050 + struct pt_regs *childregs = task_stack_page(p) + THREAD_SIZE - sizeof(struct pt_regs) - 8;
22051 struct task_struct *tsk;
22052 int err;
22053
22054 p->thread.sp = (unsigned long) childregs;
22055 p->thread.sp0 = (unsigned long) (childregs+1);
22056 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
22057
22058 if (unlikely(p->flags & PF_KTHREAD)) {
22059 /* kernel thread */
22060 memset(childregs, 0, sizeof(struct pt_regs));
22061 p->thread.ip = (unsigned long) ret_from_kernel_thread;
22062 - task_user_gs(p) = __KERNEL_STACK_CANARY;
22063 - childregs->ds = __USER_DS;
22064 - childregs->es = __USER_DS;
22065 + savesegment(gs, childregs->gs);
22066 + childregs->ds = __KERNEL_DS;
22067 + childregs->es = __KERNEL_DS;
22068 childregs->fs = __KERNEL_PERCPU;
22069 childregs->bx = sp; /* function */
22070 childregs->bp = arg;
22071 @@ -250,7 +251,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22072 struct thread_struct *prev = &prev_p->thread,
22073 *next = &next_p->thread;
22074 int cpu = smp_processor_id();
22075 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
22076 + struct tss_struct *tss = init_tss + cpu;
22077 fpu_switch_t fpu;
22078
22079 /* never put a printk in __switch_to... printk() calls wake_up*() indirectly */
22080 @@ -274,6 +275,10 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22081 */
22082 lazy_save_gs(prev->gs);
22083
22084 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22085 + __set_fs(task_thread_info(next_p)->addr_limit);
22086 +#endif
22087 +
22088 /*
22089 * Load the per-thread Thread-Local Storage descriptor.
22090 */
22091 @@ -304,6 +309,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22092 */
22093 arch_end_context_switch(next_p);
22094
22095 + this_cpu_write(current_task, next_p);
22096 + this_cpu_write(current_tinfo, &next_p->tinfo);
22097 +
22098 /*
22099 * Restore %gs if needed (which is common)
22100 */
22101 @@ -312,8 +320,6 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22102
22103 switch_fpu_finish(next_p, fpu);
22104
22105 - this_cpu_write(current_task, next_p);
22106 -
22107 return prev_p;
22108 }
22109
22110 @@ -343,4 +349,3 @@ unsigned long get_wchan(struct task_struct *p)
22111 } while (count++ < 16);
22112 return 0;
22113 }
22114 -
22115 diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
22116 index 0f49677..fcbf88c 100644
22117 --- a/arch/x86/kernel/process_64.c
22118 +++ b/arch/x86/kernel/process_64.c
22119 @@ -152,10 +152,11 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
22120 struct pt_regs *childregs;
22121 struct task_struct *me = current;
22122
22123 - p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE;
22124 + p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE - 16;
22125 childregs = task_pt_regs(p);
22126 p->thread.sp = (unsigned long) childregs;
22127 p->thread.usersp = me->thread.usersp;
22128 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
22129 set_tsk_thread_flag(p, TIF_FORK);
22130 p->fpu_counter = 0;
22131 p->thread.io_bitmap_ptr = NULL;
22132 @@ -274,7 +275,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22133 struct thread_struct *prev = &prev_p->thread;
22134 struct thread_struct *next = &next_p->thread;
22135 int cpu = smp_processor_id();
22136 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
22137 + struct tss_struct *tss = init_tss + cpu;
22138 unsigned fsindex, gsindex;
22139 fpu_switch_t fpu;
22140
22141 @@ -356,10 +357,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22142 prev->usersp = this_cpu_read(old_rsp);
22143 this_cpu_write(old_rsp, next->usersp);
22144 this_cpu_write(current_task, next_p);
22145 + this_cpu_write(current_tinfo, &next_p->tinfo);
22146
22147 - this_cpu_write(kernel_stack,
22148 - (unsigned long)task_stack_page(next_p) +
22149 - THREAD_SIZE - KERNEL_STACK_OFFSET);
22150 + this_cpu_write(kernel_stack, next->sp0);
22151
22152 /*
22153 * Now maybe reload the debug registers and handle I/O bitmaps
22154 @@ -428,12 +428,11 @@ unsigned long get_wchan(struct task_struct *p)
22155 if (!p || p == current || p->state == TASK_RUNNING)
22156 return 0;
22157 stack = (unsigned long)task_stack_page(p);
22158 - if (p->thread.sp < stack || p->thread.sp >= stack+THREAD_SIZE)
22159 + if (p->thread.sp < stack || p->thread.sp > stack+THREAD_SIZE-16-sizeof(u64))
22160 return 0;
22161 fp = *(u64 *)(p->thread.sp);
22162 do {
22163 - if (fp < (unsigned long)stack ||
22164 - fp >= (unsigned long)stack+THREAD_SIZE)
22165 + if (fp < stack || fp > stack+THREAD_SIZE-16-sizeof(u64))
22166 return 0;
22167 ip = *(u64 *)(fp+8);
22168 if (!in_sched_functions(ip))
22169 diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
22170 index 29a8120..a50b5ee 100644
22171 --- a/arch/x86/kernel/ptrace.c
22172 +++ b/arch/x86/kernel/ptrace.c
22173 @@ -184,14 +184,13 @@ unsigned long kernel_stack_pointer(struct pt_regs *regs)
22174 {
22175 unsigned long context = (unsigned long)regs & ~(THREAD_SIZE - 1);
22176 unsigned long sp = (unsigned long)&regs->sp;
22177 - struct thread_info *tinfo;
22178
22179 - if (context == (sp & ~(THREAD_SIZE - 1)))
22180 + if (context == ((sp + 8) & ~(THREAD_SIZE - 1)))
22181 return sp;
22182
22183 - tinfo = (struct thread_info *)context;
22184 - if (tinfo->previous_esp)
22185 - return tinfo->previous_esp;
22186 + sp = *(unsigned long *)context;
22187 + if (sp)
22188 + return sp;
22189
22190 return (unsigned long)regs;
22191 }
22192 @@ -588,7 +587,7 @@ static void ptrace_triggered(struct perf_event *bp,
22193 static unsigned long ptrace_get_dr7(struct perf_event *bp[])
22194 {
22195 int i;
22196 - int dr7 = 0;
22197 + unsigned long dr7 = 0;
22198 struct arch_hw_breakpoint *info;
22199
22200 for (i = 0; i < HBP_NUM; i++) {
22201 @@ -856,7 +855,7 @@ long arch_ptrace(struct task_struct *child, long request,
22202 unsigned long addr, unsigned long data)
22203 {
22204 int ret;
22205 - unsigned long __user *datap = (unsigned long __user *)data;
22206 + unsigned long __user *datap = (__force unsigned long __user *)data;
22207
22208 switch (request) {
22209 /* read the word at location addr in the USER area. */
22210 @@ -941,14 +940,14 @@ long arch_ptrace(struct task_struct *child, long request,
22211 if ((int) addr < 0)
22212 return -EIO;
22213 ret = do_get_thread_area(child, addr,
22214 - (struct user_desc __user *)data);
22215 + (__force struct user_desc __user *) data);
22216 break;
22217
22218 case PTRACE_SET_THREAD_AREA:
22219 if ((int) addr < 0)
22220 return -EIO;
22221 ret = do_set_thread_area(child, addr,
22222 - (struct user_desc __user *)data, 0);
22223 + (__force struct user_desc __user *) data, 0);
22224 break;
22225 #endif
22226
22227 @@ -1326,7 +1325,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
22228
22229 #ifdef CONFIG_X86_64
22230
22231 -static struct user_regset x86_64_regsets[] __read_mostly = {
22232 +static user_regset_no_const x86_64_regsets[] __read_only = {
22233 [REGSET_GENERAL] = {
22234 .core_note_type = NT_PRSTATUS,
22235 .n = sizeof(struct user_regs_struct) / sizeof(long),
22236 @@ -1367,7 +1366,7 @@ static const struct user_regset_view user_x86_64_view = {
22237 #endif /* CONFIG_X86_64 */
22238
22239 #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
22240 -static struct user_regset x86_32_regsets[] __read_mostly = {
22241 +static user_regset_no_const x86_32_regsets[] __read_only = {
22242 [REGSET_GENERAL] = {
22243 .core_note_type = NT_PRSTATUS,
22244 .n = sizeof(struct user_regs_struct32) / sizeof(u32),
22245 @@ -1420,7 +1419,7 @@ static const struct user_regset_view user_x86_32_view = {
22246 */
22247 u64 xstate_fx_sw_bytes[USER_XSTATE_FX_SW_WORDS];
22248
22249 -void update_regset_xstate_info(unsigned int size, u64 xstate_mask)
22250 +void __init update_regset_xstate_info(unsigned int size, u64 xstate_mask)
22251 {
22252 #ifdef CONFIG_X86_64
22253 x86_64_regsets[REGSET_XSTATE].n = size / sizeof(u64);
22254 @@ -1455,7 +1454,7 @@ static void fill_sigtrap_info(struct task_struct *tsk,
22255 memset(info, 0, sizeof(*info));
22256 info->si_signo = SIGTRAP;
22257 info->si_code = si_code;
22258 - info->si_addr = user_mode_vm(regs) ? (void __user *)regs->ip : NULL;
22259 + info->si_addr = user_mode(regs) ? (__force void __user *)regs->ip : NULL;
22260 }
22261
22262 void user_single_step_siginfo(struct task_struct *tsk,
22263 @@ -1484,6 +1483,10 @@ void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs,
22264 # define IS_IA32 0
22265 #endif
22266
22267 +#ifdef CONFIG_GRKERNSEC_SETXID
22268 +extern void gr_delayed_cred_worker(void);
22269 +#endif
22270 +
22271 /*
22272 * We must return the syscall number to actually look up in the table.
22273 * This can be -1L to skip running any syscall at all.
22274 @@ -1494,6 +1497,11 @@ long syscall_trace_enter(struct pt_regs *regs)
22275
22276 user_exit();
22277
22278 +#ifdef CONFIG_GRKERNSEC_SETXID
22279 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
22280 + gr_delayed_cred_worker();
22281 +#endif
22282 +
22283 /*
22284 * If we stepped into a sysenter/syscall insn, it trapped in
22285 * kernel mode; do_debug() cleared TF and set TIF_SINGLESTEP.
22286 @@ -1549,6 +1557,11 @@ void syscall_trace_leave(struct pt_regs *regs)
22287 */
22288 user_exit();
22289
22290 +#ifdef CONFIG_GRKERNSEC_SETXID
22291 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
22292 + gr_delayed_cred_worker();
22293 +#endif
22294 +
22295 audit_syscall_exit(regs);
22296
22297 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
22298 diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
22299 index 2cb9470..ff1fd80 100644
22300 --- a/arch/x86/kernel/pvclock.c
22301 +++ b/arch/x86/kernel/pvclock.c
22302 @@ -43,11 +43,11 @@ unsigned long pvclock_tsc_khz(struct pvclock_vcpu_time_info *src)
22303 return pv_tsc_khz;
22304 }
22305
22306 -static atomic64_t last_value = ATOMIC64_INIT(0);
22307 +static atomic64_unchecked_t last_value = ATOMIC64_INIT(0);
22308
22309 void pvclock_resume(void)
22310 {
22311 - atomic64_set(&last_value, 0);
22312 + atomic64_set_unchecked(&last_value, 0);
22313 }
22314
22315 u8 pvclock_read_flags(struct pvclock_vcpu_time_info *src)
22316 @@ -92,11 +92,11 @@ cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
22317 * updating at the same time, and one of them could be slightly behind,
22318 * making the assumption that last_value always go forward fail to hold.
22319 */
22320 - last = atomic64_read(&last_value);
22321 + last = atomic64_read_unchecked(&last_value);
22322 do {
22323 if (ret < last)
22324 return last;
22325 - last = atomic64_cmpxchg(&last_value, last, ret);
22326 + last = atomic64_cmpxchg_unchecked(&last_value, last, ret);
22327 } while (unlikely(last != ret));
22328
22329 return ret;
22330 diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
22331 index 76fa1e9..abf09ea 100644
22332 --- a/arch/x86/kernel/reboot.c
22333 +++ b/arch/x86/kernel/reboot.c
22334 @@ -36,7 +36,7 @@ void (*pm_power_off)(void);
22335 EXPORT_SYMBOL(pm_power_off);
22336
22337 static const struct desc_ptr no_idt = {};
22338 -static int reboot_mode;
22339 +static unsigned short reboot_mode;
22340 enum reboot_type reboot_type = BOOT_ACPI;
22341 int reboot_force;
22342
22343 @@ -157,6 +157,11 @@ static int __init set_bios_reboot(const struct dmi_system_id *d)
22344
22345 void __noreturn machine_real_restart(unsigned int type)
22346 {
22347 +
22348 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
22349 + struct desc_struct *gdt;
22350 +#endif
22351 +
22352 local_irq_disable();
22353
22354 /*
22355 @@ -184,7 +189,29 @@ void __noreturn machine_real_restart(unsigned int type)
22356
22357 /* Jump to the identity-mapped low memory code */
22358 #ifdef CONFIG_X86_32
22359 - asm volatile("jmpl *%0" : :
22360 +
22361 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
22362 + gdt = get_cpu_gdt_table(smp_processor_id());
22363 + pax_open_kernel();
22364 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22365 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
22366 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
22367 + loadsegment(ds, __KERNEL_DS);
22368 + loadsegment(es, __KERNEL_DS);
22369 + loadsegment(ss, __KERNEL_DS);
22370 +#endif
22371 +#ifdef CONFIG_PAX_KERNEXEC
22372 + gdt[GDT_ENTRY_KERNEL_CS].base0 = 0;
22373 + gdt[GDT_ENTRY_KERNEL_CS].base1 = 0;
22374 + gdt[GDT_ENTRY_KERNEL_CS].base2 = 0;
22375 + gdt[GDT_ENTRY_KERNEL_CS].limit0 = 0xffff;
22376 + gdt[GDT_ENTRY_KERNEL_CS].limit = 0xf;
22377 + gdt[GDT_ENTRY_KERNEL_CS].g = 1;
22378 +#endif
22379 + pax_close_kernel();
22380 +#endif
22381 +
22382 + asm volatile("ljmpl *%0" : :
22383 "rm" (real_mode_header->machine_real_restart_asm),
22384 "a" (type));
22385 #else
22386 @@ -531,7 +558,7 @@ void __attribute__((weak)) mach_reboot_fixups(void)
22387 * try to force a triple fault and then cycle between hitting the keyboard
22388 * controller and doing that
22389 */
22390 -static void native_machine_emergency_restart(void)
22391 +static void __noreturn native_machine_emergency_restart(void)
22392 {
22393 int i;
22394 int attempt = 0;
22395 @@ -654,13 +681,13 @@ void native_machine_shutdown(void)
22396 #endif
22397 }
22398
22399 -static void __machine_emergency_restart(int emergency)
22400 +static void __noreturn __machine_emergency_restart(int emergency)
22401 {
22402 reboot_emergency = emergency;
22403 machine_ops.emergency_restart();
22404 }
22405
22406 -static void native_machine_restart(char *__unused)
22407 +static void __noreturn native_machine_restart(char *__unused)
22408 {
22409 pr_notice("machine restart\n");
22410
22411 @@ -669,7 +696,7 @@ static void native_machine_restart(char *__unused)
22412 __machine_emergency_restart(0);
22413 }
22414
22415 -static void native_machine_halt(void)
22416 +static void __noreturn native_machine_halt(void)
22417 {
22418 /* Stop other cpus and apics */
22419 machine_shutdown();
22420 @@ -679,7 +706,7 @@ static void native_machine_halt(void)
22421 stop_this_cpu(NULL);
22422 }
22423
22424 -static void native_machine_power_off(void)
22425 +static void __noreturn native_machine_power_off(void)
22426 {
22427 if (pm_power_off) {
22428 if (!reboot_force)
22429 @@ -688,9 +715,10 @@ static void native_machine_power_off(void)
22430 }
22431 /* A fallback in case there is no PM info available */
22432 tboot_shutdown(TB_SHUTDOWN_HALT);
22433 + unreachable();
22434 }
22435
22436 -struct machine_ops machine_ops = {
22437 +struct machine_ops machine_ops __read_only = {
22438 .power_off = native_machine_power_off,
22439 .shutdown = native_machine_shutdown,
22440 .emergency_restart = native_machine_emergency_restart,
22441 diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S
22442 index 7a6f3b3..bed145d7 100644
22443 --- a/arch/x86/kernel/relocate_kernel_64.S
22444 +++ b/arch/x86/kernel/relocate_kernel_64.S
22445 @@ -11,6 +11,7 @@
22446 #include <asm/kexec.h>
22447 #include <asm/processor-flags.h>
22448 #include <asm/pgtable_types.h>
22449 +#include <asm/alternative-asm.h>
22450
22451 /*
22452 * Must be relocatable PIC code callable as a C function
22453 @@ -160,13 +161,14 @@ identity_mapped:
22454 xorq %rbp, %rbp
22455 xorq %r8, %r8
22456 xorq %r9, %r9
22457 - xorq %r10, %r9
22458 + xorq %r10, %r10
22459 xorq %r11, %r11
22460 xorq %r12, %r12
22461 xorq %r13, %r13
22462 xorq %r14, %r14
22463 xorq %r15, %r15
22464
22465 + pax_force_retaddr 0, 1
22466 ret
22467
22468 1:
22469 diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
22470 index fae9134..b7d4a57 100644
22471 --- a/arch/x86/kernel/setup.c
22472 +++ b/arch/x86/kernel/setup.c
22473 @@ -111,6 +111,7 @@
22474 #include <asm/mce.h>
22475 #include <asm/alternative.h>
22476 #include <asm/prom.h>
22477 +#include <asm/boot.h>
22478
22479 /*
22480 * max_low_pfn_mapped: highest direct mapped pfn under 4GB
22481 @@ -447,7 +448,7 @@ static void __init parse_setup_data(void)
22482
22483 switch (data->type) {
22484 case SETUP_E820_EXT:
22485 - parse_e820_ext(data);
22486 + parse_e820_ext((struct setup_data __force_kernel *)data);
22487 break;
22488 case SETUP_DTB:
22489 add_dtb(pa_data);
22490 @@ -774,7 +775,7 @@ static void __init trim_bios_range(void)
22491 * area (640->1Mb) as ram even though it is not.
22492 * take them out.
22493 */
22494 - e820_remove_range(BIOS_BEGIN, BIOS_END - BIOS_BEGIN, E820_RAM, 1);
22495 + e820_remove_range(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS, E820_RAM, 1);
22496
22497 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
22498 }
22499 @@ -844,8 +845,12 @@ static void __init trim_low_memory_range(void)
22500
22501 void __init setup_arch(char **cmdline_p)
22502 {
22503 +#ifdef CONFIG_X86_32
22504 + memblock_reserve(LOAD_PHYSICAL_ADDR, __pa_symbol(__bss_stop) - ____LOAD_PHYSICAL_ADDR);
22505 +#else
22506 memblock_reserve(__pa_symbol(_text),
22507 (unsigned long)__bss_stop - (unsigned long)_text);
22508 +#endif
22509
22510 early_reserve_initrd();
22511
22512 @@ -937,14 +942,14 @@ void __init setup_arch(char **cmdline_p)
22513
22514 if (!boot_params.hdr.root_flags)
22515 root_mountflags &= ~MS_RDONLY;
22516 - init_mm.start_code = (unsigned long) _text;
22517 - init_mm.end_code = (unsigned long) _etext;
22518 + init_mm.start_code = ktla_ktva((unsigned long) _text);
22519 + init_mm.end_code = ktla_ktva((unsigned long) _etext);
22520 init_mm.end_data = (unsigned long) _edata;
22521 init_mm.brk = _brk_end;
22522
22523 - code_resource.start = __pa_symbol(_text);
22524 - code_resource.end = __pa_symbol(_etext)-1;
22525 - data_resource.start = __pa_symbol(_etext);
22526 + code_resource.start = __pa_symbol(ktla_ktva(_text));
22527 + code_resource.end = __pa_symbol(ktla_ktva(_etext))-1;
22528 + data_resource.start = __pa_symbol(_sdata);
22529 data_resource.end = __pa_symbol(_edata)-1;
22530 bss_resource.start = __pa_symbol(__bss_start);
22531 bss_resource.end = __pa_symbol(__bss_stop)-1;
22532 diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
22533 index 5cdff03..80fa283 100644
22534 --- a/arch/x86/kernel/setup_percpu.c
22535 +++ b/arch/x86/kernel/setup_percpu.c
22536 @@ -21,19 +21,17 @@
22537 #include <asm/cpu.h>
22538 #include <asm/stackprotector.h>
22539
22540 -DEFINE_PER_CPU_READ_MOSTLY(int, cpu_number);
22541 +#ifdef CONFIG_SMP
22542 +DEFINE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
22543 EXPORT_PER_CPU_SYMBOL(cpu_number);
22544 +#endif
22545
22546 -#ifdef CONFIG_X86_64
22547 #define BOOT_PERCPU_OFFSET ((unsigned long)__per_cpu_load)
22548 -#else
22549 -#define BOOT_PERCPU_OFFSET 0
22550 -#endif
22551
22552 DEFINE_PER_CPU(unsigned long, this_cpu_off) = BOOT_PERCPU_OFFSET;
22553 EXPORT_PER_CPU_SYMBOL(this_cpu_off);
22554
22555 -unsigned long __per_cpu_offset[NR_CPUS] __read_mostly = {
22556 +unsigned long __per_cpu_offset[NR_CPUS] __read_only = {
22557 [0 ... NR_CPUS-1] = BOOT_PERCPU_OFFSET,
22558 };
22559 EXPORT_SYMBOL(__per_cpu_offset);
22560 @@ -66,7 +64,7 @@ static bool __init pcpu_need_numa(void)
22561 {
22562 #ifdef CONFIG_NEED_MULTIPLE_NODES
22563 pg_data_t *last = NULL;
22564 - unsigned int cpu;
22565 + int cpu;
22566
22567 for_each_possible_cpu(cpu) {
22568 int node = early_cpu_to_node(cpu);
22569 @@ -155,10 +153,10 @@ static inline void setup_percpu_segment(int cpu)
22570 {
22571 #ifdef CONFIG_X86_32
22572 struct desc_struct gdt;
22573 + unsigned long base = per_cpu_offset(cpu);
22574
22575 - pack_descriptor(&gdt, per_cpu_offset(cpu), 0xFFFFF,
22576 - 0x2 | DESCTYPE_S, 0x8);
22577 - gdt.s = 1;
22578 + pack_descriptor(&gdt, base, (VMALLOC_END - base - 1) >> PAGE_SHIFT,
22579 + 0x83 | DESCTYPE_S, 0xC);
22580 write_gdt_entry(get_cpu_gdt_table(cpu),
22581 GDT_ENTRY_PERCPU, &gdt, DESCTYPE_S);
22582 #endif
22583 @@ -219,6 +217,11 @@ void __init setup_per_cpu_areas(void)
22584 /* alrighty, percpu areas up and running */
22585 delta = (unsigned long)pcpu_base_addr - (unsigned long)__per_cpu_start;
22586 for_each_possible_cpu(cpu) {
22587 +#ifdef CONFIG_CC_STACKPROTECTOR
22588 +#ifdef CONFIG_X86_32
22589 + unsigned long canary = per_cpu(stack_canary.canary, cpu);
22590 +#endif
22591 +#endif
22592 per_cpu_offset(cpu) = delta + pcpu_unit_offsets[cpu];
22593 per_cpu(this_cpu_off, cpu) = per_cpu_offset(cpu);
22594 per_cpu(cpu_number, cpu) = cpu;
22595 @@ -259,6 +262,12 @@ void __init setup_per_cpu_areas(void)
22596 */
22597 set_cpu_numa_node(cpu, early_cpu_to_node(cpu));
22598 #endif
22599 +#ifdef CONFIG_CC_STACKPROTECTOR
22600 +#ifdef CONFIG_X86_32
22601 + if (!cpu)
22602 + per_cpu(stack_canary.canary, cpu) = canary;
22603 +#endif
22604 +#endif
22605 /*
22606 * Up to this point, the boot CPU has been using .init.data
22607 * area. Reload any changed state for the boot CPU.
22608 diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
22609 index 6956299..f20beae 100644
22610 --- a/arch/x86/kernel/signal.c
22611 +++ b/arch/x86/kernel/signal.c
22612 @@ -196,7 +196,7 @@ static unsigned long align_sigframe(unsigned long sp)
22613 * Align the stack pointer according to the i386 ABI,
22614 * i.e. so that on function entry ((sp + 4) & 15) == 0.
22615 */
22616 - sp = ((sp + 4) & -16ul) - 4;
22617 + sp = ((sp - 12) & -16ul) - 4;
22618 #else /* !CONFIG_X86_32 */
22619 sp = round_down(sp, 16) - 8;
22620 #endif
22621 @@ -304,9 +304,9 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
22622 }
22623
22624 if (current->mm->context.vdso)
22625 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
22626 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
22627 else
22628 - restorer = &frame->retcode;
22629 + restorer = (void __user *)&frame->retcode;
22630 if (ksig->ka.sa.sa_flags & SA_RESTORER)
22631 restorer = ksig->ka.sa.sa_restorer;
22632
22633 @@ -320,7 +320,7 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
22634 * reasons and because gdb uses it as a signature to notice
22635 * signal handler stack frames.
22636 */
22637 - err |= __put_user(*((u64 *)&retcode), (u64 *)frame->retcode);
22638 + err |= __put_user(*((u64 *)&retcode), (u64 __user *)frame->retcode);
22639
22640 if (err)
22641 return -EFAULT;
22642 @@ -367,7 +367,10 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
22643 err |= __save_altstack(&frame->uc.uc_stack, regs->sp);
22644
22645 /* Set up to return from userspace. */
22646 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
22647 + if (current->mm->context.vdso)
22648 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
22649 + else
22650 + restorer = (void __user *)&frame->retcode;
22651 if (ksig->ka.sa.sa_flags & SA_RESTORER)
22652 restorer = ksig->ka.sa.sa_restorer;
22653 put_user_ex(restorer, &frame->pretcode);
22654 @@ -379,7 +382,7 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
22655 * reasons and because gdb uses it as a signature to notice
22656 * signal handler stack frames.
22657 */
22658 - put_user_ex(*((u64 *)&rt_retcode), (u64 *)frame->retcode);
22659 + put_user_ex(*((u64 *)&rt_retcode), (u64 __user *)frame->retcode);
22660 } put_user_catch(err);
22661
22662 err |= copy_siginfo_to_user(&frame->info, &ksig->info);
22663 @@ -615,7 +618,12 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
22664 {
22665 int usig = signr_convert(ksig->sig);
22666 sigset_t *set = sigmask_to_save();
22667 - compat_sigset_t *cset = (compat_sigset_t *) set;
22668 + sigset_t sigcopy;
22669 + compat_sigset_t *cset;
22670 +
22671 + sigcopy = *set;
22672 +
22673 + cset = (compat_sigset_t *) &sigcopy;
22674
22675 /* Set up the stack frame */
22676 if (is_ia32_frame()) {
22677 @@ -626,7 +634,7 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
22678 } else if (is_x32_frame()) {
22679 return x32_setup_rt_frame(ksig, cset, regs);
22680 } else {
22681 - return __setup_rt_frame(ksig->sig, ksig, set, regs);
22682 + return __setup_rt_frame(ksig->sig, ksig, &sigcopy, regs);
22683 }
22684 }
22685
22686 diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c
22687 index 48d2b7d..90d328a 100644
22688 --- a/arch/x86/kernel/smp.c
22689 +++ b/arch/x86/kernel/smp.c
22690 @@ -285,7 +285,7 @@ static int __init nonmi_ipi_setup(char *str)
22691
22692 __setup("nonmi_ipi", nonmi_ipi_setup);
22693
22694 -struct smp_ops smp_ops = {
22695 +struct smp_ops smp_ops __read_only = {
22696 .smp_prepare_boot_cpu = native_smp_prepare_boot_cpu,
22697 .smp_prepare_cpus = native_smp_prepare_cpus,
22698 .smp_cpus_done = native_smp_cpus_done,
22699 diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
22700 index 9f190a2..90a0688 100644
22701 --- a/arch/x86/kernel/smpboot.c
22702 +++ b/arch/x86/kernel/smpboot.c
22703 @@ -748,6 +748,7 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
22704 idle->thread.sp = (unsigned long) (((struct pt_regs *)
22705 (THREAD_SIZE + task_stack_page(idle))) - 1);
22706 per_cpu(current_task, cpu) = idle;
22707 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
22708
22709 #ifdef CONFIG_X86_32
22710 /* Stack for startup_32 can be just as for start_secondary onwards */
22711 @@ -755,11 +756,13 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
22712 #else
22713 clear_tsk_thread_flag(idle, TIF_FORK);
22714 initial_gs = per_cpu_offset(cpu);
22715 - per_cpu(kernel_stack, cpu) =
22716 - (unsigned long)task_stack_page(idle) -
22717 - KERNEL_STACK_OFFSET + THREAD_SIZE;
22718 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
22719 #endif
22720 +
22721 + pax_open_kernel();
22722 early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
22723 + pax_close_kernel();
22724 +
22725 initial_code = (unsigned long)start_secondary;
22726 stack_start = idle->thread.sp;
22727
22728 @@ -908,6 +911,15 @@ int __cpuinit native_cpu_up(unsigned int cpu, struct task_struct *tidle)
22729 /* the FPU context is blank, nobody can own it */
22730 __cpu_disable_lazy_restore(cpu);
22731
22732 +#ifdef CONFIG_PAX_PER_CPU_PGD
22733 + clone_pgd_range(get_cpu_pgd(cpu) + KERNEL_PGD_BOUNDARY,
22734 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
22735 + KERNEL_PGD_PTRS);
22736 +#endif
22737 +
22738 + /* the FPU context is blank, nobody can own it */
22739 + __cpu_disable_lazy_restore(cpu);
22740 +
22741 err = do_boot_cpu(apicid, cpu, tidle);
22742 if (err) {
22743 pr_debug("do_boot_cpu failed %d\n", err);
22744 diff --git a/arch/x86/kernel/step.c b/arch/x86/kernel/step.c
22745 index 9b4d51d..5d28b58 100644
22746 --- a/arch/x86/kernel/step.c
22747 +++ b/arch/x86/kernel/step.c
22748 @@ -27,10 +27,10 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
22749 struct desc_struct *desc;
22750 unsigned long base;
22751
22752 - seg &= ~7UL;
22753 + seg >>= 3;
22754
22755 mutex_lock(&child->mm->context.lock);
22756 - if (unlikely((seg >> 3) >= child->mm->context.size))
22757 + if (unlikely(seg >= child->mm->context.size))
22758 addr = -1L; /* bogus selector, access would fault */
22759 else {
22760 desc = child->mm->context.ldt + seg;
22761 @@ -42,7 +42,8 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
22762 addr += base;
22763 }
22764 mutex_unlock(&child->mm->context.lock);
22765 - }
22766 + } else if (seg == __KERNEL_CS || seg == __KERNEXEC_KERNEL_CS)
22767 + addr = ktla_ktva(addr);
22768
22769 return addr;
22770 }
22771 @@ -53,6 +54,9 @@ static int is_setting_trap_flag(struct task_struct *child, struct pt_regs *regs)
22772 unsigned char opcode[15];
22773 unsigned long addr = convert_ip_to_linear(child, regs);
22774
22775 + if (addr == -EINVAL)
22776 + return 0;
22777 +
22778 copied = access_process_vm(child, addr, opcode, sizeof(opcode), 0);
22779 for (i = 0; i < copied; i++) {
22780 switch (opcode[i]) {
22781 diff --git a/arch/x86/kernel/sys_i386_32.c b/arch/x86/kernel/sys_i386_32.c
22782 new file mode 100644
22783 index 0000000..207bec6
22784 --- /dev/null
22785 +++ b/arch/x86/kernel/sys_i386_32.c
22786 @@ -0,0 +1,250 @@
22787 +/*
22788 + * This file contains various random system calls that
22789 + * have a non-standard calling sequence on the Linux/i386
22790 + * platform.
22791 + */
22792 +
22793 +#include <linux/errno.h>
22794 +#include <linux/sched.h>
22795 +#include <linux/mm.h>
22796 +#include <linux/fs.h>
22797 +#include <linux/smp.h>
22798 +#include <linux/sem.h>
22799 +#include <linux/msg.h>
22800 +#include <linux/shm.h>
22801 +#include <linux/stat.h>
22802 +#include <linux/syscalls.h>
22803 +#include <linux/mman.h>
22804 +#include <linux/file.h>
22805 +#include <linux/utsname.h>
22806 +#include <linux/ipc.h>
22807 +
22808 +#include <linux/uaccess.h>
22809 +#include <linux/unistd.h>
22810 +
22811 +#include <asm/syscalls.h>
22812 +
22813 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags)
22814 +{
22815 + unsigned long pax_task_size = TASK_SIZE;
22816 +
22817 +#ifdef CONFIG_PAX_SEGMEXEC
22818 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
22819 + pax_task_size = SEGMEXEC_TASK_SIZE;
22820 +#endif
22821 +
22822 + if (flags & MAP_FIXED)
22823 + if (len > pax_task_size || addr > pax_task_size - len)
22824 + return -EINVAL;
22825 +
22826 + return 0;
22827 +}
22828 +
22829 +unsigned long
22830 +arch_get_unmapped_area(struct file *filp, unsigned long addr,
22831 + unsigned long len, unsigned long pgoff, unsigned long flags)
22832 +{
22833 + struct mm_struct *mm = current->mm;
22834 + struct vm_area_struct *vma;
22835 + unsigned long start_addr, pax_task_size = TASK_SIZE;
22836 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
22837 +
22838 +#ifdef CONFIG_PAX_SEGMEXEC
22839 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
22840 + pax_task_size = SEGMEXEC_TASK_SIZE;
22841 +#endif
22842 +
22843 + pax_task_size -= PAGE_SIZE;
22844 +
22845 + if (len > pax_task_size)
22846 + return -ENOMEM;
22847 +
22848 + if (flags & MAP_FIXED)
22849 + return addr;
22850 +
22851 +#ifdef CONFIG_PAX_RANDMMAP
22852 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
22853 +#endif
22854 +
22855 + if (addr) {
22856 + addr = PAGE_ALIGN(addr);
22857 + if (pax_task_size - len >= addr) {
22858 + vma = find_vma(mm, addr);
22859 + if (check_heap_stack_gap(vma, addr, len, offset))
22860 + return addr;
22861 + }
22862 + }
22863 + if (len > mm->cached_hole_size) {
22864 + start_addr = addr = mm->free_area_cache;
22865 + } else {
22866 + start_addr = addr = mm->mmap_base;
22867 + mm->cached_hole_size = 0;
22868 + }
22869 +
22870 +#ifdef CONFIG_PAX_PAGEEXEC
22871 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE) && start_addr >= mm->mmap_base) {
22872 + start_addr = 0x00110000UL;
22873 +
22874 +#ifdef CONFIG_PAX_RANDMMAP
22875 + if (mm->pax_flags & MF_PAX_RANDMMAP)
22876 + start_addr += mm->delta_mmap & 0x03FFF000UL;
22877 +#endif
22878 +
22879 + if (mm->start_brk <= start_addr && start_addr < mm->mmap_base)
22880 + start_addr = addr = mm->mmap_base;
22881 + else
22882 + addr = start_addr;
22883 + }
22884 +#endif
22885 +
22886 +full_search:
22887 + for (vma = find_vma(mm, addr); ; vma = vma->vm_next) {
22888 + /* At this point: (!vma || addr < vma->vm_end). */
22889 + if (pax_task_size - len < addr) {
22890 + /*
22891 + * Start a new search - just in case we missed
22892 + * some holes.
22893 + */
22894 + if (start_addr != mm->mmap_base) {
22895 + start_addr = addr = mm->mmap_base;
22896 + mm->cached_hole_size = 0;
22897 + goto full_search;
22898 + }
22899 + return -ENOMEM;
22900 + }
22901 + if (check_heap_stack_gap(vma, addr, len, offset))
22902 + break;
22903 + if (addr + mm->cached_hole_size < vma->vm_start)
22904 + mm->cached_hole_size = vma->vm_start - addr;
22905 + addr = vma->vm_end;
22906 + if (mm->start_brk <= addr && addr < mm->mmap_base) {
22907 + start_addr = addr = mm->mmap_base;
22908 + mm->cached_hole_size = 0;
22909 + goto full_search;
22910 + }
22911 + }
22912 +
22913 + /*
22914 + * Remember the place where we stopped the search:
22915 + */
22916 + mm->free_area_cache = addr + len;
22917 + return addr;
22918 +}
22919 +
22920 +unsigned long
22921 +arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
22922 + const unsigned long len, const unsigned long pgoff,
22923 + const unsigned long flags)
22924 +{
22925 + struct vm_area_struct *vma;
22926 + struct mm_struct *mm = current->mm;
22927 + unsigned long base = mm->mmap_base, addr = addr0, pax_task_size = TASK_SIZE;
22928 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
22929 +
22930 +#ifdef CONFIG_PAX_SEGMEXEC
22931 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
22932 + pax_task_size = SEGMEXEC_TASK_SIZE;
22933 +#endif
22934 +
22935 + pax_task_size -= PAGE_SIZE;
22936 +
22937 + /* requested length too big for entire address space */
22938 + if (len > pax_task_size)
22939 + return -ENOMEM;
22940 +
22941 + if (flags & MAP_FIXED)
22942 + return addr;
22943 +
22944 +#ifdef CONFIG_PAX_PAGEEXEC
22945 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE))
22946 + goto bottomup;
22947 +#endif
22948 +
22949 +#ifdef CONFIG_PAX_RANDMMAP
22950 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
22951 +#endif
22952 +
22953 + /* requesting a specific address */
22954 + if (addr) {
22955 + addr = PAGE_ALIGN(addr);
22956 + if (pax_task_size - len >= addr) {
22957 + vma = find_vma(mm, addr);
22958 + if (check_heap_stack_gap(vma, addr, len, offset))
22959 + return addr;
22960 + }
22961 + }
22962 +
22963 + /* check if free_area_cache is useful for us */
22964 + if (len <= mm->cached_hole_size) {
22965 + mm->cached_hole_size = 0;
22966 + mm->free_area_cache = mm->mmap_base;
22967 + }
22968 +
22969 + /* either no address requested or can't fit in requested address hole */
22970 + addr = mm->free_area_cache;
22971 +
22972 + /* make sure it can fit in the remaining address space */
22973 + if (addr > len) {
22974 + vma = find_vma(mm, addr-len);
22975 + if (check_heap_stack_gap(vma, addr - len, len, offset))
22976 + /* remember the address as a hint for next time */
22977 + return (mm->free_area_cache = addr-len);
22978 + }
22979 +
22980 + if (mm->mmap_base < len)
22981 + goto bottomup;
22982 +
22983 + addr = mm->mmap_base-len;
22984 +
22985 + do {
22986 + /*
22987 + * Lookup failure means no vma is above this address,
22988 + * else if new region fits below vma->vm_start,
22989 + * return with success:
22990 + */
22991 + vma = find_vma(mm, addr);
22992 + if (check_heap_stack_gap(vma, addr, len, offset))
22993 + /* remember the address as a hint for next time */
22994 + return (mm->free_area_cache = addr);
22995 +
22996 + /* remember the largest hole we saw so far */
22997 + if (addr + mm->cached_hole_size < vma->vm_start)
22998 + mm->cached_hole_size = vma->vm_start - addr;
22999 +
23000 + /* try just below the current vma->vm_start */
23001 + addr = skip_heap_stack_gap(vma, len, offset);
23002 + } while (!IS_ERR_VALUE(addr));
23003 +
23004 +bottomup:
23005 + /*
23006 + * A failed mmap() very likely causes application failure,
23007 + * so fall back to the bottom-up function here. This scenario
23008 + * can happen with large stack limits and large mmap()
23009 + * allocations.
23010 + */
23011 +
23012 +#ifdef CONFIG_PAX_SEGMEXEC
23013 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
23014 + mm->mmap_base = SEGMEXEC_TASK_UNMAPPED_BASE;
23015 + else
23016 +#endif
23017 +
23018 + mm->mmap_base = TASK_UNMAPPED_BASE;
23019 +
23020 +#ifdef CONFIG_PAX_RANDMMAP
23021 + if (mm->pax_flags & MF_PAX_RANDMMAP)
23022 + mm->mmap_base += mm->delta_mmap;
23023 +#endif
23024 +
23025 + mm->free_area_cache = mm->mmap_base;
23026 + mm->cached_hole_size = ~0UL;
23027 + addr = arch_get_unmapped_area(filp, addr0, len, pgoff, flags);
23028 + /*
23029 + * Restore the topdown base:
23030 + */
23031 + mm->mmap_base = base;
23032 + mm->free_area_cache = base;
23033 + mm->cached_hole_size = ~0UL;
23034 +
23035 + return addr;
23036 +}
23037 diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
23038 index dbded5a..ace2781 100644
23039 --- a/arch/x86/kernel/sys_x86_64.c
23040 +++ b/arch/x86/kernel/sys_x86_64.c
23041 @@ -81,8 +81,8 @@ out:
23042 return error;
23043 }
23044
23045 -static void find_start_end(unsigned long flags, unsigned long *begin,
23046 - unsigned long *end)
23047 +static void find_start_end(struct mm_struct *mm, unsigned long flags,
23048 + unsigned long *begin, unsigned long *end)
23049 {
23050 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT)) {
23051 unsigned long new_begin;
23052 @@ -101,7 +101,7 @@ static void find_start_end(unsigned long flags, unsigned long *begin,
23053 *begin = new_begin;
23054 }
23055 } else {
23056 - *begin = TASK_UNMAPPED_BASE;
23057 + *begin = mm->mmap_base;
23058 *end = TASK_SIZE;
23059 }
23060 }
23061 @@ -114,20 +114,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
23062 struct vm_area_struct *vma;
23063 struct vm_unmapped_area_info info;
23064 unsigned long begin, end;
23065 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
23066
23067 if (flags & MAP_FIXED)
23068 return addr;
23069
23070 - find_start_end(flags, &begin, &end);
23071 + find_start_end(mm, flags, &begin, &end);
23072
23073 if (len > end)
23074 return -ENOMEM;
23075
23076 +#ifdef CONFIG_PAX_RANDMMAP
23077 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23078 +#endif
23079 +
23080 if (addr) {
23081 addr = PAGE_ALIGN(addr);
23082 vma = find_vma(mm, addr);
23083 - if (end - len >= addr &&
23084 - (!vma || addr + len <= vma->vm_start))
23085 + if (end - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
23086 return addr;
23087 }
23088
23089 @@ -137,6 +141,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
23090 info.high_limit = end;
23091 info.align_mask = filp ? get_align_mask() : 0;
23092 info.align_offset = pgoff << PAGE_SHIFT;
23093 + info.threadstack_offset = offset;
23094 return vm_unmapped_area(&info);
23095 }
23096
23097 @@ -149,6 +154,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
23098 struct mm_struct *mm = current->mm;
23099 unsigned long addr = addr0;
23100 struct vm_unmapped_area_info info;
23101 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
23102
23103 /* requested length too big for entire address space */
23104 if (len > TASK_SIZE)
23105 @@ -161,12 +167,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
23106 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT))
23107 goto bottomup;
23108
23109 +#ifdef CONFIG_PAX_RANDMMAP
23110 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23111 +#endif
23112 +
23113 /* requesting a specific address */
23114 if (addr) {
23115 addr = PAGE_ALIGN(addr);
23116 vma = find_vma(mm, addr);
23117 - if (TASK_SIZE - len >= addr &&
23118 - (!vma || addr + len <= vma->vm_start))
23119 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
23120 return addr;
23121 }
23122
23123 @@ -176,6 +185,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
23124 info.high_limit = mm->mmap_base;
23125 info.align_mask = filp ? get_align_mask() : 0;
23126 info.align_offset = pgoff << PAGE_SHIFT;
23127 + info.threadstack_offset = offset;
23128 addr = vm_unmapped_area(&info);
23129 if (!(addr & ~PAGE_MASK))
23130 return addr;
23131 diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c
23132 index f84fe00..f41d9f1 100644
23133 --- a/arch/x86/kernel/tboot.c
23134 +++ b/arch/x86/kernel/tboot.c
23135 @@ -220,7 +220,7 @@ static int tboot_setup_sleep(void)
23136
23137 void tboot_shutdown(u32 shutdown_type)
23138 {
23139 - void (*shutdown)(void);
23140 + void (* __noreturn shutdown)(void);
23141
23142 if (!tboot_enabled())
23143 return;
23144 @@ -242,7 +242,7 @@ void tboot_shutdown(u32 shutdown_type)
23145
23146 switch_to_tboot_pt();
23147
23148 - shutdown = (void(*)(void))(unsigned long)tboot->shutdown_entry;
23149 + shutdown = (void *)tboot->shutdown_entry;
23150 shutdown();
23151
23152 /* should not reach here */
23153 @@ -300,7 +300,7 @@ static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control)
23154 return 0;
23155 }
23156
23157 -static atomic_t ap_wfs_count;
23158 +static atomic_unchecked_t ap_wfs_count;
23159
23160 static int tboot_wait_for_aps(int num_aps)
23161 {
23162 @@ -324,16 +324,16 @@ static int __cpuinit tboot_cpu_callback(struct notifier_block *nfb,
23163 {
23164 switch (action) {
23165 case CPU_DYING:
23166 - atomic_inc(&ap_wfs_count);
23167 + atomic_inc_unchecked(&ap_wfs_count);
23168 if (num_online_cpus() == 1)
23169 - if (tboot_wait_for_aps(atomic_read(&ap_wfs_count)))
23170 + if (tboot_wait_for_aps(atomic_read_unchecked(&ap_wfs_count)))
23171 return NOTIFY_BAD;
23172 break;
23173 }
23174 return NOTIFY_OK;
23175 }
23176
23177 -static struct notifier_block tboot_cpu_notifier __cpuinitdata =
23178 +static struct notifier_block tboot_cpu_notifier =
23179 {
23180 .notifier_call = tboot_cpu_callback,
23181 };
23182 @@ -345,7 +345,7 @@ static __init int tboot_late_init(void)
23183
23184 tboot_create_trampoline();
23185
23186 - atomic_set(&ap_wfs_count, 0);
23187 + atomic_set_unchecked(&ap_wfs_count, 0);
23188 register_hotcpu_notifier(&tboot_cpu_notifier);
23189
23190 acpi_os_set_prepare_sleep(&tboot_sleep);
23191 diff --git a/arch/x86/kernel/time.c b/arch/x86/kernel/time.c
23192 index 24d3c91..d06b473 100644
23193 --- a/arch/x86/kernel/time.c
23194 +++ b/arch/x86/kernel/time.c
23195 @@ -30,9 +30,9 @@ unsigned long profile_pc(struct pt_regs *regs)
23196 {
23197 unsigned long pc = instruction_pointer(regs);
23198
23199 - if (!user_mode_vm(regs) && in_lock_functions(pc)) {
23200 + if (!user_mode(regs) && in_lock_functions(pc)) {
23201 #ifdef CONFIG_FRAME_POINTER
23202 - return *(unsigned long *)(regs->bp + sizeof(long));
23203 + return ktla_ktva(*(unsigned long *)(regs->bp + sizeof(long)));
23204 #else
23205 unsigned long *sp =
23206 (unsigned long *)kernel_stack_pointer(regs);
23207 @@ -41,11 +41,17 @@ unsigned long profile_pc(struct pt_regs *regs)
23208 * or above a saved flags. Eflags has bits 22-31 zero,
23209 * kernel addresses don't.
23210 */
23211 +
23212 +#ifdef CONFIG_PAX_KERNEXEC
23213 + return ktla_ktva(sp[0]);
23214 +#else
23215 if (sp[0] >> 22)
23216 return sp[0];
23217 if (sp[1] >> 22)
23218 return sp[1];
23219 #endif
23220 +
23221 +#endif
23222 }
23223 return pc;
23224 }
23225 diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c
23226 index 9d9d2f9..cad418a 100644
23227 --- a/arch/x86/kernel/tls.c
23228 +++ b/arch/x86/kernel/tls.c
23229 @@ -84,6 +84,11 @@ int do_set_thread_area(struct task_struct *p, int idx,
23230 if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)
23231 return -EINVAL;
23232
23233 +#ifdef CONFIG_PAX_SEGMEXEC
23234 + if ((p->mm->pax_flags & MF_PAX_SEGMEXEC) && (info.contents & MODIFY_LDT_CONTENTS_CODE))
23235 + return -EINVAL;
23236 +#endif
23237 +
23238 set_tls_desc(p, idx, &info, 1);
23239
23240 return 0;
23241 @@ -204,7 +209,7 @@ int regset_tls_set(struct task_struct *target, const struct user_regset *regset,
23242
23243 if (kbuf)
23244 info = kbuf;
23245 - else if (__copy_from_user(infobuf, ubuf, count))
23246 + else if (count > sizeof infobuf || __copy_from_user(infobuf, ubuf, count))
23247 return -EFAULT;
23248 else
23249 info = infobuf;
23250 diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
23251 index 68bda7a..3ec7bb7 100644
23252 --- a/arch/x86/kernel/traps.c
23253 +++ b/arch/x86/kernel/traps.c
23254 @@ -68,12 +68,6 @@
23255 #include <asm/setup.h>
23256
23257 asmlinkage int system_call(void);
23258 -
23259 -/*
23260 - * The IDT has to be page-aligned to simplify the Pentium
23261 - * F0 0F bug workaround.
23262 - */
23263 -gate_desc idt_table[NR_VECTORS] __page_aligned_data = { { { { 0, 0 } } }, };
23264 #endif
23265
23266 DECLARE_BITMAP(used_vectors, NR_VECTORS);
23267 @@ -106,11 +100,11 @@ static inline void preempt_conditional_cli(struct pt_regs *regs)
23268 }
23269
23270 static int __kprobes
23271 -do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23272 +do_trap_no_signal(struct task_struct *tsk, int trapnr, const char *str,
23273 struct pt_regs *regs, long error_code)
23274 {
23275 #ifdef CONFIG_X86_32
23276 - if (regs->flags & X86_VM_MASK) {
23277 + if (v8086_mode(regs)) {
23278 /*
23279 * Traps 0, 1, 3, 4, and 5 should be forwarded to vm86.
23280 * On nmi (interrupt 2), do_trap should not be called.
23281 @@ -123,12 +117,24 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23282 return -1;
23283 }
23284 #endif
23285 - if (!user_mode(regs)) {
23286 + if (!user_mode_novm(regs)) {
23287 if (!fixup_exception(regs)) {
23288 tsk->thread.error_code = error_code;
23289 tsk->thread.trap_nr = trapnr;
23290 +
23291 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23292 + if (trapnr == 12 && ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS))
23293 + str = "PAX: suspicious stack segment fault";
23294 +#endif
23295 +
23296 die(str, regs, error_code);
23297 }
23298 +
23299 +#ifdef CONFIG_PAX_REFCOUNT
23300 + if (trapnr == 4)
23301 + pax_report_refcount_overflow(regs);
23302 +#endif
23303 +
23304 return 0;
23305 }
23306
23307 @@ -136,7 +142,7 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23308 }
23309
23310 static void __kprobes
23311 -do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
23312 +do_trap(int trapnr, int signr, const char *str, struct pt_regs *regs,
23313 long error_code, siginfo_t *info)
23314 {
23315 struct task_struct *tsk = current;
23316 @@ -160,7 +166,7 @@ do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
23317 if (show_unhandled_signals && unhandled_signal(tsk, signr) &&
23318 printk_ratelimit()) {
23319 pr_info("%s[%d] trap %s ip:%lx sp:%lx error:%lx",
23320 - tsk->comm, tsk->pid, str,
23321 + tsk->comm, task_pid_nr(tsk), str,
23322 regs->ip, regs->sp, error_code);
23323 print_vma_addr(" in ", regs->ip);
23324 pr_cont("\n");
23325 @@ -266,7 +272,7 @@ do_general_protection(struct pt_regs *regs, long error_code)
23326 conditional_sti(regs);
23327
23328 #ifdef CONFIG_X86_32
23329 - if (regs->flags & X86_VM_MASK) {
23330 + if (v8086_mode(regs)) {
23331 local_irq_enable();
23332 handle_vm86_fault((struct kernel_vm86_regs *) regs, error_code);
23333 goto exit;
23334 @@ -274,18 +280,42 @@ do_general_protection(struct pt_regs *regs, long error_code)
23335 #endif
23336
23337 tsk = current;
23338 - if (!user_mode(regs)) {
23339 + if (!user_mode_novm(regs)) {
23340 if (fixup_exception(regs))
23341 goto exit;
23342
23343 tsk->thread.error_code = error_code;
23344 tsk->thread.trap_nr = X86_TRAP_GP;
23345 if (notify_die(DIE_GPF, "general protection fault", regs, error_code,
23346 - X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP)
23347 + X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP) {
23348 +
23349 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23350 + if ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS)
23351 + die("PAX: suspicious general protection fault", regs, error_code);
23352 + else
23353 +#endif
23354 +
23355 die("general protection fault", regs, error_code);
23356 + }
23357 goto exit;
23358 }
23359
23360 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
23361 + if (!(__supported_pte_mask & _PAGE_NX) && tsk->mm && (tsk->mm->pax_flags & MF_PAX_PAGEEXEC)) {
23362 + struct mm_struct *mm = tsk->mm;
23363 + unsigned long limit;
23364 +
23365 + down_write(&mm->mmap_sem);
23366 + limit = mm->context.user_cs_limit;
23367 + if (limit < TASK_SIZE) {
23368 + track_exec_limit(mm, limit, TASK_SIZE, VM_EXEC);
23369 + up_write(&mm->mmap_sem);
23370 + return;
23371 + }
23372 + up_write(&mm->mmap_sem);
23373 + }
23374 +#endif
23375 +
23376 tsk->thread.error_code = error_code;
23377 tsk->thread.trap_nr = X86_TRAP_GP;
23378
23379 @@ -440,7 +470,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
23380 /* It's safe to allow irq's after DR6 has been saved */
23381 preempt_conditional_sti(regs);
23382
23383 - if (regs->flags & X86_VM_MASK) {
23384 + if (v8086_mode(regs)) {
23385 handle_vm86_trap((struct kernel_vm86_regs *) regs, error_code,
23386 X86_TRAP_DB);
23387 preempt_conditional_cli(regs);
23388 @@ -455,7 +485,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
23389 * We already checked v86 mode above, so we can check for kernel mode
23390 * by just checking the CPL of CS.
23391 */
23392 - if ((dr6 & DR_STEP) && !user_mode(regs)) {
23393 + if ((dr6 & DR_STEP) && !user_mode_novm(regs)) {
23394 tsk->thread.debugreg6 &= ~DR_STEP;
23395 set_tsk_thread_flag(tsk, TIF_SINGLESTEP);
23396 regs->flags &= ~X86_EFLAGS_TF;
23397 @@ -487,7 +517,7 @@ void math_error(struct pt_regs *regs, int error_code, int trapnr)
23398 return;
23399 conditional_sti(regs);
23400
23401 - if (!user_mode_vm(regs))
23402 + if (!user_mode(regs))
23403 {
23404 if (!fixup_exception(regs)) {
23405 task->thread.error_code = error_code;
23406 diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c
23407 index 0ba4cfb..4596bec 100644
23408 --- a/arch/x86/kernel/uprobes.c
23409 +++ b/arch/x86/kernel/uprobes.c
23410 @@ -629,7 +629,7 @@ int arch_uprobe_exception_notify(struct notifier_block *self, unsigned long val,
23411 int ret = NOTIFY_DONE;
23412
23413 /* We are only interested in userspace traps */
23414 - if (regs && !user_mode_vm(regs))
23415 + if (regs && !user_mode(regs))
23416 return NOTIFY_DONE;
23417
23418 switch (val) {
23419 diff --git a/arch/x86/kernel/verify_cpu.S b/arch/x86/kernel/verify_cpu.S
23420 index b9242ba..50c5edd 100644
23421 --- a/arch/x86/kernel/verify_cpu.S
23422 +++ b/arch/x86/kernel/verify_cpu.S
23423 @@ -20,6 +20,7 @@
23424 * arch/x86/boot/compressed/head_64.S: Boot cpu verification
23425 * arch/x86/kernel/trampoline_64.S: secondary processor verification
23426 * arch/x86/kernel/head_32.S: processor startup
23427 + * arch/x86/kernel/acpi/realmode/wakeup.S: 32bit processor resume
23428 *
23429 * verify_cpu, returns the status of longmode and SSE in register %eax.
23430 * 0: Success 1: Failure
23431 diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c
23432 index 3dbdd9c..888b14e 100644
23433 --- a/arch/x86/kernel/vm86_32.c
23434 +++ b/arch/x86/kernel/vm86_32.c
23435 @@ -44,6 +44,7 @@
23436 #include <linux/ptrace.h>
23437 #include <linux/audit.h>
23438 #include <linux/stddef.h>
23439 +#include <linux/grsecurity.h>
23440
23441 #include <asm/uaccess.h>
23442 #include <asm/io.h>
23443 @@ -150,7 +151,7 @@ struct pt_regs *save_v86_state(struct kernel_vm86_regs *regs)
23444 do_exit(SIGSEGV);
23445 }
23446
23447 - tss = &per_cpu(init_tss, get_cpu());
23448 + tss = init_tss + get_cpu();
23449 current->thread.sp0 = current->thread.saved_sp0;
23450 current->thread.sysenter_cs = __KERNEL_CS;
23451 load_sp0(tss, &current->thread);
23452 @@ -214,6 +215,14 @@ SYSCALL_DEFINE1(vm86old, struct vm86_struct __user *, v86)
23453
23454 if (tsk->thread.saved_sp0)
23455 goto out;
23456 +
23457 +#ifdef CONFIG_GRKERNSEC_VM86
23458 + if (!capable(CAP_SYS_RAWIO)) {
23459 + gr_handle_vm86();
23460 + goto out;
23461 + }
23462 +#endif
23463 +
23464 tmp = copy_vm86_regs_from_user(&info.regs, &v86->regs,
23465 offsetof(struct kernel_vm86_struct, vm86plus) -
23466 sizeof(info.regs));
23467 @@ -242,6 +251,14 @@ SYSCALL_DEFINE2(vm86, unsigned long, cmd, unsigned long, arg)
23468 int tmp, ret;
23469 struct vm86plus_struct __user *v86;
23470
23471 +#ifdef CONFIG_GRKERNSEC_VM86
23472 + if (!capable(CAP_SYS_RAWIO)) {
23473 + gr_handle_vm86();
23474 + ret = -EPERM;
23475 + goto out;
23476 + }
23477 +#endif
23478 +
23479 tsk = current;
23480 switch (cmd) {
23481 case VM86_REQUEST_IRQ:
23482 @@ -329,7 +346,7 @@ static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk
23483 tsk->thread.saved_fs = info->regs32->fs;
23484 tsk->thread.saved_gs = get_user_gs(info->regs32);
23485
23486 - tss = &per_cpu(init_tss, get_cpu());
23487 + tss = init_tss + get_cpu();
23488 tsk->thread.sp0 = (unsigned long) &info->VM86_TSS_ESP0;
23489 if (cpu_has_sep)
23490 tsk->thread.sysenter_cs = 0;
23491 @@ -536,7 +553,7 @@ static void do_int(struct kernel_vm86_regs *regs, int i,
23492 goto cannot_handle;
23493 if (i == 0x21 && is_revectored(AH(regs), &KVM86->int21_revectored))
23494 goto cannot_handle;
23495 - intr_ptr = (unsigned long __user *) (i << 2);
23496 + intr_ptr = (__force unsigned long __user *) (i << 2);
23497 if (get_user(segoffs, intr_ptr))
23498 goto cannot_handle;
23499 if ((segoffs >> 16) == BIOSSEG)
23500 diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
23501 index 22a1530..8fbaaad 100644
23502 --- a/arch/x86/kernel/vmlinux.lds.S
23503 +++ b/arch/x86/kernel/vmlinux.lds.S
23504 @@ -26,6 +26,13 @@
23505 #include <asm/page_types.h>
23506 #include <asm/cache.h>
23507 #include <asm/boot.h>
23508 +#include <asm/segment.h>
23509 +
23510 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23511 +#define __KERNEL_TEXT_OFFSET (LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR)
23512 +#else
23513 +#define __KERNEL_TEXT_OFFSET 0
23514 +#endif
23515
23516 #undef i386 /* in case the preprocessor is a 32bit one */
23517
23518 @@ -69,30 +76,43 @@ jiffies_64 = jiffies;
23519
23520 PHDRS {
23521 text PT_LOAD FLAGS(5); /* R_E */
23522 +#ifdef CONFIG_X86_32
23523 + module PT_LOAD FLAGS(5); /* R_E */
23524 +#endif
23525 +#ifdef CONFIG_XEN
23526 + rodata PT_LOAD FLAGS(5); /* R_E */
23527 +#else
23528 + rodata PT_LOAD FLAGS(4); /* R__ */
23529 +#endif
23530 data PT_LOAD FLAGS(6); /* RW_ */
23531 -#ifdef CONFIG_X86_64
23532 + init.begin PT_LOAD FLAGS(6); /* RW_ */
23533 #ifdef CONFIG_SMP
23534 percpu PT_LOAD FLAGS(6); /* RW_ */
23535 #endif
23536 + text.init PT_LOAD FLAGS(5); /* R_E */
23537 + text.exit PT_LOAD FLAGS(5); /* R_E */
23538 init PT_LOAD FLAGS(7); /* RWE */
23539 -#endif
23540 note PT_NOTE FLAGS(0); /* ___ */
23541 }
23542
23543 SECTIONS
23544 {
23545 #ifdef CONFIG_X86_32
23546 - . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
23547 - phys_startup_32 = startup_32 - LOAD_OFFSET;
23548 + . = LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR;
23549 #else
23550 - . = __START_KERNEL;
23551 - phys_startup_64 = startup_64 - LOAD_OFFSET;
23552 + . = __START_KERNEL;
23553 #endif
23554
23555 /* Text and read-only data */
23556 - .text : AT(ADDR(.text) - LOAD_OFFSET) {
23557 - _text = .;
23558 + .text (. - __KERNEL_TEXT_OFFSET): AT(ADDR(.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
23559 /* bootstrapping code */
23560 +#ifdef CONFIG_X86_32
23561 + phys_startup_32 = startup_32 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23562 +#else
23563 + phys_startup_64 = startup_64 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23564 +#endif
23565 + __LOAD_PHYSICAL_ADDR = . - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23566 + _text = .;
23567 HEAD_TEXT
23568 #ifdef CONFIG_X86_32
23569 . = ALIGN(PAGE_SIZE);
23570 @@ -108,13 +128,48 @@ SECTIONS
23571 IRQENTRY_TEXT
23572 *(.fixup)
23573 *(.gnu.warning)
23574 - /* End of text section */
23575 - _etext = .;
23576 } :text = 0x9090
23577
23578 - NOTES :text :note
23579 + . += __KERNEL_TEXT_OFFSET;
23580
23581 - EXCEPTION_TABLE(16) :text = 0x9090
23582 +#ifdef CONFIG_X86_32
23583 + . = ALIGN(PAGE_SIZE);
23584 + .module.text : AT(ADDR(.module.text) - LOAD_OFFSET) {
23585 +
23586 +#if defined(CONFIG_PAX_KERNEXEC) && defined(CONFIG_MODULES)
23587 + MODULES_EXEC_VADDR = .;
23588 + BYTE(0)
23589 + . += (CONFIG_PAX_KERNEXEC_MODULE_TEXT * 1024 * 1024);
23590 + . = ALIGN(HPAGE_SIZE) - 1;
23591 + MODULES_EXEC_END = .;
23592 +#endif
23593 +
23594 + } :module
23595 +#endif
23596 +
23597 + .text.end : AT(ADDR(.text.end) - LOAD_OFFSET) {
23598 + /* End of text section */
23599 + BYTE(0)
23600 + _etext = . - __KERNEL_TEXT_OFFSET;
23601 + }
23602 +
23603 +#ifdef CONFIG_X86_32
23604 + . = ALIGN(PAGE_SIZE);
23605 + .rodata.page_aligned : AT(ADDR(.rodata.page_aligned) - LOAD_OFFSET) {
23606 + *(.idt)
23607 + . = ALIGN(PAGE_SIZE);
23608 + *(.empty_zero_page)
23609 + *(.initial_pg_fixmap)
23610 + *(.initial_pg_pmd)
23611 + *(.initial_page_table)
23612 + *(.swapper_pg_dir)
23613 + } :rodata
23614 +#endif
23615 +
23616 + . = ALIGN(PAGE_SIZE);
23617 + NOTES :rodata :note
23618 +
23619 + EXCEPTION_TABLE(16) :rodata
23620
23621 #if defined(CONFIG_DEBUG_RODATA)
23622 /* .text should occupy whole number of pages */
23623 @@ -126,16 +181,20 @@ SECTIONS
23624
23625 /* Data */
23626 .data : AT(ADDR(.data) - LOAD_OFFSET) {
23627 +
23628 +#ifdef CONFIG_PAX_KERNEXEC
23629 + . = ALIGN(HPAGE_SIZE);
23630 +#else
23631 + . = ALIGN(PAGE_SIZE);
23632 +#endif
23633 +
23634 /* Start of data section */
23635 _sdata = .;
23636
23637 /* init_task */
23638 INIT_TASK_DATA(THREAD_SIZE)
23639
23640 -#ifdef CONFIG_X86_32
23641 - /* 32 bit has nosave before _edata */
23642 NOSAVE_DATA
23643 -#endif
23644
23645 PAGE_ALIGNED_DATA(PAGE_SIZE)
23646
23647 @@ -176,12 +235,19 @@ SECTIONS
23648 #endif /* CONFIG_X86_64 */
23649
23650 /* Init code and data - will be freed after init */
23651 - . = ALIGN(PAGE_SIZE);
23652 .init.begin : AT(ADDR(.init.begin) - LOAD_OFFSET) {
23653 + BYTE(0)
23654 +
23655 +#ifdef CONFIG_PAX_KERNEXEC
23656 + . = ALIGN(HPAGE_SIZE);
23657 +#else
23658 + . = ALIGN(PAGE_SIZE);
23659 +#endif
23660 +
23661 __init_begin = .; /* paired with __init_end */
23662 - }
23663 + } :init.begin
23664
23665 -#if defined(CONFIG_X86_64) && defined(CONFIG_SMP)
23666 +#ifdef CONFIG_SMP
23667 /*
23668 * percpu offsets are zero-based on SMP. PERCPU_VADDR() changes the
23669 * output PHDR, so the next output section - .init.text - should
23670 @@ -190,12 +256,27 @@ SECTIONS
23671 PERCPU_VADDR(INTERNODE_CACHE_BYTES, 0, :percpu)
23672 #endif
23673
23674 - INIT_TEXT_SECTION(PAGE_SIZE)
23675 -#ifdef CONFIG_X86_64
23676 - :init
23677 -#endif
23678 + . = ALIGN(PAGE_SIZE);
23679 + init_begin = .;
23680 + .init.text (. - __KERNEL_TEXT_OFFSET): AT(init_begin - LOAD_OFFSET) {
23681 + VMLINUX_SYMBOL(_sinittext) = .;
23682 + INIT_TEXT
23683 + VMLINUX_SYMBOL(_einittext) = .;
23684 + . = ALIGN(PAGE_SIZE);
23685 + } :text.init
23686
23687 - INIT_DATA_SECTION(16)
23688 + /*
23689 + * .exit.text is discard at runtime, not link time, to deal with
23690 + * references from .altinstructions and .eh_frame
23691 + */
23692 + .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
23693 + EXIT_TEXT
23694 + . = ALIGN(16);
23695 + } :text.exit
23696 + . = init_begin + SIZEOF(.init.text) + SIZEOF(.exit.text);
23697 +
23698 + . = ALIGN(PAGE_SIZE);
23699 + INIT_DATA_SECTION(16) :init
23700
23701 .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
23702 __x86_cpu_dev_start = .;
23703 @@ -257,19 +338,12 @@ SECTIONS
23704 }
23705
23706 . = ALIGN(8);
23707 - /*
23708 - * .exit.text is discard at runtime, not link time, to deal with
23709 - * references from .altinstructions and .eh_frame
23710 - */
23711 - .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
23712 - EXIT_TEXT
23713 - }
23714
23715 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
23716 EXIT_DATA
23717 }
23718
23719 -#if !defined(CONFIG_X86_64) || !defined(CONFIG_SMP)
23720 +#ifndef CONFIG_SMP
23721 PERCPU_SECTION(INTERNODE_CACHE_BYTES)
23722 #endif
23723
23724 @@ -288,16 +362,10 @@ SECTIONS
23725 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
23726 __smp_locks = .;
23727 *(.smp_locks)
23728 - . = ALIGN(PAGE_SIZE);
23729 __smp_locks_end = .;
23730 + . = ALIGN(PAGE_SIZE);
23731 }
23732
23733 -#ifdef CONFIG_X86_64
23734 - .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
23735 - NOSAVE_DATA
23736 - }
23737 -#endif
23738 -
23739 /* BSS */
23740 . = ALIGN(PAGE_SIZE);
23741 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
23742 @@ -313,6 +381,7 @@ SECTIONS
23743 __brk_base = .;
23744 . += 64 * 1024; /* 64k alignment slop space */
23745 *(.brk_reservation) /* areas brk users have reserved */
23746 + . = ALIGN(HPAGE_SIZE);
23747 __brk_limit = .;
23748 }
23749
23750 @@ -339,13 +408,12 @@ SECTIONS
23751 * for the boot processor.
23752 */
23753 #define INIT_PER_CPU(x) init_per_cpu__##x = x + __per_cpu_load
23754 -INIT_PER_CPU(gdt_page);
23755 INIT_PER_CPU(irq_stack_union);
23756
23757 /*
23758 * Build-time check on the image size:
23759 */
23760 -. = ASSERT((_end - _text <= KERNEL_IMAGE_SIZE),
23761 +. = ASSERT((_end - _text - __KERNEL_TEXT_OFFSET <= KERNEL_IMAGE_SIZE),
23762 "kernel image bigger than KERNEL_IMAGE_SIZE");
23763
23764 #ifdef CONFIG_SMP
23765 diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
23766 index 9a907a6..f83f921 100644
23767 --- a/arch/x86/kernel/vsyscall_64.c
23768 +++ b/arch/x86/kernel/vsyscall_64.c
23769 @@ -56,15 +56,13 @@
23770 DEFINE_VVAR(int, vgetcpu_mode);
23771 DEFINE_VVAR(struct vsyscall_gtod_data, vsyscall_gtod_data);
23772
23773 -static enum { EMULATE, NATIVE, NONE } vsyscall_mode = EMULATE;
23774 +static enum { EMULATE, NONE } vsyscall_mode = EMULATE;
23775
23776 static int __init vsyscall_setup(char *str)
23777 {
23778 if (str) {
23779 if (!strcmp("emulate", str))
23780 vsyscall_mode = EMULATE;
23781 - else if (!strcmp("native", str))
23782 - vsyscall_mode = NATIVE;
23783 else if (!strcmp("none", str))
23784 vsyscall_mode = NONE;
23785 else
23786 @@ -323,8 +321,7 @@ do_ret:
23787 return true;
23788
23789 sigsegv:
23790 - force_sig(SIGSEGV, current);
23791 - return true;
23792 + do_group_exit(SIGKILL);
23793 }
23794
23795 /*
23796 @@ -377,10 +374,7 @@ void __init map_vsyscall(void)
23797 extern char __vvar_page;
23798 unsigned long physaddr_vvar_page = __pa_symbol(&__vvar_page);
23799
23800 - __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall,
23801 - vsyscall_mode == NATIVE
23802 - ? PAGE_KERNEL_VSYSCALL
23803 - : PAGE_KERNEL_VVAR);
23804 + __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall, PAGE_KERNEL_VVAR);
23805 BUILD_BUG_ON((unsigned long)__fix_to_virt(VSYSCALL_FIRST_PAGE) !=
23806 (unsigned long)VSYSCALL_START);
23807
23808 diff --git a/arch/x86/kernel/x8664_ksyms_64.c b/arch/x86/kernel/x8664_ksyms_64.c
23809 index b014d94..6d6ca7b 100644
23810 --- a/arch/x86/kernel/x8664_ksyms_64.c
23811 +++ b/arch/x86/kernel/x8664_ksyms_64.c
23812 @@ -34,8 +34,6 @@ EXPORT_SYMBOL(copy_user_generic_string);
23813 EXPORT_SYMBOL(copy_user_generic_unrolled);
23814 EXPORT_SYMBOL(copy_user_enhanced_fast_string);
23815 EXPORT_SYMBOL(__copy_user_nocache);
23816 -EXPORT_SYMBOL(_copy_from_user);
23817 -EXPORT_SYMBOL(_copy_to_user);
23818
23819 EXPORT_SYMBOL(copy_page);
23820 EXPORT_SYMBOL(clear_page);
23821 diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
23822 index 45a14db..075bb9b 100644
23823 --- a/arch/x86/kernel/x86_init.c
23824 +++ b/arch/x86/kernel/x86_init.c
23825 @@ -85,7 +85,7 @@ struct x86_init_ops x86_init __initdata = {
23826 },
23827 };
23828
23829 -struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = {
23830 +struct x86_cpuinit_ops x86_cpuinit __cpuinitconst = {
23831 .early_percpu_clock_init = x86_init_noop,
23832 .setup_percpu_clockev = setup_secondary_APIC_clock,
23833 };
23834 @@ -93,7 +93,7 @@ struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = {
23835 static void default_nmi_init(void) { };
23836 static int default_i8042_detect(void) { return 1; };
23837
23838 -struct x86_platform_ops x86_platform = {
23839 +struct x86_platform_ops x86_platform __read_only = {
23840 .calibrate_tsc = native_calibrate_tsc,
23841 .get_wallclock = mach_get_cmos_time,
23842 .set_wallclock = mach_set_rtc_mmss,
23843 @@ -107,7 +107,7 @@ struct x86_platform_ops x86_platform = {
23844 };
23845
23846 EXPORT_SYMBOL_GPL(x86_platform);
23847 -struct x86_msi_ops x86_msi = {
23848 +struct x86_msi_ops x86_msi __read_only = {
23849 .setup_msi_irqs = native_setup_msi_irqs,
23850 .compose_msi_msg = native_compose_msi_msg,
23851 .teardown_msi_irq = native_teardown_msi_irq,
23852 @@ -116,7 +116,7 @@ struct x86_msi_ops x86_msi = {
23853 .setup_hpet_msi = default_setup_hpet_msi,
23854 };
23855
23856 -struct x86_io_apic_ops x86_io_apic_ops = {
23857 +struct x86_io_apic_ops x86_io_apic_ops __read_only = {
23858 .init = native_io_apic_init_mappings,
23859 .read = native_io_apic_read,
23860 .write = native_io_apic_write,
23861 diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c
23862 index ada87a3..afea76d 100644
23863 --- a/arch/x86/kernel/xsave.c
23864 +++ b/arch/x86/kernel/xsave.c
23865 @@ -199,6 +199,7 @@ static inline int save_user_xstate(struct xsave_struct __user *buf)
23866 {
23867 int err;
23868
23869 + buf = (struct xsave_struct __user *)____m(buf);
23870 if (use_xsave())
23871 err = xsave_user(buf);
23872 else if (use_fxsr())
23873 @@ -311,6 +312,7 @@ sanitize_restored_xstate(struct task_struct *tsk,
23874 */
23875 static inline int restore_user_xstate(void __user *buf, u64 xbv, int fx_only)
23876 {
23877 + buf = (void __user *)____m(buf);
23878 if (use_xsave()) {
23879 if ((unsigned long)buf % 64 || fx_only) {
23880 u64 init_bv = pcntxt_mask & ~XSTATE_FPSSE;
23881 diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
23882 index a20ecb5..d0e2194 100644
23883 --- a/arch/x86/kvm/cpuid.c
23884 +++ b/arch/x86/kvm/cpuid.c
23885 @@ -124,15 +124,20 @@ int kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu *vcpu,
23886 struct kvm_cpuid2 *cpuid,
23887 struct kvm_cpuid_entry2 __user *entries)
23888 {
23889 - int r;
23890 + int r, i;
23891
23892 r = -E2BIG;
23893 if (cpuid->nent > KVM_MAX_CPUID_ENTRIES)
23894 goto out;
23895 r = -EFAULT;
23896 - if (copy_from_user(&vcpu->arch.cpuid_entries, entries,
23897 - cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
23898 + if (!access_ok(VERIFY_READ, entries, cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
23899 goto out;
23900 + for (i = 0; i < cpuid->nent; ++i) {
23901 + struct kvm_cpuid_entry2 cpuid_entry;
23902 + if (__copy_from_user(&cpuid_entry, entries + i, sizeof(cpuid_entry)))
23903 + goto out;
23904 + vcpu->arch.cpuid_entries[i] = cpuid_entry;
23905 + }
23906 vcpu->arch.cpuid_nent = cpuid->nent;
23907 kvm_apic_set_version(vcpu);
23908 kvm_x86_ops->cpuid_update(vcpu);
23909 @@ -147,15 +152,19 @@ int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu,
23910 struct kvm_cpuid2 *cpuid,
23911 struct kvm_cpuid_entry2 __user *entries)
23912 {
23913 - int r;
23914 + int r, i;
23915
23916 r = -E2BIG;
23917 if (cpuid->nent < vcpu->arch.cpuid_nent)
23918 goto out;
23919 r = -EFAULT;
23920 - if (copy_to_user(entries, &vcpu->arch.cpuid_entries,
23921 - vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
23922 + if (!access_ok(VERIFY_WRITE, entries, vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
23923 goto out;
23924 + for (i = 0; i < vcpu->arch.cpuid_nent; ++i) {
23925 + struct kvm_cpuid_entry2 cpuid_entry = vcpu->arch.cpuid_entries[i];
23926 + if (__copy_to_user(entries + i, &cpuid_entry, sizeof(cpuid_entry)))
23927 + goto out;
23928 + }
23929 return 0;
23930
23931 out:
23932 diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
23933 index 59622c9..f338414 100644
23934 --- a/arch/x86/kvm/emulate.c
23935 +++ b/arch/x86/kvm/emulate.c
23936 @@ -328,6 +328,7 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
23937
23938 #define ____emulate_2op(ctxt, _op, _x, _y, _suffix, _dsttype) \
23939 do { \
23940 + unsigned long _tmp; \
23941 __asm__ __volatile__ ( \
23942 _PRE_EFLAGS("0", "4", "2") \
23943 _op _suffix " %"_x"3,%1; " \
23944 @@ -342,8 +343,6 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
23945 /* Raw emulation: instruction has two explicit operands. */
23946 #define __emulate_2op_nobyte(ctxt,_op,_wx,_wy,_lx,_ly,_qx,_qy) \
23947 do { \
23948 - unsigned long _tmp; \
23949 - \
23950 switch ((ctxt)->dst.bytes) { \
23951 case 2: \
23952 ____emulate_2op(ctxt,_op,_wx,_wy,"w",u16); \
23953 @@ -359,7 +358,6 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
23954
23955 #define __emulate_2op(ctxt,_op,_bx,_by,_wx,_wy,_lx,_ly,_qx,_qy) \
23956 do { \
23957 - unsigned long _tmp; \
23958 switch ((ctxt)->dst.bytes) { \
23959 case 1: \
23960 ____emulate_2op(ctxt,_op,_bx,_by,"b",u8); \
23961 diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
23962 index f77df1c..6f20690 100644
23963 --- a/arch/x86/kvm/lapic.c
23964 +++ b/arch/x86/kvm/lapic.c
23965 @@ -55,7 +55,7 @@
23966 #define APIC_BUS_CYCLE_NS 1
23967
23968 /* #define apic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg) */
23969 -#define apic_debug(fmt, arg...)
23970 +#define apic_debug(fmt, arg...) do {} while (0)
23971
23972 #define APIC_LVT_NUM 6
23973 /* 14 is the version for Xeon and Pentium 8.4.8*/
23974 diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
23975 index 105dd5b..1b0ccc2 100644
23976 --- a/arch/x86/kvm/paging_tmpl.h
23977 +++ b/arch/x86/kvm/paging_tmpl.h
23978 @@ -208,7 +208,7 @@ retry_walk:
23979 if (unlikely(kvm_is_error_hva(host_addr)))
23980 goto error;
23981
23982 - ptep_user = (pt_element_t __user *)((void *)host_addr + offset);
23983 + ptep_user = (pt_element_t __force_user *)((void *)host_addr + offset);
23984 if (unlikely(__copy_from_user(&pte, ptep_user, sizeof(pte))))
23985 goto error;
23986 walker->ptep_user[walker->level - 1] = ptep_user;
23987 diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
23988 index e1b1ce2..f7b4b43 100644
23989 --- a/arch/x86/kvm/svm.c
23990 +++ b/arch/x86/kvm/svm.c
23991 @@ -3507,7 +3507,11 @@ static void reload_tss(struct kvm_vcpu *vcpu)
23992 int cpu = raw_smp_processor_id();
23993
23994 struct svm_cpu_data *sd = per_cpu(svm_data, cpu);
23995 +
23996 + pax_open_kernel();
23997 sd->tss_desc->type = 9; /* available 32/64-bit TSS */
23998 + pax_close_kernel();
23999 +
24000 load_TR_desc();
24001 }
24002
24003 @@ -3901,6 +3905,10 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
24004 #endif
24005 #endif
24006
24007 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
24008 + __set_fs(current_thread_info()->addr_limit);
24009 +#endif
24010 +
24011 reload_tss(vcpu);
24012
24013 local_irq_disable();
24014 diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
24015 index 0af1807..06912bb 100644
24016 --- a/arch/x86/kvm/vmx.c
24017 +++ b/arch/x86/kvm/vmx.c
24018 @@ -1184,12 +1184,12 @@ static void vmcs_write64(unsigned long field, u64 value)
24019 #endif
24020 }
24021
24022 -static void vmcs_clear_bits(unsigned long field, u32 mask)
24023 +static void vmcs_clear_bits(unsigned long field, unsigned long mask)
24024 {
24025 vmcs_writel(field, vmcs_readl(field) & ~mask);
24026 }
24027
24028 -static void vmcs_set_bits(unsigned long field, u32 mask)
24029 +static void vmcs_set_bits(unsigned long field, unsigned long mask)
24030 {
24031 vmcs_writel(field, vmcs_readl(field) | mask);
24032 }
24033 @@ -1390,7 +1390,11 @@ static void reload_tss(void)
24034 struct desc_struct *descs;
24035
24036 descs = (void *)gdt->address;
24037 +
24038 + pax_open_kernel();
24039 descs[GDT_ENTRY_TSS].type = 9; /* available TSS */
24040 + pax_close_kernel();
24041 +
24042 load_TR_desc();
24043 }
24044
24045 @@ -1614,6 +1618,10 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
24046 vmcs_writel(HOST_TR_BASE, kvm_read_tr_base()); /* 22.2.4 */
24047 vmcs_writel(HOST_GDTR_BASE, gdt->address); /* 22.2.4 */
24048
24049 +#ifdef CONFIG_PAX_PER_CPU_PGD
24050 + vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
24051 +#endif
24052 +
24053 rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp);
24054 vmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); /* 22.2.3 */
24055 vmx->loaded_vmcs->cpu = cpu;
24056 @@ -2779,8 +2787,11 @@ static __init int hardware_setup(void)
24057 if (!cpu_has_vmx_flexpriority())
24058 flexpriority_enabled = 0;
24059
24060 - if (!cpu_has_vmx_tpr_shadow())
24061 - kvm_x86_ops->update_cr8_intercept = NULL;
24062 + if (!cpu_has_vmx_tpr_shadow()) {
24063 + pax_open_kernel();
24064 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
24065 + pax_close_kernel();
24066 + }
24067
24068 if (enable_ept && !cpu_has_vmx_ept_2m_page())
24069 kvm_disable_largepages();
24070 @@ -2792,10 +2803,12 @@ static __init int hardware_setup(void)
24071 !cpu_has_vmx_virtual_intr_delivery())
24072 enable_apicv_reg_vid = 0;
24073
24074 + pax_open_kernel();
24075 if (enable_apicv_reg_vid)
24076 - kvm_x86_ops->update_cr8_intercept = NULL;
24077 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
24078 else
24079 - kvm_x86_ops->hwapic_irr_update = NULL;
24080 + *(void **)&kvm_x86_ops->hwapic_irr_update = NULL;
24081 + pax_close_kernel();
24082
24083 if (nested)
24084 nested_vmx_setup_ctls_msrs();
24085 @@ -3883,7 +3896,10 @@ static void vmx_set_constant_host_state(void)
24086
24087 vmcs_writel(HOST_CR0, read_cr0() & ~X86_CR0_TS); /* 22.2.3 */
24088 vmcs_writel(HOST_CR4, read_cr4()); /* 22.2.3, 22.2.5 */
24089 +
24090 +#ifndef CONFIG_PAX_PER_CPU_PGD
24091 vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
24092 +#endif
24093
24094 vmcs_write16(HOST_CS_SELECTOR, __KERNEL_CS); /* 22.2.4 */
24095 #ifdef CONFIG_X86_64
24096 @@ -3904,7 +3920,7 @@ static void vmx_set_constant_host_state(void)
24097 native_store_idt(&dt);
24098 vmcs_writel(HOST_IDTR_BASE, dt.address); /* 22.2.4 */
24099
24100 - vmcs_writel(HOST_RIP, vmx_return); /* 22.2.5 */
24101 + vmcs_writel(HOST_RIP, ktla_ktva(vmx_return)); /* 22.2.5 */
24102
24103 rdmsr(MSR_IA32_SYSENTER_CS, low32, high32);
24104 vmcs_write32(HOST_IA32_SYSENTER_CS, low32);
24105 @@ -6580,6 +6596,12 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24106 "jmp 2f \n\t"
24107 "1: " __ex(ASM_VMX_VMRESUME) "\n\t"
24108 "2: "
24109 +
24110 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
24111 + "ljmp %[cs],$3f\n\t"
24112 + "3: "
24113 +#endif
24114 +
24115 /* Save guest registers, load host registers, keep flags */
24116 "mov %0, %c[wordsize](%%" _ASM_SP ") \n\t"
24117 "pop %0 \n\t"
24118 @@ -6632,6 +6654,11 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24119 #endif
24120 [cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2)),
24121 [wordsize]"i"(sizeof(ulong))
24122 +
24123 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
24124 + ,[cs]"i"(__KERNEL_CS)
24125 +#endif
24126 +
24127 : "cc", "memory"
24128 #ifdef CONFIG_X86_64
24129 , "rax", "rbx", "rdi", "rsi"
24130 @@ -6645,7 +6672,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24131 if (debugctlmsr)
24132 update_debugctlmsr(debugctlmsr);
24133
24134 -#ifndef CONFIG_X86_64
24135 +#ifdef CONFIG_X86_32
24136 /*
24137 * The sysexit path does not restore ds/es, so we must set them to
24138 * a reasonable value ourselves.
24139 @@ -6654,8 +6681,18 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24140 * may be executed in interrupt context, which saves and restore segments
24141 * around it, nullifying its effect.
24142 */
24143 - loadsegment(ds, __USER_DS);
24144 - loadsegment(es, __USER_DS);
24145 + loadsegment(ds, __KERNEL_DS);
24146 + loadsegment(es, __KERNEL_DS);
24147 + loadsegment(ss, __KERNEL_DS);
24148 +
24149 +#ifdef CONFIG_PAX_KERNEXEC
24150 + loadsegment(fs, __KERNEL_PERCPU);
24151 +#endif
24152 +
24153 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24154 + __set_fs(current_thread_info()->addr_limit);
24155 +#endif
24156 +
24157 #endif
24158
24159 vcpu->arch.regs_avail = ~((1 << VCPU_REGS_RIP) | (1 << VCPU_REGS_RSP)
24160 diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
24161 index e172132..c3d3e27 100644
24162 --- a/arch/x86/kvm/x86.c
24163 +++ b/arch/x86/kvm/x86.c
24164 @@ -1686,8 +1686,8 @@ static int xen_hvm_config(struct kvm_vcpu *vcpu, u64 data)
24165 {
24166 struct kvm *kvm = vcpu->kvm;
24167 int lm = is_long_mode(vcpu);
24168 - u8 *blob_addr = lm ? (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_64
24169 - : (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
24170 + u8 __user *blob_addr = lm ? (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_64
24171 + : (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
24172 u8 blob_size = lm ? kvm->arch.xen_hvm_config.blob_size_64
24173 : kvm->arch.xen_hvm_config.blob_size_32;
24174 u32 page_num = data & ~PAGE_MASK;
24175 @@ -2567,6 +2567,8 @@ long kvm_arch_dev_ioctl(struct file *filp,
24176 if (n < msr_list.nmsrs)
24177 goto out;
24178 r = -EFAULT;
24179 + if (num_msrs_to_save > ARRAY_SIZE(msrs_to_save))
24180 + goto out;
24181 if (copy_to_user(user_msr_list->indices, &msrs_to_save,
24182 num_msrs_to_save * sizeof(u32)))
24183 goto out;
24184 @@ -2696,7 +2698,7 @@ static int kvm_vcpu_ioctl_set_lapic(struct kvm_vcpu *vcpu,
24185 static int kvm_vcpu_ioctl_interrupt(struct kvm_vcpu *vcpu,
24186 struct kvm_interrupt *irq)
24187 {
24188 - if (irq->irq < 0 || irq->irq >= KVM_NR_INTERRUPTS)
24189 + if (irq->irq >= KVM_NR_INTERRUPTS)
24190 return -EINVAL;
24191 if (irqchip_in_kernel(vcpu->kvm))
24192 return -ENXIO;
24193 @@ -5247,7 +5249,7 @@ static struct notifier_block pvclock_gtod_notifier = {
24194 };
24195 #endif
24196
24197 -int kvm_arch_init(void *opaque)
24198 +int kvm_arch_init(const void *opaque)
24199 {
24200 int r;
24201 struct kvm_x86_ops *ops = (struct kvm_x86_ops *)opaque;
24202 diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
24203 index 7114c63..a1018fc 100644
24204 --- a/arch/x86/lguest/boot.c
24205 +++ b/arch/x86/lguest/boot.c
24206 @@ -1201,9 +1201,10 @@ static __init int early_put_chars(u32 vtermno, const char *buf, int count)
24207 * Rebooting also tells the Host we're finished, but the RESTART flag tells the
24208 * Launcher to reboot us.
24209 */
24210 -static void lguest_restart(char *reason)
24211 +static __noreturn void lguest_restart(char *reason)
24212 {
24213 hcall(LHCALL_SHUTDOWN, __pa(reason), LGUEST_SHUTDOWN_RESTART, 0, 0);
24214 + BUG();
24215 }
24216
24217 /*G:050
24218 diff --git a/arch/x86/lib/atomic64_386_32.S b/arch/x86/lib/atomic64_386_32.S
24219 index 00933d5..3a64af9 100644
24220 --- a/arch/x86/lib/atomic64_386_32.S
24221 +++ b/arch/x86/lib/atomic64_386_32.S
24222 @@ -48,6 +48,10 @@ BEGIN(read)
24223 movl (v), %eax
24224 movl 4(v), %edx
24225 RET_ENDP
24226 +BEGIN(read_unchecked)
24227 + movl (v), %eax
24228 + movl 4(v), %edx
24229 +RET_ENDP
24230 #undef v
24231
24232 #define v %esi
24233 @@ -55,6 +59,10 @@ BEGIN(set)
24234 movl %ebx, (v)
24235 movl %ecx, 4(v)
24236 RET_ENDP
24237 +BEGIN(set_unchecked)
24238 + movl %ebx, (v)
24239 + movl %ecx, 4(v)
24240 +RET_ENDP
24241 #undef v
24242
24243 #define v %esi
24244 @@ -70,6 +78,20 @@ RET_ENDP
24245 BEGIN(add)
24246 addl %eax, (v)
24247 adcl %edx, 4(v)
24248 +
24249 +#ifdef CONFIG_PAX_REFCOUNT
24250 + jno 0f
24251 + subl %eax, (v)
24252 + sbbl %edx, 4(v)
24253 + int $4
24254 +0:
24255 + _ASM_EXTABLE(0b, 0b)
24256 +#endif
24257 +
24258 +RET_ENDP
24259 +BEGIN(add_unchecked)
24260 + addl %eax, (v)
24261 + adcl %edx, 4(v)
24262 RET_ENDP
24263 #undef v
24264
24265 @@ -77,6 +99,24 @@ RET_ENDP
24266 BEGIN(add_return)
24267 addl (v), %eax
24268 adcl 4(v), %edx
24269 +
24270 +#ifdef CONFIG_PAX_REFCOUNT
24271 + into
24272 +1234:
24273 + _ASM_EXTABLE(1234b, 2f)
24274 +#endif
24275 +
24276 + movl %eax, (v)
24277 + movl %edx, 4(v)
24278 +
24279 +#ifdef CONFIG_PAX_REFCOUNT
24280 +2:
24281 +#endif
24282 +
24283 +RET_ENDP
24284 +BEGIN(add_return_unchecked)
24285 + addl (v), %eax
24286 + adcl 4(v), %edx
24287 movl %eax, (v)
24288 movl %edx, 4(v)
24289 RET_ENDP
24290 @@ -86,6 +126,20 @@ RET_ENDP
24291 BEGIN(sub)
24292 subl %eax, (v)
24293 sbbl %edx, 4(v)
24294 +
24295 +#ifdef CONFIG_PAX_REFCOUNT
24296 + jno 0f
24297 + addl %eax, (v)
24298 + adcl %edx, 4(v)
24299 + int $4
24300 +0:
24301 + _ASM_EXTABLE(0b, 0b)
24302 +#endif
24303 +
24304 +RET_ENDP
24305 +BEGIN(sub_unchecked)
24306 + subl %eax, (v)
24307 + sbbl %edx, 4(v)
24308 RET_ENDP
24309 #undef v
24310
24311 @@ -96,6 +150,27 @@ BEGIN(sub_return)
24312 sbbl $0, %edx
24313 addl (v), %eax
24314 adcl 4(v), %edx
24315 +
24316 +#ifdef CONFIG_PAX_REFCOUNT
24317 + into
24318 +1234:
24319 + _ASM_EXTABLE(1234b, 2f)
24320 +#endif
24321 +
24322 + movl %eax, (v)
24323 + movl %edx, 4(v)
24324 +
24325 +#ifdef CONFIG_PAX_REFCOUNT
24326 +2:
24327 +#endif
24328 +
24329 +RET_ENDP
24330 +BEGIN(sub_return_unchecked)
24331 + negl %edx
24332 + negl %eax
24333 + sbbl $0, %edx
24334 + addl (v), %eax
24335 + adcl 4(v), %edx
24336 movl %eax, (v)
24337 movl %edx, 4(v)
24338 RET_ENDP
24339 @@ -105,6 +180,20 @@ RET_ENDP
24340 BEGIN(inc)
24341 addl $1, (v)
24342 adcl $0, 4(v)
24343 +
24344 +#ifdef CONFIG_PAX_REFCOUNT
24345 + jno 0f
24346 + subl $1, (v)
24347 + sbbl $0, 4(v)
24348 + int $4
24349 +0:
24350 + _ASM_EXTABLE(0b, 0b)
24351 +#endif
24352 +
24353 +RET_ENDP
24354 +BEGIN(inc_unchecked)
24355 + addl $1, (v)
24356 + adcl $0, 4(v)
24357 RET_ENDP
24358 #undef v
24359
24360 @@ -114,6 +203,26 @@ BEGIN(inc_return)
24361 movl 4(v), %edx
24362 addl $1, %eax
24363 adcl $0, %edx
24364 +
24365 +#ifdef CONFIG_PAX_REFCOUNT
24366 + into
24367 +1234:
24368 + _ASM_EXTABLE(1234b, 2f)
24369 +#endif
24370 +
24371 + movl %eax, (v)
24372 + movl %edx, 4(v)
24373 +
24374 +#ifdef CONFIG_PAX_REFCOUNT
24375 +2:
24376 +#endif
24377 +
24378 +RET_ENDP
24379 +BEGIN(inc_return_unchecked)
24380 + movl (v), %eax
24381 + movl 4(v), %edx
24382 + addl $1, %eax
24383 + adcl $0, %edx
24384 movl %eax, (v)
24385 movl %edx, 4(v)
24386 RET_ENDP
24387 @@ -123,6 +232,20 @@ RET_ENDP
24388 BEGIN(dec)
24389 subl $1, (v)
24390 sbbl $0, 4(v)
24391 +
24392 +#ifdef CONFIG_PAX_REFCOUNT
24393 + jno 0f
24394 + addl $1, (v)
24395 + adcl $0, 4(v)
24396 + int $4
24397 +0:
24398 + _ASM_EXTABLE(0b, 0b)
24399 +#endif
24400 +
24401 +RET_ENDP
24402 +BEGIN(dec_unchecked)
24403 + subl $1, (v)
24404 + sbbl $0, 4(v)
24405 RET_ENDP
24406 #undef v
24407
24408 @@ -132,6 +255,26 @@ BEGIN(dec_return)
24409 movl 4(v), %edx
24410 subl $1, %eax
24411 sbbl $0, %edx
24412 +
24413 +#ifdef CONFIG_PAX_REFCOUNT
24414 + into
24415 +1234:
24416 + _ASM_EXTABLE(1234b, 2f)
24417 +#endif
24418 +
24419 + movl %eax, (v)
24420 + movl %edx, 4(v)
24421 +
24422 +#ifdef CONFIG_PAX_REFCOUNT
24423 +2:
24424 +#endif
24425 +
24426 +RET_ENDP
24427 +BEGIN(dec_return_unchecked)
24428 + movl (v), %eax
24429 + movl 4(v), %edx
24430 + subl $1, %eax
24431 + sbbl $0, %edx
24432 movl %eax, (v)
24433 movl %edx, 4(v)
24434 RET_ENDP
24435 @@ -143,6 +286,13 @@ BEGIN(add_unless)
24436 adcl %edx, %edi
24437 addl (v), %eax
24438 adcl 4(v), %edx
24439 +
24440 +#ifdef CONFIG_PAX_REFCOUNT
24441 + into
24442 +1234:
24443 + _ASM_EXTABLE(1234b, 2f)
24444 +#endif
24445 +
24446 cmpl %eax, %ecx
24447 je 3f
24448 1:
24449 @@ -168,6 +318,13 @@ BEGIN(inc_not_zero)
24450 1:
24451 addl $1, %eax
24452 adcl $0, %edx
24453 +
24454 +#ifdef CONFIG_PAX_REFCOUNT
24455 + into
24456 +1234:
24457 + _ASM_EXTABLE(1234b, 2f)
24458 +#endif
24459 +
24460 movl %eax, (v)
24461 movl %edx, 4(v)
24462 movl $1, %eax
24463 @@ -186,6 +343,13 @@ BEGIN(dec_if_positive)
24464 movl 4(v), %edx
24465 subl $1, %eax
24466 sbbl $0, %edx
24467 +
24468 +#ifdef CONFIG_PAX_REFCOUNT
24469 + into
24470 +1234:
24471 + _ASM_EXTABLE(1234b, 1f)
24472 +#endif
24473 +
24474 js 1f
24475 movl %eax, (v)
24476 movl %edx, 4(v)
24477 diff --git a/arch/x86/lib/atomic64_cx8_32.S b/arch/x86/lib/atomic64_cx8_32.S
24478 index f5cc9eb..51fa319 100644
24479 --- a/arch/x86/lib/atomic64_cx8_32.S
24480 +++ b/arch/x86/lib/atomic64_cx8_32.S
24481 @@ -35,10 +35,20 @@ ENTRY(atomic64_read_cx8)
24482 CFI_STARTPROC
24483
24484 read64 %ecx
24485 + pax_force_retaddr
24486 ret
24487 CFI_ENDPROC
24488 ENDPROC(atomic64_read_cx8)
24489
24490 +ENTRY(atomic64_read_unchecked_cx8)
24491 + CFI_STARTPROC
24492 +
24493 + read64 %ecx
24494 + pax_force_retaddr
24495 + ret
24496 + CFI_ENDPROC
24497 +ENDPROC(atomic64_read_unchecked_cx8)
24498 +
24499 ENTRY(atomic64_set_cx8)
24500 CFI_STARTPROC
24501
24502 @@ -48,10 +58,25 @@ ENTRY(atomic64_set_cx8)
24503 cmpxchg8b (%esi)
24504 jne 1b
24505
24506 + pax_force_retaddr
24507 ret
24508 CFI_ENDPROC
24509 ENDPROC(atomic64_set_cx8)
24510
24511 +ENTRY(atomic64_set_unchecked_cx8)
24512 + CFI_STARTPROC
24513 +
24514 +1:
24515 +/* we don't need LOCK_PREFIX since aligned 64-bit writes
24516 + * are atomic on 586 and newer */
24517 + cmpxchg8b (%esi)
24518 + jne 1b
24519 +
24520 + pax_force_retaddr
24521 + ret
24522 + CFI_ENDPROC
24523 +ENDPROC(atomic64_set_unchecked_cx8)
24524 +
24525 ENTRY(atomic64_xchg_cx8)
24526 CFI_STARTPROC
24527
24528 @@ -60,12 +85,13 @@ ENTRY(atomic64_xchg_cx8)
24529 cmpxchg8b (%esi)
24530 jne 1b
24531
24532 + pax_force_retaddr
24533 ret
24534 CFI_ENDPROC
24535 ENDPROC(atomic64_xchg_cx8)
24536
24537 -.macro addsub_return func ins insc
24538 -ENTRY(atomic64_\func\()_return_cx8)
24539 +.macro addsub_return func ins insc unchecked=""
24540 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
24541 CFI_STARTPROC
24542 SAVE ebp
24543 SAVE ebx
24544 @@ -82,27 +108,44 @@ ENTRY(atomic64_\func\()_return_cx8)
24545 movl %edx, %ecx
24546 \ins\()l %esi, %ebx
24547 \insc\()l %edi, %ecx
24548 +
24549 +.ifb \unchecked
24550 +#ifdef CONFIG_PAX_REFCOUNT
24551 + into
24552 +2:
24553 + _ASM_EXTABLE(2b, 3f)
24554 +#endif
24555 +.endif
24556 +
24557 LOCK_PREFIX
24558 cmpxchg8b (%ebp)
24559 jne 1b
24560 -
24561 -10:
24562 movl %ebx, %eax
24563 movl %ecx, %edx
24564 +
24565 +.ifb \unchecked
24566 +#ifdef CONFIG_PAX_REFCOUNT
24567 +3:
24568 +#endif
24569 +.endif
24570 +
24571 RESTORE edi
24572 RESTORE esi
24573 RESTORE ebx
24574 RESTORE ebp
24575 + pax_force_retaddr
24576 ret
24577 CFI_ENDPROC
24578 -ENDPROC(atomic64_\func\()_return_cx8)
24579 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
24580 .endm
24581
24582 addsub_return add add adc
24583 addsub_return sub sub sbb
24584 +addsub_return add add adc _unchecked
24585 +addsub_return sub sub sbb _unchecked
24586
24587 -.macro incdec_return func ins insc
24588 -ENTRY(atomic64_\func\()_return_cx8)
24589 +.macro incdec_return func ins insc unchecked=""
24590 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
24591 CFI_STARTPROC
24592 SAVE ebx
24593
24594 @@ -112,21 +155,39 @@ ENTRY(atomic64_\func\()_return_cx8)
24595 movl %edx, %ecx
24596 \ins\()l $1, %ebx
24597 \insc\()l $0, %ecx
24598 +
24599 +.ifb \unchecked
24600 +#ifdef CONFIG_PAX_REFCOUNT
24601 + into
24602 +2:
24603 + _ASM_EXTABLE(2b, 3f)
24604 +#endif
24605 +.endif
24606 +
24607 LOCK_PREFIX
24608 cmpxchg8b (%esi)
24609 jne 1b
24610
24611 -10:
24612 movl %ebx, %eax
24613 movl %ecx, %edx
24614 +
24615 +.ifb \unchecked
24616 +#ifdef CONFIG_PAX_REFCOUNT
24617 +3:
24618 +#endif
24619 +.endif
24620 +
24621 RESTORE ebx
24622 + pax_force_retaddr
24623 ret
24624 CFI_ENDPROC
24625 -ENDPROC(atomic64_\func\()_return_cx8)
24626 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
24627 .endm
24628
24629 incdec_return inc add adc
24630 incdec_return dec sub sbb
24631 +incdec_return inc add adc _unchecked
24632 +incdec_return dec sub sbb _unchecked
24633
24634 ENTRY(atomic64_dec_if_positive_cx8)
24635 CFI_STARTPROC
24636 @@ -138,6 +199,13 @@ ENTRY(atomic64_dec_if_positive_cx8)
24637 movl %edx, %ecx
24638 subl $1, %ebx
24639 sbb $0, %ecx
24640 +
24641 +#ifdef CONFIG_PAX_REFCOUNT
24642 + into
24643 +1234:
24644 + _ASM_EXTABLE(1234b, 2f)
24645 +#endif
24646 +
24647 js 2f
24648 LOCK_PREFIX
24649 cmpxchg8b (%esi)
24650 @@ -147,6 +215,7 @@ ENTRY(atomic64_dec_if_positive_cx8)
24651 movl %ebx, %eax
24652 movl %ecx, %edx
24653 RESTORE ebx
24654 + pax_force_retaddr
24655 ret
24656 CFI_ENDPROC
24657 ENDPROC(atomic64_dec_if_positive_cx8)
24658 @@ -171,6 +240,13 @@ ENTRY(atomic64_add_unless_cx8)
24659 movl %edx, %ecx
24660 addl %ebp, %ebx
24661 adcl %edi, %ecx
24662 +
24663 +#ifdef CONFIG_PAX_REFCOUNT
24664 + into
24665 +1234:
24666 + _ASM_EXTABLE(1234b, 3f)
24667 +#endif
24668 +
24669 LOCK_PREFIX
24670 cmpxchg8b (%esi)
24671 jne 1b
24672 @@ -181,6 +257,7 @@ ENTRY(atomic64_add_unless_cx8)
24673 CFI_ADJUST_CFA_OFFSET -8
24674 RESTORE ebx
24675 RESTORE ebp
24676 + pax_force_retaddr
24677 ret
24678 4:
24679 cmpl %edx, 4(%esp)
24680 @@ -203,6 +280,13 @@ ENTRY(atomic64_inc_not_zero_cx8)
24681 xorl %ecx, %ecx
24682 addl $1, %ebx
24683 adcl %edx, %ecx
24684 +
24685 +#ifdef CONFIG_PAX_REFCOUNT
24686 + into
24687 +1234:
24688 + _ASM_EXTABLE(1234b, 3f)
24689 +#endif
24690 +
24691 LOCK_PREFIX
24692 cmpxchg8b (%esi)
24693 jne 1b
24694 @@ -210,6 +294,7 @@ ENTRY(atomic64_inc_not_zero_cx8)
24695 movl $1, %eax
24696 3:
24697 RESTORE ebx
24698 + pax_force_retaddr
24699 ret
24700 CFI_ENDPROC
24701 ENDPROC(atomic64_inc_not_zero_cx8)
24702 diff --git a/arch/x86/lib/checksum_32.S b/arch/x86/lib/checksum_32.S
24703 index 2af5df3..62b1a5a 100644
24704 --- a/arch/x86/lib/checksum_32.S
24705 +++ b/arch/x86/lib/checksum_32.S
24706 @@ -29,7 +29,8 @@
24707 #include <asm/dwarf2.h>
24708 #include <asm/errno.h>
24709 #include <asm/asm.h>
24710 -
24711 +#include <asm/segment.h>
24712 +
24713 /*
24714 * computes a partial checksum, e.g. for TCP/UDP fragments
24715 */
24716 @@ -293,9 +294,24 @@ unsigned int csum_partial_copy_generic (const char *src, char *dst,
24717
24718 #define ARGBASE 16
24719 #define FP 12
24720 -
24721 -ENTRY(csum_partial_copy_generic)
24722 +
24723 +ENTRY(csum_partial_copy_generic_to_user)
24724 CFI_STARTPROC
24725 +
24726 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24727 + pushl_cfi %gs
24728 + popl_cfi %es
24729 + jmp csum_partial_copy_generic
24730 +#endif
24731 +
24732 +ENTRY(csum_partial_copy_generic_from_user)
24733 +
24734 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24735 + pushl_cfi %gs
24736 + popl_cfi %ds
24737 +#endif
24738 +
24739 +ENTRY(csum_partial_copy_generic)
24740 subl $4,%esp
24741 CFI_ADJUST_CFA_OFFSET 4
24742 pushl_cfi %edi
24743 @@ -317,7 +333,7 @@ ENTRY(csum_partial_copy_generic)
24744 jmp 4f
24745 SRC(1: movw (%esi), %bx )
24746 addl $2, %esi
24747 -DST( movw %bx, (%edi) )
24748 +DST( movw %bx, %es:(%edi) )
24749 addl $2, %edi
24750 addw %bx, %ax
24751 adcl $0, %eax
24752 @@ -329,30 +345,30 @@ DST( movw %bx, (%edi) )
24753 SRC(1: movl (%esi), %ebx )
24754 SRC( movl 4(%esi), %edx )
24755 adcl %ebx, %eax
24756 -DST( movl %ebx, (%edi) )
24757 +DST( movl %ebx, %es:(%edi) )
24758 adcl %edx, %eax
24759 -DST( movl %edx, 4(%edi) )
24760 +DST( movl %edx, %es:4(%edi) )
24761
24762 SRC( movl 8(%esi), %ebx )
24763 SRC( movl 12(%esi), %edx )
24764 adcl %ebx, %eax
24765 -DST( movl %ebx, 8(%edi) )
24766 +DST( movl %ebx, %es:8(%edi) )
24767 adcl %edx, %eax
24768 -DST( movl %edx, 12(%edi) )
24769 +DST( movl %edx, %es:12(%edi) )
24770
24771 SRC( movl 16(%esi), %ebx )
24772 SRC( movl 20(%esi), %edx )
24773 adcl %ebx, %eax
24774 -DST( movl %ebx, 16(%edi) )
24775 +DST( movl %ebx, %es:16(%edi) )
24776 adcl %edx, %eax
24777 -DST( movl %edx, 20(%edi) )
24778 +DST( movl %edx, %es:20(%edi) )
24779
24780 SRC( movl 24(%esi), %ebx )
24781 SRC( movl 28(%esi), %edx )
24782 adcl %ebx, %eax
24783 -DST( movl %ebx, 24(%edi) )
24784 +DST( movl %ebx, %es:24(%edi) )
24785 adcl %edx, %eax
24786 -DST( movl %edx, 28(%edi) )
24787 +DST( movl %edx, %es:28(%edi) )
24788
24789 lea 32(%esi), %esi
24790 lea 32(%edi), %edi
24791 @@ -366,7 +382,7 @@ DST( movl %edx, 28(%edi) )
24792 shrl $2, %edx # This clears CF
24793 SRC(3: movl (%esi), %ebx )
24794 adcl %ebx, %eax
24795 -DST( movl %ebx, (%edi) )
24796 +DST( movl %ebx, %es:(%edi) )
24797 lea 4(%esi), %esi
24798 lea 4(%edi), %edi
24799 dec %edx
24800 @@ -378,12 +394,12 @@ DST( movl %ebx, (%edi) )
24801 jb 5f
24802 SRC( movw (%esi), %cx )
24803 leal 2(%esi), %esi
24804 -DST( movw %cx, (%edi) )
24805 +DST( movw %cx, %es:(%edi) )
24806 leal 2(%edi), %edi
24807 je 6f
24808 shll $16,%ecx
24809 SRC(5: movb (%esi), %cl )
24810 -DST( movb %cl, (%edi) )
24811 +DST( movb %cl, %es:(%edi) )
24812 6: addl %ecx, %eax
24813 adcl $0, %eax
24814 7:
24815 @@ -394,7 +410,7 @@ DST( movb %cl, (%edi) )
24816
24817 6001:
24818 movl ARGBASE+20(%esp), %ebx # src_err_ptr
24819 - movl $-EFAULT, (%ebx)
24820 + movl $-EFAULT, %ss:(%ebx)
24821
24822 # zero the complete destination - computing the rest
24823 # is too much work
24824 @@ -407,11 +423,15 @@ DST( movb %cl, (%edi) )
24825
24826 6002:
24827 movl ARGBASE+24(%esp), %ebx # dst_err_ptr
24828 - movl $-EFAULT,(%ebx)
24829 + movl $-EFAULT,%ss:(%ebx)
24830 jmp 5000b
24831
24832 .previous
24833
24834 + pushl_cfi %ss
24835 + popl_cfi %ds
24836 + pushl_cfi %ss
24837 + popl_cfi %es
24838 popl_cfi %ebx
24839 CFI_RESTORE ebx
24840 popl_cfi %esi
24841 @@ -421,26 +441,43 @@ DST( movb %cl, (%edi) )
24842 popl_cfi %ecx # equivalent to addl $4,%esp
24843 ret
24844 CFI_ENDPROC
24845 -ENDPROC(csum_partial_copy_generic)
24846 +ENDPROC(csum_partial_copy_generic_to_user)
24847
24848 #else
24849
24850 /* Version for PentiumII/PPro */
24851
24852 #define ROUND1(x) \
24853 + nop; nop; nop; \
24854 SRC(movl x(%esi), %ebx ) ; \
24855 addl %ebx, %eax ; \
24856 - DST(movl %ebx, x(%edi) ) ;
24857 + DST(movl %ebx, %es:x(%edi)) ;
24858
24859 #define ROUND(x) \
24860 + nop; nop; nop; \
24861 SRC(movl x(%esi), %ebx ) ; \
24862 adcl %ebx, %eax ; \
24863 - DST(movl %ebx, x(%edi) ) ;
24864 + DST(movl %ebx, %es:x(%edi)) ;
24865
24866 #define ARGBASE 12
24867 -
24868 -ENTRY(csum_partial_copy_generic)
24869 +
24870 +ENTRY(csum_partial_copy_generic_to_user)
24871 CFI_STARTPROC
24872 +
24873 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24874 + pushl_cfi %gs
24875 + popl_cfi %es
24876 + jmp csum_partial_copy_generic
24877 +#endif
24878 +
24879 +ENTRY(csum_partial_copy_generic_from_user)
24880 +
24881 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24882 + pushl_cfi %gs
24883 + popl_cfi %ds
24884 +#endif
24885 +
24886 +ENTRY(csum_partial_copy_generic)
24887 pushl_cfi %ebx
24888 CFI_REL_OFFSET ebx, 0
24889 pushl_cfi %edi
24890 @@ -461,7 +498,7 @@ ENTRY(csum_partial_copy_generic)
24891 subl %ebx, %edi
24892 lea -1(%esi),%edx
24893 andl $-32,%edx
24894 - lea 3f(%ebx,%ebx), %ebx
24895 + lea 3f(%ebx,%ebx,2), %ebx
24896 testl %esi, %esi
24897 jmp *%ebx
24898 1: addl $64,%esi
24899 @@ -482,19 +519,19 @@ ENTRY(csum_partial_copy_generic)
24900 jb 5f
24901 SRC( movw (%esi), %dx )
24902 leal 2(%esi), %esi
24903 -DST( movw %dx, (%edi) )
24904 +DST( movw %dx, %es:(%edi) )
24905 leal 2(%edi), %edi
24906 je 6f
24907 shll $16,%edx
24908 5:
24909 SRC( movb (%esi), %dl )
24910 -DST( movb %dl, (%edi) )
24911 +DST( movb %dl, %es:(%edi) )
24912 6: addl %edx, %eax
24913 adcl $0, %eax
24914 7:
24915 .section .fixup, "ax"
24916 6001: movl ARGBASE+20(%esp), %ebx # src_err_ptr
24917 - movl $-EFAULT, (%ebx)
24918 + movl $-EFAULT, %ss:(%ebx)
24919 # zero the complete destination (computing the rest is too much work)
24920 movl ARGBASE+8(%esp),%edi # dst
24921 movl ARGBASE+12(%esp),%ecx # len
24922 @@ -502,10 +539,17 @@ DST( movb %dl, (%edi) )
24923 rep; stosb
24924 jmp 7b
24925 6002: movl ARGBASE+24(%esp), %ebx # dst_err_ptr
24926 - movl $-EFAULT, (%ebx)
24927 + movl $-EFAULT, %ss:(%ebx)
24928 jmp 7b
24929 .previous
24930
24931 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24932 + pushl_cfi %ss
24933 + popl_cfi %ds
24934 + pushl_cfi %ss
24935 + popl_cfi %es
24936 +#endif
24937 +
24938 popl_cfi %esi
24939 CFI_RESTORE esi
24940 popl_cfi %edi
24941 @@ -514,7 +558,7 @@ DST( movb %dl, (%edi) )
24942 CFI_RESTORE ebx
24943 ret
24944 CFI_ENDPROC
24945 -ENDPROC(csum_partial_copy_generic)
24946 +ENDPROC(csum_partial_copy_generic_to_user)
24947
24948 #undef ROUND
24949 #undef ROUND1
24950 diff --git a/arch/x86/lib/clear_page_64.S b/arch/x86/lib/clear_page_64.S
24951 index f2145cf..cea889d 100644
24952 --- a/arch/x86/lib/clear_page_64.S
24953 +++ b/arch/x86/lib/clear_page_64.S
24954 @@ -11,6 +11,7 @@ ENTRY(clear_page_c)
24955 movl $4096/8,%ecx
24956 xorl %eax,%eax
24957 rep stosq
24958 + pax_force_retaddr
24959 ret
24960 CFI_ENDPROC
24961 ENDPROC(clear_page_c)
24962 @@ -20,6 +21,7 @@ ENTRY(clear_page_c_e)
24963 movl $4096,%ecx
24964 xorl %eax,%eax
24965 rep stosb
24966 + pax_force_retaddr
24967 ret
24968 CFI_ENDPROC
24969 ENDPROC(clear_page_c_e)
24970 @@ -43,6 +45,7 @@ ENTRY(clear_page)
24971 leaq 64(%rdi),%rdi
24972 jnz .Lloop
24973 nop
24974 + pax_force_retaddr
24975 ret
24976 CFI_ENDPROC
24977 .Lclear_page_end:
24978 @@ -58,7 +61,7 @@ ENDPROC(clear_page)
24979
24980 #include <asm/cpufeature.h>
24981
24982 - .section .altinstr_replacement,"ax"
24983 + .section .altinstr_replacement,"a"
24984 1: .byte 0xeb /* jmp <disp8> */
24985 .byte (clear_page_c - clear_page) - (2f - 1b) /* offset */
24986 2: .byte 0xeb /* jmp <disp8> */
24987 diff --git a/arch/x86/lib/cmpxchg16b_emu.S b/arch/x86/lib/cmpxchg16b_emu.S
24988 index 1e572c5..2a162cd 100644
24989 --- a/arch/x86/lib/cmpxchg16b_emu.S
24990 +++ b/arch/x86/lib/cmpxchg16b_emu.S
24991 @@ -53,11 +53,13 @@ this_cpu_cmpxchg16b_emu:
24992
24993 popf
24994 mov $1, %al
24995 + pax_force_retaddr
24996 ret
24997
24998 not_same:
24999 popf
25000 xor %al,%al
25001 + pax_force_retaddr
25002 ret
25003
25004 CFI_ENDPROC
25005 diff --git a/arch/x86/lib/copy_page_64.S b/arch/x86/lib/copy_page_64.S
25006 index 176cca6..1166c50 100644
25007 --- a/arch/x86/lib/copy_page_64.S
25008 +++ b/arch/x86/lib/copy_page_64.S
25009 @@ -9,6 +9,7 @@ copy_page_rep:
25010 CFI_STARTPROC
25011 movl $4096/8, %ecx
25012 rep movsq
25013 + pax_force_retaddr
25014 ret
25015 CFI_ENDPROC
25016 ENDPROC(copy_page_rep)
25017 @@ -20,12 +21,14 @@ ENDPROC(copy_page_rep)
25018
25019 ENTRY(copy_page)
25020 CFI_STARTPROC
25021 - subq $2*8, %rsp
25022 - CFI_ADJUST_CFA_OFFSET 2*8
25023 + subq $3*8, %rsp
25024 + CFI_ADJUST_CFA_OFFSET 3*8
25025 movq %rbx, (%rsp)
25026 CFI_REL_OFFSET rbx, 0
25027 movq %r12, 1*8(%rsp)
25028 CFI_REL_OFFSET r12, 1*8
25029 + movq %r13, 2*8(%rsp)
25030 + CFI_REL_OFFSET r13, 2*8
25031
25032 movl $(4096/64)-5, %ecx
25033 .p2align 4
25034 @@ -36,7 +39,7 @@ ENTRY(copy_page)
25035 movq 0x8*2(%rsi), %rdx
25036 movq 0x8*3(%rsi), %r8
25037 movq 0x8*4(%rsi), %r9
25038 - movq 0x8*5(%rsi), %r10
25039 + movq 0x8*5(%rsi), %r13
25040 movq 0x8*6(%rsi), %r11
25041 movq 0x8*7(%rsi), %r12
25042
25043 @@ -47,7 +50,7 @@ ENTRY(copy_page)
25044 movq %rdx, 0x8*2(%rdi)
25045 movq %r8, 0x8*3(%rdi)
25046 movq %r9, 0x8*4(%rdi)
25047 - movq %r10, 0x8*5(%rdi)
25048 + movq %r13, 0x8*5(%rdi)
25049 movq %r11, 0x8*6(%rdi)
25050 movq %r12, 0x8*7(%rdi)
25051
25052 @@ -66,7 +69,7 @@ ENTRY(copy_page)
25053 movq 0x8*2(%rsi), %rdx
25054 movq 0x8*3(%rsi), %r8
25055 movq 0x8*4(%rsi), %r9
25056 - movq 0x8*5(%rsi), %r10
25057 + movq 0x8*5(%rsi), %r13
25058 movq 0x8*6(%rsi), %r11
25059 movq 0x8*7(%rsi), %r12
25060
25061 @@ -75,7 +78,7 @@ ENTRY(copy_page)
25062 movq %rdx, 0x8*2(%rdi)
25063 movq %r8, 0x8*3(%rdi)
25064 movq %r9, 0x8*4(%rdi)
25065 - movq %r10, 0x8*5(%rdi)
25066 + movq %r13, 0x8*5(%rdi)
25067 movq %r11, 0x8*6(%rdi)
25068 movq %r12, 0x8*7(%rdi)
25069
25070 @@ -87,8 +90,11 @@ ENTRY(copy_page)
25071 CFI_RESTORE rbx
25072 movq 1*8(%rsp), %r12
25073 CFI_RESTORE r12
25074 - addq $2*8, %rsp
25075 - CFI_ADJUST_CFA_OFFSET -2*8
25076 + movq 2*8(%rsp), %r13
25077 + CFI_RESTORE r13
25078 + addq $3*8, %rsp
25079 + CFI_ADJUST_CFA_OFFSET -3*8
25080 + pax_force_retaddr
25081 ret
25082 .Lcopy_page_end:
25083 CFI_ENDPROC
25084 @@ -99,7 +105,7 @@ ENDPROC(copy_page)
25085
25086 #include <asm/cpufeature.h>
25087
25088 - .section .altinstr_replacement,"ax"
25089 + .section .altinstr_replacement,"a"
25090 1: .byte 0xeb /* jmp <disp8> */
25091 .byte (copy_page_rep - copy_page) - (2f - 1b) /* offset */
25092 2:
25093 diff --git a/arch/x86/lib/copy_user_64.S b/arch/x86/lib/copy_user_64.S
25094 index a30ca15..d25fab6 100644
25095 --- a/arch/x86/lib/copy_user_64.S
25096 +++ b/arch/x86/lib/copy_user_64.S
25097 @@ -18,6 +18,7 @@
25098 #include <asm/alternative-asm.h>
25099 #include <asm/asm.h>
25100 #include <asm/smap.h>
25101 +#include <asm/pgtable.h>
25102
25103 /*
25104 * By placing feature2 after feature1 in altinstructions section, we logically
25105 @@ -31,7 +32,7 @@
25106 .byte 0xe9 /* 32bit jump */
25107 .long \orig-1f /* by default jump to orig */
25108 1:
25109 - .section .altinstr_replacement,"ax"
25110 + .section .altinstr_replacement,"a"
25111 2: .byte 0xe9 /* near jump with 32bit immediate */
25112 .long \alt1-1b /* offset */ /* or alternatively to alt1 */
25113 3: .byte 0xe9 /* near jump with 32bit immediate */
25114 @@ -70,47 +71,20 @@
25115 #endif
25116 .endm
25117
25118 -/* Standard copy_to_user with segment limit checking */
25119 -ENTRY(_copy_to_user)
25120 - CFI_STARTPROC
25121 - GET_THREAD_INFO(%rax)
25122 - movq %rdi,%rcx
25123 - addq %rdx,%rcx
25124 - jc bad_to_user
25125 - cmpq TI_addr_limit(%rax),%rcx
25126 - ja bad_to_user
25127 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
25128 - copy_user_generic_unrolled,copy_user_generic_string, \
25129 - copy_user_enhanced_fast_string
25130 - CFI_ENDPROC
25131 -ENDPROC(_copy_to_user)
25132 -
25133 -/* Standard copy_from_user with segment limit checking */
25134 -ENTRY(_copy_from_user)
25135 - CFI_STARTPROC
25136 - GET_THREAD_INFO(%rax)
25137 - movq %rsi,%rcx
25138 - addq %rdx,%rcx
25139 - jc bad_from_user
25140 - cmpq TI_addr_limit(%rax),%rcx
25141 - ja bad_from_user
25142 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
25143 - copy_user_generic_unrolled,copy_user_generic_string, \
25144 - copy_user_enhanced_fast_string
25145 - CFI_ENDPROC
25146 -ENDPROC(_copy_from_user)
25147 -
25148 .section .fixup,"ax"
25149 /* must zero dest */
25150 ENTRY(bad_from_user)
25151 bad_from_user:
25152 CFI_STARTPROC
25153 + testl %edx,%edx
25154 + js bad_to_user
25155 movl %edx,%ecx
25156 xorl %eax,%eax
25157 rep
25158 stosb
25159 bad_to_user:
25160 movl %edx,%eax
25161 + pax_force_retaddr
25162 ret
25163 CFI_ENDPROC
25164 ENDPROC(bad_from_user)
25165 @@ -141,19 +115,19 @@ ENTRY(copy_user_generic_unrolled)
25166 jz 17f
25167 1: movq (%rsi),%r8
25168 2: movq 1*8(%rsi),%r9
25169 -3: movq 2*8(%rsi),%r10
25170 +3: movq 2*8(%rsi),%rax
25171 4: movq 3*8(%rsi),%r11
25172 5: movq %r8,(%rdi)
25173 6: movq %r9,1*8(%rdi)
25174 -7: movq %r10,2*8(%rdi)
25175 +7: movq %rax,2*8(%rdi)
25176 8: movq %r11,3*8(%rdi)
25177 9: movq 4*8(%rsi),%r8
25178 10: movq 5*8(%rsi),%r9
25179 -11: movq 6*8(%rsi),%r10
25180 +11: movq 6*8(%rsi),%rax
25181 12: movq 7*8(%rsi),%r11
25182 13: movq %r8,4*8(%rdi)
25183 14: movq %r9,5*8(%rdi)
25184 -15: movq %r10,6*8(%rdi)
25185 +15: movq %rax,6*8(%rdi)
25186 16: movq %r11,7*8(%rdi)
25187 leaq 64(%rsi),%rsi
25188 leaq 64(%rdi),%rdi
25189 @@ -180,6 +154,7 @@ ENTRY(copy_user_generic_unrolled)
25190 jnz 21b
25191 23: xor %eax,%eax
25192 ASM_CLAC
25193 + pax_force_retaddr
25194 ret
25195
25196 .section .fixup,"ax"
25197 @@ -251,6 +226,7 @@ ENTRY(copy_user_generic_string)
25198 movsb
25199 4: xorl %eax,%eax
25200 ASM_CLAC
25201 + pax_force_retaddr
25202 ret
25203
25204 .section .fixup,"ax"
25205 @@ -286,6 +262,7 @@ ENTRY(copy_user_enhanced_fast_string)
25206 movsb
25207 2: xorl %eax,%eax
25208 ASM_CLAC
25209 + pax_force_retaddr
25210 ret
25211
25212 .section .fixup,"ax"
25213 diff --git a/arch/x86/lib/copy_user_nocache_64.S b/arch/x86/lib/copy_user_nocache_64.S
25214 index 6a4f43c..f08b4a2 100644
25215 --- a/arch/x86/lib/copy_user_nocache_64.S
25216 +++ b/arch/x86/lib/copy_user_nocache_64.S
25217 @@ -8,6 +8,7 @@
25218
25219 #include <linux/linkage.h>
25220 #include <asm/dwarf2.h>
25221 +#include <asm/alternative-asm.h>
25222
25223 #define FIX_ALIGNMENT 1
25224
25225 @@ -16,6 +17,7 @@
25226 #include <asm/thread_info.h>
25227 #include <asm/asm.h>
25228 #include <asm/smap.h>
25229 +#include <asm/pgtable.h>
25230
25231 .macro ALIGN_DESTINATION
25232 #ifdef FIX_ALIGNMENT
25233 @@ -49,6 +51,15 @@
25234 */
25235 ENTRY(__copy_user_nocache)
25236 CFI_STARTPROC
25237 +
25238 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25239 + mov pax_user_shadow_base,%rcx
25240 + cmp %rcx,%rsi
25241 + jae 1f
25242 + add %rcx,%rsi
25243 +1:
25244 +#endif
25245 +
25246 ASM_STAC
25247 cmpl $8,%edx
25248 jb 20f /* less then 8 bytes, go to byte copy loop */
25249 @@ -59,19 +70,19 @@ ENTRY(__copy_user_nocache)
25250 jz 17f
25251 1: movq (%rsi),%r8
25252 2: movq 1*8(%rsi),%r9
25253 -3: movq 2*8(%rsi),%r10
25254 +3: movq 2*8(%rsi),%rax
25255 4: movq 3*8(%rsi),%r11
25256 5: movnti %r8,(%rdi)
25257 6: movnti %r9,1*8(%rdi)
25258 -7: movnti %r10,2*8(%rdi)
25259 +7: movnti %rax,2*8(%rdi)
25260 8: movnti %r11,3*8(%rdi)
25261 9: movq 4*8(%rsi),%r8
25262 10: movq 5*8(%rsi),%r9
25263 -11: movq 6*8(%rsi),%r10
25264 +11: movq 6*8(%rsi),%rax
25265 12: movq 7*8(%rsi),%r11
25266 13: movnti %r8,4*8(%rdi)
25267 14: movnti %r9,5*8(%rdi)
25268 -15: movnti %r10,6*8(%rdi)
25269 +15: movnti %rax,6*8(%rdi)
25270 16: movnti %r11,7*8(%rdi)
25271 leaq 64(%rsi),%rsi
25272 leaq 64(%rdi),%rdi
25273 @@ -99,6 +110,7 @@ ENTRY(__copy_user_nocache)
25274 23: xorl %eax,%eax
25275 ASM_CLAC
25276 sfence
25277 + pax_force_retaddr
25278 ret
25279
25280 .section .fixup,"ax"
25281 diff --git a/arch/x86/lib/csum-copy_64.S b/arch/x86/lib/csum-copy_64.S
25282 index 2419d5f..953ee51 100644
25283 --- a/arch/x86/lib/csum-copy_64.S
25284 +++ b/arch/x86/lib/csum-copy_64.S
25285 @@ -9,6 +9,7 @@
25286 #include <asm/dwarf2.h>
25287 #include <asm/errno.h>
25288 #include <asm/asm.h>
25289 +#include <asm/alternative-asm.h>
25290
25291 /*
25292 * Checksum copy with exception handling.
25293 @@ -220,6 +221,7 @@ ENTRY(csum_partial_copy_generic)
25294 CFI_RESTORE rbp
25295 addq $7*8, %rsp
25296 CFI_ADJUST_CFA_OFFSET -7*8
25297 + pax_force_retaddr 0, 1
25298 ret
25299 CFI_RESTORE_STATE
25300
25301 diff --git a/arch/x86/lib/csum-wrappers_64.c b/arch/x86/lib/csum-wrappers_64.c
25302 index 25b7ae8..169fafc 100644
25303 --- a/arch/x86/lib/csum-wrappers_64.c
25304 +++ b/arch/x86/lib/csum-wrappers_64.c
25305 @@ -52,7 +52,7 @@ csum_partial_copy_from_user(const void __user *src, void *dst,
25306 len -= 2;
25307 }
25308 }
25309 - isum = csum_partial_copy_generic((__force const void *)src,
25310 + isum = csum_partial_copy_generic((const void __force_kernel *)____m(src),
25311 dst, len, isum, errp, NULL);
25312 if (unlikely(*errp))
25313 goto out_err;
25314 @@ -105,7 +105,7 @@ csum_partial_copy_to_user(const void *src, void __user *dst,
25315 }
25316
25317 *errp = 0;
25318 - return csum_partial_copy_generic(src, (void __force *)dst,
25319 + return csum_partial_copy_generic(src, (void __force_kernel *)____m(dst),
25320 len, isum, NULL, errp);
25321 }
25322 EXPORT_SYMBOL(csum_partial_copy_to_user);
25323 diff --git a/arch/x86/lib/getuser.S b/arch/x86/lib/getuser.S
25324 index a451235..79fb5cf 100644
25325 --- a/arch/x86/lib/getuser.S
25326 +++ b/arch/x86/lib/getuser.S
25327 @@ -33,17 +33,40 @@
25328 #include <asm/thread_info.h>
25329 #include <asm/asm.h>
25330 #include <asm/smap.h>
25331 +#include <asm/segment.h>
25332 +#include <asm/pgtable.h>
25333 +#include <asm/alternative-asm.h>
25334 +
25335 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
25336 +#define __copyuser_seg gs;
25337 +#else
25338 +#define __copyuser_seg
25339 +#endif
25340
25341 .text
25342 ENTRY(__get_user_1)
25343 CFI_STARTPROC
25344 +
25345 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25346 GET_THREAD_INFO(%_ASM_DX)
25347 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25348 jae bad_get_user
25349 ASM_STAC
25350 -1: movzbl (%_ASM_AX),%edx
25351 +
25352 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25353 + mov pax_user_shadow_base,%_ASM_DX
25354 + cmp %_ASM_DX,%_ASM_AX
25355 + jae 1234f
25356 + add %_ASM_DX,%_ASM_AX
25357 +1234:
25358 +#endif
25359 +
25360 +#endif
25361 +
25362 +1: __copyuser_seg movzbl (%_ASM_AX),%edx
25363 xor %eax,%eax
25364 ASM_CLAC
25365 + pax_force_retaddr
25366 ret
25367 CFI_ENDPROC
25368 ENDPROC(__get_user_1)
25369 @@ -51,14 +74,28 @@ ENDPROC(__get_user_1)
25370 ENTRY(__get_user_2)
25371 CFI_STARTPROC
25372 add $1,%_ASM_AX
25373 +
25374 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25375 jc bad_get_user
25376 GET_THREAD_INFO(%_ASM_DX)
25377 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25378 jae bad_get_user
25379 ASM_STAC
25380 -2: movzwl -1(%_ASM_AX),%edx
25381 +
25382 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25383 + mov pax_user_shadow_base,%_ASM_DX
25384 + cmp %_ASM_DX,%_ASM_AX
25385 + jae 1234f
25386 + add %_ASM_DX,%_ASM_AX
25387 +1234:
25388 +#endif
25389 +
25390 +#endif
25391 +
25392 +2: __copyuser_seg movzwl -1(%_ASM_AX),%edx
25393 xor %eax,%eax
25394 ASM_CLAC
25395 + pax_force_retaddr
25396 ret
25397 CFI_ENDPROC
25398 ENDPROC(__get_user_2)
25399 @@ -66,14 +103,28 @@ ENDPROC(__get_user_2)
25400 ENTRY(__get_user_4)
25401 CFI_STARTPROC
25402 add $3,%_ASM_AX
25403 +
25404 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25405 jc bad_get_user
25406 GET_THREAD_INFO(%_ASM_DX)
25407 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25408 jae bad_get_user
25409 ASM_STAC
25410 -3: movl -3(%_ASM_AX),%edx
25411 +
25412 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25413 + mov pax_user_shadow_base,%_ASM_DX
25414 + cmp %_ASM_DX,%_ASM_AX
25415 + jae 1234f
25416 + add %_ASM_DX,%_ASM_AX
25417 +1234:
25418 +#endif
25419 +
25420 +#endif
25421 +
25422 +3: __copyuser_seg movl -3(%_ASM_AX),%edx
25423 xor %eax,%eax
25424 ASM_CLAC
25425 + pax_force_retaddr
25426 ret
25427 CFI_ENDPROC
25428 ENDPROC(__get_user_4)
25429 @@ -86,10 +137,20 @@ ENTRY(__get_user_8)
25430 GET_THREAD_INFO(%_ASM_DX)
25431 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25432 jae bad_get_user
25433 +
25434 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25435 + mov pax_user_shadow_base,%_ASM_DX
25436 + cmp %_ASM_DX,%_ASM_AX
25437 + jae 1234f
25438 + add %_ASM_DX,%_ASM_AX
25439 +1234:
25440 +#endif
25441 +
25442 ASM_STAC
25443 4: movq -7(%_ASM_AX),%rdx
25444 xor %eax,%eax
25445 ASM_CLAC
25446 + pax_force_retaddr
25447 ret
25448 #else
25449 add $7,%_ASM_AX
25450 @@ -102,6 +163,7 @@ ENTRY(__get_user_8)
25451 5: movl -3(%_ASM_AX),%ecx
25452 xor %eax,%eax
25453 ASM_CLAC
25454 + pax_force_retaddr
25455 ret
25456 #endif
25457 CFI_ENDPROC
25458 @@ -113,6 +175,7 @@ bad_get_user:
25459 xor %edx,%edx
25460 mov $(-EFAULT),%_ASM_AX
25461 ASM_CLAC
25462 + pax_force_retaddr
25463 ret
25464 CFI_ENDPROC
25465 END(bad_get_user)
25466 @@ -124,6 +187,7 @@ bad_get_user_8:
25467 xor %ecx,%ecx
25468 mov $(-EFAULT),%_ASM_AX
25469 ASM_CLAC
25470 + pax_force_retaddr
25471 ret
25472 CFI_ENDPROC
25473 END(bad_get_user_8)
25474 diff --git a/arch/x86/lib/insn.c b/arch/x86/lib/insn.c
25475 index 54fcffe..7be149e 100644
25476 --- a/arch/x86/lib/insn.c
25477 +++ b/arch/x86/lib/insn.c
25478 @@ -20,8 +20,10 @@
25479
25480 #ifdef __KERNEL__
25481 #include <linux/string.h>
25482 +#include <asm/pgtable_types.h>
25483 #else
25484 #include <string.h>
25485 +#define ktla_ktva(addr) addr
25486 #endif
25487 #include <asm/inat.h>
25488 #include <asm/insn.h>
25489 @@ -53,8 +55,8 @@
25490 void insn_init(struct insn *insn, const void *kaddr, int x86_64)
25491 {
25492 memset(insn, 0, sizeof(*insn));
25493 - insn->kaddr = kaddr;
25494 - insn->next_byte = kaddr;
25495 + insn->kaddr = ktla_ktva(kaddr);
25496 + insn->next_byte = ktla_ktva(kaddr);
25497 insn->x86_64 = x86_64 ? 1 : 0;
25498 insn->opnd_bytes = 4;
25499 if (x86_64)
25500 diff --git a/arch/x86/lib/iomap_copy_64.S b/arch/x86/lib/iomap_copy_64.S
25501 index 05a95e7..326f2fa 100644
25502 --- a/arch/x86/lib/iomap_copy_64.S
25503 +++ b/arch/x86/lib/iomap_copy_64.S
25504 @@ -17,6 +17,7 @@
25505
25506 #include <linux/linkage.h>
25507 #include <asm/dwarf2.h>
25508 +#include <asm/alternative-asm.h>
25509
25510 /*
25511 * override generic version in lib/iomap_copy.c
25512 @@ -25,6 +26,7 @@ ENTRY(__iowrite32_copy)
25513 CFI_STARTPROC
25514 movl %edx,%ecx
25515 rep movsd
25516 + pax_force_retaddr
25517 ret
25518 CFI_ENDPROC
25519 ENDPROC(__iowrite32_copy)
25520 diff --git a/arch/x86/lib/memcpy_64.S b/arch/x86/lib/memcpy_64.S
25521 index 1c273be..da9cc0e 100644
25522 --- a/arch/x86/lib/memcpy_64.S
25523 +++ b/arch/x86/lib/memcpy_64.S
25524 @@ -33,6 +33,7 @@
25525 rep movsq
25526 movl %edx, %ecx
25527 rep movsb
25528 + pax_force_retaddr
25529 ret
25530 .Lmemcpy_e:
25531 .previous
25532 @@ -49,6 +50,7 @@
25533 movq %rdi, %rax
25534 movq %rdx, %rcx
25535 rep movsb
25536 + pax_force_retaddr
25537 ret
25538 .Lmemcpy_e_e:
25539 .previous
25540 @@ -76,13 +78,13 @@ ENTRY(memcpy)
25541 */
25542 movq 0*8(%rsi), %r8
25543 movq 1*8(%rsi), %r9
25544 - movq 2*8(%rsi), %r10
25545 + movq 2*8(%rsi), %rcx
25546 movq 3*8(%rsi), %r11
25547 leaq 4*8(%rsi), %rsi
25548
25549 movq %r8, 0*8(%rdi)
25550 movq %r9, 1*8(%rdi)
25551 - movq %r10, 2*8(%rdi)
25552 + movq %rcx, 2*8(%rdi)
25553 movq %r11, 3*8(%rdi)
25554 leaq 4*8(%rdi), %rdi
25555 jae .Lcopy_forward_loop
25556 @@ -105,12 +107,12 @@ ENTRY(memcpy)
25557 subq $0x20, %rdx
25558 movq -1*8(%rsi), %r8
25559 movq -2*8(%rsi), %r9
25560 - movq -3*8(%rsi), %r10
25561 + movq -3*8(%rsi), %rcx
25562 movq -4*8(%rsi), %r11
25563 leaq -4*8(%rsi), %rsi
25564 movq %r8, -1*8(%rdi)
25565 movq %r9, -2*8(%rdi)
25566 - movq %r10, -3*8(%rdi)
25567 + movq %rcx, -3*8(%rdi)
25568 movq %r11, -4*8(%rdi)
25569 leaq -4*8(%rdi), %rdi
25570 jae .Lcopy_backward_loop
25571 @@ -130,12 +132,13 @@ ENTRY(memcpy)
25572 */
25573 movq 0*8(%rsi), %r8
25574 movq 1*8(%rsi), %r9
25575 - movq -2*8(%rsi, %rdx), %r10
25576 + movq -2*8(%rsi, %rdx), %rcx
25577 movq -1*8(%rsi, %rdx), %r11
25578 movq %r8, 0*8(%rdi)
25579 movq %r9, 1*8(%rdi)
25580 - movq %r10, -2*8(%rdi, %rdx)
25581 + movq %rcx, -2*8(%rdi, %rdx)
25582 movq %r11, -1*8(%rdi, %rdx)
25583 + pax_force_retaddr
25584 retq
25585 .p2align 4
25586 .Lless_16bytes:
25587 @@ -148,6 +151,7 @@ ENTRY(memcpy)
25588 movq -1*8(%rsi, %rdx), %r9
25589 movq %r8, 0*8(%rdi)
25590 movq %r9, -1*8(%rdi, %rdx)
25591 + pax_force_retaddr
25592 retq
25593 .p2align 4
25594 .Lless_8bytes:
25595 @@ -161,6 +165,7 @@ ENTRY(memcpy)
25596 movl -4(%rsi, %rdx), %r8d
25597 movl %ecx, (%rdi)
25598 movl %r8d, -4(%rdi, %rdx)
25599 + pax_force_retaddr
25600 retq
25601 .p2align 4
25602 .Lless_3bytes:
25603 @@ -179,6 +184,7 @@ ENTRY(memcpy)
25604 movb %cl, (%rdi)
25605
25606 .Lend:
25607 + pax_force_retaddr
25608 retq
25609 CFI_ENDPROC
25610 ENDPROC(memcpy)
25611 diff --git a/arch/x86/lib/memmove_64.S b/arch/x86/lib/memmove_64.S
25612 index ee16461..c39c199 100644
25613 --- a/arch/x86/lib/memmove_64.S
25614 +++ b/arch/x86/lib/memmove_64.S
25615 @@ -61,13 +61,13 @@ ENTRY(memmove)
25616 5:
25617 sub $0x20, %rdx
25618 movq 0*8(%rsi), %r11
25619 - movq 1*8(%rsi), %r10
25620 + movq 1*8(%rsi), %rcx
25621 movq 2*8(%rsi), %r9
25622 movq 3*8(%rsi), %r8
25623 leaq 4*8(%rsi), %rsi
25624
25625 movq %r11, 0*8(%rdi)
25626 - movq %r10, 1*8(%rdi)
25627 + movq %rcx, 1*8(%rdi)
25628 movq %r9, 2*8(%rdi)
25629 movq %r8, 3*8(%rdi)
25630 leaq 4*8(%rdi), %rdi
25631 @@ -81,10 +81,10 @@ ENTRY(memmove)
25632 4:
25633 movq %rdx, %rcx
25634 movq -8(%rsi, %rdx), %r11
25635 - lea -8(%rdi, %rdx), %r10
25636 + lea -8(%rdi, %rdx), %r9
25637 shrq $3, %rcx
25638 rep movsq
25639 - movq %r11, (%r10)
25640 + movq %r11, (%r9)
25641 jmp 13f
25642 .Lmemmove_end_forward:
25643
25644 @@ -95,14 +95,14 @@ ENTRY(memmove)
25645 7:
25646 movq %rdx, %rcx
25647 movq (%rsi), %r11
25648 - movq %rdi, %r10
25649 + movq %rdi, %r9
25650 leaq -8(%rsi, %rdx), %rsi
25651 leaq -8(%rdi, %rdx), %rdi
25652 shrq $3, %rcx
25653 std
25654 rep movsq
25655 cld
25656 - movq %r11, (%r10)
25657 + movq %r11, (%r9)
25658 jmp 13f
25659
25660 /*
25661 @@ -127,13 +127,13 @@ ENTRY(memmove)
25662 8:
25663 subq $0x20, %rdx
25664 movq -1*8(%rsi), %r11
25665 - movq -2*8(%rsi), %r10
25666 + movq -2*8(%rsi), %rcx
25667 movq -3*8(%rsi), %r9
25668 movq -4*8(%rsi), %r8
25669 leaq -4*8(%rsi), %rsi
25670
25671 movq %r11, -1*8(%rdi)
25672 - movq %r10, -2*8(%rdi)
25673 + movq %rcx, -2*8(%rdi)
25674 movq %r9, -3*8(%rdi)
25675 movq %r8, -4*8(%rdi)
25676 leaq -4*8(%rdi), %rdi
25677 @@ -151,11 +151,11 @@ ENTRY(memmove)
25678 * Move data from 16 bytes to 31 bytes.
25679 */
25680 movq 0*8(%rsi), %r11
25681 - movq 1*8(%rsi), %r10
25682 + movq 1*8(%rsi), %rcx
25683 movq -2*8(%rsi, %rdx), %r9
25684 movq -1*8(%rsi, %rdx), %r8
25685 movq %r11, 0*8(%rdi)
25686 - movq %r10, 1*8(%rdi)
25687 + movq %rcx, 1*8(%rdi)
25688 movq %r9, -2*8(%rdi, %rdx)
25689 movq %r8, -1*8(%rdi, %rdx)
25690 jmp 13f
25691 @@ -167,9 +167,9 @@ ENTRY(memmove)
25692 * Move data from 8 bytes to 15 bytes.
25693 */
25694 movq 0*8(%rsi), %r11
25695 - movq -1*8(%rsi, %rdx), %r10
25696 + movq -1*8(%rsi, %rdx), %r9
25697 movq %r11, 0*8(%rdi)
25698 - movq %r10, -1*8(%rdi, %rdx)
25699 + movq %r9, -1*8(%rdi, %rdx)
25700 jmp 13f
25701 10:
25702 cmpq $4, %rdx
25703 @@ -178,9 +178,9 @@ ENTRY(memmove)
25704 * Move data from 4 bytes to 7 bytes.
25705 */
25706 movl (%rsi), %r11d
25707 - movl -4(%rsi, %rdx), %r10d
25708 + movl -4(%rsi, %rdx), %r9d
25709 movl %r11d, (%rdi)
25710 - movl %r10d, -4(%rdi, %rdx)
25711 + movl %r9d, -4(%rdi, %rdx)
25712 jmp 13f
25713 11:
25714 cmp $2, %rdx
25715 @@ -189,9 +189,9 @@ ENTRY(memmove)
25716 * Move data from 2 bytes to 3 bytes.
25717 */
25718 movw (%rsi), %r11w
25719 - movw -2(%rsi, %rdx), %r10w
25720 + movw -2(%rsi, %rdx), %r9w
25721 movw %r11w, (%rdi)
25722 - movw %r10w, -2(%rdi, %rdx)
25723 + movw %r9w, -2(%rdi, %rdx)
25724 jmp 13f
25725 12:
25726 cmp $1, %rdx
25727 @@ -202,6 +202,7 @@ ENTRY(memmove)
25728 movb (%rsi), %r11b
25729 movb %r11b, (%rdi)
25730 13:
25731 + pax_force_retaddr
25732 retq
25733 CFI_ENDPROC
25734
25735 @@ -210,6 +211,7 @@ ENTRY(memmove)
25736 /* Forward moving data. */
25737 movq %rdx, %rcx
25738 rep movsb
25739 + pax_force_retaddr
25740 retq
25741 .Lmemmove_end_forward_efs:
25742 .previous
25743 diff --git a/arch/x86/lib/memset_64.S b/arch/x86/lib/memset_64.S
25744 index 2dcb380..963660a 100644
25745 --- a/arch/x86/lib/memset_64.S
25746 +++ b/arch/x86/lib/memset_64.S
25747 @@ -30,6 +30,7 @@
25748 movl %edx,%ecx
25749 rep stosb
25750 movq %r9,%rax
25751 + pax_force_retaddr
25752 ret
25753 .Lmemset_e:
25754 .previous
25755 @@ -52,6 +53,7 @@
25756 movq %rdx,%rcx
25757 rep stosb
25758 movq %r9,%rax
25759 + pax_force_retaddr
25760 ret
25761 .Lmemset_e_e:
25762 .previous
25763 @@ -59,7 +61,7 @@
25764 ENTRY(memset)
25765 ENTRY(__memset)
25766 CFI_STARTPROC
25767 - movq %rdi,%r10
25768 + movq %rdi,%r11
25769
25770 /* expand byte value */
25771 movzbl %sil,%ecx
25772 @@ -117,7 +119,8 @@ ENTRY(__memset)
25773 jnz .Lloop_1
25774
25775 .Lende:
25776 - movq %r10,%rax
25777 + movq %r11,%rax
25778 + pax_force_retaddr
25779 ret
25780
25781 CFI_RESTORE_STATE
25782 diff --git a/arch/x86/lib/mmx_32.c b/arch/x86/lib/mmx_32.c
25783 index c9f2d9b..e7fd2c0 100644
25784 --- a/arch/x86/lib/mmx_32.c
25785 +++ b/arch/x86/lib/mmx_32.c
25786 @@ -29,6 +29,7 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
25787 {
25788 void *p;
25789 int i;
25790 + unsigned long cr0;
25791
25792 if (unlikely(in_interrupt()))
25793 return __memcpy(to, from, len);
25794 @@ -39,44 +40,72 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
25795 kernel_fpu_begin();
25796
25797 __asm__ __volatile__ (
25798 - "1: prefetch (%0)\n" /* This set is 28 bytes */
25799 - " prefetch 64(%0)\n"
25800 - " prefetch 128(%0)\n"
25801 - " prefetch 192(%0)\n"
25802 - " prefetch 256(%0)\n"
25803 + "1: prefetch (%1)\n" /* This set is 28 bytes */
25804 + " prefetch 64(%1)\n"
25805 + " prefetch 128(%1)\n"
25806 + " prefetch 192(%1)\n"
25807 + " prefetch 256(%1)\n"
25808 "2: \n"
25809 ".section .fixup, \"ax\"\n"
25810 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
25811 + "3: \n"
25812 +
25813 +#ifdef CONFIG_PAX_KERNEXEC
25814 + " movl %%cr0, %0\n"
25815 + " movl %0, %%eax\n"
25816 + " andl $0xFFFEFFFF, %%eax\n"
25817 + " movl %%eax, %%cr0\n"
25818 +#endif
25819 +
25820 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
25821 +
25822 +#ifdef CONFIG_PAX_KERNEXEC
25823 + " movl %0, %%cr0\n"
25824 +#endif
25825 +
25826 " jmp 2b\n"
25827 ".previous\n"
25828 _ASM_EXTABLE(1b, 3b)
25829 - : : "r" (from));
25830 + : "=&r" (cr0) : "r" (from) : "ax");
25831
25832 for ( ; i > 5; i--) {
25833 __asm__ __volatile__ (
25834 - "1: prefetch 320(%0)\n"
25835 - "2: movq (%0), %%mm0\n"
25836 - " movq 8(%0), %%mm1\n"
25837 - " movq 16(%0), %%mm2\n"
25838 - " movq 24(%0), %%mm3\n"
25839 - " movq %%mm0, (%1)\n"
25840 - " movq %%mm1, 8(%1)\n"
25841 - " movq %%mm2, 16(%1)\n"
25842 - " movq %%mm3, 24(%1)\n"
25843 - " movq 32(%0), %%mm0\n"
25844 - " movq 40(%0), %%mm1\n"
25845 - " movq 48(%0), %%mm2\n"
25846 - " movq 56(%0), %%mm3\n"
25847 - " movq %%mm0, 32(%1)\n"
25848 - " movq %%mm1, 40(%1)\n"
25849 - " movq %%mm2, 48(%1)\n"
25850 - " movq %%mm3, 56(%1)\n"
25851 + "1: prefetch 320(%1)\n"
25852 + "2: movq (%1), %%mm0\n"
25853 + " movq 8(%1), %%mm1\n"
25854 + " movq 16(%1), %%mm2\n"
25855 + " movq 24(%1), %%mm3\n"
25856 + " movq %%mm0, (%2)\n"
25857 + " movq %%mm1, 8(%2)\n"
25858 + " movq %%mm2, 16(%2)\n"
25859 + " movq %%mm3, 24(%2)\n"
25860 + " movq 32(%1), %%mm0\n"
25861 + " movq 40(%1), %%mm1\n"
25862 + " movq 48(%1), %%mm2\n"
25863 + " movq 56(%1), %%mm3\n"
25864 + " movq %%mm0, 32(%2)\n"
25865 + " movq %%mm1, 40(%2)\n"
25866 + " movq %%mm2, 48(%2)\n"
25867 + " movq %%mm3, 56(%2)\n"
25868 ".section .fixup, \"ax\"\n"
25869 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
25870 + "3:\n"
25871 +
25872 +#ifdef CONFIG_PAX_KERNEXEC
25873 + " movl %%cr0, %0\n"
25874 + " movl %0, %%eax\n"
25875 + " andl $0xFFFEFFFF, %%eax\n"
25876 + " movl %%eax, %%cr0\n"
25877 +#endif
25878 +
25879 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
25880 +
25881 +#ifdef CONFIG_PAX_KERNEXEC
25882 + " movl %0, %%cr0\n"
25883 +#endif
25884 +
25885 " jmp 2b\n"
25886 ".previous\n"
25887 _ASM_EXTABLE(1b, 3b)
25888 - : : "r" (from), "r" (to) : "memory");
25889 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
25890
25891 from += 64;
25892 to += 64;
25893 @@ -158,6 +187,7 @@ static void fast_clear_page(void *page)
25894 static void fast_copy_page(void *to, void *from)
25895 {
25896 int i;
25897 + unsigned long cr0;
25898
25899 kernel_fpu_begin();
25900
25901 @@ -166,42 +196,70 @@ static void fast_copy_page(void *to, void *from)
25902 * but that is for later. -AV
25903 */
25904 __asm__ __volatile__(
25905 - "1: prefetch (%0)\n"
25906 - " prefetch 64(%0)\n"
25907 - " prefetch 128(%0)\n"
25908 - " prefetch 192(%0)\n"
25909 - " prefetch 256(%0)\n"
25910 + "1: prefetch (%1)\n"
25911 + " prefetch 64(%1)\n"
25912 + " prefetch 128(%1)\n"
25913 + " prefetch 192(%1)\n"
25914 + " prefetch 256(%1)\n"
25915 "2: \n"
25916 ".section .fixup, \"ax\"\n"
25917 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
25918 + "3: \n"
25919 +
25920 +#ifdef CONFIG_PAX_KERNEXEC
25921 + " movl %%cr0, %0\n"
25922 + " movl %0, %%eax\n"
25923 + " andl $0xFFFEFFFF, %%eax\n"
25924 + " movl %%eax, %%cr0\n"
25925 +#endif
25926 +
25927 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
25928 +
25929 +#ifdef CONFIG_PAX_KERNEXEC
25930 + " movl %0, %%cr0\n"
25931 +#endif
25932 +
25933 " jmp 2b\n"
25934 ".previous\n"
25935 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
25936 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
25937
25938 for (i = 0; i < (4096-320)/64; i++) {
25939 __asm__ __volatile__ (
25940 - "1: prefetch 320(%0)\n"
25941 - "2: movq (%0), %%mm0\n"
25942 - " movntq %%mm0, (%1)\n"
25943 - " movq 8(%0), %%mm1\n"
25944 - " movntq %%mm1, 8(%1)\n"
25945 - " movq 16(%0), %%mm2\n"
25946 - " movntq %%mm2, 16(%1)\n"
25947 - " movq 24(%0), %%mm3\n"
25948 - " movntq %%mm3, 24(%1)\n"
25949 - " movq 32(%0), %%mm4\n"
25950 - " movntq %%mm4, 32(%1)\n"
25951 - " movq 40(%0), %%mm5\n"
25952 - " movntq %%mm5, 40(%1)\n"
25953 - " movq 48(%0), %%mm6\n"
25954 - " movntq %%mm6, 48(%1)\n"
25955 - " movq 56(%0), %%mm7\n"
25956 - " movntq %%mm7, 56(%1)\n"
25957 + "1: prefetch 320(%1)\n"
25958 + "2: movq (%1), %%mm0\n"
25959 + " movntq %%mm0, (%2)\n"
25960 + " movq 8(%1), %%mm1\n"
25961 + " movntq %%mm1, 8(%2)\n"
25962 + " movq 16(%1), %%mm2\n"
25963 + " movntq %%mm2, 16(%2)\n"
25964 + " movq 24(%1), %%mm3\n"
25965 + " movntq %%mm3, 24(%2)\n"
25966 + " movq 32(%1), %%mm4\n"
25967 + " movntq %%mm4, 32(%2)\n"
25968 + " movq 40(%1), %%mm5\n"
25969 + " movntq %%mm5, 40(%2)\n"
25970 + " movq 48(%1), %%mm6\n"
25971 + " movntq %%mm6, 48(%2)\n"
25972 + " movq 56(%1), %%mm7\n"
25973 + " movntq %%mm7, 56(%2)\n"
25974 ".section .fixup, \"ax\"\n"
25975 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
25976 + "3:\n"
25977 +
25978 +#ifdef CONFIG_PAX_KERNEXEC
25979 + " movl %%cr0, %0\n"
25980 + " movl %0, %%eax\n"
25981 + " andl $0xFFFEFFFF, %%eax\n"
25982 + " movl %%eax, %%cr0\n"
25983 +#endif
25984 +
25985 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
25986 +
25987 +#ifdef CONFIG_PAX_KERNEXEC
25988 + " movl %0, %%cr0\n"
25989 +#endif
25990 +
25991 " jmp 2b\n"
25992 ".previous\n"
25993 - _ASM_EXTABLE(1b, 3b) : : "r" (from), "r" (to) : "memory");
25994 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
25995
25996 from += 64;
25997 to += 64;
25998 @@ -280,47 +338,76 @@ static void fast_clear_page(void *page)
25999 static void fast_copy_page(void *to, void *from)
26000 {
26001 int i;
26002 + unsigned long cr0;
26003
26004 kernel_fpu_begin();
26005
26006 __asm__ __volatile__ (
26007 - "1: prefetch (%0)\n"
26008 - " prefetch 64(%0)\n"
26009 - " prefetch 128(%0)\n"
26010 - " prefetch 192(%0)\n"
26011 - " prefetch 256(%0)\n"
26012 + "1: prefetch (%1)\n"
26013 + " prefetch 64(%1)\n"
26014 + " prefetch 128(%1)\n"
26015 + " prefetch 192(%1)\n"
26016 + " prefetch 256(%1)\n"
26017 "2: \n"
26018 ".section .fixup, \"ax\"\n"
26019 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26020 + "3: \n"
26021 +
26022 +#ifdef CONFIG_PAX_KERNEXEC
26023 + " movl %%cr0, %0\n"
26024 + " movl %0, %%eax\n"
26025 + " andl $0xFFFEFFFF, %%eax\n"
26026 + " movl %%eax, %%cr0\n"
26027 +#endif
26028 +
26029 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26030 +
26031 +#ifdef CONFIG_PAX_KERNEXEC
26032 + " movl %0, %%cr0\n"
26033 +#endif
26034 +
26035 " jmp 2b\n"
26036 ".previous\n"
26037 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
26038 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
26039
26040 for (i = 0; i < 4096/64; i++) {
26041 __asm__ __volatile__ (
26042 - "1: prefetch 320(%0)\n"
26043 - "2: movq (%0), %%mm0\n"
26044 - " movq 8(%0), %%mm1\n"
26045 - " movq 16(%0), %%mm2\n"
26046 - " movq 24(%0), %%mm3\n"
26047 - " movq %%mm0, (%1)\n"
26048 - " movq %%mm1, 8(%1)\n"
26049 - " movq %%mm2, 16(%1)\n"
26050 - " movq %%mm3, 24(%1)\n"
26051 - " movq 32(%0), %%mm0\n"
26052 - " movq 40(%0), %%mm1\n"
26053 - " movq 48(%0), %%mm2\n"
26054 - " movq 56(%0), %%mm3\n"
26055 - " movq %%mm0, 32(%1)\n"
26056 - " movq %%mm1, 40(%1)\n"
26057 - " movq %%mm2, 48(%1)\n"
26058 - " movq %%mm3, 56(%1)\n"
26059 + "1: prefetch 320(%1)\n"
26060 + "2: movq (%1), %%mm0\n"
26061 + " movq 8(%1), %%mm1\n"
26062 + " movq 16(%1), %%mm2\n"
26063 + " movq 24(%1), %%mm3\n"
26064 + " movq %%mm0, (%2)\n"
26065 + " movq %%mm1, 8(%2)\n"
26066 + " movq %%mm2, 16(%2)\n"
26067 + " movq %%mm3, 24(%2)\n"
26068 + " movq 32(%1), %%mm0\n"
26069 + " movq 40(%1), %%mm1\n"
26070 + " movq 48(%1), %%mm2\n"
26071 + " movq 56(%1), %%mm3\n"
26072 + " movq %%mm0, 32(%2)\n"
26073 + " movq %%mm1, 40(%2)\n"
26074 + " movq %%mm2, 48(%2)\n"
26075 + " movq %%mm3, 56(%2)\n"
26076 ".section .fixup, \"ax\"\n"
26077 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26078 + "3:\n"
26079 +
26080 +#ifdef CONFIG_PAX_KERNEXEC
26081 + " movl %%cr0, %0\n"
26082 + " movl %0, %%eax\n"
26083 + " andl $0xFFFEFFFF, %%eax\n"
26084 + " movl %%eax, %%cr0\n"
26085 +#endif
26086 +
26087 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26088 +
26089 +#ifdef CONFIG_PAX_KERNEXEC
26090 + " movl %0, %%cr0\n"
26091 +#endif
26092 +
26093 " jmp 2b\n"
26094 ".previous\n"
26095 _ASM_EXTABLE(1b, 3b)
26096 - : : "r" (from), "r" (to) : "memory");
26097 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
26098
26099 from += 64;
26100 to += 64;
26101 diff --git a/arch/x86/lib/msr-reg.S b/arch/x86/lib/msr-reg.S
26102 index f6d13ee..aca5f0b 100644
26103 --- a/arch/x86/lib/msr-reg.S
26104 +++ b/arch/x86/lib/msr-reg.S
26105 @@ -3,6 +3,7 @@
26106 #include <asm/dwarf2.h>
26107 #include <asm/asm.h>
26108 #include <asm/msr.h>
26109 +#include <asm/alternative-asm.h>
26110
26111 #ifdef CONFIG_X86_64
26112 /*
26113 @@ -16,7 +17,7 @@ ENTRY(\op\()_safe_regs)
26114 CFI_STARTPROC
26115 pushq_cfi %rbx
26116 pushq_cfi %rbp
26117 - movq %rdi, %r10 /* Save pointer */
26118 + movq %rdi, %r9 /* Save pointer */
26119 xorl %r11d, %r11d /* Return value */
26120 movl (%rdi), %eax
26121 movl 4(%rdi), %ecx
26122 @@ -27,16 +28,17 @@ ENTRY(\op\()_safe_regs)
26123 movl 28(%rdi), %edi
26124 CFI_REMEMBER_STATE
26125 1: \op
26126 -2: movl %eax, (%r10)
26127 +2: movl %eax, (%r9)
26128 movl %r11d, %eax /* Return value */
26129 - movl %ecx, 4(%r10)
26130 - movl %edx, 8(%r10)
26131 - movl %ebx, 12(%r10)
26132 - movl %ebp, 20(%r10)
26133 - movl %esi, 24(%r10)
26134 - movl %edi, 28(%r10)
26135 + movl %ecx, 4(%r9)
26136 + movl %edx, 8(%r9)
26137 + movl %ebx, 12(%r9)
26138 + movl %ebp, 20(%r9)
26139 + movl %esi, 24(%r9)
26140 + movl %edi, 28(%r9)
26141 popq_cfi %rbp
26142 popq_cfi %rbx
26143 + pax_force_retaddr
26144 ret
26145 3:
26146 CFI_RESTORE_STATE
26147 diff --git a/arch/x86/lib/putuser.S b/arch/x86/lib/putuser.S
26148 index fc6ba17..d4d989d 100644
26149 --- a/arch/x86/lib/putuser.S
26150 +++ b/arch/x86/lib/putuser.S
26151 @@ -16,7 +16,9 @@
26152 #include <asm/errno.h>
26153 #include <asm/asm.h>
26154 #include <asm/smap.h>
26155 -
26156 +#include <asm/segment.h>
26157 +#include <asm/pgtable.h>
26158 +#include <asm/alternative-asm.h>
26159
26160 /*
26161 * __put_user_X
26162 @@ -30,57 +32,125 @@
26163 * as they get called from within inline assembly.
26164 */
26165
26166 -#define ENTER CFI_STARTPROC ; \
26167 - GET_THREAD_INFO(%_ASM_BX)
26168 -#define EXIT ASM_CLAC ; \
26169 - ret ; \
26170 +#define ENTER CFI_STARTPROC
26171 +#define EXIT ASM_CLAC ; \
26172 + pax_force_retaddr ; \
26173 + ret ; \
26174 CFI_ENDPROC
26175
26176 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26177 +#define _DEST %_ASM_CX,%_ASM_BX
26178 +#else
26179 +#define _DEST %_ASM_CX
26180 +#endif
26181 +
26182 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
26183 +#define __copyuser_seg gs;
26184 +#else
26185 +#define __copyuser_seg
26186 +#endif
26187 +
26188 .text
26189 ENTRY(__put_user_1)
26190 ENTER
26191 +
26192 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26193 + GET_THREAD_INFO(%_ASM_BX)
26194 cmp TI_addr_limit(%_ASM_BX),%_ASM_CX
26195 jae bad_put_user
26196 ASM_STAC
26197 -1: movb %al,(%_ASM_CX)
26198 +
26199 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26200 + mov pax_user_shadow_base,%_ASM_BX
26201 + cmp %_ASM_BX,%_ASM_CX
26202 + jb 1234f
26203 + xor %ebx,%ebx
26204 +1234:
26205 +#endif
26206 +
26207 +#endif
26208 +
26209 +1: __copyuser_seg movb %al,(_DEST)
26210 xor %eax,%eax
26211 EXIT
26212 ENDPROC(__put_user_1)
26213
26214 ENTRY(__put_user_2)
26215 ENTER
26216 +
26217 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26218 + GET_THREAD_INFO(%_ASM_BX)
26219 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
26220 sub $1,%_ASM_BX
26221 cmp %_ASM_BX,%_ASM_CX
26222 jae bad_put_user
26223 ASM_STAC
26224 -2: movw %ax,(%_ASM_CX)
26225 +
26226 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26227 + mov pax_user_shadow_base,%_ASM_BX
26228 + cmp %_ASM_BX,%_ASM_CX
26229 + jb 1234f
26230 + xor %ebx,%ebx
26231 +1234:
26232 +#endif
26233 +
26234 +#endif
26235 +
26236 +2: __copyuser_seg movw %ax,(_DEST)
26237 xor %eax,%eax
26238 EXIT
26239 ENDPROC(__put_user_2)
26240
26241 ENTRY(__put_user_4)
26242 ENTER
26243 +
26244 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26245 + GET_THREAD_INFO(%_ASM_BX)
26246 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
26247 sub $3,%_ASM_BX
26248 cmp %_ASM_BX,%_ASM_CX
26249 jae bad_put_user
26250 ASM_STAC
26251 -3: movl %eax,(%_ASM_CX)
26252 +
26253 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26254 + mov pax_user_shadow_base,%_ASM_BX
26255 + cmp %_ASM_BX,%_ASM_CX
26256 + jb 1234f
26257 + xor %ebx,%ebx
26258 +1234:
26259 +#endif
26260 +
26261 +#endif
26262 +
26263 +3: __copyuser_seg movl %eax,(_DEST)
26264 xor %eax,%eax
26265 EXIT
26266 ENDPROC(__put_user_4)
26267
26268 ENTRY(__put_user_8)
26269 ENTER
26270 +
26271 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26272 + GET_THREAD_INFO(%_ASM_BX)
26273 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
26274 sub $7,%_ASM_BX
26275 cmp %_ASM_BX,%_ASM_CX
26276 jae bad_put_user
26277 ASM_STAC
26278 -4: mov %_ASM_AX,(%_ASM_CX)
26279 +
26280 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26281 + mov pax_user_shadow_base,%_ASM_BX
26282 + cmp %_ASM_BX,%_ASM_CX
26283 + jb 1234f
26284 + xor %ebx,%ebx
26285 +1234:
26286 +#endif
26287 +
26288 +#endif
26289 +
26290 +4: __copyuser_seg mov %_ASM_AX,(_DEST)
26291 #ifdef CONFIG_X86_32
26292 -5: movl %edx,4(%_ASM_CX)
26293 +5: __copyuser_seg movl %edx,4(_DEST)
26294 #endif
26295 xor %eax,%eax
26296 EXIT
26297 diff --git a/arch/x86/lib/rwlock.S b/arch/x86/lib/rwlock.S
26298 index 1cad221..de671ee 100644
26299 --- a/arch/x86/lib/rwlock.S
26300 +++ b/arch/x86/lib/rwlock.S
26301 @@ -16,13 +16,34 @@ ENTRY(__write_lock_failed)
26302 FRAME
26303 0: LOCK_PREFIX
26304 WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
26305 +
26306 +#ifdef CONFIG_PAX_REFCOUNT
26307 + jno 1234f
26308 + LOCK_PREFIX
26309 + WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
26310 + int $4
26311 +1234:
26312 + _ASM_EXTABLE(1234b, 1234b)
26313 +#endif
26314 +
26315 1: rep; nop
26316 cmpl $WRITE_LOCK_CMP, (%__lock_ptr)
26317 jne 1b
26318 LOCK_PREFIX
26319 WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
26320 +
26321 +#ifdef CONFIG_PAX_REFCOUNT
26322 + jno 1234f
26323 + LOCK_PREFIX
26324 + WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
26325 + int $4
26326 +1234:
26327 + _ASM_EXTABLE(1234b, 1234b)
26328 +#endif
26329 +
26330 jnz 0b
26331 ENDFRAME
26332 + pax_force_retaddr
26333 ret
26334 CFI_ENDPROC
26335 END(__write_lock_failed)
26336 @@ -32,13 +53,34 @@ ENTRY(__read_lock_failed)
26337 FRAME
26338 0: LOCK_PREFIX
26339 READ_LOCK_SIZE(inc) (%__lock_ptr)
26340 +
26341 +#ifdef CONFIG_PAX_REFCOUNT
26342 + jno 1234f
26343 + LOCK_PREFIX
26344 + READ_LOCK_SIZE(dec) (%__lock_ptr)
26345 + int $4
26346 +1234:
26347 + _ASM_EXTABLE(1234b, 1234b)
26348 +#endif
26349 +
26350 1: rep; nop
26351 READ_LOCK_SIZE(cmp) $1, (%__lock_ptr)
26352 js 1b
26353 LOCK_PREFIX
26354 READ_LOCK_SIZE(dec) (%__lock_ptr)
26355 +
26356 +#ifdef CONFIG_PAX_REFCOUNT
26357 + jno 1234f
26358 + LOCK_PREFIX
26359 + READ_LOCK_SIZE(inc) (%__lock_ptr)
26360 + int $4
26361 +1234:
26362 + _ASM_EXTABLE(1234b, 1234b)
26363 +#endif
26364 +
26365 js 0b
26366 ENDFRAME
26367 + pax_force_retaddr
26368 ret
26369 CFI_ENDPROC
26370 END(__read_lock_failed)
26371 diff --git a/arch/x86/lib/rwsem.S b/arch/x86/lib/rwsem.S
26372 index 5dff5f0..cadebf4 100644
26373 --- a/arch/x86/lib/rwsem.S
26374 +++ b/arch/x86/lib/rwsem.S
26375 @@ -94,6 +94,7 @@ ENTRY(call_rwsem_down_read_failed)
26376 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
26377 CFI_RESTORE __ASM_REG(dx)
26378 restore_common_regs
26379 + pax_force_retaddr
26380 ret
26381 CFI_ENDPROC
26382 ENDPROC(call_rwsem_down_read_failed)
26383 @@ -104,6 +105,7 @@ ENTRY(call_rwsem_down_write_failed)
26384 movq %rax,%rdi
26385 call rwsem_down_write_failed
26386 restore_common_regs
26387 + pax_force_retaddr
26388 ret
26389 CFI_ENDPROC
26390 ENDPROC(call_rwsem_down_write_failed)
26391 @@ -117,7 +119,8 @@ ENTRY(call_rwsem_wake)
26392 movq %rax,%rdi
26393 call rwsem_wake
26394 restore_common_regs
26395 -1: ret
26396 +1: pax_force_retaddr
26397 + ret
26398 CFI_ENDPROC
26399 ENDPROC(call_rwsem_wake)
26400
26401 @@ -131,6 +134,7 @@ ENTRY(call_rwsem_downgrade_wake)
26402 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
26403 CFI_RESTORE __ASM_REG(dx)
26404 restore_common_regs
26405 + pax_force_retaddr
26406 ret
26407 CFI_ENDPROC
26408 ENDPROC(call_rwsem_downgrade_wake)
26409 diff --git a/arch/x86/lib/thunk_64.S b/arch/x86/lib/thunk_64.S
26410 index a63efd6..ccecad8 100644
26411 --- a/arch/x86/lib/thunk_64.S
26412 +++ b/arch/x86/lib/thunk_64.S
26413 @@ -8,6 +8,7 @@
26414 #include <linux/linkage.h>
26415 #include <asm/dwarf2.h>
26416 #include <asm/calling.h>
26417 +#include <asm/alternative-asm.h>
26418
26419 /* rdi: arg1 ... normal C conventions. rax is saved/restored. */
26420 .macro THUNK name, func, put_ret_addr_in_rdi=0
26421 @@ -41,5 +42,6 @@
26422 SAVE_ARGS
26423 restore:
26424 RESTORE_ARGS
26425 + pax_force_retaddr
26426 ret
26427 CFI_ENDPROC
26428 diff --git a/arch/x86/lib/usercopy_32.c b/arch/x86/lib/usercopy_32.c
26429 index f0312d7..9c39d63 100644
26430 --- a/arch/x86/lib/usercopy_32.c
26431 +++ b/arch/x86/lib/usercopy_32.c
26432 @@ -42,11 +42,13 @@ do { \
26433 int __d0; \
26434 might_fault(); \
26435 __asm__ __volatile__( \
26436 + __COPYUSER_SET_ES \
26437 ASM_STAC "\n" \
26438 "0: rep; stosl\n" \
26439 " movl %2,%0\n" \
26440 "1: rep; stosb\n" \
26441 "2: " ASM_CLAC "\n" \
26442 + __COPYUSER_RESTORE_ES \
26443 ".section .fixup,\"ax\"\n" \
26444 "3: lea 0(%2,%0,4),%0\n" \
26445 " jmp 2b\n" \
26446 @@ -98,7 +100,7 @@ EXPORT_SYMBOL(__clear_user);
26447
26448 #ifdef CONFIG_X86_INTEL_USERCOPY
26449 static unsigned long
26450 -__copy_user_intel(void __user *to, const void *from, unsigned long size)
26451 +__generic_copy_to_user_intel(void __user *to, const void *from, unsigned long size)
26452 {
26453 int d0, d1;
26454 __asm__ __volatile__(
26455 @@ -110,36 +112,36 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26456 " .align 2,0x90\n"
26457 "3: movl 0(%4), %%eax\n"
26458 "4: movl 4(%4), %%edx\n"
26459 - "5: movl %%eax, 0(%3)\n"
26460 - "6: movl %%edx, 4(%3)\n"
26461 + "5: "__copyuser_seg" movl %%eax, 0(%3)\n"
26462 + "6: "__copyuser_seg" movl %%edx, 4(%3)\n"
26463 "7: movl 8(%4), %%eax\n"
26464 "8: movl 12(%4),%%edx\n"
26465 - "9: movl %%eax, 8(%3)\n"
26466 - "10: movl %%edx, 12(%3)\n"
26467 + "9: "__copyuser_seg" movl %%eax, 8(%3)\n"
26468 + "10: "__copyuser_seg" movl %%edx, 12(%3)\n"
26469 "11: movl 16(%4), %%eax\n"
26470 "12: movl 20(%4), %%edx\n"
26471 - "13: movl %%eax, 16(%3)\n"
26472 - "14: movl %%edx, 20(%3)\n"
26473 + "13: "__copyuser_seg" movl %%eax, 16(%3)\n"
26474 + "14: "__copyuser_seg" movl %%edx, 20(%3)\n"
26475 "15: movl 24(%4), %%eax\n"
26476 "16: movl 28(%4), %%edx\n"
26477 - "17: movl %%eax, 24(%3)\n"
26478 - "18: movl %%edx, 28(%3)\n"
26479 + "17: "__copyuser_seg" movl %%eax, 24(%3)\n"
26480 + "18: "__copyuser_seg" movl %%edx, 28(%3)\n"
26481 "19: movl 32(%4), %%eax\n"
26482 "20: movl 36(%4), %%edx\n"
26483 - "21: movl %%eax, 32(%3)\n"
26484 - "22: movl %%edx, 36(%3)\n"
26485 + "21: "__copyuser_seg" movl %%eax, 32(%3)\n"
26486 + "22: "__copyuser_seg" movl %%edx, 36(%3)\n"
26487 "23: movl 40(%4), %%eax\n"
26488 "24: movl 44(%4), %%edx\n"
26489 - "25: movl %%eax, 40(%3)\n"
26490 - "26: movl %%edx, 44(%3)\n"
26491 + "25: "__copyuser_seg" movl %%eax, 40(%3)\n"
26492 + "26: "__copyuser_seg" movl %%edx, 44(%3)\n"
26493 "27: movl 48(%4), %%eax\n"
26494 "28: movl 52(%4), %%edx\n"
26495 - "29: movl %%eax, 48(%3)\n"
26496 - "30: movl %%edx, 52(%3)\n"
26497 + "29: "__copyuser_seg" movl %%eax, 48(%3)\n"
26498 + "30: "__copyuser_seg" movl %%edx, 52(%3)\n"
26499 "31: movl 56(%4), %%eax\n"
26500 "32: movl 60(%4), %%edx\n"
26501 - "33: movl %%eax, 56(%3)\n"
26502 - "34: movl %%edx, 60(%3)\n"
26503 + "33: "__copyuser_seg" movl %%eax, 56(%3)\n"
26504 + "34: "__copyuser_seg" movl %%edx, 60(%3)\n"
26505 " addl $-64, %0\n"
26506 " addl $64, %4\n"
26507 " addl $64, %3\n"
26508 @@ -149,10 +151,12 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26509 " shrl $2, %0\n"
26510 " andl $3, %%eax\n"
26511 " cld\n"
26512 + __COPYUSER_SET_ES
26513 "99: rep; movsl\n"
26514 "36: movl %%eax, %0\n"
26515 "37: rep; movsb\n"
26516 "100:\n"
26517 + __COPYUSER_RESTORE_ES
26518 ".section .fixup,\"ax\"\n"
26519 "101: lea 0(%%eax,%0,4),%0\n"
26520 " jmp 100b\n"
26521 @@ -202,46 +206,150 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26522 }
26523
26524 static unsigned long
26525 +__generic_copy_from_user_intel(void *to, const void __user *from, unsigned long size)
26526 +{
26527 + int d0, d1;
26528 + __asm__ __volatile__(
26529 + " .align 2,0x90\n"
26530 + "1: "__copyuser_seg" movl 32(%4), %%eax\n"
26531 + " cmpl $67, %0\n"
26532 + " jbe 3f\n"
26533 + "2: "__copyuser_seg" movl 64(%4), %%eax\n"
26534 + " .align 2,0x90\n"
26535 + "3: "__copyuser_seg" movl 0(%4), %%eax\n"
26536 + "4: "__copyuser_seg" movl 4(%4), %%edx\n"
26537 + "5: movl %%eax, 0(%3)\n"
26538 + "6: movl %%edx, 4(%3)\n"
26539 + "7: "__copyuser_seg" movl 8(%4), %%eax\n"
26540 + "8: "__copyuser_seg" movl 12(%4),%%edx\n"
26541 + "9: movl %%eax, 8(%3)\n"
26542 + "10: movl %%edx, 12(%3)\n"
26543 + "11: "__copyuser_seg" movl 16(%4), %%eax\n"
26544 + "12: "__copyuser_seg" movl 20(%4), %%edx\n"
26545 + "13: movl %%eax, 16(%3)\n"
26546 + "14: movl %%edx, 20(%3)\n"
26547 + "15: "__copyuser_seg" movl 24(%4), %%eax\n"
26548 + "16: "__copyuser_seg" movl 28(%4), %%edx\n"
26549 + "17: movl %%eax, 24(%3)\n"
26550 + "18: movl %%edx, 28(%3)\n"
26551 + "19: "__copyuser_seg" movl 32(%4), %%eax\n"
26552 + "20: "__copyuser_seg" movl 36(%4), %%edx\n"
26553 + "21: movl %%eax, 32(%3)\n"
26554 + "22: movl %%edx, 36(%3)\n"
26555 + "23: "__copyuser_seg" movl 40(%4), %%eax\n"
26556 + "24: "__copyuser_seg" movl 44(%4), %%edx\n"
26557 + "25: movl %%eax, 40(%3)\n"
26558 + "26: movl %%edx, 44(%3)\n"
26559 + "27: "__copyuser_seg" movl 48(%4), %%eax\n"
26560 + "28: "__copyuser_seg" movl 52(%4), %%edx\n"
26561 + "29: movl %%eax, 48(%3)\n"
26562 + "30: movl %%edx, 52(%3)\n"
26563 + "31: "__copyuser_seg" movl 56(%4), %%eax\n"
26564 + "32: "__copyuser_seg" movl 60(%4), %%edx\n"
26565 + "33: movl %%eax, 56(%3)\n"
26566 + "34: movl %%edx, 60(%3)\n"
26567 + " addl $-64, %0\n"
26568 + " addl $64, %4\n"
26569 + " addl $64, %3\n"
26570 + " cmpl $63, %0\n"
26571 + " ja 1b\n"
26572 + "35: movl %0, %%eax\n"
26573 + " shrl $2, %0\n"
26574 + " andl $3, %%eax\n"
26575 + " cld\n"
26576 + "99: rep; "__copyuser_seg" movsl\n"
26577 + "36: movl %%eax, %0\n"
26578 + "37: rep; "__copyuser_seg" movsb\n"
26579 + "100:\n"
26580 + ".section .fixup,\"ax\"\n"
26581 + "101: lea 0(%%eax,%0,4),%0\n"
26582 + " jmp 100b\n"
26583 + ".previous\n"
26584 + _ASM_EXTABLE(1b,100b)
26585 + _ASM_EXTABLE(2b,100b)
26586 + _ASM_EXTABLE(3b,100b)
26587 + _ASM_EXTABLE(4b,100b)
26588 + _ASM_EXTABLE(5b,100b)
26589 + _ASM_EXTABLE(6b,100b)
26590 + _ASM_EXTABLE(7b,100b)
26591 + _ASM_EXTABLE(8b,100b)
26592 + _ASM_EXTABLE(9b,100b)
26593 + _ASM_EXTABLE(10b,100b)
26594 + _ASM_EXTABLE(11b,100b)
26595 + _ASM_EXTABLE(12b,100b)
26596 + _ASM_EXTABLE(13b,100b)
26597 + _ASM_EXTABLE(14b,100b)
26598 + _ASM_EXTABLE(15b,100b)
26599 + _ASM_EXTABLE(16b,100b)
26600 + _ASM_EXTABLE(17b,100b)
26601 + _ASM_EXTABLE(18b,100b)
26602 + _ASM_EXTABLE(19b,100b)
26603 + _ASM_EXTABLE(20b,100b)
26604 + _ASM_EXTABLE(21b,100b)
26605 + _ASM_EXTABLE(22b,100b)
26606 + _ASM_EXTABLE(23b,100b)
26607 + _ASM_EXTABLE(24b,100b)
26608 + _ASM_EXTABLE(25b,100b)
26609 + _ASM_EXTABLE(26b,100b)
26610 + _ASM_EXTABLE(27b,100b)
26611 + _ASM_EXTABLE(28b,100b)
26612 + _ASM_EXTABLE(29b,100b)
26613 + _ASM_EXTABLE(30b,100b)
26614 + _ASM_EXTABLE(31b,100b)
26615 + _ASM_EXTABLE(32b,100b)
26616 + _ASM_EXTABLE(33b,100b)
26617 + _ASM_EXTABLE(34b,100b)
26618 + _ASM_EXTABLE(35b,100b)
26619 + _ASM_EXTABLE(36b,100b)
26620 + _ASM_EXTABLE(37b,100b)
26621 + _ASM_EXTABLE(99b,101b)
26622 + : "=&c"(size), "=&D" (d0), "=&S" (d1)
26623 + : "1"(to), "2"(from), "0"(size)
26624 + : "eax", "edx", "memory");
26625 + return size;
26626 +}
26627 +
26628 +static unsigned long __size_overflow(3)
26629 __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
26630 {
26631 int d0, d1;
26632 __asm__ __volatile__(
26633 " .align 2,0x90\n"
26634 - "0: movl 32(%4), %%eax\n"
26635 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
26636 " cmpl $67, %0\n"
26637 " jbe 2f\n"
26638 - "1: movl 64(%4), %%eax\n"
26639 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
26640 " .align 2,0x90\n"
26641 - "2: movl 0(%4), %%eax\n"
26642 - "21: movl 4(%4), %%edx\n"
26643 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
26644 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
26645 " movl %%eax, 0(%3)\n"
26646 " movl %%edx, 4(%3)\n"
26647 - "3: movl 8(%4), %%eax\n"
26648 - "31: movl 12(%4),%%edx\n"
26649 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
26650 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
26651 " movl %%eax, 8(%3)\n"
26652 " movl %%edx, 12(%3)\n"
26653 - "4: movl 16(%4), %%eax\n"
26654 - "41: movl 20(%4), %%edx\n"
26655 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
26656 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
26657 " movl %%eax, 16(%3)\n"
26658 " movl %%edx, 20(%3)\n"
26659 - "10: movl 24(%4), %%eax\n"
26660 - "51: movl 28(%4), %%edx\n"
26661 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
26662 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
26663 " movl %%eax, 24(%3)\n"
26664 " movl %%edx, 28(%3)\n"
26665 - "11: movl 32(%4), %%eax\n"
26666 - "61: movl 36(%4), %%edx\n"
26667 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
26668 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
26669 " movl %%eax, 32(%3)\n"
26670 " movl %%edx, 36(%3)\n"
26671 - "12: movl 40(%4), %%eax\n"
26672 - "71: movl 44(%4), %%edx\n"
26673 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
26674 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
26675 " movl %%eax, 40(%3)\n"
26676 " movl %%edx, 44(%3)\n"
26677 - "13: movl 48(%4), %%eax\n"
26678 - "81: movl 52(%4), %%edx\n"
26679 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
26680 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
26681 " movl %%eax, 48(%3)\n"
26682 " movl %%edx, 52(%3)\n"
26683 - "14: movl 56(%4), %%eax\n"
26684 - "91: movl 60(%4), %%edx\n"
26685 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
26686 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
26687 " movl %%eax, 56(%3)\n"
26688 " movl %%edx, 60(%3)\n"
26689 " addl $-64, %0\n"
26690 @@ -253,9 +361,9 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
26691 " shrl $2, %0\n"
26692 " andl $3, %%eax\n"
26693 " cld\n"
26694 - "6: rep; movsl\n"
26695 + "6: rep; "__copyuser_seg" movsl\n"
26696 " movl %%eax,%0\n"
26697 - "7: rep; movsb\n"
26698 + "7: rep; "__copyuser_seg" movsb\n"
26699 "8:\n"
26700 ".section .fixup,\"ax\"\n"
26701 "9: lea 0(%%eax,%0,4),%0\n"
26702 @@ -298,48 +406,48 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
26703 * hyoshiok@miraclelinux.com
26704 */
26705
26706 -static unsigned long __copy_user_zeroing_intel_nocache(void *to,
26707 +static unsigned long __size_overflow(3) __copy_user_zeroing_intel_nocache(void *to,
26708 const void __user *from, unsigned long size)
26709 {
26710 int d0, d1;
26711
26712 __asm__ __volatile__(
26713 " .align 2,0x90\n"
26714 - "0: movl 32(%4), %%eax\n"
26715 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
26716 " cmpl $67, %0\n"
26717 " jbe 2f\n"
26718 - "1: movl 64(%4), %%eax\n"
26719 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
26720 " .align 2,0x90\n"
26721 - "2: movl 0(%4), %%eax\n"
26722 - "21: movl 4(%4), %%edx\n"
26723 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
26724 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
26725 " movnti %%eax, 0(%3)\n"
26726 " movnti %%edx, 4(%3)\n"
26727 - "3: movl 8(%4), %%eax\n"
26728 - "31: movl 12(%4),%%edx\n"
26729 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
26730 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
26731 " movnti %%eax, 8(%3)\n"
26732 " movnti %%edx, 12(%3)\n"
26733 - "4: movl 16(%4), %%eax\n"
26734 - "41: movl 20(%4), %%edx\n"
26735 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
26736 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
26737 " movnti %%eax, 16(%3)\n"
26738 " movnti %%edx, 20(%3)\n"
26739 - "10: movl 24(%4), %%eax\n"
26740 - "51: movl 28(%4), %%edx\n"
26741 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
26742 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
26743 " movnti %%eax, 24(%3)\n"
26744 " movnti %%edx, 28(%3)\n"
26745 - "11: movl 32(%4), %%eax\n"
26746 - "61: movl 36(%4), %%edx\n"
26747 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
26748 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
26749 " movnti %%eax, 32(%3)\n"
26750 " movnti %%edx, 36(%3)\n"
26751 - "12: movl 40(%4), %%eax\n"
26752 - "71: movl 44(%4), %%edx\n"
26753 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
26754 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
26755 " movnti %%eax, 40(%3)\n"
26756 " movnti %%edx, 44(%3)\n"
26757 - "13: movl 48(%4), %%eax\n"
26758 - "81: movl 52(%4), %%edx\n"
26759 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
26760 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
26761 " movnti %%eax, 48(%3)\n"
26762 " movnti %%edx, 52(%3)\n"
26763 - "14: movl 56(%4), %%eax\n"
26764 - "91: movl 60(%4), %%edx\n"
26765 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
26766 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
26767 " movnti %%eax, 56(%3)\n"
26768 " movnti %%edx, 60(%3)\n"
26769 " addl $-64, %0\n"
26770 @@ -352,9 +460,9 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
26771 " shrl $2, %0\n"
26772 " andl $3, %%eax\n"
26773 " cld\n"
26774 - "6: rep; movsl\n"
26775 + "6: rep; "__copyuser_seg" movsl\n"
26776 " movl %%eax,%0\n"
26777 - "7: rep; movsb\n"
26778 + "7: rep; "__copyuser_seg" movsb\n"
26779 "8:\n"
26780 ".section .fixup,\"ax\"\n"
26781 "9: lea 0(%%eax,%0,4),%0\n"
26782 @@ -392,48 +500,48 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
26783 return size;
26784 }
26785
26786 -static unsigned long __copy_user_intel_nocache(void *to,
26787 +static unsigned long __size_overflow(3) __copy_user_intel_nocache(void *to,
26788 const void __user *from, unsigned long size)
26789 {
26790 int d0, d1;
26791
26792 __asm__ __volatile__(
26793 " .align 2,0x90\n"
26794 - "0: movl 32(%4), %%eax\n"
26795 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
26796 " cmpl $67, %0\n"
26797 " jbe 2f\n"
26798 - "1: movl 64(%4), %%eax\n"
26799 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
26800 " .align 2,0x90\n"
26801 - "2: movl 0(%4), %%eax\n"
26802 - "21: movl 4(%4), %%edx\n"
26803 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
26804 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
26805 " movnti %%eax, 0(%3)\n"
26806 " movnti %%edx, 4(%3)\n"
26807 - "3: movl 8(%4), %%eax\n"
26808 - "31: movl 12(%4),%%edx\n"
26809 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
26810 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
26811 " movnti %%eax, 8(%3)\n"
26812 " movnti %%edx, 12(%3)\n"
26813 - "4: movl 16(%4), %%eax\n"
26814 - "41: movl 20(%4), %%edx\n"
26815 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
26816 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
26817 " movnti %%eax, 16(%3)\n"
26818 " movnti %%edx, 20(%3)\n"
26819 - "10: movl 24(%4), %%eax\n"
26820 - "51: movl 28(%4), %%edx\n"
26821 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
26822 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
26823 " movnti %%eax, 24(%3)\n"
26824 " movnti %%edx, 28(%3)\n"
26825 - "11: movl 32(%4), %%eax\n"
26826 - "61: movl 36(%4), %%edx\n"
26827 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
26828 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
26829 " movnti %%eax, 32(%3)\n"
26830 " movnti %%edx, 36(%3)\n"
26831 - "12: movl 40(%4), %%eax\n"
26832 - "71: movl 44(%4), %%edx\n"
26833 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
26834 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
26835 " movnti %%eax, 40(%3)\n"
26836 " movnti %%edx, 44(%3)\n"
26837 - "13: movl 48(%4), %%eax\n"
26838 - "81: movl 52(%4), %%edx\n"
26839 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
26840 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
26841 " movnti %%eax, 48(%3)\n"
26842 " movnti %%edx, 52(%3)\n"
26843 - "14: movl 56(%4), %%eax\n"
26844 - "91: movl 60(%4), %%edx\n"
26845 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
26846 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
26847 " movnti %%eax, 56(%3)\n"
26848 " movnti %%edx, 60(%3)\n"
26849 " addl $-64, %0\n"
26850 @@ -446,9 +554,9 @@ static unsigned long __copy_user_intel_nocache(void *to,
26851 " shrl $2, %0\n"
26852 " andl $3, %%eax\n"
26853 " cld\n"
26854 - "6: rep; movsl\n"
26855 + "6: rep; "__copyuser_seg" movsl\n"
26856 " movl %%eax,%0\n"
26857 - "7: rep; movsb\n"
26858 + "7: rep; "__copyuser_seg" movsb\n"
26859 "8:\n"
26860 ".section .fixup,\"ax\"\n"
26861 "9: lea 0(%%eax,%0,4),%0\n"
26862 @@ -488,32 +596,36 @@ static unsigned long __copy_user_intel_nocache(void *to,
26863 */
26864 unsigned long __copy_user_zeroing_intel(void *to, const void __user *from,
26865 unsigned long size);
26866 -unsigned long __copy_user_intel(void __user *to, const void *from,
26867 +unsigned long __generic_copy_to_user_intel(void __user *to, const void *from,
26868 + unsigned long size);
26869 +unsigned long __generic_copy_from_user_intel(void *to, const void __user *from,
26870 unsigned long size);
26871 unsigned long __copy_user_zeroing_intel_nocache(void *to,
26872 const void __user *from, unsigned long size);
26873 #endif /* CONFIG_X86_INTEL_USERCOPY */
26874
26875 /* Generic arbitrary sized copy. */
26876 -#define __copy_user(to, from, size) \
26877 +#define __copy_user(to, from, size, prefix, set, restore) \
26878 do { \
26879 int __d0, __d1, __d2; \
26880 __asm__ __volatile__( \
26881 + set \
26882 " cmp $7,%0\n" \
26883 " jbe 1f\n" \
26884 " movl %1,%0\n" \
26885 " negl %0\n" \
26886 " andl $7,%0\n" \
26887 " subl %0,%3\n" \
26888 - "4: rep; movsb\n" \
26889 + "4: rep; "prefix"movsb\n" \
26890 " movl %3,%0\n" \
26891 " shrl $2,%0\n" \
26892 " andl $3,%3\n" \
26893 " .align 2,0x90\n" \
26894 - "0: rep; movsl\n" \
26895 + "0: rep; "prefix"movsl\n" \
26896 " movl %3,%0\n" \
26897 - "1: rep; movsb\n" \
26898 + "1: rep; "prefix"movsb\n" \
26899 "2:\n" \
26900 + restore \
26901 ".section .fixup,\"ax\"\n" \
26902 "5: addl %3,%0\n" \
26903 " jmp 2b\n" \
26904 @@ -538,14 +650,14 @@ do { \
26905 " negl %0\n" \
26906 " andl $7,%0\n" \
26907 " subl %0,%3\n" \
26908 - "4: rep; movsb\n" \
26909 + "4: rep; "__copyuser_seg"movsb\n" \
26910 " movl %3,%0\n" \
26911 " shrl $2,%0\n" \
26912 " andl $3,%3\n" \
26913 " .align 2,0x90\n" \
26914 - "0: rep; movsl\n" \
26915 + "0: rep; "__copyuser_seg"movsl\n" \
26916 " movl %3,%0\n" \
26917 - "1: rep; movsb\n" \
26918 + "1: rep; "__copyuser_seg"movsb\n" \
26919 "2:\n" \
26920 ".section .fixup,\"ax\"\n" \
26921 "5: addl %3,%0\n" \
26922 @@ -572,9 +684,9 @@ unsigned long __copy_to_user_ll(void __user *to, const void *from,
26923 {
26924 stac();
26925 if (movsl_is_ok(to, from, n))
26926 - __copy_user(to, from, n);
26927 + __copy_user(to, from, n, "", __COPYUSER_SET_ES, __COPYUSER_RESTORE_ES);
26928 else
26929 - n = __copy_user_intel(to, from, n);
26930 + n = __generic_copy_to_user_intel(to, from, n);
26931 clac();
26932 return n;
26933 }
26934 @@ -598,10 +710,9 @@ unsigned long __copy_from_user_ll_nozero(void *to, const void __user *from,
26935 {
26936 stac();
26937 if (movsl_is_ok(to, from, n))
26938 - __copy_user(to, from, n);
26939 + __copy_user(to, from, n, __copyuser_seg, "", "");
26940 else
26941 - n = __copy_user_intel((void __user *)to,
26942 - (const void *)from, n);
26943 + n = __generic_copy_from_user_intel(to, from, n);
26944 clac();
26945 return n;
26946 }
26947 @@ -632,66 +743,51 @@ unsigned long __copy_from_user_ll_nocache_nozero(void *to, const void __user *fr
26948 if (n > 64 && cpu_has_xmm2)
26949 n = __copy_user_intel_nocache(to, from, n);
26950 else
26951 - __copy_user(to, from, n);
26952 + __copy_user(to, from, n, __copyuser_seg, "", "");
26953 #else
26954 - __copy_user(to, from, n);
26955 + __copy_user(to, from, n, __copyuser_seg, "", "");
26956 #endif
26957 clac();
26958 return n;
26959 }
26960 EXPORT_SYMBOL(__copy_from_user_ll_nocache_nozero);
26961
26962 -/**
26963 - * copy_to_user: - Copy a block of data into user space.
26964 - * @to: Destination address, in user space.
26965 - * @from: Source address, in kernel space.
26966 - * @n: Number of bytes to copy.
26967 - *
26968 - * Context: User context only. This function may sleep.
26969 - *
26970 - * Copy data from kernel space to user space.
26971 - *
26972 - * Returns number of bytes that could not be copied.
26973 - * On success, this will be zero.
26974 - */
26975 -unsigned long
26976 -copy_to_user(void __user *to, const void *from, unsigned long n)
26977 -{
26978 - if (access_ok(VERIFY_WRITE, to, n))
26979 - n = __copy_to_user(to, from, n);
26980 - return n;
26981 -}
26982 -EXPORT_SYMBOL(copy_to_user);
26983 -
26984 -/**
26985 - * copy_from_user: - Copy a block of data from user space.
26986 - * @to: Destination address, in kernel space.
26987 - * @from: Source address, in user space.
26988 - * @n: Number of bytes to copy.
26989 - *
26990 - * Context: User context only. This function may sleep.
26991 - *
26992 - * Copy data from user space to kernel space.
26993 - *
26994 - * Returns number of bytes that could not be copied.
26995 - * On success, this will be zero.
26996 - *
26997 - * If some data could not be copied, this function will pad the copied
26998 - * data to the requested size using zero bytes.
26999 - */
27000 -unsigned long
27001 -_copy_from_user(void *to, const void __user *from, unsigned long n)
27002 -{
27003 - if (access_ok(VERIFY_READ, from, n))
27004 - n = __copy_from_user(to, from, n);
27005 - else
27006 - memset(to, 0, n);
27007 - return n;
27008 -}
27009 -EXPORT_SYMBOL(_copy_from_user);
27010 -
27011 void copy_from_user_overflow(void)
27012 {
27013 WARN(1, "Buffer overflow detected!\n");
27014 }
27015 EXPORT_SYMBOL(copy_from_user_overflow);
27016 +
27017 +void copy_to_user_overflow(void)
27018 +{
27019 + WARN(1, "Buffer overflow detected!\n");
27020 +}
27021 +EXPORT_SYMBOL(copy_to_user_overflow);
27022 +
27023 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27024 +void __set_fs(mm_segment_t x)
27025 +{
27026 + switch (x.seg) {
27027 + case 0:
27028 + loadsegment(gs, 0);
27029 + break;
27030 + case TASK_SIZE_MAX:
27031 + loadsegment(gs, __USER_DS);
27032 + break;
27033 + case -1UL:
27034 + loadsegment(gs, __KERNEL_DS);
27035 + break;
27036 + default:
27037 + BUG();
27038 + }
27039 + return;
27040 +}
27041 +EXPORT_SYMBOL(__set_fs);
27042 +
27043 +void set_fs(mm_segment_t x)
27044 +{
27045 + current_thread_info()->addr_limit = x;
27046 + __set_fs(x);
27047 +}
27048 +EXPORT_SYMBOL(set_fs);
27049 +#endif
27050 diff --git a/arch/x86/lib/usercopy_64.c b/arch/x86/lib/usercopy_64.c
27051 index 906fea3..ee8a097 100644
27052 --- a/arch/x86/lib/usercopy_64.c
27053 +++ b/arch/x86/lib/usercopy_64.c
27054 @@ -39,7 +39,7 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
27055 _ASM_EXTABLE(0b,3b)
27056 _ASM_EXTABLE(1b,2b)
27057 : [size8] "=&c"(size), [dst] "=&D" (__d0)
27058 - : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr),
27059 + : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(____m(addr)),
27060 [zero] "r" (0UL), [eight] "r" (8UL));
27061 clac();
27062 return size;
27063 @@ -54,12 +54,11 @@ unsigned long clear_user(void __user *to, unsigned long n)
27064 }
27065 EXPORT_SYMBOL(clear_user);
27066
27067 -unsigned long copy_in_user(void __user *to, const void __user *from, unsigned len)
27068 +unsigned long copy_in_user(void __user *to, const void __user *from, unsigned long len)
27069 {
27070 - if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len)) {
27071 - return copy_user_generic((__force void *)to, (__force void *)from, len);
27072 - }
27073 - return len;
27074 + if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len))
27075 + return copy_user_generic((void __force_kernel *)____m(to), (void __force_kernel *)____m(from), len);
27076 + return len;
27077 }
27078 EXPORT_SYMBOL(copy_in_user);
27079
27080 @@ -69,7 +68,7 @@ EXPORT_SYMBOL(copy_in_user);
27081 * it is not necessary to optimize tail handling.
27082 */
27083 unsigned long
27084 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
27085 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest)
27086 {
27087 char c;
27088 unsigned zero_len;
27089 @@ -87,3 +86,15 @@ copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
27090 clac();
27091 return len;
27092 }
27093 +
27094 +void copy_from_user_overflow(void)
27095 +{
27096 + WARN(1, "Buffer overflow detected!\n");
27097 +}
27098 +EXPORT_SYMBOL(copy_from_user_overflow);
27099 +
27100 +void copy_to_user_overflow(void)
27101 +{
27102 + WARN(1, "Buffer overflow detected!\n");
27103 +}
27104 +EXPORT_SYMBOL(copy_to_user_overflow);
27105 diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
27106 index 903ec1e..c4166b2 100644
27107 --- a/arch/x86/mm/extable.c
27108 +++ b/arch/x86/mm/extable.c
27109 @@ -6,12 +6,24 @@
27110 static inline unsigned long
27111 ex_insn_addr(const struct exception_table_entry *x)
27112 {
27113 - return (unsigned long)&x->insn + x->insn;
27114 + unsigned long reloc = 0;
27115 +
27116 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27117 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27118 +#endif
27119 +
27120 + return (unsigned long)&x->insn + x->insn + reloc;
27121 }
27122 static inline unsigned long
27123 ex_fixup_addr(const struct exception_table_entry *x)
27124 {
27125 - return (unsigned long)&x->fixup + x->fixup;
27126 + unsigned long reloc = 0;
27127 +
27128 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27129 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27130 +#endif
27131 +
27132 + return (unsigned long)&x->fixup + x->fixup + reloc;
27133 }
27134
27135 int fixup_exception(struct pt_regs *regs)
27136 @@ -20,7 +32,7 @@ int fixup_exception(struct pt_regs *regs)
27137 unsigned long new_ip;
27138
27139 #ifdef CONFIG_PNPBIOS
27140 - if (unlikely(SEGMENT_IS_PNP_CODE(regs->cs))) {
27141 + if (unlikely(!v8086_mode(regs) && SEGMENT_IS_PNP_CODE(regs->cs))) {
27142 extern u32 pnp_bios_fault_eip, pnp_bios_fault_esp;
27143 extern u32 pnp_bios_is_utter_crap;
27144 pnp_bios_is_utter_crap = 1;
27145 @@ -145,6 +157,13 @@ void sort_extable(struct exception_table_entry *start,
27146 i += 4;
27147 p->fixup -= i;
27148 i += 4;
27149 +
27150 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27151 + BUILD_BUG_ON(!IS_ENABLED(CONFIG_BUILDTIME_EXTABLE_SORT));
27152 + p->insn -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27153 + p->fixup -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27154 +#endif
27155 +
27156 }
27157 }
27158
27159 diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
27160 index 0e88336..2bb9777 100644
27161 --- a/arch/x86/mm/fault.c
27162 +++ b/arch/x86/mm/fault.c
27163 @@ -13,12 +13,19 @@
27164 #include <linux/perf_event.h> /* perf_sw_event */
27165 #include <linux/hugetlb.h> /* hstate_index_to_shift */
27166 #include <linux/prefetch.h> /* prefetchw */
27167 +#include <linux/unistd.h>
27168 +#include <linux/compiler.h>
27169
27170 #include <asm/traps.h> /* dotraplinkage, ... */
27171 #include <asm/pgalloc.h> /* pgd_*(), ... */
27172 #include <asm/kmemcheck.h> /* kmemcheck_*(), ... */
27173 #include <asm/fixmap.h> /* VSYSCALL_START */
27174 #include <asm/context_tracking.h> /* exception_enter(), ... */
27175 +#include <asm/tlbflush.h>
27176 +
27177 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
27178 +#include <asm/stacktrace.h>
27179 +#endif
27180
27181 /*
27182 * Page fault error code bits:
27183 @@ -56,7 +63,7 @@ static inline int __kprobes notify_page_fault(struct pt_regs *regs)
27184 int ret = 0;
27185
27186 /* kprobe_running() needs smp_processor_id() */
27187 - if (kprobes_built_in() && !user_mode_vm(regs)) {
27188 + if (kprobes_built_in() && !user_mode(regs)) {
27189 preempt_disable();
27190 if (kprobe_running() && kprobe_fault_handler(regs, 14))
27191 ret = 1;
27192 @@ -117,7 +124,10 @@ check_prefetch_opcode(struct pt_regs *regs, unsigned char *instr,
27193 return !instr_lo || (instr_lo>>1) == 1;
27194 case 0x00:
27195 /* Prefetch instruction is 0x0F0D or 0x0F18 */
27196 - if (probe_kernel_address(instr, opcode))
27197 + if (user_mode(regs)) {
27198 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
27199 + return 0;
27200 + } else if (probe_kernel_address(instr, opcode))
27201 return 0;
27202
27203 *prefetch = (instr_lo == 0xF) &&
27204 @@ -151,7 +161,10 @@ is_prefetch(struct pt_regs *regs, unsigned long error_code, unsigned long addr)
27205 while (instr < max_instr) {
27206 unsigned char opcode;
27207
27208 - if (probe_kernel_address(instr, opcode))
27209 + if (user_mode(regs)) {
27210 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
27211 + break;
27212 + } else if (probe_kernel_address(instr, opcode))
27213 break;
27214
27215 instr++;
27216 @@ -182,6 +195,34 @@ force_sig_info_fault(int si_signo, int si_code, unsigned long address,
27217 force_sig_info(si_signo, &info, tsk);
27218 }
27219
27220 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27221 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address);
27222 +#endif
27223 +
27224 +#ifdef CONFIG_PAX_EMUTRAMP
27225 +static int pax_handle_fetch_fault(struct pt_regs *regs);
27226 +#endif
27227 +
27228 +#ifdef CONFIG_PAX_PAGEEXEC
27229 +static inline pmd_t * pax_get_pmd(struct mm_struct *mm, unsigned long address)
27230 +{
27231 + pgd_t *pgd;
27232 + pud_t *pud;
27233 + pmd_t *pmd;
27234 +
27235 + pgd = pgd_offset(mm, address);
27236 + if (!pgd_present(*pgd))
27237 + return NULL;
27238 + pud = pud_offset(pgd, address);
27239 + if (!pud_present(*pud))
27240 + return NULL;
27241 + pmd = pmd_offset(pud, address);
27242 + if (!pmd_present(*pmd))
27243 + return NULL;
27244 + return pmd;
27245 +}
27246 +#endif
27247 +
27248 DEFINE_SPINLOCK(pgd_lock);
27249 LIST_HEAD(pgd_list);
27250
27251 @@ -232,10 +273,22 @@ void vmalloc_sync_all(void)
27252 for (address = VMALLOC_START & PMD_MASK;
27253 address >= TASK_SIZE && address < FIXADDR_TOP;
27254 address += PMD_SIZE) {
27255 +
27256 +#ifdef CONFIG_PAX_PER_CPU_PGD
27257 + unsigned long cpu;
27258 +#else
27259 struct page *page;
27260 +#endif
27261
27262 spin_lock(&pgd_lock);
27263 +
27264 +#ifdef CONFIG_PAX_PER_CPU_PGD
27265 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
27266 + pgd_t *pgd = get_cpu_pgd(cpu);
27267 + pmd_t *ret;
27268 +#else
27269 list_for_each_entry(page, &pgd_list, lru) {
27270 + pgd_t *pgd;
27271 spinlock_t *pgt_lock;
27272 pmd_t *ret;
27273
27274 @@ -243,8 +296,14 @@ void vmalloc_sync_all(void)
27275 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
27276
27277 spin_lock(pgt_lock);
27278 - ret = vmalloc_sync_one(page_address(page), address);
27279 + pgd = page_address(page);
27280 +#endif
27281 +
27282 + ret = vmalloc_sync_one(pgd, address);
27283 +
27284 +#ifndef CONFIG_PAX_PER_CPU_PGD
27285 spin_unlock(pgt_lock);
27286 +#endif
27287
27288 if (!ret)
27289 break;
27290 @@ -278,6 +337,11 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
27291 * an interrupt in the middle of a task switch..
27292 */
27293 pgd_paddr = read_cr3();
27294 +
27295 +#ifdef CONFIG_PAX_PER_CPU_PGD
27296 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id())) != (pgd_paddr & PHYSICAL_PAGE_MASK));
27297 +#endif
27298 +
27299 pmd_k = vmalloc_sync_one(__va(pgd_paddr), address);
27300 if (!pmd_k)
27301 return -1;
27302 @@ -373,7 +437,14 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
27303 * happen within a race in page table update. In the later
27304 * case just flush:
27305 */
27306 +
27307 +#ifdef CONFIG_PAX_PER_CPU_PGD
27308 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id())) != (read_cr3() & PHYSICAL_PAGE_MASK));
27309 + pgd = pgd_offset_cpu(smp_processor_id(), address);
27310 +#else
27311 pgd = pgd_offset(current->active_mm, address);
27312 +#endif
27313 +
27314 pgd_ref = pgd_offset_k(address);
27315 if (pgd_none(*pgd_ref))
27316 return -1;
27317 @@ -543,7 +614,7 @@ static int is_errata93(struct pt_regs *regs, unsigned long address)
27318 static int is_errata100(struct pt_regs *regs, unsigned long address)
27319 {
27320 #ifdef CONFIG_X86_64
27321 - if ((regs->cs == __USER32_CS || (regs->cs & (1<<2))) && (address >> 32))
27322 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)) && (address >> 32))
27323 return 1;
27324 #endif
27325 return 0;
27326 @@ -570,7 +641,7 @@ static int is_f00f_bug(struct pt_regs *regs, unsigned long address)
27327 }
27328
27329 static const char nx_warning[] = KERN_CRIT
27330 -"kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n";
27331 +"kernel tried to execute NX-protected page - exploit attempt? (uid: %d, task: %s, pid: %d)\n";
27332
27333 static void
27334 show_fault_oops(struct pt_regs *regs, unsigned long error_code,
27335 @@ -579,15 +650,27 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
27336 if (!oops_may_print())
27337 return;
27338
27339 - if (error_code & PF_INSTR) {
27340 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR)) {
27341 unsigned int level;
27342
27343 pte_t *pte = lookup_address(address, &level);
27344
27345 if (pte && pte_present(*pte) && !pte_exec(*pte))
27346 - printk(nx_warning, from_kuid(&init_user_ns, current_uid()));
27347 + printk(nx_warning, from_kuid_munged(&init_user_ns, current_uid()), current->comm, task_pid_nr(current));
27348 }
27349
27350 +#ifdef CONFIG_PAX_KERNEXEC
27351 + if (init_mm.start_code <= address && address < init_mm.end_code) {
27352 + if (current->signal->curr_ip)
27353 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n",
27354 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
27355 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
27356 + else
27357 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
27358 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
27359 + }
27360 +#endif
27361 +
27362 printk(KERN_ALERT "BUG: unable to handle kernel ");
27363 if (address < PAGE_SIZE)
27364 printk(KERN_CONT "NULL pointer dereference");
27365 @@ -750,6 +833,22 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
27366 return;
27367 }
27368 #endif
27369 +
27370 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27371 + if (pax_is_fetch_fault(regs, error_code, address)) {
27372 +
27373 +#ifdef CONFIG_PAX_EMUTRAMP
27374 + switch (pax_handle_fetch_fault(regs)) {
27375 + case 2:
27376 + return;
27377 + }
27378 +#endif
27379 +
27380 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
27381 + do_group_exit(SIGKILL);
27382 + }
27383 +#endif
27384 +
27385 /* Kernel addresses are always protection faults: */
27386 if (address >= TASK_SIZE)
27387 error_code |= PF_PROT;
27388 @@ -835,7 +934,7 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
27389 if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) {
27390 printk(KERN_ERR
27391 "MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n",
27392 - tsk->comm, tsk->pid, address);
27393 + tsk->comm, task_pid_nr(tsk), address);
27394 code = BUS_MCEERR_AR;
27395 }
27396 #endif
27397 @@ -898,6 +997,99 @@ static int spurious_fault_check(unsigned long error_code, pte_t *pte)
27398 return 1;
27399 }
27400
27401 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
27402 +static int pax_handle_pageexec_fault(struct pt_regs *regs, struct mm_struct *mm, unsigned long address, unsigned long error_code)
27403 +{
27404 + pte_t *pte;
27405 + pmd_t *pmd;
27406 + spinlock_t *ptl;
27407 + unsigned char pte_mask;
27408 +
27409 + if ((__supported_pte_mask & _PAGE_NX) || (error_code & (PF_PROT|PF_USER)) != (PF_PROT|PF_USER) || v8086_mode(regs) ||
27410 + !(mm->pax_flags & MF_PAX_PAGEEXEC))
27411 + return 0;
27412 +
27413 + /* PaX: it's our fault, let's handle it if we can */
27414 +
27415 + /* PaX: take a look at read faults before acquiring any locks */
27416 + if (unlikely(!(error_code & PF_WRITE) && (regs->ip == address))) {
27417 + /* instruction fetch attempt from a protected page in user mode */
27418 + up_read(&mm->mmap_sem);
27419 +
27420 +#ifdef CONFIG_PAX_EMUTRAMP
27421 + switch (pax_handle_fetch_fault(regs)) {
27422 + case 2:
27423 + return 1;
27424 + }
27425 +#endif
27426 +
27427 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
27428 + do_group_exit(SIGKILL);
27429 + }
27430 +
27431 + pmd = pax_get_pmd(mm, address);
27432 + if (unlikely(!pmd))
27433 + return 0;
27434 +
27435 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
27436 + if (unlikely(!(pte_val(*pte) & _PAGE_PRESENT) || pte_user(*pte))) {
27437 + pte_unmap_unlock(pte, ptl);
27438 + return 0;
27439 + }
27440 +
27441 + if (unlikely((error_code & PF_WRITE) && !pte_write(*pte))) {
27442 + /* write attempt to a protected page in user mode */
27443 + pte_unmap_unlock(pte, ptl);
27444 + return 0;
27445 + }
27446 +
27447 +#ifdef CONFIG_SMP
27448 + if (likely(address > get_limit(regs->cs) && cpu_isset(smp_processor_id(), mm->context.cpu_user_cs_mask)))
27449 +#else
27450 + if (likely(address > get_limit(regs->cs)))
27451 +#endif
27452 + {
27453 + set_pte(pte, pte_mkread(*pte));
27454 + __flush_tlb_one(address);
27455 + pte_unmap_unlock(pte, ptl);
27456 + up_read(&mm->mmap_sem);
27457 + return 1;
27458 + }
27459 +
27460 + pte_mask = _PAGE_ACCESSED | _PAGE_USER | ((error_code & PF_WRITE) << (_PAGE_BIT_DIRTY-1));
27461 +
27462 + /*
27463 + * PaX: fill DTLB with user rights and retry
27464 + */
27465 + __asm__ __volatile__ (
27466 + "orb %2,(%1)\n"
27467 +#if defined(CONFIG_M586) || defined(CONFIG_M586TSC)
27468 +/*
27469 + * PaX: let this uncommented 'invlpg' remind us on the behaviour of Intel's
27470 + * (and AMD's) TLBs. namely, they do not cache PTEs that would raise *any*
27471 + * page fault when examined during a TLB load attempt. this is true not only
27472 + * for PTEs holding a non-present entry but also present entries that will
27473 + * raise a page fault (such as those set up by PaX, or the copy-on-write
27474 + * mechanism). in effect it means that we do *not* need to flush the TLBs
27475 + * for our target pages since their PTEs are simply not in the TLBs at all.
27476 +
27477 + * the best thing in omitting it is that we gain around 15-20% speed in the
27478 + * fast path of the page fault handler and can get rid of tracing since we
27479 + * can no longer flush unintended entries.
27480 + */
27481 + "invlpg (%0)\n"
27482 +#endif
27483 + __copyuser_seg"testb $0,(%0)\n"
27484 + "xorb %3,(%1)\n"
27485 + :
27486 + : "r" (address), "r" (pte), "q" (pte_mask), "i" (_PAGE_USER)
27487 + : "memory", "cc");
27488 + pte_unmap_unlock(pte, ptl);
27489 + up_read(&mm->mmap_sem);
27490 + return 1;
27491 +}
27492 +#endif
27493 +
27494 /*
27495 * Handle a spurious fault caused by a stale TLB entry.
27496 *
27497 @@ -964,6 +1156,9 @@ int show_unhandled_signals = 1;
27498 static inline int
27499 access_error(unsigned long error_code, struct vm_area_struct *vma)
27500 {
27501 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR) && !(vma->vm_flags & VM_EXEC))
27502 + return 1;
27503 +
27504 if (error_code & PF_WRITE) {
27505 /* write, present and write, not present: */
27506 if (unlikely(!(vma->vm_flags & VM_WRITE)))
27507 @@ -992,7 +1187,7 @@ static inline bool smap_violation(int error_code, struct pt_regs *regs)
27508 if (error_code & PF_USER)
27509 return false;
27510
27511 - if (!user_mode_vm(regs) && (regs->flags & X86_EFLAGS_AC))
27512 + if (!user_mode(regs) && (regs->flags & X86_EFLAGS_AC))
27513 return false;
27514
27515 return true;
27516 @@ -1008,18 +1203,33 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
27517 {
27518 struct vm_area_struct *vma;
27519 struct task_struct *tsk;
27520 - unsigned long address;
27521 struct mm_struct *mm;
27522 int fault;
27523 int write = error_code & PF_WRITE;
27524 unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE |
27525 (write ? FAULT_FLAG_WRITE : 0);
27526
27527 - tsk = current;
27528 - mm = tsk->mm;
27529 -
27530 /* Get the faulting address: */
27531 - address = read_cr2();
27532 + unsigned long address = read_cr2();
27533 +
27534 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
27535 + if (!user_mode(regs) && address < 2 * pax_user_shadow_base) {
27536 + if (!search_exception_tables(regs->ip)) {
27537 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
27538 + bad_area_nosemaphore(regs, error_code, address);
27539 + return;
27540 + }
27541 + if (address < pax_user_shadow_base) {
27542 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
27543 + printk(KERN_ERR "PAX: faulting IP: %pS\n", (void *)regs->ip);
27544 + show_trace_log_lvl(NULL, NULL, (void *)regs->sp, regs->bp, KERN_ERR);
27545 + } else
27546 + address -= pax_user_shadow_base;
27547 + }
27548 +#endif
27549 +
27550 + tsk = current;
27551 + mm = tsk->mm;
27552
27553 /*
27554 * Detect and handle instructions that would cause a page fault for
27555 @@ -1080,7 +1290,7 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
27556 * User-mode registers count as a user access even for any
27557 * potential system fault or CPU buglet:
27558 */
27559 - if (user_mode_vm(regs)) {
27560 + if (user_mode(regs)) {
27561 local_irq_enable();
27562 error_code |= PF_USER;
27563 } else {
27564 @@ -1142,6 +1352,11 @@ retry:
27565 might_sleep();
27566 }
27567
27568 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
27569 + if (pax_handle_pageexec_fault(regs, mm, address, error_code))
27570 + return;
27571 +#endif
27572 +
27573 vma = find_vma(mm, address);
27574 if (unlikely(!vma)) {
27575 bad_area(regs, error_code, address);
27576 @@ -1153,18 +1368,24 @@ retry:
27577 bad_area(regs, error_code, address);
27578 return;
27579 }
27580 - if (error_code & PF_USER) {
27581 - /*
27582 - * Accessing the stack below %sp is always a bug.
27583 - * The large cushion allows instructions like enter
27584 - * and pusha to work. ("enter $65535, $31" pushes
27585 - * 32 pointers and then decrements %sp by 65535.)
27586 - */
27587 - if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < regs->sp)) {
27588 - bad_area(regs, error_code, address);
27589 - return;
27590 - }
27591 + /*
27592 + * Accessing the stack below %sp is always a bug.
27593 + * The large cushion allows instructions like enter
27594 + * and pusha to work. ("enter $65535, $31" pushes
27595 + * 32 pointers and then decrements %sp by 65535.)
27596 + */
27597 + if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < task_pt_regs(tsk)->sp)) {
27598 + bad_area(regs, error_code, address);
27599 + return;
27600 }
27601 +
27602 +#ifdef CONFIG_PAX_SEGMEXEC
27603 + if (unlikely((mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end - SEGMEXEC_TASK_SIZE - 1 < address - SEGMEXEC_TASK_SIZE - 1)) {
27604 + bad_area(regs, error_code, address);
27605 + return;
27606 + }
27607 +#endif
27608 +
27609 if (unlikely(expand_stack(vma, address))) {
27610 bad_area(regs, error_code, address);
27611 return;
27612 @@ -1228,3 +1449,292 @@ do_page_fault(struct pt_regs *regs, unsigned long error_code)
27613 __do_page_fault(regs, error_code);
27614 exception_exit(regs);
27615 }
27616 +
27617 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27618 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address)
27619 +{
27620 + struct mm_struct *mm = current->mm;
27621 + unsigned long ip = regs->ip;
27622 +
27623 + if (v8086_mode(regs))
27624 + ip = ((regs->cs & 0xffff) << 4) + (ip & 0xffff);
27625 +
27626 +#ifdef CONFIG_PAX_PAGEEXEC
27627 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
27628 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR))
27629 + return true;
27630 + if (!(error_code & (PF_PROT | PF_WRITE)) && ip == address)
27631 + return true;
27632 + return false;
27633 + }
27634 +#endif
27635 +
27636 +#ifdef CONFIG_PAX_SEGMEXEC
27637 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
27638 + if (!(error_code & (PF_PROT | PF_WRITE)) && (ip + SEGMEXEC_TASK_SIZE == address))
27639 + return true;
27640 + return false;
27641 + }
27642 +#endif
27643 +
27644 + return false;
27645 +}
27646 +#endif
27647 +
27648 +#ifdef CONFIG_PAX_EMUTRAMP
27649 +static int pax_handle_fetch_fault_32(struct pt_regs *regs)
27650 +{
27651 + int err;
27652 +
27653 + do { /* PaX: libffi trampoline emulation */
27654 + unsigned char mov, jmp;
27655 + unsigned int addr1, addr2;
27656 +
27657 +#ifdef CONFIG_X86_64
27658 + if ((regs->ip + 9) >> 32)
27659 + break;
27660 +#endif
27661 +
27662 + err = get_user(mov, (unsigned char __user *)regs->ip);
27663 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
27664 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
27665 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
27666 +
27667 + if (err)
27668 + break;
27669 +
27670 + if (mov == 0xB8 && jmp == 0xE9) {
27671 + regs->ax = addr1;
27672 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
27673 + return 2;
27674 + }
27675 + } while (0);
27676 +
27677 + do { /* PaX: gcc trampoline emulation #1 */
27678 + unsigned char mov1, mov2;
27679 + unsigned short jmp;
27680 + unsigned int addr1, addr2;
27681 +
27682 +#ifdef CONFIG_X86_64
27683 + if ((regs->ip + 11) >> 32)
27684 + break;
27685 +#endif
27686 +
27687 + err = get_user(mov1, (unsigned char __user *)regs->ip);
27688 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
27689 + err |= get_user(mov2, (unsigned char __user *)(regs->ip + 5));
27690 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
27691 + err |= get_user(jmp, (unsigned short __user *)(regs->ip + 10));
27692 +
27693 + if (err)
27694 + break;
27695 +
27696 + if (mov1 == 0xB9 && mov2 == 0xB8 && jmp == 0xE0FF) {
27697 + regs->cx = addr1;
27698 + regs->ax = addr2;
27699 + regs->ip = addr2;
27700 + return 2;
27701 + }
27702 + } while (0);
27703 +
27704 + do { /* PaX: gcc trampoline emulation #2 */
27705 + unsigned char mov, jmp;
27706 + unsigned int addr1, addr2;
27707 +
27708 +#ifdef CONFIG_X86_64
27709 + if ((regs->ip + 9) >> 32)
27710 + break;
27711 +#endif
27712 +
27713 + err = get_user(mov, (unsigned char __user *)regs->ip);
27714 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
27715 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
27716 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
27717 +
27718 + if (err)
27719 + break;
27720 +
27721 + if (mov == 0xB9 && jmp == 0xE9) {
27722 + regs->cx = addr1;
27723 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
27724 + return 2;
27725 + }
27726 + } while (0);
27727 +
27728 + return 1; /* PaX in action */
27729 +}
27730 +
27731 +#ifdef CONFIG_X86_64
27732 +static int pax_handle_fetch_fault_64(struct pt_regs *regs)
27733 +{
27734 + int err;
27735 +
27736 + do { /* PaX: libffi trampoline emulation */
27737 + unsigned short mov1, mov2, jmp1;
27738 + unsigned char stcclc, jmp2;
27739 + unsigned long addr1, addr2;
27740 +
27741 + err = get_user(mov1, (unsigned short __user *)regs->ip);
27742 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
27743 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
27744 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
27745 + err |= get_user(stcclc, (unsigned char __user *)(regs->ip + 20));
27746 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 21));
27747 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 23));
27748 +
27749 + if (err)
27750 + break;
27751 +
27752 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && (stcclc == 0xF8 || stcclc == 0xF9) && jmp1 == 0xFF49 && jmp2 == 0xE3) {
27753 + regs->r11 = addr1;
27754 + regs->r10 = addr2;
27755 + if (stcclc == 0xF8)
27756 + regs->flags &= ~X86_EFLAGS_CF;
27757 + else
27758 + regs->flags |= X86_EFLAGS_CF;
27759 + regs->ip = addr1;
27760 + return 2;
27761 + }
27762 + } while (0);
27763 +
27764 + do { /* PaX: gcc trampoline emulation #1 */
27765 + unsigned short mov1, mov2, jmp1;
27766 + unsigned char jmp2;
27767 + unsigned int addr1;
27768 + unsigned long addr2;
27769 +
27770 + err = get_user(mov1, (unsigned short __user *)regs->ip);
27771 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 2));
27772 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 6));
27773 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 8));
27774 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 16));
27775 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 18));
27776 +
27777 + if (err)
27778 + break;
27779 +
27780 + if (mov1 == 0xBB41 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
27781 + regs->r11 = addr1;
27782 + regs->r10 = addr2;
27783 + regs->ip = addr1;
27784 + return 2;
27785 + }
27786 + } while (0);
27787 +
27788 + do { /* PaX: gcc trampoline emulation #2 */
27789 + unsigned short mov1, mov2, jmp1;
27790 + unsigned char jmp2;
27791 + unsigned long addr1, addr2;
27792 +
27793 + err = get_user(mov1, (unsigned short __user *)regs->ip);
27794 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
27795 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
27796 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
27797 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 20));
27798 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 22));
27799 +
27800 + if (err)
27801 + break;
27802 +
27803 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
27804 + regs->r11 = addr1;
27805 + regs->r10 = addr2;
27806 + regs->ip = addr1;
27807 + return 2;
27808 + }
27809 + } while (0);
27810 +
27811 + return 1; /* PaX in action */
27812 +}
27813 +#endif
27814 +
27815 +/*
27816 + * PaX: decide what to do with offenders (regs->ip = fault address)
27817 + *
27818 + * returns 1 when task should be killed
27819 + * 2 when gcc trampoline was detected
27820 + */
27821 +static int pax_handle_fetch_fault(struct pt_regs *regs)
27822 +{
27823 + if (v8086_mode(regs))
27824 + return 1;
27825 +
27826 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
27827 + return 1;
27828 +
27829 +#ifdef CONFIG_X86_32
27830 + return pax_handle_fetch_fault_32(regs);
27831 +#else
27832 + if (regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))
27833 + return pax_handle_fetch_fault_32(regs);
27834 + else
27835 + return pax_handle_fetch_fault_64(regs);
27836 +#endif
27837 +}
27838 +#endif
27839 +
27840 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27841 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
27842 +{
27843 + long i;
27844 +
27845 + printk(KERN_ERR "PAX: bytes at PC: ");
27846 + for (i = 0; i < 20; i++) {
27847 + unsigned char c;
27848 + if (get_user(c, (unsigned char __force_user *)pc+i))
27849 + printk(KERN_CONT "?? ");
27850 + else
27851 + printk(KERN_CONT "%02x ", c);
27852 + }
27853 + printk("\n");
27854 +
27855 + printk(KERN_ERR "PAX: bytes at SP-%lu: ", (unsigned long)sizeof(long));
27856 + for (i = -1; i < 80 / (long)sizeof(long); i++) {
27857 + unsigned long c;
27858 + if (get_user(c, (unsigned long __force_user *)sp+i)) {
27859 +#ifdef CONFIG_X86_32
27860 + printk(KERN_CONT "???????? ");
27861 +#else
27862 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)))
27863 + printk(KERN_CONT "???????? ???????? ");
27864 + else
27865 + printk(KERN_CONT "???????????????? ");
27866 +#endif
27867 + } else {
27868 +#ifdef CONFIG_X86_64
27869 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))) {
27870 + printk(KERN_CONT "%08x ", (unsigned int)c);
27871 + printk(KERN_CONT "%08x ", (unsigned int)(c >> 32));
27872 + } else
27873 +#endif
27874 + printk(KERN_CONT "%0*lx ", 2 * (int)sizeof(long), c);
27875 + }
27876 + }
27877 + printk("\n");
27878 +}
27879 +#endif
27880 +
27881 +/**
27882 + * probe_kernel_write(): safely attempt to write to a location
27883 + * @dst: address to write to
27884 + * @src: pointer to the data that shall be written
27885 + * @size: size of the data chunk
27886 + *
27887 + * Safely write to address @dst from the buffer at @src. If a kernel fault
27888 + * happens, handle that and return -EFAULT.
27889 + */
27890 +long notrace probe_kernel_write(void *dst, const void *src, size_t size)
27891 +{
27892 + long ret;
27893 + mm_segment_t old_fs = get_fs();
27894 +
27895 + set_fs(KERNEL_DS);
27896 + pagefault_disable();
27897 + pax_open_kernel();
27898 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
27899 + pax_close_kernel();
27900 + pagefault_enable();
27901 + set_fs(old_fs);
27902 +
27903 + return ret ? -EFAULT : 0;
27904 +}
27905 diff --git a/arch/x86/mm/gup.c b/arch/x86/mm/gup.c
27906 index dd74e46..7d26398 100644
27907 --- a/arch/x86/mm/gup.c
27908 +++ b/arch/x86/mm/gup.c
27909 @@ -255,7 +255,7 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
27910 addr = start;
27911 len = (unsigned long) nr_pages << PAGE_SHIFT;
27912 end = start + len;
27913 - if (unlikely(!access_ok(write ? VERIFY_WRITE : VERIFY_READ,
27914 + if (unlikely(!__access_ok(write ? VERIFY_WRITE : VERIFY_READ,
27915 (void __user *)start, len)))
27916 return 0;
27917
27918 diff --git a/arch/x86/mm/highmem_32.c b/arch/x86/mm/highmem_32.c
27919 index 6f31ee5..8ee4164 100644
27920 --- a/arch/x86/mm/highmem_32.c
27921 +++ b/arch/x86/mm/highmem_32.c
27922 @@ -44,7 +44,11 @@ void *kmap_atomic_prot(struct page *page, pgprot_t prot)
27923 idx = type + KM_TYPE_NR*smp_processor_id();
27924 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
27925 BUG_ON(!pte_none(*(kmap_pte-idx)));
27926 +
27927 + pax_open_kernel();
27928 set_pte(kmap_pte-idx, mk_pte(page, prot));
27929 + pax_close_kernel();
27930 +
27931 arch_flush_lazy_mmu_mode();
27932
27933 return (void *)vaddr;
27934 diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c
27935 index ae1aa71..d9bea75 100644
27936 --- a/arch/x86/mm/hugetlbpage.c
27937 +++ b/arch/x86/mm/hugetlbpage.c
27938 @@ -271,23 +271,30 @@ follow_huge_pud(struct mm_struct *mm, unsigned long address,
27939 #ifdef HAVE_ARCH_HUGETLB_UNMAPPED_AREA
27940 static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
27941 unsigned long addr, unsigned long len,
27942 - unsigned long pgoff, unsigned long flags)
27943 + unsigned long pgoff, unsigned long flags, unsigned long offset)
27944 {
27945 struct hstate *h = hstate_file(file);
27946 struct vm_unmapped_area_info info;
27947 -
27948 +
27949 info.flags = 0;
27950 info.length = len;
27951 info.low_limit = TASK_UNMAPPED_BASE;
27952 +
27953 +#ifdef CONFIG_PAX_RANDMMAP
27954 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
27955 + info.low_limit += current->mm->delta_mmap;
27956 +#endif
27957 +
27958 info.high_limit = TASK_SIZE;
27959 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
27960 info.align_offset = 0;
27961 + info.threadstack_offset = offset;
27962 return vm_unmapped_area(&info);
27963 }
27964
27965 static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
27966 unsigned long addr0, unsigned long len,
27967 - unsigned long pgoff, unsigned long flags)
27968 + unsigned long pgoff, unsigned long flags, unsigned long offset)
27969 {
27970 struct hstate *h = hstate_file(file);
27971 struct vm_unmapped_area_info info;
27972 @@ -299,6 +306,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
27973 info.high_limit = current->mm->mmap_base;
27974 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
27975 info.align_offset = 0;
27976 + info.threadstack_offset = offset;
27977 addr = vm_unmapped_area(&info);
27978
27979 /*
27980 @@ -311,6 +319,12 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
27981 VM_BUG_ON(addr != -ENOMEM);
27982 info.flags = 0;
27983 info.low_limit = TASK_UNMAPPED_BASE;
27984 +
27985 +#ifdef CONFIG_PAX_RANDMMAP
27986 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
27987 + info.low_limit += current->mm->delta_mmap;
27988 +#endif
27989 +
27990 info.high_limit = TASK_SIZE;
27991 addr = vm_unmapped_area(&info);
27992 }
27993 @@ -325,10 +339,20 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
27994 struct hstate *h = hstate_file(file);
27995 struct mm_struct *mm = current->mm;
27996 struct vm_area_struct *vma;
27997 + unsigned long pax_task_size = TASK_SIZE;
27998 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
27999
28000 if (len & ~huge_page_mask(h))
28001 return -EINVAL;
28002 - if (len > TASK_SIZE)
28003 +
28004 +#ifdef CONFIG_PAX_SEGMEXEC
28005 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
28006 + pax_task_size = SEGMEXEC_TASK_SIZE;
28007 +#endif
28008 +
28009 + pax_task_size -= PAGE_SIZE;
28010 +
28011 + if (len > pax_task_size)
28012 return -ENOMEM;
28013
28014 if (flags & MAP_FIXED) {
28015 @@ -337,19 +361,22 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
28016 return addr;
28017 }
28018
28019 +#ifdef CONFIG_PAX_RANDMMAP
28020 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
28021 +#endif
28022 +
28023 if (addr) {
28024 addr = ALIGN(addr, huge_page_size(h));
28025 vma = find_vma(mm, addr);
28026 - if (TASK_SIZE - len >= addr &&
28027 - (!vma || addr + len <= vma->vm_start))
28028 + if (pax_task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
28029 return addr;
28030 }
28031 if (mm->get_unmapped_area == arch_get_unmapped_area)
28032 return hugetlb_get_unmapped_area_bottomup(file, addr, len,
28033 - pgoff, flags);
28034 + pgoff, flags, offset);
28035 else
28036 return hugetlb_get_unmapped_area_topdown(file, addr, len,
28037 - pgoff, flags);
28038 + pgoff, flags, offset);
28039 }
28040
28041 #endif /*HAVE_ARCH_HUGETLB_UNMAPPED_AREA*/
28042 diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
28043 index 59b7fc4..b1dd75f 100644
28044 --- a/arch/x86/mm/init.c
28045 +++ b/arch/x86/mm/init.c
28046 @@ -4,6 +4,7 @@
28047 #include <linux/swap.h>
28048 #include <linux/memblock.h>
28049 #include <linux/bootmem.h> /* for max_low_pfn */
28050 +#include <linux/tboot.h>
28051
28052 #include <asm/cacheflush.h>
28053 #include <asm/e820.h>
28054 @@ -17,6 +18,8 @@
28055 #include <asm/proto.h>
28056 #include <asm/dma.h> /* for MAX_DMA_PFN */
28057 #include <asm/microcode.h>
28058 +#include <asm/desc.h>
28059 +#include <asm/bios_ebda.h>
28060
28061 #include "mm_internal.h"
28062
28063 @@ -464,10 +467,40 @@ void __init init_mem_mapping(void)
28064 * Access has to be given to non-kernel-ram areas as well, these contain the PCI
28065 * mmio resources as well as potential bios/acpi data regions.
28066 */
28067 +
28068 +#ifdef CONFIG_GRKERNSEC_KMEM
28069 +static unsigned int ebda_start __read_only;
28070 +static unsigned int ebda_end __read_only;
28071 +#endif
28072 +
28073 int devmem_is_allowed(unsigned long pagenr)
28074 {
28075 - if (pagenr < 256)
28076 +#ifdef CONFIG_GRKERNSEC_KMEM
28077 + /* allow BDA */
28078 + if (!pagenr)
28079 return 1;
28080 + /* allow EBDA */
28081 + if (pagenr >= ebda_start && pagenr < ebda_end)
28082 + return 1;
28083 + /* if tboot is in use, allow access to its hardcoded serial log range */
28084 + if (tboot_enabled() && ((0x60000 >> PAGE_SHIFT) <= pagenr) && (pagenr < (0x68000 >> PAGE_SHIFT)))
28085 + return 1;
28086 +#else
28087 + if (!pagenr)
28088 + return 1;
28089 +#ifdef CONFIG_VM86
28090 + if (pagenr < (ISA_START_ADDRESS >> PAGE_SHIFT))
28091 + return 1;
28092 +#endif
28093 +#endif
28094 +
28095 + if ((ISA_START_ADDRESS >> PAGE_SHIFT) <= pagenr && pagenr < (ISA_END_ADDRESS >> PAGE_SHIFT))
28096 + return 1;
28097 +#ifdef CONFIG_GRKERNSEC_KMEM
28098 + /* throw out everything else below 1MB */
28099 + if (pagenr <= 256)
28100 + return 0;
28101 +#endif
28102 if (iomem_is_exclusive(pagenr << PAGE_SHIFT))
28103 return 0;
28104 if (!page_is_ram(pagenr))
28105 @@ -524,8 +557,117 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
28106 #endif
28107 }
28108
28109 +#ifdef CONFIG_GRKERNSEC_KMEM
28110 +static inline void gr_init_ebda(void)
28111 +{
28112 + unsigned int ebda_addr;
28113 + unsigned int ebda_size = 0;
28114 +
28115 + ebda_addr = get_bios_ebda();
28116 + if (ebda_addr) {
28117 + ebda_size = *(unsigned char *)phys_to_virt(ebda_addr);
28118 + ebda_size <<= 10;
28119 + }
28120 + if (ebda_addr && ebda_size) {
28121 + ebda_start = ebda_addr >> PAGE_SHIFT;
28122 + ebda_end = min((unsigned int)PAGE_ALIGN(ebda_addr + ebda_size), (unsigned int)0xa0000) >> PAGE_SHIFT;
28123 + } else {
28124 + ebda_start = 0x9f000 >> PAGE_SHIFT;
28125 + ebda_end = 0xa0000 >> PAGE_SHIFT;
28126 + }
28127 +}
28128 +#else
28129 +static inline void gr_init_ebda(void) { }
28130 +#endif
28131 +
28132 void free_initmem(void)
28133 {
28134 +#ifdef CONFIG_PAX_KERNEXEC
28135 +#ifdef CONFIG_X86_32
28136 + /* PaX: limit KERNEL_CS to actual size */
28137 + unsigned long addr, limit;
28138 + struct desc_struct d;
28139 + int cpu;
28140 +#else
28141 + pgd_t *pgd;
28142 + pud_t *pud;
28143 + pmd_t *pmd;
28144 + unsigned long addr, end;
28145 +#endif
28146 +#endif
28147 +
28148 + gr_init_ebda();
28149 +
28150 +#ifdef CONFIG_PAX_KERNEXEC
28151 +#ifdef CONFIG_X86_32
28152 + limit = paravirt_enabled() ? ktva_ktla(0xffffffff) : (unsigned long)&_etext;
28153 + limit = (limit - 1UL) >> PAGE_SHIFT;
28154 +
28155 + memset(__LOAD_PHYSICAL_ADDR + PAGE_OFFSET, POISON_FREE_INITMEM, PAGE_SIZE);
28156 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
28157 + pack_descriptor(&d, get_desc_base(&get_cpu_gdt_table(cpu)[GDT_ENTRY_KERNEL_CS]), limit, 0x9B, 0xC);
28158 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEL_CS, &d, DESCTYPE_S);
28159 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEXEC_KERNEL_CS, &d, DESCTYPE_S);
28160 + }
28161 +
28162 + /* PaX: make KERNEL_CS read-only */
28163 + addr = PFN_ALIGN(ktla_ktva((unsigned long)&_text));
28164 + if (!paravirt_enabled())
28165 + set_memory_ro(addr, (PFN_ALIGN(_sdata) - addr) >> PAGE_SHIFT);
28166 +/*
28167 + for (addr = ktla_ktva((unsigned long)&_text); addr < (unsigned long)&_sdata; addr += PMD_SIZE) {
28168 + pgd = pgd_offset_k(addr);
28169 + pud = pud_offset(pgd, addr);
28170 + pmd = pmd_offset(pud, addr);
28171 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28172 + }
28173 +*/
28174 +#ifdef CONFIG_X86_PAE
28175 + set_memory_nx(PFN_ALIGN(__init_begin), (PFN_ALIGN(__init_end) - PFN_ALIGN(__init_begin)) >> PAGE_SHIFT);
28176 +/*
28177 + for (addr = (unsigned long)&__init_begin; addr < (unsigned long)&__init_end; addr += PMD_SIZE) {
28178 + pgd = pgd_offset_k(addr);
28179 + pud = pud_offset(pgd, addr);
28180 + pmd = pmd_offset(pud, addr);
28181 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
28182 + }
28183 +*/
28184 +#endif
28185 +
28186 +#ifdef CONFIG_MODULES
28187 + set_memory_4k((unsigned long)MODULES_EXEC_VADDR, (MODULES_EXEC_END - MODULES_EXEC_VADDR) >> PAGE_SHIFT);
28188 +#endif
28189 +
28190 +#else
28191 + /* PaX: make kernel code/rodata read-only, rest non-executable */
28192 + for (addr = __START_KERNEL_map; addr < __START_KERNEL_map + KERNEL_IMAGE_SIZE; addr += PMD_SIZE) {
28193 + pgd = pgd_offset_k(addr);
28194 + pud = pud_offset(pgd, addr);
28195 + pmd = pmd_offset(pud, addr);
28196 + if (!pmd_present(*pmd))
28197 + continue;
28198 + if ((unsigned long)_text <= addr && addr < (unsigned long)_sdata)
28199 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28200 + else
28201 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
28202 + }
28203 +
28204 + addr = (unsigned long)__va(__pa(__START_KERNEL_map));
28205 + end = addr + KERNEL_IMAGE_SIZE;
28206 + for (; addr < end; addr += PMD_SIZE) {
28207 + pgd = pgd_offset_k(addr);
28208 + pud = pud_offset(pgd, addr);
28209 + pmd = pmd_offset(pud, addr);
28210 + if (!pmd_present(*pmd))
28211 + continue;
28212 + if ((unsigned long)__va(__pa(_text)) <= addr && addr < (unsigned long)__va(__pa(_sdata)))
28213 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28214 + }
28215 +#endif
28216 +
28217 + flush_tlb_all();
28218 +#endif
28219 +
28220 free_init_pages("unused kernel memory",
28221 (unsigned long)(&__init_begin),
28222 (unsigned long)(&__init_end));
28223 diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
28224 index 2d19001..6a1046c 100644
28225 --- a/arch/x86/mm/init_32.c
28226 +++ b/arch/x86/mm/init_32.c
28227 @@ -62,33 +62,6 @@ static noinline int do_test_wp_bit(void);
28228 bool __read_mostly __vmalloc_start_set = false;
28229
28230 /*
28231 - * Creates a middle page table and puts a pointer to it in the
28232 - * given global directory entry. This only returns the gd entry
28233 - * in non-PAE compilation mode, since the middle layer is folded.
28234 - */
28235 -static pmd_t * __init one_md_table_init(pgd_t *pgd)
28236 -{
28237 - pud_t *pud;
28238 - pmd_t *pmd_table;
28239 -
28240 -#ifdef CONFIG_X86_PAE
28241 - if (!(pgd_val(*pgd) & _PAGE_PRESENT)) {
28242 - pmd_table = (pmd_t *)alloc_low_page();
28243 - paravirt_alloc_pmd(&init_mm, __pa(pmd_table) >> PAGE_SHIFT);
28244 - set_pgd(pgd, __pgd(__pa(pmd_table) | _PAGE_PRESENT));
28245 - pud = pud_offset(pgd, 0);
28246 - BUG_ON(pmd_table != pmd_offset(pud, 0));
28247 -
28248 - return pmd_table;
28249 - }
28250 -#endif
28251 - pud = pud_offset(pgd, 0);
28252 - pmd_table = pmd_offset(pud, 0);
28253 -
28254 - return pmd_table;
28255 -}
28256 -
28257 -/*
28258 * Create a page table and place a pointer to it in a middle page
28259 * directory entry:
28260 */
28261 @@ -98,13 +71,28 @@ static pte_t * __init one_page_table_init(pmd_t *pmd)
28262 pte_t *page_table = (pte_t *)alloc_low_page();
28263
28264 paravirt_alloc_pte(&init_mm, __pa(page_table) >> PAGE_SHIFT);
28265 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
28266 + set_pmd(pmd, __pmd(__pa(page_table) | _KERNPG_TABLE));
28267 +#else
28268 set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE));
28269 +#endif
28270 BUG_ON(page_table != pte_offset_kernel(pmd, 0));
28271 }
28272
28273 return pte_offset_kernel(pmd, 0);
28274 }
28275
28276 +static pmd_t * __init one_md_table_init(pgd_t *pgd)
28277 +{
28278 + pud_t *pud;
28279 + pmd_t *pmd_table;
28280 +
28281 + pud = pud_offset(pgd, 0);
28282 + pmd_table = pmd_offset(pud, 0);
28283 +
28284 + return pmd_table;
28285 +}
28286 +
28287 pmd_t * __init populate_extra_pmd(unsigned long vaddr)
28288 {
28289 int pgd_idx = pgd_index(vaddr);
28290 @@ -208,6 +196,7 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28291 int pgd_idx, pmd_idx;
28292 unsigned long vaddr;
28293 pgd_t *pgd;
28294 + pud_t *pud;
28295 pmd_t *pmd;
28296 pte_t *pte = NULL;
28297 unsigned long count = page_table_range_init_count(start, end);
28298 @@ -222,8 +211,13 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28299 pgd = pgd_base + pgd_idx;
28300
28301 for ( ; (pgd_idx < PTRS_PER_PGD) && (vaddr != end); pgd++, pgd_idx++) {
28302 - pmd = one_md_table_init(pgd);
28303 - pmd = pmd + pmd_index(vaddr);
28304 + pud = pud_offset(pgd, vaddr);
28305 + pmd = pmd_offset(pud, vaddr);
28306 +
28307 +#ifdef CONFIG_X86_PAE
28308 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
28309 +#endif
28310 +
28311 for (; (pmd_idx < PTRS_PER_PMD) && (vaddr != end);
28312 pmd++, pmd_idx++) {
28313 pte = page_table_kmap_check(one_page_table_init(pmd),
28314 @@ -235,11 +229,20 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28315 }
28316 }
28317
28318 -static inline int is_kernel_text(unsigned long addr)
28319 +static inline int is_kernel_text(unsigned long start, unsigned long end)
28320 {
28321 - if (addr >= (unsigned long)_text && addr <= (unsigned long)__init_end)
28322 - return 1;
28323 - return 0;
28324 + if ((start > ktla_ktva((unsigned long)_etext) ||
28325 + end <= ktla_ktva((unsigned long)_stext)) &&
28326 + (start > ktla_ktva((unsigned long)_einittext) ||
28327 + end <= ktla_ktva((unsigned long)_sinittext)) &&
28328 +
28329 +#ifdef CONFIG_ACPI_SLEEP
28330 + (start > (unsigned long)__va(acpi_wakeup_address) + 0x4000 || end <= (unsigned long)__va(acpi_wakeup_address)) &&
28331 +#endif
28332 +
28333 + (start > (unsigned long)__va(0xfffff) || end <= (unsigned long)__va(0xc0000)))
28334 + return 0;
28335 + return 1;
28336 }
28337
28338 /*
28339 @@ -256,9 +259,10 @@ kernel_physical_mapping_init(unsigned long start,
28340 unsigned long last_map_addr = end;
28341 unsigned long start_pfn, end_pfn;
28342 pgd_t *pgd_base = swapper_pg_dir;
28343 - int pgd_idx, pmd_idx, pte_ofs;
28344 + unsigned int pgd_idx, pmd_idx, pte_ofs;
28345 unsigned long pfn;
28346 pgd_t *pgd;
28347 + pud_t *pud;
28348 pmd_t *pmd;
28349 pte_t *pte;
28350 unsigned pages_2m, pages_4k;
28351 @@ -291,8 +295,13 @@ repeat:
28352 pfn = start_pfn;
28353 pgd_idx = pgd_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
28354 pgd = pgd_base + pgd_idx;
28355 - for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) {
28356 - pmd = one_md_table_init(pgd);
28357 + for (; pgd_idx < PTRS_PER_PGD && pfn < max_low_pfn; pgd++, pgd_idx++) {
28358 + pud = pud_offset(pgd, 0);
28359 + pmd = pmd_offset(pud, 0);
28360 +
28361 +#ifdef CONFIG_X86_PAE
28362 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
28363 +#endif
28364
28365 if (pfn >= end_pfn)
28366 continue;
28367 @@ -304,14 +313,13 @@ repeat:
28368 #endif
28369 for (; pmd_idx < PTRS_PER_PMD && pfn < end_pfn;
28370 pmd++, pmd_idx++) {
28371 - unsigned int addr = pfn * PAGE_SIZE + PAGE_OFFSET;
28372 + unsigned long address = pfn * PAGE_SIZE + PAGE_OFFSET;
28373
28374 /*
28375 * Map with big pages if possible, otherwise
28376 * create normal page tables:
28377 */
28378 if (use_pse) {
28379 - unsigned int addr2;
28380 pgprot_t prot = PAGE_KERNEL_LARGE;
28381 /*
28382 * first pass will use the same initial
28383 @@ -322,11 +330,7 @@ repeat:
28384 _PAGE_PSE);
28385
28386 pfn &= PMD_MASK >> PAGE_SHIFT;
28387 - addr2 = (pfn + PTRS_PER_PTE-1) * PAGE_SIZE +
28388 - PAGE_OFFSET + PAGE_SIZE-1;
28389 -
28390 - if (is_kernel_text(addr) ||
28391 - is_kernel_text(addr2))
28392 + if (is_kernel_text(address, address + PMD_SIZE))
28393 prot = PAGE_KERNEL_LARGE_EXEC;
28394
28395 pages_2m++;
28396 @@ -343,7 +347,7 @@ repeat:
28397 pte_ofs = pte_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
28398 pte += pte_ofs;
28399 for (; pte_ofs < PTRS_PER_PTE && pfn < end_pfn;
28400 - pte++, pfn++, pte_ofs++, addr += PAGE_SIZE) {
28401 + pte++, pfn++, pte_ofs++, address += PAGE_SIZE) {
28402 pgprot_t prot = PAGE_KERNEL;
28403 /*
28404 * first pass will use the same initial
28405 @@ -351,7 +355,7 @@ repeat:
28406 */
28407 pgprot_t init_prot = __pgprot(PTE_IDENT_ATTR);
28408
28409 - if (is_kernel_text(addr))
28410 + if (is_kernel_text(address, address + PAGE_SIZE))
28411 prot = PAGE_KERNEL_EXEC;
28412
28413 pages_4k++;
28414 @@ -482,7 +486,7 @@ void __init native_pagetable_init(void)
28415
28416 pud = pud_offset(pgd, va);
28417 pmd = pmd_offset(pud, va);
28418 - if (!pmd_present(*pmd))
28419 + if (!pmd_present(*pmd)) // PAX TODO || pmd_large(*pmd))
28420 break;
28421
28422 /* should not be large page here */
28423 @@ -540,12 +544,10 @@ void __init early_ioremap_page_table_range_init(void)
28424
28425 static void __init pagetable_init(void)
28426 {
28427 - pgd_t *pgd_base = swapper_pg_dir;
28428 -
28429 - permanent_kmaps_init(pgd_base);
28430 + permanent_kmaps_init(swapper_pg_dir);
28431 }
28432
28433 -pteval_t __supported_pte_mask __read_mostly = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
28434 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
28435 EXPORT_SYMBOL_GPL(__supported_pte_mask);
28436
28437 /* user-defined highmem size */
28438 @@ -752,6 +754,12 @@ void __init mem_init(void)
28439
28440 pci_iommu_alloc();
28441
28442 +#ifdef CONFIG_PAX_PER_CPU_PGD
28443 + clone_pgd_range(get_cpu_pgd(0) + KERNEL_PGD_BOUNDARY,
28444 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
28445 + KERNEL_PGD_PTRS);
28446 +#endif
28447 +
28448 #ifdef CONFIG_FLATMEM
28449 BUG_ON(!mem_map);
28450 #endif
28451 @@ -780,7 +788,7 @@ void __init mem_init(void)
28452 after_bootmem = 1;
28453
28454 codesize = (unsigned long) &_etext - (unsigned long) &_text;
28455 - datasize = (unsigned long) &_edata - (unsigned long) &_etext;
28456 + datasize = (unsigned long) &_edata - (unsigned long) &_sdata;
28457 initsize = (unsigned long) &__init_end - (unsigned long) &__init_begin;
28458
28459 printk(KERN_INFO "Memory: %luk/%luk available (%dk kernel code, "
28460 @@ -821,10 +829,10 @@ void __init mem_init(void)
28461 ((unsigned long)&__init_end -
28462 (unsigned long)&__init_begin) >> 10,
28463
28464 - (unsigned long)&_etext, (unsigned long)&_edata,
28465 - ((unsigned long)&_edata - (unsigned long)&_etext) >> 10,
28466 + (unsigned long)&_sdata, (unsigned long)&_edata,
28467 + ((unsigned long)&_edata - (unsigned long)&_sdata) >> 10,
28468
28469 - (unsigned long)&_text, (unsigned long)&_etext,
28470 + ktla_ktva((unsigned long)&_text), ktla_ktva((unsigned long)&_etext),
28471 ((unsigned long)&_etext - (unsigned long)&_text) >> 10);
28472
28473 /*
28474 @@ -914,6 +922,7 @@ void set_kernel_text_rw(void)
28475 if (!kernel_set_to_readonly)
28476 return;
28477
28478 + start = ktla_ktva(start);
28479 pr_debug("Set kernel text: %lx - %lx for read write\n",
28480 start, start+size);
28481
28482 @@ -928,6 +937,7 @@ void set_kernel_text_ro(void)
28483 if (!kernel_set_to_readonly)
28484 return;
28485
28486 + start = ktla_ktva(start);
28487 pr_debug("Set kernel text: %lx - %lx for read only\n",
28488 start, start+size);
28489
28490 @@ -956,6 +966,7 @@ void mark_rodata_ro(void)
28491 unsigned long start = PFN_ALIGN(_text);
28492 unsigned long size = PFN_ALIGN(_etext) - start;
28493
28494 + start = ktla_ktva(start);
28495 set_pages_ro(virt_to_page(start), size >> PAGE_SHIFT);
28496 printk(KERN_INFO "Write protecting the kernel text: %luk\n",
28497 size >> 10);
28498 diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
28499 index 474e28f..647dd12 100644
28500 --- a/arch/x86/mm/init_64.c
28501 +++ b/arch/x86/mm/init_64.c
28502 @@ -150,7 +150,7 @@ early_param("gbpages", parse_direct_gbpages_on);
28503 * around without checking the pgd every time.
28504 */
28505
28506 -pteval_t __supported_pte_mask __read_mostly = ~_PAGE_IOMAP;
28507 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_IOMAP);
28508 EXPORT_SYMBOL_GPL(__supported_pte_mask);
28509
28510 int force_personality32;
28511 @@ -183,12 +183,22 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28512
28513 for (address = start; address <= end; address += PGDIR_SIZE) {
28514 const pgd_t *pgd_ref = pgd_offset_k(address);
28515 +
28516 +#ifdef CONFIG_PAX_PER_CPU_PGD
28517 + unsigned long cpu;
28518 +#else
28519 struct page *page;
28520 +#endif
28521
28522 if (pgd_none(*pgd_ref))
28523 continue;
28524
28525 spin_lock(&pgd_lock);
28526 +
28527 +#ifdef CONFIG_PAX_PER_CPU_PGD
28528 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
28529 + pgd_t *pgd = pgd_offset_cpu(cpu, address);
28530 +#else
28531 list_for_each_entry(page, &pgd_list, lru) {
28532 pgd_t *pgd;
28533 spinlock_t *pgt_lock;
28534 @@ -197,6 +207,7 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28535 /* the pgt_lock only for Xen */
28536 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
28537 spin_lock(pgt_lock);
28538 +#endif
28539
28540 if (pgd_none(*pgd))
28541 set_pgd(pgd, *pgd_ref);
28542 @@ -204,7 +215,10 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28543 BUG_ON(pgd_page_vaddr(*pgd)
28544 != pgd_page_vaddr(*pgd_ref));
28545
28546 +#ifndef CONFIG_PAX_PER_CPU_PGD
28547 spin_unlock(pgt_lock);
28548 +#endif
28549 +
28550 }
28551 spin_unlock(&pgd_lock);
28552 }
28553 @@ -237,7 +251,7 @@ static pud_t *fill_pud(pgd_t *pgd, unsigned long vaddr)
28554 {
28555 if (pgd_none(*pgd)) {
28556 pud_t *pud = (pud_t *)spp_getpage();
28557 - pgd_populate(&init_mm, pgd, pud);
28558 + pgd_populate_kernel(&init_mm, pgd, pud);
28559 if (pud != pud_offset(pgd, 0))
28560 printk(KERN_ERR "PAGETABLE BUG #00! %p <-> %p\n",
28561 pud, pud_offset(pgd, 0));
28562 @@ -249,7 +263,7 @@ static pmd_t *fill_pmd(pud_t *pud, unsigned long vaddr)
28563 {
28564 if (pud_none(*pud)) {
28565 pmd_t *pmd = (pmd_t *) spp_getpage();
28566 - pud_populate(&init_mm, pud, pmd);
28567 + pud_populate_kernel(&init_mm, pud, pmd);
28568 if (pmd != pmd_offset(pud, 0))
28569 printk(KERN_ERR "PAGETABLE BUG #01! %p <-> %p\n",
28570 pmd, pmd_offset(pud, 0));
28571 @@ -278,7 +292,9 @@ void set_pte_vaddr_pud(pud_t *pud_page, unsigned long vaddr, pte_t new_pte)
28572 pmd = fill_pmd(pud, vaddr);
28573 pte = fill_pte(pmd, vaddr);
28574
28575 + pax_open_kernel();
28576 set_pte(pte, new_pte);
28577 + pax_close_kernel();
28578
28579 /*
28580 * It's enough to flush this one mapping.
28581 @@ -337,14 +353,12 @@ static void __init __init_extra_mapping(unsigned long phys, unsigned long size,
28582 pgd = pgd_offset_k((unsigned long)__va(phys));
28583 if (pgd_none(*pgd)) {
28584 pud = (pud_t *) spp_getpage();
28585 - set_pgd(pgd, __pgd(__pa(pud) | _KERNPG_TABLE |
28586 - _PAGE_USER));
28587 + set_pgd(pgd, __pgd(__pa(pud) | _PAGE_TABLE));
28588 }
28589 pud = pud_offset(pgd, (unsigned long)__va(phys));
28590 if (pud_none(*pud)) {
28591 pmd = (pmd_t *) spp_getpage();
28592 - set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE |
28593 - _PAGE_USER));
28594 + set_pud(pud, __pud(__pa(pmd) | _PAGE_TABLE));
28595 }
28596 pmd = pmd_offset(pud, phys);
28597 BUG_ON(!pmd_none(*pmd));
28598 @@ -585,7 +599,7 @@ phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end,
28599 prot);
28600
28601 spin_lock(&init_mm.page_table_lock);
28602 - pud_populate(&init_mm, pud, pmd);
28603 + pud_populate_kernel(&init_mm, pud, pmd);
28604 spin_unlock(&init_mm.page_table_lock);
28605 }
28606 __flush_tlb_all();
28607 @@ -626,7 +640,7 @@ kernel_physical_mapping_init(unsigned long start,
28608 page_size_mask);
28609
28610 spin_lock(&init_mm.page_table_lock);
28611 - pgd_populate(&init_mm, pgd, pud);
28612 + pgd_populate_kernel(&init_mm, pgd, pud);
28613 spin_unlock(&init_mm.page_table_lock);
28614 pgd_changed = true;
28615 }
28616 @@ -1065,6 +1079,12 @@ void __init mem_init(void)
28617
28618 pci_iommu_alloc();
28619
28620 +#ifdef CONFIG_PAX_PER_CPU_PGD
28621 + clone_pgd_range(get_cpu_pgd(0) + KERNEL_PGD_BOUNDARY,
28622 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
28623 + KERNEL_PGD_PTRS);
28624 +#endif
28625 +
28626 /* clear_bss() already clear the empty_zero_page */
28627
28628 reservedpages = 0;
28629 @@ -1224,8 +1244,8 @@ int kern_addr_valid(unsigned long addr)
28630 static struct vm_area_struct gate_vma = {
28631 .vm_start = VSYSCALL_START,
28632 .vm_end = VSYSCALL_START + (VSYSCALL_MAPPED_PAGES * PAGE_SIZE),
28633 - .vm_page_prot = PAGE_READONLY_EXEC,
28634 - .vm_flags = VM_READ | VM_EXEC
28635 + .vm_page_prot = PAGE_READONLY,
28636 + .vm_flags = VM_READ
28637 };
28638
28639 struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
28640 @@ -1259,7 +1279,7 @@ int in_gate_area_no_mm(unsigned long addr)
28641
28642 const char *arch_vma_name(struct vm_area_struct *vma)
28643 {
28644 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
28645 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
28646 return "[vdso]";
28647 if (vma == &gate_vma)
28648 return "[vsyscall]";
28649 diff --git a/arch/x86/mm/iomap_32.c b/arch/x86/mm/iomap_32.c
28650 index 7b179b4..6bd17777 100644
28651 --- a/arch/x86/mm/iomap_32.c
28652 +++ b/arch/x86/mm/iomap_32.c
28653 @@ -64,7 +64,11 @@ void *kmap_atomic_prot_pfn(unsigned long pfn, pgprot_t prot)
28654 type = kmap_atomic_idx_push();
28655 idx = type + KM_TYPE_NR * smp_processor_id();
28656 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
28657 +
28658 + pax_open_kernel();
28659 set_pte(kmap_pte - idx, pfn_pte(pfn, prot));
28660 + pax_close_kernel();
28661 +
28662 arch_flush_lazy_mmu_mode();
28663
28664 return (void *)vaddr;
28665 diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
28666 index 78fe3f1..73b95e2 100644
28667 --- a/arch/x86/mm/ioremap.c
28668 +++ b/arch/x86/mm/ioremap.c
28669 @@ -97,7 +97,7 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr,
28670 for (pfn = phys_addr >> PAGE_SHIFT; pfn <= last_pfn; pfn++) {
28671 int is_ram = page_is_ram(pfn);
28672
28673 - if (is_ram && pfn_valid(pfn) && !PageReserved(pfn_to_page(pfn)))
28674 + if (is_ram && pfn_valid(pfn) && (pfn >= 0x100 || !PageReserved(pfn_to_page(pfn))))
28675 return NULL;
28676 WARN_ON_ONCE(is_ram);
28677 }
28678 @@ -256,7 +256,7 @@ EXPORT_SYMBOL(ioremap_prot);
28679 *
28680 * Caller must ensure there is only one unmapping for the same pointer.
28681 */
28682 -void iounmap(volatile void __iomem *addr)
28683 +void iounmap(const volatile void __iomem *addr)
28684 {
28685 struct vm_struct *p, *o;
28686
28687 @@ -315,6 +315,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
28688
28689 /* If page is RAM, we can use __va. Otherwise ioremap and unmap. */
28690 if (page_is_ram(start >> PAGE_SHIFT))
28691 +#ifdef CONFIG_HIGHMEM
28692 + if ((start >> PAGE_SHIFT) < max_low_pfn)
28693 +#endif
28694 return __va(phys);
28695
28696 addr = (void __force *)ioremap_cache(start, PAGE_SIZE);
28697 @@ -327,6 +330,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
28698 void unxlate_dev_mem_ptr(unsigned long phys, void *addr)
28699 {
28700 if (page_is_ram(phys >> PAGE_SHIFT))
28701 +#ifdef CONFIG_HIGHMEM
28702 + if ((phys >> PAGE_SHIFT) < max_low_pfn)
28703 +#endif
28704 return;
28705
28706 iounmap((void __iomem *)((unsigned long)addr & PAGE_MASK));
28707 @@ -344,7 +350,7 @@ static int __init early_ioremap_debug_setup(char *str)
28708 early_param("early_ioremap_debug", early_ioremap_debug_setup);
28709
28710 static __initdata int after_paging_init;
28711 -static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __page_aligned_bss;
28712 +static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __read_only __aligned(PAGE_SIZE);
28713
28714 static inline pmd_t * __init early_ioremap_pmd(unsigned long addr)
28715 {
28716 @@ -381,8 +387,7 @@ void __init early_ioremap_init(void)
28717 slot_virt[i] = __fix_to_virt(FIX_BTMAP_BEGIN - NR_FIX_BTMAPS*i);
28718
28719 pmd = early_ioremap_pmd(fix_to_virt(FIX_BTMAP_BEGIN));
28720 - memset(bm_pte, 0, sizeof(bm_pte));
28721 - pmd_populate_kernel(&init_mm, pmd, bm_pte);
28722 + pmd_populate_user(&init_mm, pmd, bm_pte);
28723
28724 /*
28725 * The boot-ioremap range spans multiple pmds, for which
28726 diff --git a/arch/x86/mm/kmemcheck/kmemcheck.c b/arch/x86/mm/kmemcheck/kmemcheck.c
28727 index d87dd6d..bf3fa66 100644
28728 --- a/arch/x86/mm/kmemcheck/kmemcheck.c
28729 +++ b/arch/x86/mm/kmemcheck/kmemcheck.c
28730 @@ -622,9 +622,9 @@ bool kmemcheck_fault(struct pt_regs *regs, unsigned long address,
28731 * memory (e.g. tracked pages)? For now, we need this to avoid
28732 * invoking kmemcheck for PnP BIOS calls.
28733 */
28734 - if (regs->flags & X86_VM_MASK)
28735 + if (v8086_mode(regs))
28736 return false;
28737 - if (regs->cs != __KERNEL_CS)
28738 + if (regs->cs != __KERNEL_CS && regs->cs != __KERNEXEC_KERNEL_CS)
28739 return false;
28740
28741 pte = kmemcheck_pte_lookup(address);
28742 diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
28743 index 845df68..1d8d29f 100644
28744 --- a/arch/x86/mm/mmap.c
28745 +++ b/arch/x86/mm/mmap.c
28746 @@ -52,7 +52,7 @@ static unsigned int stack_maxrandom_size(void)
28747 * Leave an at least ~128 MB hole with possible stack randomization.
28748 */
28749 #define MIN_GAP (128*1024*1024UL + stack_maxrandom_size())
28750 -#define MAX_GAP (TASK_SIZE/6*5)
28751 +#define MAX_GAP (pax_task_size/6*5)
28752
28753 static int mmap_is_legacy(void)
28754 {
28755 @@ -82,27 +82,40 @@ static unsigned long mmap_rnd(void)
28756 return rnd << PAGE_SHIFT;
28757 }
28758
28759 -static unsigned long mmap_base(void)
28760 +static unsigned long mmap_base(struct mm_struct *mm)
28761 {
28762 unsigned long gap = rlimit(RLIMIT_STACK);
28763 + unsigned long pax_task_size = TASK_SIZE;
28764 +
28765 +#ifdef CONFIG_PAX_SEGMEXEC
28766 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
28767 + pax_task_size = SEGMEXEC_TASK_SIZE;
28768 +#endif
28769
28770 if (gap < MIN_GAP)
28771 gap = MIN_GAP;
28772 else if (gap > MAX_GAP)
28773 gap = MAX_GAP;
28774
28775 - return PAGE_ALIGN(TASK_SIZE - gap - mmap_rnd());
28776 + return PAGE_ALIGN(pax_task_size - gap - mmap_rnd());
28777 }
28778
28779 /*
28780 * Bottom-up (legacy) layout on X86_32 did not support randomization, X86_64
28781 * does, but not when emulating X86_32
28782 */
28783 -static unsigned long mmap_legacy_base(void)
28784 +static unsigned long mmap_legacy_base(struct mm_struct *mm)
28785 {
28786 - if (mmap_is_ia32())
28787 + if (mmap_is_ia32()) {
28788 +
28789 +#ifdef CONFIG_PAX_SEGMEXEC
28790 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
28791 + return SEGMEXEC_TASK_UNMAPPED_BASE;
28792 + else
28793 +#endif
28794 +
28795 return TASK_UNMAPPED_BASE;
28796 - else
28797 + } else
28798 return TASK_UNMAPPED_BASE + mmap_rnd();
28799 }
28800
28801 @@ -113,11 +126,23 @@ static unsigned long mmap_legacy_base(void)
28802 void arch_pick_mmap_layout(struct mm_struct *mm)
28803 {
28804 if (mmap_is_legacy()) {
28805 - mm->mmap_base = mmap_legacy_base();
28806 + mm->mmap_base = mmap_legacy_base(mm);
28807 +
28808 +#ifdef CONFIG_PAX_RANDMMAP
28809 + if (mm->pax_flags & MF_PAX_RANDMMAP)
28810 + mm->mmap_base += mm->delta_mmap;
28811 +#endif
28812 +
28813 mm->get_unmapped_area = arch_get_unmapped_area;
28814 mm->unmap_area = arch_unmap_area;
28815 } else {
28816 - mm->mmap_base = mmap_base();
28817 + mm->mmap_base = mmap_base(mm);
28818 +
28819 +#ifdef CONFIG_PAX_RANDMMAP
28820 + if (mm->pax_flags & MF_PAX_RANDMMAP)
28821 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
28822 +#endif
28823 +
28824 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
28825 mm->unmap_area = arch_unmap_area_topdown;
28826 }
28827 diff --git a/arch/x86/mm/mmio-mod.c b/arch/x86/mm/mmio-mod.c
28828 index dc0b727..f612039 100644
28829 --- a/arch/x86/mm/mmio-mod.c
28830 +++ b/arch/x86/mm/mmio-mod.c
28831 @@ -194,7 +194,7 @@ static void pre(struct kmmio_probe *p, struct pt_regs *regs,
28832 break;
28833 default:
28834 {
28835 - unsigned char *ip = (unsigned char *)instptr;
28836 + unsigned char *ip = (unsigned char *)ktla_ktva(instptr);
28837 my_trace->opcode = MMIO_UNKNOWN_OP;
28838 my_trace->width = 0;
28839 my_trace->value = (*ip) << 16 | *(ip + 1) << 8 |
28840 @@ -234,7 +234,7 @@ static void post(struct kmmio_probe *p, unsigned long condition,
28841 static void ioremap_trace_core(resource_size_t offset, unsigned long size,
28842 void __iomem *addr)
28843 {
28844 - static atomic_t next_id;
28845 + static atomic_unchecked_t next_id;
28846 struct remap_trace *trace = kmalloc(sizeof(*trace), GFP_KERNEL);
28847 /* These are page-unaligned. */
28848 struct mmiotrace_map map = {
28849 @@ -258,7 +258,7 @@ static void ioremap_trace_core(resource_size_t offset, unsigned long size,
28850 .private = trace
28851 },
28852 .phys = offset,
28853 - .id = atomic_inc_return(&next_id)
28854 + .id = atomic_inc_return_unchecked(&next_id)
28855 };
28856 map.map_id = trace->id;
28857
28858 @@ -290,7 +290,7 @@ void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
28859 ioremap_trace_core(offset, size, addr);
28860 }
28861
28862 -static void iounmap_trace_core(volatile void __iomem *addr)
28863 +static void iounmap_trace_core(const volatile void __iomem *addr)
28864 {
28865 struct mmiotrace_map map = {
28866 .phys = 0,
28867 @@ -328,7 +328,7 @@ not_enabled:
28868 }
28869 }
28870
28871 -void mmiotrace_iounmap(volatile void __iomem *addr)
28872 +void mmiotrace_iounmap(const volatile void __iomem *addr)
28873 {
28874 might_sleep();
28875 if (is_enabled()) /* recheck and proper locking in *_core() */
28876 diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
28877 index 72fe01e..f1a8daa 100644
28878 --- a/arch/x86/mm/numa.c
28879 +++ b/arch/x86/mm/numa.c
28880 @@ -477,7 +477,7 @@ static bool __init numa_meminfo_cover_memory(const struct numa_meminfo *mi)
28881 return true;
28882 }
28883
28884 -static int __init numa_register_memblks(struct numa_meminfo *mi)
28885 +static int __init __intentional_overflow(-1) numa_register_memblks(struct numa_meminfo *mi)
28886 {
28887 unsigned long uninitialized_var(pfn_align);
28888 int i, nid;
28889 diff --git a/arch/x86/mm/pageattr-test.c b/arch/x86/mm/pageattr-test.c
28890 index 0e38951..4ca8458 100644
28891 --- a/arch/x86/mm/pageattr-test.c
28892 +++ b/arch/x86/mm/pageattr-test.c
28893 @@ -36,7 +36,7 @@ enum {
28894
28895 static int pte_testbit(pte_t pte)
28896 {
28897 - return pte_flags(pte) & _PAGE_UNUSED1;
28898 + return pte_flags(pte) & _PAGE_CPA_TEST;
28899 }
28900
28901 struct split_state {
28902 diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
28903 index fb4e73e..43f7238 100644
28904 --- a/arch/x86/mm/pageattr.c
28905 +++ b/arch/x86/mm/pageattr.c
28906 @@ -261,7 +261,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
28907 */
28908 #ifdef CONFIG_PCI_BIOS
28909 if (pcibios_enabled && within(pfn, BIOS_BEGIN >> PAGE_SHIFT, BIOS_END >> PAGE_SHIFT))
28910 - pgprot_val(forbidden) |= _PAGE_NX;
28911 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
28912 #endif
28913
28914 /*
28915 @@ -269,9 +269,10 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
28916 * Does not cover __inittext since that is gone later on. On
28917 * 64bit we do not enforce !NX on the low mapping
28918 */
28919 - if (within(address, (unsigned long)_text, (unsigned long)_etext))
28920 - pgprot_val(forbidden) |= _PAGE_NX;
28921 + if (within(address, ktla_ktva((unsigned long)_text), ktla_ktva((unsigned long)_etext)))
28922 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
28923
28924 +#ifdef CONFIG_DEBUG_RODATA
28925 /*
28926 * The .rodata section needs to be read-only. Using the pfn
28927 * catches all aliases.
28928 @@ -279,6 +280,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
28929 if (within(pfn, __pa_symbol(__start_rodata) >> PAGE_SHIFT,
28930 __pa_symbol(__end_rodata) >> PAGE_SHIFT))
28931 pgprot_val(forbidden) |= _PAGE_RW;
28932 +#endif
28933
28934 #if defined(CONFIG_X86_64) && defined(CONFIG_DEBUG_RODATA)
28935 /*
28936 @@ -317,6 +319,13 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
28937 }
28938 #endif
28939
28940 +#ifdef CONFIG_PAX_KERNEXEC
28941 + if (within(pfn, __pa(ktla_ktva((unsigned long)&_text)), __pa((unsigned long)&_sdata))) {
28942 + pgprot_val(forbidden) |= _PAGE_RW;
28943 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
28944 + }
28945 +#endif
28946 +
28947 prot = __pgprot(pgprot_val(prot) & ~pgprot_val(forbidden));
28948
28949 return prot;
28950 @@ -400,23 +409,37 @@ EXPORT_SYMBOL_GPL(slow_virt_to_phys);
28951 static void __set_pmd_pte(pte_t *kpte, unsigned long address, pte_t pte)
28952 {
28953 /* change init_mm */
28954 + pax_open_kernel();
28955 set_pte_atomic(kpte, pte);
28956 +
28957 #ifdef CONFIG_X86_32
28958 if (!SHARED_KERNEL_PMD) {
28959 +
28960 +#ifdef CONFIG_PAX_PER_CPU_PGD
28961 + unsigned long cpu;
28962 +#else
28963 struct page *page;
28964 +#endif
28965
28966 +#ifdef CONFIG_PAX_PER_CPU_PGD
28967 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
28968 + pgd_t *pgd = get_cpu_pgd(cpu);
28969 +#else
28970 list_for_each_entry(page, &pgd_list, lru) {
28971 - pgd_t *pgd;
28972 + pgd_t *pgd = (pgd_t *)page_address(page);
28973 +#endif
28974 +
28975 pud_t *pud;
28976 pmd_t *pmd;
28977
28978 - pgd = (pgd_t *)page_address(page) + pgd_index(address);
28979 + pgd += pgd_index(address);
28980 pud = pud_offset(pgd, address);
28981 pmd = pmd_offset(pud, address);
28982 set_pte_atomic((pte_t *)pmd, pte);
28983 }
28984 }
28985 #endif
28986 + pax_close_kernel();
28987 }
28988
28989 static int
28990 diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
28991 index 6574388..87e9bef 100644
28992 --- a/arch/x86/mm/pat.c
28993 +++ b/arch/x86/mm/pat.c
28994 @@ -376,7 +376,7 @@ int free_memtype(u64 start, u64 end)
28995
28996 if (!entry) {
28997 printk(KERN_INFO "%s:%d freeing invalid memtype [mem %#010Lx-%#010Lx]\n",
28998 - current->comm, current->pid, start, end - 1);
28999 + current->comm, task_pid_nr(current), start, end - 1);
29000 return -EINVAL;
29001 }
29002
29003 @@ -506,8 +506,8 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
29004
29005 while (cursor < to) {
29006 if (!devmem_is_allowed(pfn)) {
29007 - printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx]\n",
29008 - current->comm, from, to - 1);
29009 + printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx] (%#010Lx)\n",
29010 + current->comm, from, to - 1, cursor);
29011 return 0;
29012 }
29013 cursor += PAGE_SIZE;
29014 @@ -577,7 +577,7 @@ int kernel_map_sync_memtype(u64 base, unsigned long size, unsigned long flags)
29015 if (ioremap_change_attr((unsigned long)__va(base), id_sz, flags) < 0) {
29016 printk(KERN_INFO "%s:%d ioremap_change_attr failed %s "
29017 "for [mem %#010Lx-%#010Lx]\n",
29018 - current->comm, current->pid,
29019 + current->comm, task_pid_nr(current),
29020 cattr_name(flags),
29021 base, (unsigned long long)(base + size-1));
29022 return -EINVAL;
29023 @@ -612,7 +612,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
29024 flags = lookup_memtype(paddr);
29025 if (want_flags != flags) {
29026 printk(KERN_WARNING "%s:%d map pfn RAM range req %s for [mem %#010Lx-%#010Lx], got %s\n",
29027 - current->comm, current->pid,
29028 + current->comm, task_pid_nr(current),
29029 cattr_name(want_flags),
29030 (unsigned long long)paddr,
29031 (unsigned long long)(paddr + size - 1),
29032 @@ -634,7 +634,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
29033 free_memtype(paddr, paddr + size);
29034 printk(KERN_ERR "%s:%d map pfn expected mapping type %s"
29035 " for [mem %#010Lx-%#010Lx], got %s\n",
29036 - current->comm, current->pid,
29037 + current->comm, task_pid_nr(current),
29038 cattr_name(want_flags),
29039 (unsigned long long)paddr,
29040 (unsigned long long)(paddr + size - 1),
29041 diff --git a/arch/x86/mm/pf_in.c b/arch/x86/mm/pf_in.c
29042 index 9f0614d..92ae64a 100644
29043 --- a/arch/x86/mm/pf_in.c
29044 +++ b/arch/x86/mm/pf_in.c
29045 @@ -148,7 +148,7 @@ enum reason_type get_ins_type(unsigned long ins_addr)
29046 int i;
29047 enum reason_type rv = OTHERS;
29048
29049 - p = (unsigned char *)ins_addr;
29050 + p = (unsigned char *)ktla_ktva(ins_addr);
29051 p += skip_prefix(p, &prf);
29052 p += get_opcode(p, &opcode);
29053
29054 @@ -168,7 +168,7 @@ static unsigned int get_ins_reg_width(unsigned long ins_addr)
29055 struct prefix_bits prf;
29056 int i;
29057
29058 - p = (unsigned char *)ins_addr;
29059 + p = (unsigned char *)ktla_ktva(ins_addr);
29060 p += skip_prefix(p, &prf);
29061 p += get_opcode(p, &opcode);
29062
29063 @@ -191,7 +191,7 @@ unsigned int get_ins_mem_width(unsigned long ins_addr)
29064 struct prefix_bits prf;
29065 int i;
29066
29067 - p = (unsigned char *)ins_addr;
29068 + p = (unsigned char *)ktla_ktva(ins_addr);
29069 p += skip_prefix(p, &prf);
29070 p += get_opcode(p, &opcode);
29071
29072 @@ -415,7 +415,7 @@ unsigned long get_ins_reg_val(unsigned long ins_addr, struct pt_regs *regs)
29073 struct prefix_bits prf;
29074 int i;
29075
29076 - p = (unsigned char *)ins_addr;
29077 + p = (unsigned char *)ktla_ktva(ins_addr);
29078 p += skip_prefix(p, &prf);
29079 p += get_opcode(p, &opcode);
29080 for (i = 0; i < ARRAY_SIZE(reg_rop); i++)
29081 @@ -470,7 +470,7 @@ unsigned long get_ins_imm_val(unsigned long ins_addr)
29082 struct prefix_bits prf;
29083 int i;
29084
29085 - p = (unsigned char *)ins_addr;
29086 + p = (unsigned char *)ktla_ktva(ins_addr);
29087 p += skip_prefix(p, &prf);
29088 p += get_opcode(p, &opcode);
29089 for (i = 0; i < ARRAY_SIZE(imm_wop); i++)
29090 diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
29091 index 17fda6a..489c74a 100644
29092 --- a/arch/x86/mm/pgtable.c
29093 +++ b/arch/x86/mm/pgtable.c
29094 @@ -91,10 +91,64 @@ static inline void pgd_list_del(pgd_t *pgd)
29095 list_del(&page->lru);
29096 }
29097
29098 -#define UNSHARED_PTRS_PER_PGD \
29099 - (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
29100 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29101 +pgdval_t clone_pgd_mask __read_only = ~_PAGE_PRESENT;
29102
29103 +void __shadow_user_pgds(pgd_t *dst, const pgd_t *src)
29104 +{
29105 + unsigned int count = USER_PGD_PTRS;
29106
29107 + while (count--)
29108 + *dst++ = __pgd((pgd_val(*src++) | (_PAGE_NX & __supported_pte_mask)) & ~_PAGE_USER);
29109 +}
29110 +#endif
29111 +
29112 +#ifdef CONFIG_PAX_PER_CPU_PGD
29113 +void __clone_user_pgds(pgd_t *dst, const pgd_t *src)
29114 +{
29115 + unsigned int count = USER_PGD_PTRS;
29116 +
29117 + while (count--) {
29118 + pgd_t pgd;
29119 +
29120 +#ifdef CONFIG_X86_64
29121 + pgd = __pgd(pgd_val(*src++) | _PAGE_USER);
29122 +#else
29123 + pgd = *src++;
29124 +#endif
29125 +
29126 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29127 + pgd = __pgd(pgd_val(pgd) & clone_pgd_mask);
29128 +#endif
29129 +
29130 + *dst++ = pgd;
29131 + }
29132 +
29133 +}
29134 +#endif
29135 +
29136 +#ifdef CONFIG_X86_64
29137 +#define pxd_t pud_t
29138 +#define pyd_t pgd_t
29139 +#define paravirt_release_pxd(pfn) paravirt_release_pud(pfn)
29140 +#define pxd_free(mm, pud) pud_free((mm), (pud))
29141 +#define pyd_populate(mm, pgd, pud) pgd_populate((mm), (pgd), (pud))
29142 +#define pyd_offset(mm, address) pgd_offset((mm), (address))
29143 +#define PYD_SIZE PGDIR_SIZE
29144 +#else
29145 +#define pxd_t pmd_t
29146 +#define pyd_t pud_t
29147 +#define paravirt_release_pxd(pfn) paravirt_release_pmd(pfn)
29148 +#define pxd_free(mm, pud) pmd_free((mm), (pud))
29149 +#define pyd_populate(mm, pgd, pud) pud_populate((mm), (pgd), (pud))
29150 +#define pyd_offset(mm, address) pud_offset((mm), (address))
29151 +#define PYD_SIZE PUD_SIZE
29152 +#endif
29153 +
29154 +#ifdef CONFIG_PAX_PER_CPU_PGD
29155 +static inline void pgd_ctor(struct mm_struct *mm, pgd_t *pgd) {}
29156 +static inline void pgd_dtor(pgd_t *pgd) {}
29157 +#else
29158 static void pgd_set_mm(pgd_t *pgd, struct mm_struct *mm)
29159 {
29160 BUILD_BUG_ON(sizeof(virt_to_page(pgd)->index) < sizeof(mm));
29161 @@ -135,6 +189,7 @@ static void pgd_dtor(pgd_t *pgd)
29162 pgd_list_del(pgd);
29163 spin_unlock(&pgd_lock);
29164 }
29165 +#endif
29166
29167 /*
29168 * List of all pgd's needed for non-PAE so it can invalidate entries
29169 @@ -147,7 +202,7 @@ static void pgd_dtor(pgd_t *pgd)
29170 * -- nyc
29171 */
29172
29173 -#ifdef CONFIG_X86_PAE
29174 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
29175 /*
29176 * In PAE mode, we need to do a cr3 reload (=tlb flush) when
29177 * updating the top-level pagetable entries to guarantee the
29178 @@ -159,7 +214,7 @@ static void pgd_dtor(pgd_t *pgd)
29179 * not shared between pagetables (!SHARED_KERNEL_PMDS), we allocate
29180 * and initialize the kernel pmds here.
29181 */
29182 -#define PREALLOCATED_PMDS UNSHARED_PTRS_PER_PGD
29183 +#define PREALLOCATED_PXDS (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
29184
29185 void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
29186 {
29187 @@ -177,36 +232,38 @@ void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
29188 */
29189 flush_tlb_mm(mm);
29190 }
29191 +#elif defined(CONFIG_X86_64) && defined(CONFIG_PAX_PER_CPU_PGD)
29192 +#define PREALLOCATED_PXDS USER_PGD_PTRS
29193 #else /* !CONFIG_X86_PAE */
29194
29195 /* No need to prepopulate any pagetable entries in non-PAE modes. */
29196 -#define PREALLOCATED_PMDS 0
29197 +#define PREALLOCATED_PXDS 0
29198
29199 #endif /* CONFIG_X86_PAE */
29200
29201 -static void free_pmds(pmd_t *pmds[])
29202 +static void free_pxds(pxd_t *pxds[])
29203 {
29204 int i;
29205
29206 - for(i = 0; i < PREALLOCATED_PMDS; i++)
29207 - if (pmds[i])
29208 - free_page((unsigned long)pmds[i]);
29209 + for(i = 0; i < PREALLOCATED_PXDS; i++)
29210 + if (pxds[i])
29211 + free_page((unsigned long)pxds[i]);
29212 }
29213
29214 -static int preallocate_pmds(pmd_t *pmds[])
29215 +static int preallocate_pxds(pxd_t *pxds[])
29216 {
29217 int i;
29218 bool failed = false;
29219
29220 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
29221 - pmd_t *pmd = (pmd_t *)__get_free_page(PGALLOC_GFP);
29222 - if (pmd == NULL)
29223 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
29224 + pxd_t *pxd = (pxd_t *)__get_free_page(PGALLOC_GFP);
29225 + if (pxd == NULL)
29226 failed = true;
29227 - pmds[i] = pmd;
29228 + pxds[i] = pxd;
29229 }
29230
29231 if (failed) {
29232 - free_pmds(pmds);
29233 + free_pxds(pxds);
29234 return -ENOMEM;
29235 }
29236
29237 @@ -219,51 +276,55 @@ static int preallocate_pmds(pmd_t *pmds[])
29238 * preallocate which never got a corresponding vma will need to be
29239 * freed manually.
29240 */
29241 -static void pgd_mop_up_pmds(struct mm_struct *mm, pgd_t *pgdp)
29242 +static void pgd_mop_up_pxds(struct mm_struct *mm, pgd_t *pgdp)
29243 {
29244 int i;
29245
29246 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
29247 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
29248 pgd_t pgd = pgdp[i];
29249
29250 if (pgd_val(pgd) != 0) {
29251 - pmd_t *pmd = (pmd_t *)pgd_page_vaddr(pgd);
29252 + pxd_t *pxd = (pxd_t *)pgd_page_vaddr(pgd);
29253
29254 - pgdp[i] = native_make_pgd(0);
29255 + set_pgd(pgdp + i, native_make_pgd(0));
29256
29257 - paravirt_release_pmd(pgd_val(pgd) >> PAGE_SHIFT);
29258 - pmd_free(mm, pmd);
29259 + paravirt_release_pxd(pgd_val(pgd) >> PAGE_SHIFT);
29260 + pxd_free(mm, pxd);
29261 }
29262 }
29263 }
29264
29265 -static void pgd_prepopulate_pmd(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmds[])
29266 +static void pgd_prepopulate_pxd(struct mm_struct *mm, pgd_t *pgd, pxd_t *pxds[])
29267 {
29268 - pud_t *pud;
29269 + pyd_t *pyd;
29270 unsigned long addr;
29271 int i;
29272
29273 - if (PREALLOCATED_PMDS == 0) /* Work around gcc-3.4.x bug */
29274 + if (PREALLOCATED_PXDS == 0) /* Work around gcc-3.4.x bug */
29275 return;
29276
29277 - pud = pud_offset(pgd, 0);
29278 +#ifdef CONFIG_X86_64
29279 + pyd = pyd_offset(mm, 0L);
29280 +#else
29281 + pyd = pyd_offset(pgd, 0L);
29282 +#endif
29283
29284 - for (addr = i = 0; i < PREALLOCATED_PMDS;
29285 - i++, pud++, addr += PUD_SIZE) {
29286 - pmd_t *pmd = pmds[i];
29287 + for (addr = i = 0; i < PREALLOCATED_PXDS;
29288 + i++, pyd++, addr += PYD_SIZE) {
29289 + pxd_t *pxd = pxds[i];
29290
29291 if (i >= KERNEL_PGD_BOUNDARY)
29292 - memcpy(pmd, (pmd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
29293 - sizeof(pmd_t) * PTRS_PER_PMD);
29294 + memcpy(pxd, (pxd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
29295 + sizeof(pxd_t) * PTRS_PER_PMD);
29296
29297 - pud_populate(mm, pud, pmd);
29298 + pyd_populate(mm, pyd, pxd);
29299 }
29300 }
29301
29302 pgd_t *pgd_alloc(struct mm_struct *mm)
29303 {
29304 pgd_t *pgd;
29305 - pmd_t *pmds[PREALLOCATED_PMDS];
29306 + pxd_t *pxds[PREALLOCATED_PXDS];
29307
29308 pgd = (pgd_t *)__get_free_page(PGALLOC_GFP);
29309
29310 @@ -272,11 +333,11 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
29311
29312 mm->pgd = pgd;
29313
29314 - if (preallocate_pmds(pmds) != 0)
29315 + if (preallocate_pxds(pxds) != 0)
29316 goto out_free_pgd;
29317
29318 if (paravirt_pgd_alloc(mm) != 0)
29319 - goto out_free_pmds;
29320 + goto out_free_pxds;
29321
29322 /*
29323 * Make sure that pre-populating the pmds is atomic with
29324 @@ -286,14 +347,14 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
29325 spin_lock(&pgd_lock);
29326
29327 pgd_ctor(mm, pgd);
29328 - pgd_prepopulate_pmd(mm, pgd, pmds);
29329 + pgd_prepopulate_pxd(mm, pgd, pxds);
29330
29331 spin_unlock(&pgd_lock);
29332
29333 return pgd;
29334
29335 -out_free_pmds:
29336 - free_pmds(pmds);
29337 +out_free_pxds:
29338 + free_pxds(pxds);
29339 out_free_pgd:
29340 free_page((unsigned long)pgd);
29341 out:
29342 @@ -302,7 +363,7 @@ out:
29343
29344 void pgd_free(struct mm_struct *mm, pgd_t *pgd)
29345 {
29346 - pgd_mop_up_pmds(mm, pgd);
29347 + pgd_mop_up_pxds(mm, pgd);
29348 pgd_dtor(pgd);
29349 paravirt_pgd_free(mm, pgd);
29350 free_page((unsigned long)pgd);
29351 diff --git a/arch/x86/mm/pgtable_32.c b/arch/x86/mm/pgtable_32.c
29352 index a69bcb8..19068ab 100644
29353 --- a/arch/x86/mm/pgtable_32.c
29354 +++ b/arch/x86/mm/pgtable_32.c
29355 @@ -47,10 +47,13 @@ void set_pte_vaddr(unsigned long vaddr, pte_t pteval)
29356 return;
29357 }
29358 pte = pte_offset_kernel(pmd, vaddr);
29359 +
29360 + pax_open_kernel();
29361 if (pte_val(pteval))
29362 set_pte_at(&init_mm, vaddr, pte, pteval);
29363 else
29364 pte_clear(&init_mm, vaddr, pte);
29365 + pax_close_kernel();
29366
29367 /*
29368 * It's enough to flush this one mapping.
29369 diff --git a/arch/x86/mm/physaddr.c b/arch/x86/mm/physaddr.c
29370 index e666cbb..61788c45 100644
29371 --- a/arch/x86/mm/physaddr.c
29372 +++ b/arch/x86/mm/physaddr.c
29373 @@ -10,7 +10,7 @@
29374 #ifdef CONFIG_X86_64
29375
29376 #ifdef CONFIG_DEBUG_VIRTUAL
29377 -unsigned long __phys_addr(unsigned long x)
29378 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
29379 {
29380 unsigned long y = x - __START_KERNEL_map;
29381
29382 @@ -67,7 +67,7 @@ EXPORT_SYMBOL(__virt_addr_valid);
29383 #else
29384
29385 #ifdef CONFIG_DEBUG_VIRTUAL
29386 -unsigned long __phys_addr(unsigned long x)
29387 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
29388 {
29389 unsigned long phys_addr = x - PAGE_OFFSET;
29390 /* VMALLOC_* aren't constants */
29391 diff --git a/arch/x86/mm/setup_nx.c b/arch/x86/mm/setup_nx.c
29392 index 410531d..0f16030 100644
29393 --- a/arch/x86/mm/setup_nx.c
29394 +++ b/arch/x86/mm/setup_nx.c
29395 @@ -5,8 +5,10 @@
29396 #include <asm/pgtable.h>
29397 #include <asm/proto.h>
29398
29399 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
29400 static int disable_nx __cpuinitdata;
29401
29402 +#ifndef CONFIG_PAX_PAGEEXEC
29403 /*
29404 * noexec = on|off
29405 *
29406 @@ -28,12 +30,17 @@ static int __init noexec_setup(char *str)
29407 return 0;
29408 }
29409 early_param("noexec", noexec_setup);
29410 +#endif
29411 +
29412 +#endif
29413
29414 void __cpuinit x86_configure_nx(void)
29415 {
29416 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
29417 if (cpu_has_nx && !disable_nx)
29418 __supported_pte_mask |= _PAGE_NX;
29419 else
29420 +#endif
29421 __supported_pte_mask &= ~_PAGE_NX;
29422 }
29423
29424 diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
29425 index 282375f..e03a98f 100644
29426 --- a/arch/x86/mm/tlb.c
29427 +++ b/arch/x86/mm/tlb.c
29428 @@ -48,7 +48,11 @@ void leave_mm(int cpu)
29429 BUG();
29430 if (cpumask_test_cpu(cpu, mm_cpumask(active_mm))) {
29431 cpumask_clear_cpu(cpu, mm_cpumask(active_mm));
29432 +
29433 +#ifndef CONFIG_PAX_PER_CPU_PGD
29434 load_cr3(swapper_pg_dir);
29435 +#endif
29436 +
29437 }
29438 }
29439 EXPORT_SYMBOL_GPL(leave_mm);
29440 diff --git a/arch/x86/net/bpf_jit.S b/arch/x86/net/bpf_jit.S
29441 index 877b9a1..a8ecf42 100644
29442 --- a/arch/x86/net/bpf_jit.S
29443 +++ b/arch/x86/net/bpf_jit.S
29444 @@ -9,6 +9,7 @@
29445 */
29446 #include <linux/linkage.h>
29447 #include <asm/dwarf2.h>
29448 +#include <asm/alternative-asm.h>
29449
29450 /*
29451 * Calling convention :
29452 @@ -35,6 +36,7 @@ sk_load_word_positive_offset:
29453 jle bpf_slow_path_word
29454 mov (SKBDATA,%rsi),%eax
29455 bswap %eax /* ntohl() */
29456 + pax_force_retaddr
29457 ret
29458
29459 sk_load_half:
29460 @@ -52,6 +54,7 @@ sk_load_half_positive_offset:
29461 jle bpf_slow_path_half
29462 movzwl (SKBDATA,%rsi),%eax
29463 rol $8,%ax # ntohs()
29464 + pax_force_retaddr
29465 ret
29466
29467 sk_load_byte:
29468 @@ -66,6 +69,7 @@ sk_load_byte_positive_offset:
29469 cmp %esi,%r9d /* if (offset >= hlen) goto bpf_slow_path_byte */
29470 jle bpf_slow_path_byte
29471 movzbl (SKBDATA,%rsi),%eax
29472 + pax_force_retaddr
29473 ret
29474
29475 /**
29476 @@ -87,6 +91,7 @@ sk_load_byte_msh_positive_offset:
29477 movzbl (SKBDATA,%rsi),%ebx
29478 and $15,%bl
29479 shl $2,%bl
29480 + pax_force_retaddr
29481 ret
29482
29483 /* rsi contains offset and can be scratched */
29484 @@ -109,6 +114,7 @@ bpf_slow_path_word:
29485 js bpf_error
29486 mov -12(%rbp),%eax
29487 bswap %eax
29488 + pax_force_retaddr
29489 ret
29490
29491 bpf_slow_path_half:
29492 @@ -117,12 +123,14 @@ bpf_slow_path_half:
29493 mov -12(%rbp),%ax
29494 rol $8,%ax
29495 movzwl %ax,%eax
29496 + pax_force_retaddr
29497 ret
29498
29499 bpf_slow_path_byte:
29500 bpf_slow_path_common(1)
29501 js bpf_error
29502 movzbl -12(%rbp),%eax
29503 + pax_force_retaddr
29504 ret
29505
29506 bpf_slow_path_byte_msh:
29507 @@ -133,6 +141,7 @@ bpf_slow_path_byte_msh:
29508 and $15,%al
29509 shl $2,%al
29510 xchg %eax,%ebx
29511 + pax_force_retaddr
29512 ret
29513
29514 #define sk_negative_common(SIZE) \
29515 @@ -157,6 +166,7 @@ sk_load_word_negative_offset:
29516 sk_negative_common(4)
29517 mov (%rax), %eax
29518 bswap %eax
29519 + pax_force_retaddr
29520 ret
29521
29522 bpf_slow_path_half_neg:
29523 @@ -168,6 +178,7 @@ sk_load_half_negative_offset:
29524 mov (%rax),%ax
29525 rol $8,%ax
29526 movzwl %ax,%eax
29527 + pax_force_retaddr
29528 ret
29529
29530 bpf_slow_path_byte_neg:
29531 @@ -177,6 +188,7 @@ sk_load_byte_negative_offset:
29532 .globl sk_load_byte_negative_offset
29533 sk_negative_common(1)
29534 movzbl (%rax), %eax
29535 + pax_force_retaddr
29536 ret
29537
29538 bpf_slow_path_byte_msh_neg:
29539 @@ -190,6 +202,7 @@ sk_load_byte_msh_negative_offset:
29540 and $15,%al
29541 shl $2,%al
29542 xchg %eax,%ebx
29543 + pax_force_retaddr
29544 ret
29545
29546 bpf_error:
29547 @@ -197,4 +210,5 @@ bpf_error:
29548 xor %eax,%eax
29549 mov -8(%rbp),%rbx
29550 leaveq
29551 + pax_force_retaddr
29552 ret
29553 diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
29554 index 3cbe4538..fd756dc 100644
29555 --- a/arch/x86/net/bpf_jit_comp.c
29556 +++ b/arch/x86/net/bpf_jit_comp.c
29557 @@ -12,6 +12,7 @@
29558 #include <linux/netdevice.h>
29559 #include <linux/filter.h>
29560 #include <linux/if_vlan.h>
29561 +#include <linux/random.h>
29562
29563 /*
29564 * Conventions :
29565 @@ -49,13 +50,87 @@ static inline u8 *emit_code(u8 *ptr, u32 bytes, unsigned int len)
29566 return ptr + len;
29567 }
29568
29569 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29570 +#define MAX_INSTR_CODE_SIZE 96
29571 +#else
29572 +#define MAX_INSTR_CODE_SIZE 64
29573 +#endif
29574 +
29575 #define EMIT(bytes, len) do { prog = emit_code(prog, bytes, len); } while (0)
29576
29577 #define EMIT1(b1) EMIT(b1, 1)
29578 #define EMIT2(b1, b2) EMIT((b1) + ((b2) << 8), 2)
29579 #define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
29580 #define EMIT4(b1, b2, b3, b4) EMIT((b1) + ((b2) << 8) + ((b3) << 16) + ((b4) << 24), 4)
29581 +
29582 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29583 +/* original constant will appear in ecx */
29584 +#define DILUTE_CONST_SEQUENCE(_off, _key) \
29585 +do { \
29586 + /* mov ecx, randkey */ \
29587 + EMIT1(0xb9); \
29588 + EMIT(_key, 4); \
29589 + /* xor ecx, randkey ^ off */ \
29590 + EMIT2(0x81, 0xf1); \
29591 + EMIT((_key) ^ (_off), 4); \
29592 +} while (0)
29593 +
29594 +#define EMIT1_off32(b1, _off) \
29595 +do { \
29596 + switch (b1) { \
29597 + case 0x05: /* add eax, imm32 */ \
29598 + case 0x2d: /* sub eax, imm32 */ \
29599 + case 0x25: /* and eax, imm32 */ \
29600 + case 0x0d: /* or eax, imm32 */ \
29601 + case 0xb8: /* mov eax, imm32 */ \
29602 + case 0x3d: /* cmp eax, imm32 */ \
29603 + case 0xa9: /* test eax, imm32 */ \
29604 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29605 + EMIT2((b1) - 4, 0xc8); /* convert imm instruction to eax, ecx */\
29606 + break; \
29607 + case 0xbb: /* mov ebx, imm32 */ \
29608 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29609 + /* mov ebx, ecx */ \
29610 + EMIT2(0x89, 0xcb); \
29611 + break; \
29612 + case 0xbe: /* mov esi, imm32 */ \
29613 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29614 + /* mov esi, ecx */ \
29615 + EMIT2(0x89, 0xce); \
29616 + break; \
29617 + case 0xe9: /* jmp rel imm32 */ \
29618 + EMIT1(b1); \
29619 + EMIT(_off, 4); \
29620 + /* prevent fall-through, we're not called if off = 0 */ \
29621 + EMIT(0xcccccccc, 4); \
29622 + EMIT(0xcccccccc, 4); \
29623 + break; \
29624 + default: \
29625 + EMIT1(b1); \
29626 + EMIT(_off, 4); \
29627 + } \
29628 +} while (0)
29629 +
29630 +#define EMIT2_off32(b1, b2, _off) \
29631 +do { \
29632 + if ((b1) == 0x8d && (b2) == 0xb3) { /* lea esi, [rbx+imm32] */ \
29633 + EMIT2(0x8d, 0xb3); /* lea esi, [rbx+randkey] */ \
29634 + EMIT(randkey, 4); \
29635 + EMIT2(0x8d, 0xb6); /* lea esi, [esi+off-randkey] */ \
29636 + EMIT((_off) - randkey, 4); \
29637 + } else if ((b1) == 0x69 && (b2) == 0xc0) { /* imul eax, imm32 */\
29638 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29639 + /* imul eax, ecx */ \
29640 + EMIT3(0x0f, 0xaf, 0xc1); \
29641 + } else { \
29642 + EMIT2(b1, b2); \
29643 + EMIT(_off, 4); \
29644 + } \
29645 +} while (0)
29646 +#else
29647 #define EMIT1_off32(b1, off) do { EMIT1(b1); EMIT(off, 4);} while (0)
29648 +#define EMIT2_off32(b1, b2, off) do { EMIT2(b1, b2); EMIT(off, 4);} while (0)
29649 +#endif
29650
29651 #define CLEAR_A() EMIT2(0x31, 0xc0) /* xor %eax,%eax */
29652 #define CLEAR_X() EMIT2(0x31, 0xdb) /* xor %ebx,%ebx */
29653 @@ -90,6 +165,24 @@ do { \
29654 #define X86_JBE 0x76
29655 #define X86_JA 0x77
29656
29657 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29658 +#define APPEND_FLOW_VERIFY() \
29659 +do { \
29660 + /* mov ecx, randkey */ \
29661 + EMIT1(0xb9); \
29662 + EMIT(randkey, 4); \
29663 + /* cmp ecx, randkey */ \
29664 + EMIT2(0x81, 0xf9); \
29665 + EMIT(randkey, 4); \
29666 + /* jz after 8 int 3s */ \
29667 + EMIT2(0x74, 0x08); \
29668 + EMIT(0xcccccccc, 4); \
29669 + EMIT(0xcccccccc, 4); \
29670 +} while (0)
29671 +#else
29672 +#define APPEND_FLOW_VERIFY() do { } while (0)
29673 +#endif
29674 +
29675 #define EMIT_COND_JMP(op, offset) \
29676 do { \
29677 if (is_near(offset)) \
29678 @@ -97,6 +190,7 @@ do { \
29679 else { \
29680 EMIT2(0x0f, op + 0x10); \
29681 EMIT(offset, 4); /* jxx .+off32 */ \
29682 + APPEND_FLOW_VERIFY(); \
29683 } \
29684 } while (0)
29685
29686 @@ -121,6 +215,11 @@ static inline void bpf_flush_icache(void *start, void *end)
29687 set_fs(old_fs);
29688 }
29689
29690 +struct bpf_jit_work {
29691 + struct work_struct work;
29692 + void *image;
29693 +};
29694 +
29695 #define CHOOSE_LOAD_FUNC(K, func) \
29696 ((int)K < 0 ? ((int)K >= SKF_LL_OFF ? func##_negative_offset : func) : func##_positive_offset)
29697
29698 @@ -146,7 +245,7 @@ static int pkt_type_offset(void)
29699
29700 void bpf_jit_compile(struct sk_filter *fp)
29701 {
29702 - u8 temp[64];
29703 + u8 temp[MAX_INSTR_CODE_SIZE];
29704 u8 *prog;
29705 unsigned int proglen, oldproglen = 0;
29706 int ilen, i;
29707 @@ -159,6 +258,9 @@ void bpf_jit_compile(struct sk_filter *fp)
29708 unsigned int *addrs;
29709 const struct sock_filter *filter = fp->insns;
29710 int flen = fp->len;
29711 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29712 + unsigned int randkey;
29713 +#endif
29714
29715 if (!bpf_jit_enable)
29716 return;
29717 @@ -167,11 +269,19 @@ void bpf_jit_compile(struct sk_filter *fp)
29718 if (addrs == NULL)
29719 return;
29720
29721 + fp->work = kmalloc(sizeof(*fp->work), GFP_KERNEL);
29722 + if (!fp->work)
29723 + goto out;
29724 +
29725 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29726 + randkey = get_random_int();
29727 +#endif
29728 +
29729 /* Before first pass, make a rough estimation of addrs[]
29730 - * each bpf instruction is translated to less than 64 bytes
29731 + * each bpf instruction is translated to less than MAX_INSTR_CODE_SIZE bytes
29732 */
29733 for (proglen = 0, i = 0; i < flen; i++) {
29734 - proglen += 64;
29735 + proglen += MAX_INSTR_CODE_SIZE;
29736 addrs[i] = proglen;
29737 }
29738 cleanup_addr = proglen; /* epilogue address */
29739 @@ -282,10 +392,8 @@ void bpf_jit_compile(struct sk_filter *fp)
29740 case BPF_S_ALU_MUL_K: /* A *= K */
29741 if (is_imm8(K))
29742 EMIT3(0x6b, 0xc0, K); /* imul imm8,%eax,%eax */
29743 - else {
29744 - EMIT2(0x69, 0xc0); /* imul imm32,%eax */
29745 - EMIT(K, 4);
29746 - }
29747 + else
29748 + EMIT2_off32(0x69, 0xc0, K); /* imul imm32,%eax */
29749 break;
29750 case BPF_S_ALU_DIV_X: /* A /= X; */
29751 seen |= SEEN_XREG;
29752 @@ -325,13 +433,23 @@ void bpf_jit_compile(struct sk_filter *fp)
29753 break;
29754 case BPF_S_ALU_MOD_K: /* A %= K; */
29755 EMIT2(0x31, 0xd2); /* xor %edx,%edx */
29756 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29757 + DILUTE_CONST_SEQUENCE(K, randkey);
29758 +#else
29759 EMIT1(0xb9);EMIT(K, 4); /* mov imm32,%ecx */
29760 +#endif
29761 EMIT2(0xf7, 0xf1); /* div %ecx */
29762 EMIT2(0x89, 0xd0); /* mov %edx,%eax */
29763 break;
29764 case BPF_S_ALU_DIV_K: /* A = reciprocal_divide(A, K); */
29765 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29766 + DILUTE_CONST_SEQUENCE(K, randkey);
29767 + // imul rax, rcx
29768 + EMIT4(0x48, 0x0f, 0xaf, 0xc1);
29769 +#else
29770 EMIT3(0x48, 0x69, 0xc0); /* imul imm32,%rax,%rax */
29771 EMIT(K, 4);
29772 +#endif
29773 EMIT4(0x48, 0xc1, 0xe8, 0x20); /* shr $0x20,%rax */
29774 break;
29775 case BPF_S_ALU_AND_X:
29776 @@ -602,8 +720,7 @@ common_load_ind: seen |= SEEN_DATAREF | SEEN_XREG;
29777 if (is_imm8(K)) {
29778 EMIT3(0x8d, 0x73, K); /* lea imm8(%rbx), %esi */
29779 } else {
29780 - EMIT2(0x8d, 0xb3); /* lea imm32(%rbx),%esi */
29781 - EMIT(K, 4);
29782 + EMIT2_off32(0x8d, 0xb3, K); /* lea imm32(%rbx),%esi */
29783 }
29784 } else {
29785 EMIT2(0x89,0xde); /* mov %ebx,%esi */
29786 @@ -686,17 +803,18 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
29787 break;
29788 default:
29789 /* hmm, too complex filter, give up with jit compiler */
29790 - goto out;
29791 + goto error;
29792 }
29793 ilen = prog - temp;
29794 if (image) {
29795 if (unlikely(proglen + ilen > oldproglen)) {
29796 pr_err("bpb_jit_compile fatal error\n");
29797 - kfree(addrs);
29798 - module_free(NULL, image);
29799 - return;
29800 + module_free_exec(NULL, image);
29801 + goto error;
29802 }
29803 + pax_open_kernel();
29804 memcpy(image + proglen, temp, ilen);
29805 + pax_close_kernel();
29806 }
29807 proglen += ilen;
29808 addrs[i] = proglen;
29809 @@ -717,11 +835,9 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
29810 break;
29811 }
29812 if (proglen == oldproglen) {
29813 - image = module_alloc(max_t(unsigned int,
29814 - proglen,
29815 - sizeof(struct work_struct)));
29816 + image = module_alloc_exec(proglen);
29817 if (!image)
29818 - goto out;
29819 + goto error;
29820 }
29821 oldproglen = proglen;
29822 }
29823 @@ -737,7 +853,10 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
29824 bpf_flush_icache(image, image + proglen);
29825
29826 fp->bpf_func = (void *)image;
29827 - }
29828 + } else
29829 +error:
29830 + kfree(fp->work);
29831 +
29832 out:
29833 kfree(addrs);
29834 return;
29835 @@ -745,18 +864,20 @@ out:
29836
29837 static void jit_free_defer(struct work_struct *arg)
29838 {
29839 - module_free(NULL, arg);
29840 + module_free_exec(NULL, ((struct bpf_jit_work *)arg)->image);
29841 + kfree(arg);
29842 }
29843
29844 /* run from softirq, we must use a work_struct to call
29845 - * module_free() from process context
29846 + * module_free_exec() from process context
29847 */
29848 void bpf_jit_free(struct sk_filter *fp)
29849 {
29850 if (fp->bpf_func != sk_run_filter) {
29851 - struct work_struct *work = (struct work_struct *)fp->bpf_func;
29852 + struct work_struct *work = &fp->work->work;
29853
29854 INIT_WORK(work, jit_free_defer);
29855 + fp->work->image = fp->bpf_func;
29856 schedule_work(work);
29857 }
29858 }
29859 diff --git a/arch/x86/oprofile/backtrace.c b/arch/x86/oprofile/backtrace.c
29860 index d6aa6e8..266395a 100644
29861 --- a/arch/x86/oprofile/backtrace.c
29862 +++ b/arch/x86/oprofile/backtrace.c
29863 @@ -46,11 +46,11 @@ dump_user_backtrace_32(struct stack_frame_ia32 *head)
29864 struct stack_frame_ia32 *fp;
29865 unsigned long bytes;
29866
29867 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
29868 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
29869 if (bytes != sizeof(bufhead))
29870 return NULL;
29871
29872 - fp = (struct stack_frame_ia32 *) compat_ptr(bufhead[0].next_frame);
29873 + fp = (struct stack_frame_ia32 __force_kernel *) compat_ptr(bufhead[0].next_frame);
29874
29875 oprofile_add_trace(bufhead[0].return_address);
29876
29877 @@ -92,7 +92,7 @@ static struct stack_frame *dump_user_backtrace(struct stack_frame *head)
29878 struct stack_frame bufhead[2];
29879 unsigned long bytes;
29880
29881 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
29882 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
29883 if (bytes != sizeof(bufhead))
29884 return NULL;
29885
29886 @@ -111,7 +111,7 @@ x86_backtrace(struct pt_regs * const regs, unsigned int depth)
29887 {
29888 struct stack_frame *head = (struct stack_frame *)frame_pointer(regs);
29889
29890 - if (!user_mode_vm(regs)) {
29891 + if (!user_mode(regs)) {
29892 unsigned long stack = kernel_stack_pointer(regs);
29893 if (depth)
29894 dump_trace(NULL, regs, (unsigned long *)stack, 0,
29895 diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
29896 index 48768df..ba9143c 100644
29897 --- a/arch/x86/oprofile/nmi_int.c
29898 +++ b/arch/x86/oprofile/nmi_int.c
29899 @@ -23,6 +23,7 @@
29900 #include <asm/nmi.h>
29901 #include <asm/msr.h>
29902 #include <asm/apic.h>
29903 +#include <asm/pgtable.h>
29904
29905 #include "op_counter.h"
29906 #include "op_x86_model.h"
29907 @@ -774,8 +775,11 @@ int __init op_nmi_init(struct oprofile_operations *ops)
29908 if (ret)
29909 return ret;
29910
29911 - if (!model->num_virt_counters)
29912 - model->num_virt_counters = model->num_counters;
29913 + if (!model->num_virt_counters) {
29914 + pax_open_kernel();
29915 + *(unsigned int *)&model->num_virt_counters = model->num_counters;
29916 + pax_close_kernel();
29917 + }
29918
29919 mux_init(ops);
29920
29921 diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c
29922 index b2b9443..be58856 100644
29923 --- a/arch/x86/oprofile/op_model_amd.c
29924 +++ b/arch/x86/oprofile/op_model_amd.c
29925 @@ -519,9 +519,11 @@ static int op_amd_init(struct oprofile_operations *ops)
29926 num_counters = AMD64_NUM_COUNTERS;
29927 }
29928
29929 - op_amd_spec.num_counters = num_counters;
29930 - op_amd_spec.num_controls = num_counters;
29931 - op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
29932 + pax_open_kernel();
29933 + *(unsigned int *)&op_amd_spec.num_counters = num_counters;
29934 + *(unsigned int *)&op_amd_spec.num_controls = num_counters;
29935 + *(unsigned int *)&op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
29936 + pax_close_kernel();
29937
29938 return 0;
29939 }
29940 diff --git a/arch/x86/oprofile/op_model_ppro.c b/arch/x86/oprofile/op_model_ppro.c
29941 index d90528e..0127e2b 100644
29942 --- a/arch/x86/oprofile/op_model_ppro.c
29943 +++ b/arch/x86/oprofile/op_model_ppro.c
29944 @@ -19,6 +19,7 @@
29945 #include <asm/msr.h>
29946 #include <asm/apic.h>
29947 #include <asm/nmi.h>
29948 +#include <asm/pgtable.h>
29949
29950 #include "op_x86_model.h"
29951 #include "op_counter.h"
29952 @@ -221,8 +222,10 @@ static void arch_perfmon_setup_counters(void)
29953
29954 num_counters = min((int)eax.split.num_counters, OP_MAX_COUNTER);
29955
29956 - op_arch_perfmon_spec.num_counters = num_counters;
29957 - op_arch_perfmon_spec.num_controls = num_counters;
29958 + pax_open_kernel();
29959 + *(unsigned int *)&op_arch_perfmon_spec.num_counters = num_counters;
29960 + *(unsigned int *)&op_arch_perfmon_spec.num_controls = num_counters;
29961 + pax_close_kernel();
29962 }
29963
29964 static int arch_perfmon_init(struct oprofile_operations *ignore)
29965 diff --git a/arch/x86/oprofile/op_x86_model.h b/arch/x86/oprofile/op_x86_model.h
29966 index 71e8a67..6a313bb 100644
29967 --- a/arch/x86/oprofile/op_x86_model.h
29968 +++ b/arch/x86/oprofile/op_x86_model.h
29969 @@ -52,7 +52,7 @@ struct op_x86_model_spec {
29970 void (*switch_ctrl)(struct op_x86_model_spec const *model,
29971 struct op_msrs const * const msrs);
29972 #endif
29973 -};
29974 +} __do_const;
29975
29976 struct op_counter_config;
29977
29978 diff --git a/arch/x86/pci/amd_bus.c b/arch/x86/pci/amd_bus.c
29979 index e9e6ed5..e47ae67 100644
29980 --- a/arch/x86/pci/amd_bus.c
29981 +++ b/arch/x86/pci/amd_bus.c
29982 @@ -337,7 +337,7 @@ static int __cpuinit amd_cpu_notify(struct notifier_block *self,
29983 return NOTIFY_OK;
29984 }
29985
29986 -static struct notifier_block __cpuinitdata amd_cpu_notifier = {
29987 +static struct notifier_block amd_cpu_notifier = {
29988 .notifier_call = amd_cpu_notify,
29989 };
29990
29991 diff --git a/arch/x86/pci/irq.c b/arch/x86/pci/irq.c
29992 index 372e9b8..e775a6c 100644
29993 --- a/arch/x86/pci/irq.c
29994 +++ b/arch/x86/pci/irq.c
29995 @@ -50,7 +50,7 @@ struct irq_router {
29996 struct irq_router_handler {
29997 u16 vendor;
29998 int (*probe)(struct irq_router *r, struct pci_dev *router, u16 device);
29999 -};
30000 +} __do_const;
30001
30002 int (*pcibios_enable_irq)(struct pci_dev *dev) = pirq_enable_irq;
30003 void (*pcibios_disable_irq)(struct pci_dev *dev) = NULL;
30004 @@ -794,7 +794,7 @@ static __init int pico_router_probe(struct irq_router *r, struct pci_dev *router
30005 return 0;
30006 }
30007
30008 -static __initdata struct irq_router_handler pirq_routers[] = {
30009 +static __initconst const struct irq_router_handler pirq_routers[] = {
30010 { PCI_VENDOR_ID_INTEL, intel_router_probe },
30011 { PCI_VENDOR_ID_AL, ali_router_probe },
30012 { PCI_VENDOR_ID_ITE, ite_router_probe },
30013 @@ -821,7 +821,7 @@ static struct pci_dev *pirq_router_dev;
30014 static void __init pirq_find_router(struct irq_router *r)
30015 {
30016 struct irq_routing_table *rt = pirq_table;
30017 - struct irq_router_handler *h;
30018 + const struct irq_router_handler *h;
30019
30020 #ifdef CONFIG_PCI_BIOS
30021 if (!rt->signature) {
30022 @@ -1094,7 +1094,7 @@ static int __init fix_acer_tm360_irqrouting(const struct dmi_system_id *d)
30023 return 0;
30024 }
30025
30026 -static struct dmi_system_id __initdata pciirq_dmi_table[] = {
30027 +static const struct dmi_system_id __initconst pciirq_dmi_table[] = {
30028 {
30029 .callback = fix_broken_hp_bios_irq9,
30030 .ident = "HP Pavilion N5400 Series Laptop",
30031 diff --git a/arch/x86/pci/mrst.c b/arch/x86/pci/mrst.c
30032 index 6eb18c4..20d83de 100644
30033 --- a/arch/x86/pci/mrst.c
30034 +++ b/arch/x86/pci/mrst.c
30035 @@ -238,7 +238,9 @@ int __init pci_mrst_init(void)
30036 printk(KERN_INFO "Intel MID platform detected, using MID PCI ops\n");
30037 pci_mmcfg_late_init();
30038 pcibios_enable_irq = mrst_pci_irq_enable;
30039 - pci_root_ops = pci_mrst_ops;
30040 + pax_open_kernel();
30041 + memcpy((void *)&pci_root_ops, &pci_mrst_ops, sizeof(pci_mrst_ops));
30042 + pax_close_kernel();
30043 pci_soc_mode = 1;
30044 /* Continue with standard init */
30045 return 1;
30046 diff --git a/arch/x86/pci/pcbios.c b/arch/x86/pci/pcbios.c
30047 index c77b24a..c979855 100644
30048 --- a/arch/x86/pci/pcbios.c
30049 +++ b/arch/x86/pci/pcbios.c
30050 @@ -79,7 +79,7 @@ union bios32 {
30051 static struct {
30052 unsigned long address;
30053 unsigned short segment;
30054 -} bios32_indirect = { 0, __KERNEL_CS };
30055 +} bios32_indirect __read_only = { 0, __PCIBIOS_CS };
30056
30057 /*
30058 * Returns the entry point for the given service, NULL on error
30059 @@ -92,37 +92,80 @@ static unsigned long bios32_service(unsigned long service)
30060 unsigned long length; /* %ecx */
30061 unsigned long entry; /* %edx */
30062 unsigned long flags;
30063 + struct desc_struct d, *gdt;
30064
30065 local_irq_save(flags);
30066 - __asm__("lcall *(%%edi); cld"
30067 +
30068 + gdt = get_cpu_gdt_table(smp_processor_id());
30069 +
30070 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x9B, 0xC);
30071 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
30072 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x93, 0xC);
30073 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
30074 +
30075 + __asm__("movw %w7, %%ds; lcall *(%%edi); push %%ss; pop %%ds; cld"
30076 : "=a" (return_code),
30077 "=b" (address),
30078 "=c" (length),
30079 "=d" (entry)
30080 : "0" (service),
30081 "1" (0),
30082 - "D" (&bios32_indirect));
30083 + "D" (&bios32_indirect),
30084 + "r"(__PCIBIOS_DS)
30085 + : "memory");
30086 +
30087 + pax_open_kernel();
30088 + gdt[GDT_ENTRY_PCIBIOS_CS].a = 0;
30089 + gdt[GDT_ENTRY_PCIBIOS_CS].b = 0;
30090 + gdt[GDT_ENTRY_PCIBIOS_DS].a = 0;
30091 + gdt[GDT_ENTRY_PCIBIOS_DS].b = 0;
30092 + pax_close_kernel();
30093 +
30094 local_irq_restore(flags);
30095
30096 switch (return_code) {
30097 - case 0:
30098 - return address + entry;
30099 - case 0x80: /* Not present */
30100 - printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
30101 - return 0;
30102 - default: /* Shouldn't happen */
30103 - printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
30104 - service, return_code);
30105 + case 0: {
30106 + int cpu;
30107 + unsigned char flags;
30108 +
30109 + printk(KERN_INFO "bios32_service: base:%08lx length:%08lx entry:%08lx\n", address, length, entry);
30110 + if (address >= 0xFFFF0 || length > 0x100000 - address || length <= entry) {
30111 + printk(KERN_WARNING "bios32_service: not valid\n");
30112 return 0;
30113 + }
30114 + address = address + PAGE_OFFSET;
30115 + length += 16UL; /* some BIOSs underreport this... */
30116 + flags = 4;
30117 + if (length >= 64*1024*1024) {
30118 + length >>= PAGE_SHIFT;
30119 + flags |= 8;
30120 + }
30121 +
30122 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
30123 + gdt = get_cpu_gdt_table(cpu);
30124 + pack_descriptor(&d, address, length, 0x9b, flags);
30125 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
30126 + pack_descriptor(&d, address, length, 0x93, flags);
30127 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
30128 + }
30129 + return entry;
30130 + }
30131 + case 0x80: /* Not present */
30132 + printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
30133 + return 0;
30134 + default: /* Shouldn't happen */
30135 + printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
30136 + service, return_code);
30137 + return 0;
30138 }
30139 }
30140
30141 static struct {
30142 unsigned long address;
30143 unsigned short segment;
30144 -} pci_indirect = { 0, __KERNEL_CS };
30145 +} pci_indirect __read_only = { 0, __PCIBIOS_CS };
30146
30147 -static int pci_bios_present;
30148 +static int pci_bios_present __read_only;
30149
30150 static int check_pcibios(void)
30151 {
30152 @@ -131,11 +174,13 @@ static int check_pcibios(void)
30153 unsigned long flags, pcibios_entry;
30154
30155 if ((pcibios_entry = bios32_service(PCI_SERVICE))) {
30156 - pci_indirect.address = pcibios_entry + PAGE_OFFSET;
30157 + pci_indirect.address = pcibios_entry;
30158
30159 local_irq_save(flags);
30160 - __asm__(
30161 - "lcall *(%%edi); cld\n\t"
30162 + __asm__("movw %w6, %%ds\n\t"
30163 + "lcall *%%ss:(%%edi); cld\n\t"
30164 + "push %%ss\n\t"
30165 + "pop %%ds\n\t"
30166 "jc 1f\n\t"
30167 "xor %%ah, %%ah\n"
30168 "1:"
30169 @@ -144,7 +189,8 @@ static int check_pcibios(void)
30170 "=b" (ebx),
30171 "=c" (ecx)
30172 : "1" (PCIBIOS_PCI_BIOS_PRESENT),
30173 - "D" (&pci_indirect)
30174 + "D" (&pci_indirect),
30175 + "r" (__PCIBIOS_DS)
30176 : "memory");
30177 local_irq_restore(flags);
30178
30179 @@ -189,7 +235,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30180
30181 switch (len) {
30182 case 1:
30183 - __asm__("lcall *(%%esi); cld\n\t"
30184 + __asm__("movw %w6, %%ds\n\t"
30185 + "lcall *%%ss:(%%esi); cld\n\t"
30186 + "push %%ss\n\t"
30187 + "pop %%ds\n\t"
30188 "jc 1f\n\t"
30189 "xor %%ah, %%ah\n"
30190 "1:"
30191 @@ -198,7 +247,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30192 : "1" (PCIBIOS_READ_CONFIG_BYTE),
30193 "b" (bx),
30194 "D" ((long)reg),
30195 - "S" (&pci_indirect));
30196 + "S" (&pci_indirect),
30197 + "r" (__PCIBIOS_DS));
30198 /*
30199 * Zero-extend the result beyond 8 bits, do not trust the
30200 * BIOS having done it:
30201 @@ -206,7 +256,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30202 *value &= 0xff;
30203 break;
30204 case 2:
30205 - __asm__("lcall *(%%esi); cld\n\t"
30206 + __asm__("movw %w6, %%ds\n\t"
30207 + "lcall *%%ss:(%%esi); cld\n\t"
30208 + "push %%ss\n\t"
30209 + "pop %%ds\n\t"
30210 "jc 1f\n\t"
30211 "xor %%ah, %%ah\n"
30212 "1:"
30213 @@ -215,7 +268,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30214 : "1" (PCIBIOS_READ_CONFIG_WORD),
30215 "b" (bx),
30216 "D" ((long)reg),
30217 - "S" (&pci_indirect));
30218 + "S" (&pci_indirect),
30219 + "r" (__PCIBIOS_DS));
30220 /*
30221 * Zero-extend the result beyond 16 bits, do not trust the
30222 * BIOS having done it:
30223 @@ -223,7 +277,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30224 *value &= 0xffff;
30225 break;
30226 case 4:
30227 - __asm__("lcall *(%%esi); cld\n\t"
30228 + __asm__("movw %w6, %%ds\n\t"
30229 + "lcall *%%ss:(%%esi); cld\n\t"
30230 + "push %%ss\n\t"
30231 + "pop %%ds\n\t"
30232 "jc 1f\n\t"
30233 "xor %%ah, %%ah\n"
30234 "1:"
30235 @@ -232,7 +289,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30236 : "1" (PCIBIOS_READ_CONFIG_DWORD),
30237 "b" (bx),
30238 "D" ((long)reg),
30239 - "S" (&pci_indirect));
30240 + "S" (&pci_indirect),
30241 + "r" (__PCIBIOS_DS));
30242 break;
30243 }
30244
30245 @@ -256,7 +314,10 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30246
30247 switch (len) {
30248 case 1:
30249 - __asm__("lcall *(%%esi); cld\n\t"
30250 + __asm__("movw %w6, %%ds\n\t"
30251 + "lcall *%%ss:(%%esi); cld\n\t"
30252 + "push %%ss\n\t"
30253 + "pop %%ds\n\t"
30254 "jc 1f\n\t"
30255 "xor %%ah, %%ah\n"
30256 "1:"
30257 @@ -265,10 +326,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30258 "c" (value),
30259 "b" (bx),
30260 "D" ((long)reg),
30261 - "S" (&pci_indirect));
30262 + "S" (&pci_indirect),
30263 + "r" (__PCIBIOS_DS));
30264 break;
30265 case 2:
30266 - __asm__("lcall *(%%esi); cld\n\t"
30267 + __asm__("movw %w6, %%ds\n\t"
30268 + "lcall *%%ss:(%%esi); cld\n\t"
30269 + "push %%ss\n\t"
30270 + "pop %%ds\n\t"
30271 "jc 1f\n\t"
30272 "xor %%ah, %%ah\n"
30273 "1:"
30274 @@ -277,10 +342,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30275 "c" (value),
30276 "b" (bx),
30277 "D" ((long)reg),
30278 - "S" (&pci_indirect));
30279 + "S" (&pci_indirect),
30280 + "r" (__PCIBIOS_DS));
30281 break;
30282 case 4:
30283 - __asm__("lcall *(%%esi); cld\n\t"
30284 + __asm__("movw %w6, %%ds\n\t"
30285 + "lcall *%%ss:(%%esi); cld\n\t"
30286 + "push %%ss\n\t"
30287 + "pop %%ds\n\t"
30288 "jc 1f\n\t"
30289 "xor %%ah, %%ah\n"
30290 "1:"
30291 @@ -289,7 +358,8 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30292 "c" (value),
30293 "b" (bx),
30294 "D" ((long)reg),
30295 - "S" (&pci_indirect));
30296 + "S" (&pci_indirect),
30297 + "r" (__PCIBIOS_DS));
30298 break;
30299 }
30300
30301 @@ -394,10 +464,13 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
30302
30303 DBG("PCI: Fetching IRQ routing table... ");
30304 __asm__("push %%es\n\t"
30305 + "movw %w8, %%ds\n\t"
30306 "push %%ds\n\t"
30307 "pop %%es\n\t"
30308 - "lcall *(%%esi); cld\n\t"
30309 + "lcall *%%ss:(%%esi); cld\n\t"
30310 "pop %%es\n\t"
30311 + "push %%ss\n\t"
30312 + "pop %%ds\n"
30313 "jc 1f\n\t"
30314 "xor %%ah, %%ah\n"
30315 "1:"
30316 @@ -408,7 +481,8 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
30317 "1" (0),
30318 "D" ((long) &opt),
30319 "S" (&pci_indirect),
30320 - "m" (opt)
30321 + "m" (opt),
30322 + "r" (__PCIBIOS_DS)
30323 : "memory");
30324 DBG("OK ret=%d, size=%d, map=%x\n", ret, opt.size, map);
30325 if (ret & 0xff00)
30326 @@ -432,7 +506,10 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
30327 {
30328 int ret;
30329
30330 - __asm__("lcall *(%%esi); cld\n\t"
30331 + __asm__("movw %w5, %%ds\n\t"
30332 + "lcall *%%ss:(%%esi); cld\n\t"
30333 + "push %%ss\n\t"
30334 + "pop %%ds\n"
30335 "jc 1f\n\t"
30336 "xor %%ah, %%ah\n"
30337 "1:"
30338 @@ -440,7 +517,8 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
30339 : "0" (PCIBIOS_SET_PCI_HW_INT),
30340 "b" ((dev->bus->number << 8) | dev->devfn),
30341 "c" ((irq << 8) | (pin + 10)),
30342 - "S" (&pci_indirect));
30343 + "S" (&pci_indirect),
30344 + "r" (__PCIBIOS_DS));
30345 return !(ret & 0xff00);
30346 }
30347 EXPORT_SYMBOL(pcibios_set_irq_routing);
30348 diff --git a/arch/x86/platform/efi/efi_32.c b/arch/x86/platform/efi/efi_32.c
30349 index 40e4469..1ab536e 100644
30350 --- a/arch/x86/platform/efi/efi_32.c
30351 +++ b/arch/x86/platform/efi/efi_32.c
30352 @@ -44,11 +44,22 @@ void efi_call_phys_prelog(void)
30353 {
30354 struct desc_ptr gdt_descr;
30355
30356 +#ifdef CONFIG_PAX_KERNEXEC
30357 + struct desc_struct d;
30358 +#endif
30359 +
30360 local_irq_save(efi_rt_eflags);
30361
30362 load_cr3(initial_page_table);
30363 __flush_tlb_all();
30364
30365 +#ifdef CONFIG_PAX_KERNEXEC
30366 + pack_descriptor(&d, 0, 0xFFFFF, 0x9B, 0xC);
30367 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
30368 + pack_descriptor(&d, 0, 0xFFFFF, 0x93, 0xC);
30369 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
30370 +#endif
30371 +
30372 gdt_descr.address = __pa(get_cpu_gdt_table(0));
30373 gdt_descr.size = GDT_SIZE - 1;
30374 load_gdt(&gdt_descr);
30375 @@ -58,6 +69,14 @@ void efi_call_phys_epilog(void)
30376 {
30377 struct desc_ptr gdt_descr;
30378
30379 +#ifdef CONFIG_PAX_KERNEXEC
30380 + struct desc_struct d;
30381 +
30382 + memset(&d, 0, sizeof d);
30383 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
30384 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
30385 +#endif
30386 +
30387 gdt_descr.address = (unsigned long)get_cpu_gdt_table(0);
30388 gdt_descr.size = GDT_SIZE - 1;
30389 load_gdt(&gdt_descr);
30390 diff --git a/arch/x86/platform/efi/efi_stub_32.S b/arch/x86/platform/efi/efi_stub_32.S
30391 index fbe66e6..eae5e38 100644
30392 --- a/arch/x86/platform/efi/efi_stub_32.S
30393 +++ b/arch/x86/platform/efi/efi_stub_32.S
30394 @@ -6,7 +6,9 @@
30395 */
30396
30397 #include <linux/linkage.h>
30398 +#include <linux/init.h>
30399 #include <asm/page_types.h>
30400 +#include <asm/segment.h>
30401
30402 /*
30403 * efi_call_phys(void *, ...) is a function with variable parameters.
30404 @@ -20,7 +22,7 @@
30405 * service functions will comply with gcc calling convention, too.
30406 */
30407
30408 -.text
30409 +__INIT
30410 ENTRY(efi_call_phys)
30411 /*
30412 * 0. The function can only be called in Linux kernel. So CS has been
30413 @@ -36,10 +38,24 @@ ENTRY(efi_call_phys)
30414 * The mapping of lower virtual memory has been created in prelog and
30415 * epilog.
30416 */
30417 - movl $1f, %edx
30418 - subl $__PAGE_OFFSET, %edx
30419 - jmp *%edx
30420 +#ifdef CONFIG_PAX_KERNEXEC
30421 + movl $(__KERNEXEC_EFI_DS), %edx
30422 + mov %edx, %ds
30423 + mov %edx, %es
30424 + mov %edx, %ss
30425 + addl $2f,(1f)
30426 + ljmp *(1f)
30427 +
30428 +__INITDATA
30429 +1: .long __LOAD_PHYSICAL_ADDR, __KERNEXEC_EFI_CS
30430 +.previous
30431 +
30432 +2:
30433 + subl $2b,(1b)
30434 +#else
30435 + jmp 1f-__PAGE_OFFSET
30436 1:
30437 +#endif
30438
30439 /*
30440 * 2. Now on the top of stack is the return
30441 @@ -47,14 +63,8 @@ ENTRY(efi_call_phys)
30442 * parameter 2, ..., param n. To make things easy, we save the return
30443 * address of efi_call_phys in a global variable.
30444 */
30445 - popl %edx
30446 - movl %edx, saved_return_addr
30447 - /* get the function pointer into ECX*/
30448 - popl %ecx
30449 - movl %ecx, efi_rt_function_ptr
30450 - movl $2f, %edx
30451 - subl $__PAGE_OFFSET, %edx
30452 - pushl %edx
30453 + popl (saved_return_addr)
30454 + popl (efi_rt_function_ptr)
30455
30456 /*
30457 * 3. Clear PG bit in %CR0.
30458 @@ -73,9 +83,8 @@ ENTRY(efi_call_phys)
30459 /*
30460 * 5. Call the physical function.
30461 */
30462 - jmp *%ecx
30463 + call *(efi_rt_function_ptr-__PAGE_OFFSET)
30464
30465 -2:
30466 /*
30467 * 6. After EFI runtime service returns, control will return to
30468 * following instruction. We'd better readjust stack pointer first.
30469 @@ -88,35 +97,36 @@ ENTRY(efi_call_phys)
30470 movl %cr0, %edx
30471 orl $0x80000000, %edx
30472 movl %edx, %cr0
30473 - jmp 1f
30474 -1:
30475 +
30476 /*
30477 * 8. Now restore the virtual mode from flat mode by
30478 * adding EIP with PAGE_OFFSET.
30479 */
30480 - movl $1f, %edx
30481 - jmp *%edx
30482 +#ifdef CONFIG_PAX_KERNEXEC
30483 + movl $(__KERNEL_DS), %edx
30484 + mov %edx, %ds
30485 + mov %edx, %es
30486 + mov %edx, %ss
30487 + ljmp $(__KERNEL_CS),$1f
30488 +#else
30489 + jmp 1f+__PAGE_OFFSET
30490 +#endif
30491 1:
30492
30493 /*
30494 * 9. Balance the stack. And because EAX contain the return value,
30495 * we'd better not clobber it.
30496 */
30497 - leal efi_rt_function_ptr, %edx
30498 - movl (%edx), %ecx
30499 - pushl %ecx
30500 + pushl (efi_rt_function_ptr)
30501
30502 /*
30503 - * 10. Push the saved return address onto the stack and return.
30504 + * 10. Return to the saved return address.
30505 */
30506 - leal saved_return_addr, %edx
30507 - movl (%edx), %ecx
30508 - pushl %ecx
30509 - ret
30510 + jmpl *(saved_return_addr)
30511 ENDPROC(efi_call_phys)
30512 .previous
30513
30514 -.data
30515 +__INITDATA
30516 saved_return_addr:
30517 .long 0
30518 efi_rt_function_ptr:
30519 diff --git a/arch/x86/platform/efi/efi_stub_64.S b/arch/x86/platform/efi/efi_stub_64.S
30520 index 4c07cca..2c8427d 100644
30521 --- a/arch/x86/platform/efi/efi_stub_64.S
30522 +++ b/arch/x86/platform/efi/efi_stub_64.S
30523 @@ -7,6 +7,7 @@
30524 */
30525
30526 #include <linux/linkage.h>
30527 +#include <asm/alternative-asm.h>
30528
30529 #define SAVE_XMM \
30530 mov %rsp, %rax; \
30531 @@ -40,6 +41,7 @@ ENTRY(efi_call0)
30532 call *%rdi
30533 addq $32, %rsp
30534 RESTORE_XMM
30535 + pax_force_retaddr 0, 1
30536 ret
30537 ENDPROC(efi_call0)
30538
30539 @@ -50,6 +52,7 @@ ENTRY(efi_call1)
30540 call *%rdi
30541 addq $32, %rsp
30542 RESTORE_XMM
30543 + pax_force_retaddr 0, 1
30544 ret
30545 ENDPROC(efi_call1)
30546
30547 @@ -60,6 +63,7 @@ ENTRY(efi_call2)
30548 call *%rdi
30549 addq $32, %rsp
30550 RESTORE_XMM
30551 + pax_force_retaddr 0, 1
30552 ret
30553 ENDPROC(efi_call2)
30554
30555 @@ -71,6 +75,7 @@ ENTRY(efi_call3)
30556 call *%rdi
30557 addq $32, %rsp
30558 RESTORE_XMM
30559 + pax_force_retaddr 0, 1
30560 ret
30561 ENDPROC(efi_call3)
30562
30563 @@ -83,6 +88,7 @@ ENTRY(efi_call4)
30564 call *%rdi
30565 addq $32, %rsp
30566 RESTORE_XMM
30567 + pax_force_retaddr 0, 1
30568 ret
30569 ENDPROC(efi_call4)
30570
30571 @@ -96,6 +102,7 @@ ENTRY(efi_call5)
30572 call *%rdi
30573 addq $48, %rsp
30574 RESTORE_XMM
30575 + pax_force_retaddr 0, 1
30576 ret
30577 ENDPROC(efi_call5)
30578
30579 @@ -112,5 +119,6 @@ ENTRY(efi_call6)
30580 call *%rdi
30581 addq $48, %rsp
30582 RESTORE_XMM
30583 + pax_force_retaddr 0, 1
30584 ret
30585 ENDPROC(efi_call6)
30586 diff --git a/arch/x86/platform/mrst/mrst.c b/arch/x86/platform/mrst/mrst.c
30587 index e31bcd8..f12dc46 100644
30588 --- a/arch/x86/platform/mrst/mrst.c
30589 +++ b/arch/x86/platform/mrst/mrst.c
30590 @@ -78,13 +78,15 @@ struct sfi_rtc_table_entry sfi_mrtc_array[SFI_MRTC_MAX];
30591 EXPORT_SYMBOL_GPL(sfi_mrtc_array);
30592 int sfi_mrtc_num;
30593
30594 -static void mrst_power_off(void)
30595 +static __noreturn void mrst_power_off(void)
30596 {
30597 + BUG();
30598 }
30599
30600 -static void mrst_reboot(void)
30601 +static __noreturn void mrst_reboot(void)
30602 {
30603 intel_scu_ipc_simple_command(IPCMSG_COLD_BOOT, 0);
30604 + BUG();
30605 }
30606
30607 /* parse all the mtimer info to a static mtimer array */
30608 diff --git a/arch/x86/platform/olpc/olpc_dt.c b/arch/x86/platform/olpc/olpc_dt.c
30609 index d6ee929..3637cb5 100644
30610 --- a/arch/x86/platform/olpc/olpc_dt.c
30611 +++ b/arch/x86/platform/olpc/olpc_dt.c
30612 @@ -156,7 +156,7 @@ void * __init prom_early_alloc(unsigned long size)
30613 return res;
30614 }
30615
30616 -static struct of_pdt_ops prom_olpc_ops __initdata = {
30617 +static struct of_pdt_ops prom_olpc_ops __initconst = {
30618 .nextprop = olpc_dt_nextprop,
30619 .getproplen = olpc_dt_getproplen,
30620 .getproperty = olpc_dt_getproperty,
30621 diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c
30622 index 3c68768..07e82b8 100644
30623 --- a/arch/x86/power/cpu.c
30624 +++ b/arch/x86/power/cpu.c
30625 @@ -134,7 +134,7 @@ static void do_fpu_end(void)
30626 static void fix_processor_context(void)
30627 {
30628 int cpu = smp_processor_id();
30629 - struct tss_struct *t = &per_cpu(init_tss, cpu);
30630 + struct tss_struct *t = init_tss + cpu;
30631
30632 set_tss_desc(cpu, t); /*
30633 * This just modifies memory; should not be
30634 @@ -144,8 +144,6 @@ static void fix_processor_context(void)
30635 */
30636
30637 #ifdef CONFIG_X86_64
30638 - get_cpu_gdt_table(cpu)[GDT_ENTRY_TSS].type = 9;
30639 -
30640 syscall_init(); /* This sets MSR_*STAR and related */
30641 #endif
30642 load_TR_desc(); /* This does ltr */
30643 diff --git a/arch/x86/realmode/init.c b/arch/x86/realmode/init.c
30644 index a44f457..9140171 100644
30645 --- a/arch/x86/realmode/init.c
30646 +++ b/arch/x86/realmode/init.c
30647 @@ -70,7 +70,13 @@ void __init setup_real_mode(void)
30648 __va(real_mode_header->trampoline_header);
30649
30650 #ifdef CONFIG_X86_32
30651 - trampoline_header->start = __pa_symbol(startup_32_smp);
30652 + trampoline_header->start = __pa_symbol(ktla_ktva(startup_32_smp));
30653 +
30654 +#ifdef CONFIG_PAX_KERNEXEC
30655 + trampoline_header->start -= LOAD_PHYSICAL_ADDR;
30656 +#endif
30657 +
30658 + trampoline_header->boot_cs = __BOOT_CS;
30659 trampoline_header->gdt_limit = __BOOT_DS + 7;
30660 trampoline_header->gdt_base = __pa_symbol(boot_gdt);
30661 #else
30662 @@ -86,7 +92,7 @@ void __init setup_real_mode(void)
30663 *trampoline_cr4_features = read_cr4();
30664
30665 trampoline_pgd = (u64 *) __va(real_mode_header->trampoline_pgd);
30666 - trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd;
30667 + trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd & ~_PAGE_NX;
30668 trampoline_pgd[511] = init_level4_pgt[511].pgd;
30669 #endif
30670 }
30671 diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Makefile
30672 index 8869287..d577672 100644
30673 --- a/arch/x86/realmode/rm/Makefile
30674 +++ b/arch/x86/realmode/rm/Makefile
30675 @@ -78,5 +78,8 @@ KBUILD_CFLAGS := $(LINUXINCLUDE) -m32 -g -Os -D_SETUP -D__KERNEL__ -D_WAKEUP \
30676 $(call cc-option, -fno-unit-at-a-time)) \
30677 $(call cc-option, -fno-stack-protector) \
30678 $(call cc-option, -mpreferred-stack-boundary=2)
30679 +ifdef CONSTIFY_PLUGIN
30680 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
30681 +endif
30682 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
30683 GCOV_PROFILE := n
30684 diff --git a/arch/x86/realmode/rm/header.S b/arch/x86/realmode/rm/header.S
30685 index a28221d..93c40f1 100644
30686 --- a/arch/x86/realmode/rm/header.S
30687 +++ b/arch/x86/realmode/rm/header.S
30688 @@ -30,7 +30,9 @@ GLOBAL(real_mode_header)
30689 #endif
30690 /* APM/BIOS reboot */
30691 .long pa_machine_real_restart_asm
30692 -#ifdef CONFIG_X86_64
30693 +#ifdef CONFIG_X86_32
30694 + .long __KERNEL_CS
30695 +#else
30696 .long __KERNEL32_CS
30697 #endif
30698 END(real_mode_header)
30699 diff --git a/arch/x86/realmode/rm/trampoline_32.S b/arch/x86/realmode/rm/trampoline_32.S
30700 index c1b2791..f9e31c7 100644
30701 --- a/arch/x86/realmode/rm/trampoline_32.S
30702 +++ b/arch/x86/realmode/rm/trampoline_32.S
30703 @@ -25,6 +25,12 @@
30704 #include <asm/page_types.h>
30705 #include "realmode.h"
30706
30707 +#ifdef CONFIG_PAX_KERNEXEC
30708 +#define ta(X) (X)
30709 +#else
30710 +#define ta(X) (pa_ ## X)
30711 +#endif
30712 +
30713 .text
30714 .code16
30715
30716 @@ -39,8 +45,6 @@ ENTRY(trampoline_start)
30717
30718 cli # We should be safe anyway
30719
30720 - movl tr_start, %eax # where we need to go
30721 -
30722 movl $0xA5A5A5A5, trampoline_status
30723 # write marker for master knows we're running
30724
30725 @@ -56,7 +60,7 @@ ENTRY(trampoline_start)
30726 movw $1, %dx # protected mode (PE) bit
30727 lmsw %dx # into protected mode
30728
30729 - ljmpl $__BOOT_CS, $pa_startup_32
30730 + ljmpl *(trampoline_header)
30731
30732 .section ".text32","ax"
30733 .code32
30734 @@ -67,7 +71,7 @@ ENTRY(startup_32) # note: also used from wakeup_asm.S
30735 .balign 8
30736 GLOBAL(trampoline_header)
30737 tr_start: .space 4
30738 - tr_gdt_pad: .space 2
30739 + tr_boot_cs: .space 2
30740 tr_gdt: .space 6
30741 END(trampoline_header)
30742
30743 diff --git a/arch/x86/realmode/rm/trampoline_64.S b/arch/x86/realmode/rm/trampoline_64.S
30744 index bb360dc..3e5945f 100644
30745 --- a/arch/x86/realmode/rm/trampoline_64.S
30746 +++ b/arch/x86/realmode/rm/trampoline_64.S
30747 @@ -107,7 +107,7 @@ ENTRY(startup_32)
30748 wrmsr
30749
30750 # Enable paging and in turn activate Long Mode
30751 - movl $(X86_CR0_PG | X86_CR0_WP | X86_CR0_PE), %eax
30752 + movl $(X86_CR0_PG | X86_CR0_PE), %eax
30753 movl %eax, %cr0
30754
30755 /*
30756 diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
30757 index 79d67bd..c7e1b90 100644
30758 --- a/arch/x86/tools/relocs.c
30759 +++ b/arch/x86/tools/relocs.c
30760 @@ -12,10 +12,13 @@
30761 #include <regex.h>
30762 #include <tools/le_byteshift.h>
30763
30764 +#include "../../../include/generated/autoconf.h"
30765 +
30766 static void die(char *fmt, ...);
30767
30768 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
30769 static Elf32_Ehdr ehdr;
30770 +static Elf32_Phdr *phdr;
30771 static unsigned long reloc_count, reloc_idx;
30772 static unsigned long *relocs;
30773 static unsigned long reloc16_count, reloc16_idx;
30774 @@ -330,9 +333,39 @@ static void read_ehdr(FILE *fp)
30775 }
30776 }
30777
30778 +static void read_phdrs(FILE *fp)
30779 +{
30780 + unsigned int i;
30781 +
30782 + phdr = calloc(ehdr.e_phnum, sizeof(Elf32_Phdr));
30783 + if (!phdr) {
30784 + die("Unable to allocate %d program headers\n",
30785 + ehdr.e_phnum);
30786 + }
30787 + if (fseek(fp, ehdr.e_phoff, SEEK_SET) < 0) {
30788 + die("Seek to %d failed: %s\n",
30789 + ehdr.e_phoff, strerror(errno));
30790 + }
30791 + if (fread(phdr, sizeof(*phdr), ehdr.e_phnum, fp) != ehdr.e_phnum) {
30792 + die("Cannot read ELF program headers: %s\n",
30793 + strerror(errno));
30794 + }
30795 + for(i = 0; i < ehdr.e_phnum; i++) {
30796 + phdr[i].p_type = elf32_to_cpu(phdr[i].p_type);
30797 + phdr[i].p_offset = elf32_to_cpu(phdr[i].p_offset);
30798 + phdr[i].p_vaddr = elf32_to_cpu(phdr[i].p_vaddr);
30799 + phdr[i].p_paddr = elf32_to_cpu(phdr[i].p_paddr);
30800 + phdr[i].p_filesz = elf32_to_cpu(phdr[i].p_filesz);
30801 + phdr[i].p_memsz = elf32_to_cpu(phdr[i].p_memsz);
30802 + phdr[i].p_flags = elf32_to_cpu(phdr[i].p_flags);
30803 + phdr[i].p_align = elf32_to_cpu(phdr[i].p_align);
30804 + }
30805 +
30806 +}
30807 +
30808 static void read_shdrs(FILE *fp)
30809 {
30810 - int i;
30811 + unsigned int i;
30812 Elf32_Shdr shdr;
30813
30814 secs = calloc(ehdr.e_shnum, sizeof(struct section));
30815 @@ -367,7 +400,7 @@ static void read_shdrs(FILE *fp)
30816
30817 static void read_strtabs(FILE *fp)
30818 {
30819 - int i;
30820 + unsigned int i;
30821 for (i = 0; i < ehdr.e_shnum; i++) {
30822 struct section *sec = &secs[i];
30823 if (sec->shdr.sh_type != SHT_STRTAB) {
30824 @@ -392,7 +425,7 @@ static void read_strtabs(FILE *fp)
30825
30826 static void read_symtabs(FILE *fp)
30827 {
30828 - int i,j;
30829 + unsigned int i,j;
30830 for (i = 0; i < ehdr.e_shnum; i++) {
30831 struct section *sec = &secs[i];
30832 if (sec->shdr.sh_type != SHT_SYMTAB) {
30833 @@ -423,9 +456,11 @@ static void read_symtabs(FILE *fp)
30834 }
30835
30836
30837 -static void read_relocs(FILE *fp)
30838 +static void read_relocs(FILE *fp, int use_real_mode)
30839 {
30840 - int i,j;
30841 + unsigned int i,j;
30842 + uint32_t base;
30843 +
30844 for (i = 0; i < ehdr.e_shnum; i++) {
30845 struct section *sec = &secs[i];
30846 if (sec->shdr.sh_type != SHT_REL) {
30847 @@ -445,9 +480,22 @@ static void read_relocs(FILE *fp)
30848 die("Cannot read symbol table: %s\n",
30849 strerror(errno));
30850 }
30851 + base = 0;
30852 +
30853 +#ifdef CONFIG_X86_32
30854 + for (j = 0; !use_real_mode && j < ehdr.e_phnum; j++) {
30855 + if (phdr[j].p_type != PT_LOAD )
30856 + continue;
30857 + 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)
30858 + continue;
30859 + base = CONFIG_PAGE_OFFSET + phdr[j].p_paddr - phdr[j].p_vaddr;
30860 + break;
30861 + }
30862 +#endif
30863 +
30864 for (j = 0; j < sec->shdr.sh_size/sizeof(Elf32_Rel); j++) {
30865 Elf32_Rel *rel = &sec->reltab[j];
30866 - rel->r_offset = elf32_to_cpu(rel->r_offset);
30867 + rel->r_offset = elf32_to_cpu(rel->r_offset) + base;
30868 rel->r_info = elf32_to_cpu(rel->r_info);
30869 }
30870 }
30871 @@ -456,13 +504,13 @@ static void read_relocs(FILE *fp)
30872
30873 static void print_absolute_symbols(void)
30874 {
30875 - int i;
30876 + unsigned int i;
30877 printf("Absolute symbols\n");
30878 printf(" Num: Value Size Type Bind Visibility Name\n");
30879 for (i = 0; i < ehdr.e_shnum; i++) {
30880 struct section *sec = &secs[i];
30881 char *sym_strtab;
30882 - int j;
30883 + unsigned int j;
30884
30885 if (sec->shdr.sh_type != SHT_SYMTAB) {
30886 continue;
30887 @@ -489,14 +537,14 @@ static void print_absolute_symbols(void)
30888
30889 static void print_absolute_relocs(void)
30890 {
30891 - int i, printed = 0;
30892 + unsigned int i, printed = 0;
30893
30894 for (i = 0; i < ehdr.e_shnum; i++) {
30895 struct section *sec = &secs[i];
30896 struct section *sec_applies, *sec_symtab;
30897 char *sym_strtab;
30898 Elf32_Sym *sh_symtab;
30899 - int j;
30900 + unsigned int j;
30901 if (sec->shdr.sh_type != SHT_REL) {
30902 continue;
30903 }
30904 @@ -558,13 +606,13 @@ static void print_absolute_relocs(void)
30905 static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym),
30906 int use_real_mode)
30907 {
30908 - int i;
30909 + unsigned int i;
30910 /* Walk through the relocations */
30911 for (i = 0; i < ehdr.e_shnum; i++) {
30912 char *sym_strtab;
30913 Elf32_Sym *sh_symtab;
30914 struct section *sec_applies, *sec_symtab;
30915 - int j;
30916 + unsigned int j;
30917 struct section *sec = &secs[i];
30918
30919 if (sec->shdr.sh_type != SHT_REL) {
30920 @@ -588,6 +636,24 @@ static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym),
30921 sym = &sh_symtab[ELF32_R_SYM(rel->r_info)];
30922 r_type = ELF32_R_TYPE(rel->r_info);
30923
30924 + if (!use_real_mode) {
30925 + /* Don't relocate actual per-cpu variables, they are absolute indices, not addresses */
30926 + if (!strcmp(sec_name(sym->st_shndx), ".data..percpu") && strcmp(sym_name(sym_strtab, sym), "__per_cpu_load"))
30927 + continue;
30928 +
30929 +#if defined(CONFIG_PAX_KERNEXEC) && defined(CONFIG_X86_32)
30930 + /* Don't relocate actual code, they are relocated implicitly by the base address of KERNEL_CS */
30931 + if (!strcmp(sec_name(sym->st_shndx), ".text.end") && !strcmp(sym_name(sym_strtab, sym), "_etext"))
30932 + continue;
30933 + if (!strcmp(sec_name(sym->st_shndx), ".init.text"))
30934 + continue;
30935 + if (!strcmp(sec_name(sym->st_shndx), ".exit.text"))
30936 + continue;
30937 + if (!strcmp(sec_name(sym->st_shndx), ".text") && strcmp(sym_name(sym_strtab, sym), "__LOAD_PHYSICAL_ADDR"))
30938 + continue;
30939 +#endif
30940 + }
30941 +
30942 shn_abs = sym->st_shndx == SHN_ABS;
30943
30944 switch (r_type) {
30945 @@ -681,7 +747,7 @@ static int write32(unsigned int v, FILE *f)
30946
30947 static void emit_relocs(int as_text, int use_real_mode)
30948 {
30949 - int i;
30950 + unsigned int i;
30951 /* Count how many relocations I have and allocate space for them. */
30952 reloc_count = 0;
30953 walk_relocs(count_reloc, use_real_mode);
30954 @@ -808,10 +874,11 @@ int main(int argc, char **argv)
30955 fname, strerror(errno));
30956 }
30957 read_ehdr(fp);
30958 + read_phdrs(fp);
30959 read_shdrs(fp);
30960 read_strtabs(fp);
30961 read_symtabs(fp);
30962 - read_relocs(fp);
30963 + read_relocs(fp, use_real_mode);
30964 if (show_absolute_syms) {
30965 print_absolute_symbols();
30966 goto out;
30967 diff --git a/arch/x86/vdso/Makefile b/arch/x86/vdso/Makefile
30968 index fd14be1..e3c79c0 100644
30969 --- a/arch/x86/vdso/Makefile
30970 +++ b/arch/x86/vdso/Makefile
30971 @@ -181,7 +181,7 @@ quiet_cmd_vdso = VDSO $@
30972 -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
30973 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
30974
30975 -VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
30976 +VDSO_LDFLAGS = -fPIC -shared -Wl,--no-undefined $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
30977 GCOV_PROFILE := n
30978
30979 #
30980 diff --git a/arch/x86/vdso/vdso32-setup.c b/arch/x86/vdso/vdso32-setup.c
30981 index 0faad64..39ef157 100644
30982 --- a/arch/x86/vdso/vdso32-setup.c
30983 +++ b/arch/x86/vdso/vdso32-setup.c
30984 @@ -25,6 +25,7 @@
30985 #include <asm/tlbflush.h>
30986 #include <asm/vdso.h>
30987 #include <asm/proto.h>
30988 +#include <asm/mman.h>
30989
30990 enum {
30991 VDSO_DISABLED = 0,
30992 @@ -226,7 +227,7 @@ static inline void map_compat_vdso(int map)
30993 void enable_sep_cpu(void)
30994 {
30995 int cpu = get_cpu();
30996 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
30997 + struct tss_struct *tss = init_tss + cpu;
30998
30999 if (!boot_cpu_has(X86_FEATURE_SEP)) {
31000 put_cpu();
31001 @@ -249,7 +250,7 @@ static int __init gate_vma_init(void)
31002 gate_vma.vm_start = FIXADDR_USER_START;
31003 gate_vma.vm_end = FIXADDR_USER_END;
31004 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
31005 - gate_vma.vm_page_prot = __P101;
31006 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
31007
31008 return 0;
31009 }
31010 @@ -330,14 +331,14 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
31011 if (compat)
31012 addr = VDSO_HIGH_BASE;
31013 else {
31014 - addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
31015 + addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, MAP_EXECUTABLE);
31016 if (IS_ERR_VALUE(addr)) {
31017 ret = addr;
31018 goto up_fail;
31019 }
31020 }
31021
31022 - current->mm->context.vdso = (void *)addr;
31023 + current->mm->context.vdso = addr;
31024
31025 if (compat_uses_vma || !compat) {
31026 /*
31027 @@ -353,11 +354,11 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
31028 }
31029
31030 current_thread_info()->sysenter_return =
31031 - VDSO32_SYMBOL(addr, SYSENTER_RETURN);
31032 + (__force void __user *)VDSO32_SYMBOL(addr, SYSENTER_RETURN);
31033
31034 up_fail:
31035 if (ret)
31036 - current->mm->context.vdso = NULL;
31037 + current->mm->context.vdso = 0;
31038
31039 up_write(&mm->mmap_sem);
31040
31041 @@ -404,8 +405,14 @@ __initcall(ia32_binfmt_init);
31042
31043 const char *arch_vma_name(struct vm_area_struct *vma)
31044 {
31045 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
31046 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
31047 return "[vdso]";
31048 +
31049 +#ifdef CONFIG_PAX_SEGMEXEC
31050 + if (vma->vm_mm && vma->vm_mirror && vma->vm_mirror->vm_start == vma->vm_mm->context.vdso)
31051 + return "[vdso]";
31052 +#endif
31053 +
31054 return NULL;
31055 }
31056
31057 @@ -415,7 +422,7 @@ struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
31058 * Check to see if the corresponding task was created in compat vdso
31059 * mode.
31060 */
31061 - if (mm && mm->context.vdso == (void *)VDSO_HIGH_BASE)
31062 + if (mm && mm->context.vdso == VDSO_HIGH_BASE)
31063 return &gate_vma;
31064 return NULL;
31065 }
31066 diff --git a/arch/x86/vdso/vma.c b/arch/x86/vdso/vma.c
31067 index 431e875..cbb23f3 100644
31068 --- a/arch/x86/vdso/vma.c
31069 +++ b/arch/x86/vdso/vma.c
31070 @@ -16,8 +16,6 @@
31071 #include <asm/vdso.h>
31072 #include <asm/page.h>
31073
31074 -unsigned int __read_mostly vdso_enabled = 1;
31075 -
31076 extern char vdso_start[], vdso_end[];
31077 extern unsigned short vdso_sync_cpuid;
31078
31079 @@ -141,7 +139,6 @@ static unsigned long vdso_addr(unsigned long start, unsigned len)
31080 * unaligned here as a result of stack start randomization.
31081 */
31082 addr = PAGE_ALIGN(addr);
31083 - addr = align_vdso_addr(addr);
31084
31085 return addr;
31086 }
31087 @@ -154,30 +151,31 @@ static int setup_additional_pages(struct linux_binprm *bprm,
31088 unsigned size)
31089 {
31090 struct mm_struct *mm = current->mm;
31091 - unsigned long addr;
31092 + unsigned long addr = 0;
31093 int ret;
31094
31095 - if (!vdso_enabled)
31096 - return 0;
31097 -
31098 down_write(&mm->mmap_sem);
31099 +
31100 +#ifdef CONFIG_PAX_RANDMMAP
31101 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
31102 +#endif
31103 +
31104 addr = vdso_addr(mm->start_stack, size);
31105 + addr = align_vdso_addr(addr);
31106 addr = get_unmapped_area(NULL, addr, size, 0, 0);
31107 if (IS_ERR_VALUE(addr)) {
31108 ret = addr;
31109 goto up_fail;
31110 }
31111
31112 - current->mm->context.vdso = (void *)addr;
31113 + mm->context.vdso = addr;
31114
31115 ret = install_special_mapping(mm, addr, size,
31116 VM_READ|VM_EXEC|
31117 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
31118 pages);
31119 - if (ret) {
31120 - current->mm->context.vdso = NULL;
31121 - goto up_fail;
31122 - }
31123 + if (ret)
31124 + mm->context.vdso = 0;
31125
31126 up_fail:
31127 up_write(&mm->mmap_sem);
31128 @@ -197,10 +195,3 @@ int x32_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
31129 vdsox32_size);
31130 }
31131 #endif
31132 -
31133 -static __init int vdso_setup(char *s)
31134 -{
31135 - vdso_enabled = simple_strtoul(s, NULL, 0);
31136 - return 0;
31137 -}
31138 -__setup("vdso=", vdso_setup);
31139 diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
31140 index cf95e19..17e9f50 100644
31141 --- a/arch/x86/xen/enlighten.c
31142 +++ b/arch/x86/xen/enlighten.c
31143 @@ -100,8 +100,6 @@ EXPORT_SYMBOL_GPL(xen_start_info);
31144
31145 struct shared_info xen_dummy_shared_info;
31146
31147 -void *xen_initial_gdt;
31148 -
31149 RESERVE_BRK(shared_info_page_brk, PAGE_SIZE);
31150 __read_mostly int xen_have_vector_callback;
31151 EXPORT_SYMBOL_GPL(xen_have_vector_callback);
31152 @@ -511,8 +509,7 @@ static void xen_load_gdt(const struct desc_ptr *dtr)
31153 {
31154 unsigned long va = dtr->address;
31155 unsigned int size = dtr->size + 1;
31156 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
31157 - unsigned long frames[pages];
31158 + unsigned long frames[65536 / PAGE_SIZE];
31159 int f;
31160
31161 /*
31162 @@ -560,8 +557,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
31163 {
31164 unsigned long va = dtr->address;
31165 unsigned int size = dtr->size + 1;
31166 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
31167 - unsigned long frames[pages];
31168 + unsigned long frames[(GDT_SIZE + PAGE_SIZE - 1) / PAGE_SIZE];
31169 int f;
31170
31171 /*
31172 @@ -569,7 +565,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
31173 * 8-byte entries, or 16 4k pages..
31174 */
31175
31176 - BUG_ON(size > 65536);
31177 + BUG_ON(size > GDT_SIZE);
31178 BUG_ON(va & ~PAGE_MASK);
31179
31180 for (f = 0; va < dtr->address + size; va += PAGE_SIZE, f++) {
31181 @@ -954,7 +950,7 @@ static u32 xen_safe_apic_wait_icr_idle(void)
31182 return 0;
31183 }
31184
31185 -static void set_xen_basic_apic_ops(void)
31186 +static void __init set_xen_basic_apic_ops(void)
31187 {
31188 apic->read = xen_apic_read;
31189 apic->write = xen_apic_write;
31190 @@ -1260,30 +1256,30 @@ static const struct pv_apic_ops xen_apic_ops __initconst = {
31191 #endif
31192 };
31193
31194 -static void xen_reboot(int reason)
31195 +static __noreturn void xen_reboot(int reason)
31196 {
31197 struct sched_shutdown r = { .reason = reason };
31198
31199 - if (HYPERVISOR_sched_op(SCHEDOP_shutdown, &r))
31200 - BUG();
31201 + HYPERVISOR_sched_op(SCHEDOP_shutdown, &r);
31202 + BUG();
31203 }
31204
31205 -static void xen_restart(char *msg)
31206 +static __noreturn void xen_restart(char *msg)
31207 {
31208 xen_reboot(SHUTDOWN_reboot);
31209 }
31210
31211 -static void xen_emergency_restart(void)
31212 +static __noreturn void xen_emergency_restart(void)
31213 {
31214 xen_reboot(SHUTDOWN_reboot);
31215 }
31216
31217 -static void xen_machine_halt(void)
31218 +static __noreturn void xen_machine_halt(void)
31219 {
31220 xen_reboot(SHUTDOWN_poweroff);
31221 }
31222
31223 -static void xen_machine_power_off(void)
31224 +static __noreturn void xen_machine_power_off(void)
31225 {
31226 if (pm_power_off)
31227 pm_power_off();
31228 @@ -1385,7 +1381,17 @@ asmlinkage void __init xen_start_kernel(void)
31229 __userpte_alloc_gfp &= ~__GFP_HIGHMEM;
31230
31231 /* Work out if we support NX */
31232 - x86_configure_nx();
31233 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
31234 + if ((cpuid_eax(0x80000000) & 0xffff0000) == 0x80000000 &&
31235 + (cpuid_edx(0x80000001) & (1U << (X86_FEATURE_NX & 31)))) {
31236 + unsigned l, h;
31237 +
31238 + __supported_pte_mask |= _PAGE_NX;
31239 + rdmsr(MSR_EFER, l, h);
31240 + l |= EFER_NX;
31241 + wrmsr(MSR_EFER, l, h);
31242 + }
31243 +#endif
31244
31245 xen_setup_features();
31246
31247 @@ -1416,13 +1422,6 @@ asmlinkage void __init xen_start_kernel(void)
31248
31249 machine_ops = xen_machine_ops;
31250
31251 - /*
31252 - * The only reliable way to retain the initial address of the
31253 - * percpu gdt_page is to remember it here, so we can go and
31254 - * mark it RW later, when the initial percpu area is freed.
31255 - */
31256 - xen_initial_gdt = &per_cpu(gdt_page, 0);
31257 -
31258 xen_smp_init();
31259
31260 #ifdef CONFIG_ACPI_NUMA
31261 @@ -1616,7 +1615,7 @@ static int __cpuinit xen_hvm_cpu_notify(struct notifier_block *self,
31262 return NOTIFY_OK;
31263 }
31264
31265 -static struct notifier_block xen_hvm_cpu_notifier __cpuinitdata = {
31266 +static struct notifier_block xen_hvm_cpu_notifier = {
31267 .notifier_call = xen_hvm_cpu_notify,
31268 };
31269
31270 diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
31271 index e006c18..b9a7d6c 100644
31272 --- a/arch/x86/xen/mmu.c
31273 +++ b/arch/x86/xen/mmu.c
31274 @@ -1894,6 +1894,9 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
31275 /* L3_k[510] -> level2_kernel_pgt
31276 * L3_i[511] -> level2_fixmap_pgt */
31277 convert_pfn_mfn(level3_kernel_pgt);
31278 + convert_pfn_mfn(level3_vmalloc_start_pgt);
31279 + convert_pfn_mfn(level3_vmalloc_end_pgt);
31280 + convert_pfn_mfn(level3_vmemmap_pgt);
31281
31282 /* We get [511][511] and have Xen's version of level2_kernel_pgt */
31283 l3 = m2v(pgd[pgd_index(__START_KERNEL_map)].pgd);
31284 @@ -1923,8 +1926,12 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
31285 set_page_prot(init_level4_pgt, PAGE_KERNEL_RO);
31286 set_page_prot(level3_ident_pgt, PAGE_KERNEL_RO);
31287 set_page_prot(level3_kernel_pgt, PAGE_KERNEL_RO);
31288 + set_page_prot(level3_vmalloc_start_pgt, PAGE_KERNEL_RO);
31289 + set_page_prot(level3_vmalloc_end_pgt, PAGE_KERNEL_RO);
31290 + set_page_prot(level3_vmemmap_pgt, PAGE_KERNEL_RO);
31291 set_page_prot(level3_user_vsyscall, PAGE_KERNEL_RO);
31292 set_page_prot(level2_ident_pgt, PAGE_KERNEL_RO);
31293 + set_page_prot(level2_vmemmap_pgt, PAGE_KERNEL_RO);
31294 set_page_prot(level2_kernel_pgt, PAGE_KERNEL_RO);
31295 set_page_prot(level2_fixmap_pgt, PAGE_KERNEL_RO);
31296
31297 @@ -2110,6 +2117,7 @@ static void __init xen_post_allocator_init(void)
31298 pv_mmu_ops.set_pud = xen_set_pud;
31299 #if PAGETABLE_LEVELS == 4
31300 pv_mmu_ops.set_pgd = xen_set_pgd;
31301 + pv_mmu_ops.set_pgd_batched = xen_set_pgd;
31302 #endif
31303
31304 /* This will work as long as patching hasn't happened yet
31305 @@ -2188,6 +2196,7 @@ static const struct pv_mmu_ops xen_mmu_ops __initconst = {
31306 .pud_val = PV_CALLEE_SAVE(xen_pud_val),
31307 .make_pud = PV_CALLEE_SAVE(xen_make_pud),
31308 .set_pgd = xen_set_pgd_hyper,
31309 + .set_pgd_batched = xen_set_pgd_hyper,
31310
31311 .alloc_pud = xen_alloc_pmd_init,
31312 .release_pud = xen_release_pmd_init,
31313 diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
31314 index 22c800a..8915f1e 100644
31315 --- a/arch/x86/xen/smp.c
31316 +++ b/arch/x86/xen/smp.c
31317 @@ -229,11 +229,6 @@ static void __init xen_smp_prepare_boot_cpu(void)
31318 {
31319 BUG_ON(smp_processor_id() != 0);
31320 native_smp_prepare_boot_cpu();
31321 -
31322 - /* We've switched to the "real" per-cpu gdt, so make sure the
31323 - old memory can be recycled */
31324 - make_lowmem_page_readwrite(xen_initial_gdt);
31325 -
31326 xen_filter_cpu_maps();
31327 xen_setup_vcpu_info_placement();
31328 }
31329 @@ -303,7 +298,7 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
31330 ctxt->user_regs.ss = __KERNEL_DS;
31331 #ifdef CONFIG_X86_32
31332 ctxt->user_regs.fs = __KERNEL_PERCPU;
31333 - ctxt->user_regs.gs = __KERNEL_STACK_CANARY;
31334 + savesegment(gs, ctxt->user_regs.gs);
31335 #else
31336 ctxt->gs_base_kernel = per_cpu_offset(cpu);
31337 #endif
31338 @@ -313,8 +308,8 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
31339
31340 {
31341 ctxt->user_regs.eflags = 0x1000; /* IOPL_RING1 */
31342 - ctxt->user_regs.ds = __USER_DS;
31343 - ctxt->user_regs.es = __USER_DS;
31344 + ctxt->user_regs.ds = __KERNEL_DS;
31345 + ctxt->user_regs.es = __KERNEL_DS;
31346
31347 xen_copy_trap_info(ctxt->trap_ctxt);
31348
31349 @@ -359,13 +354,12 @@ static int __cpuinit xen_cpu_up(unsigned int cpu, struct task_struct *idle)
31350 int rc;
31351
31352 per_cpu(current_task, cpu) = idle;
31353 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
31354 #ifdef CONFIG_X86_32
31355 irq_ctx_init(cpu);
31356 #else
31357 clear_tsk_thread_flag(idle, TIF_FORK);
31358 - per_cpu(kernel_stack, cpu) =
31359 - (unsigned long)task_stack_page(idle) -
31360 - KERNEL_STACK_OFFSET + THREAD_SIZE;
31361 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
31362 #endif
31363 xen_setup_runstate_info(cpu);
31364 xen_setup_timer(cpu);
31365 @@ -634,7 +628,7 @@ static const struct smp_ops xen_smp_ops __initconst = {
31366
31367 void __init xen_smp_init(void)
31368 {
31369 - smp_ops = xen_smp_ops;
31370 + memcpy((void *)&smp_ops, &xen_smp_ops, sizeof smp_ops);
31371 xen_fill_possible_map();
31372 xen_init_spinlocks();
31373 }
31374 diff --git a/arch/x86/xen/xen-asm_32.S b/arch/x86/xen/xen-asm_32.S
31375 index 33ca6e4..0ded929 100644
31376 --- a/arch/x86/xen/xen-asm_32.S
31377 +++ b/arch/x86/xen/xen-asm_32.S
31378 @@ -84,14 +84,14 @@ ENTRY(xen_iret)
31379 ESP_OFFSET=4 # bytes pushed onto stack
31380
31381 /*
31382 - * Store vcpu_info pointer for easy access. Do it this way to
31383 - * avoid having to reload %fs
31384 + * Store vcpu_info pointer for easy access.
31385 */
31386 #ifdef CONFIG_SMP
31387 - GET_THREAD_INFO(%eax)
31388 - movl %ss:TI_cpu(%eax), %eax
31389 - movl %ss:__per_cpu_offset(,%eax,4), %eax
31390 - mov %ss:xen_vcpu(%eax), %eax
31391 + push %fs
31392 + mov $(__KERNEL_PERCPU), %eax
31393 + mov %eax, %fs
31394 + mov PER_CPU_VAR(xen_vcpu), %eax
31395 + pop %fs
31396 #else
31397 movl %ss:xen_vcpu, %eax
31398 #endif
31399 diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S
31400 index 7faed58..ba4427c 100644
31401 --- a/arch/x86/xen/xen-head.S
31402 +++ b/arch/x86/xen/xen-head.S
31403 @@ -19,6 +19,17 @@ ENTRY(startup_xen)
31404 #ifdef CONFIG_X86_32
31405 mov %esi,xen_start_info
31406 mov $init_thread_union+THREAD_SIZE,%esp
31407 +#ifdef CONFIG_SMP
31408 + movl $cpu_gdt_table,%edi
31409 + movl $__per_cpu_load,%eax
31410 + movw %ax,__KERNEL_PERCPU + 2(%edi)
31411 + rorl $16,%eax
31412 + movb %al,__KERNEL_PERCPU + 4(%edi)
31413 + movb %ah,__KERNEL_PERCPU + 7(%edi)
31414 + movl $__per_cpu_end - 1,%eax
31415 + subl $__per_cpu_start,%eax
31416 + movw %ax,__KERNEL_PERCPU + 0(%edi)
31417 +#endif
31418 #else
31419 mov %rsi,xen_start_info
31420 mov $init_thread_union+THREAD_SIZE,%rsp
31421 diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
31422 index a95b417..b6dbd0b 100644
31423 --- a/arch/x86/xen/xen-ops.h
31424 +++ b/arch/x86/xen/xen-ops.h
31425 @@ -10,8 +10,6 @@
31426 extern const char xen_hypervisor_callback[];
31427 extern const char xen_failsafe_callback[];
31428
31429 -extern void *xen_initial_gdt;
31430 -
31431 struct trap_info;
31432 void xen_copy_trap_info(struct trap_info *traps);
31433
31434 diff --git a/arch/xtensa/variants/dc232b/include/variant/core.h b/arch/xtensa/variants/dc232b/include/variant/core.h
31435 index 525bd3d..ef888b1 100644
31436 --- a/arch/xtensa/variants/dc232b/include/variant/core.h
31437 +++ b/arch/xtensa/variants/dc232b/include/variant/core.h
31438 @@ -119,9 +119,9 @@
31439 ----------------------------------------------------------------------*/
31440
31441 #define XCHAL_ICACHE_LINESIZE 32 /* I-cache line size in bytes */
31442 -#define XCHAL_DCACHE_LINESIZE 32 /* D-cache line size in bytes */
31443 #define XCHAL_ICACHE_LINEWIDTH 5 /* log2(I line size in bytes) */
31444 #define XCHAL_DCACHE_LINEWIDTH 5 /* log2(D line size in bytes) */
31445 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31446
31447 #define XCHAL_ICACHE_SIZE 16384 /* I-cache size in bytes or 0 */
31448 #define XCHAL_DCACHE_SIZE 16384 /* D-cache size in bytes or 0 */
31449 diff --git a/arch/xtensa/variants/fsf/include/variant/core.h b/arch/xtensa/variants/fsf/include/variant/core.h
31450 index 2f33760..835e50a 100644
31451 --- a/arch/xtensa/variants/fsf/include/variant/core.h
31452 +++ b/arch/xtensa/variants/fsf/include/variant/core.h
31453 @@ -11,6 +11,7 @@
31454 #ifndef _XTENSA_CORE_H
31455 #define _XTENSA_CORE_H
31456
31457 +#include <linux/const.h>
31458
31459 /****************************************************************************
31460 Parameters Useful for Any Code, USER or PRIVILEGED
31461 @@ -112,9 +113,9 @@
31462 ----------------------------------------------------------------------*/
31463
31464 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
31465 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
31466 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
31467 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
31468 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31469
31470 #define XCHAL_ICACHE_SIZE 8192 /* I-cache size in bytes or 0 */
31471 #define XCHAL_DCACHE_SIZE 8192 /* D-cache size in bytes or 0 */
31472 diff --git a/arch/xtensa/variants/s6000/include/variant/core.h b/arch/xtensa/variants/s6000/include/variant/core.h
31473 index af00795..2bb8105 100644
31474 --- a/arch/xtensa/variants/s6000/include/variant/core.h
31475 +++ b/arch/xtensa/variants/s6000/include/variant/core.h
31476 @@ -11,6 +11,7 @@
31477 #ifndef _XTENSA_CORE_CONFIGURATION_H
31478 #define _XTENSA_CORE_CONFIGURATION_H
31479
31480 +#include <linux/const.h>
31481
31482 /****************************************************************************
31483 Parameters Useful for Any Code, USER or PRIVILEGED
31484 @@ -118,9 +119,9 @@
31485 ----------------------------------------------------------------------*/
31486
31487 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
31488 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
31489 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
31490 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
31491 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31492
31493 #define XCHAL_ICACHE_SIZE 32768 /* I-cache size in bytes or 0 */
31494 #define XCHAL_DCACHE_SIZE 32768 /* D-cache size in bytes or 0 */
31495 diff --git a/block/blk-iopoll.c b/block/blk-iopoll.c
31496 index 58916af..eb9dbcf6 100644
31497 --- a/block/blk-iopoll.c
31498 +++ b/block/blk-iopoll.c
31499 @@ -77,7 +77,7 @@ void blk_iopoll_complete(struct blk_iopoll *iopoll)
31500 }
31501 EXPORT_SYMBOL(blk_iopoll_complete);
31502
31503 -static void blk_iopoll_softirq(struct softirq_action *h)
31504 +static void blk_iopoll_softirq(void)
31505 {
31506 struct list_head *list = &__get_cpu_var(blk_cpu_iopoll);
31507 int rearm = 0, budget = blk_iopoll_budget;
31508 @@ -209,7 +209,7 @@ static int __cpuinit blk_iopoll_cpu_notify(struct notifier_block *self,
31509 return NOTIFY_OK;
31510 }
31511
31512 -static struct notifier_block __cpuinitdata blk_iopoll_cpu_notifier = {
31513 +static struct notifier_block blk_iopoll_cpu_notifier = {
31514 .notifier_call = blk_iopoll_cpu_notify,
31515 };
31516
31517 diff --git a/block/blk-map.c b/block/blk-map.c
31518 index 623e1cd..ca1e109 100644
31519 --- a/block/blk-map.c
31520 +++ b/block/blk-map.c
31521 @@ -302,7 +302,7 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
31522 if (!len || !kbuf)
31523 return -EINVAL;
31524
31525 - do_copy = !blk_rq_aligned(q, addr, len) || object_is_on_stack(kbuf);
31526 + do_copy = !blk_rq_aligned(q, addr, len) || object_starts_on_stack(kbuf);
31527 if (do_copy)
31528 bio = bio_copy_kern(q, kbuf, len, gfp_mask, reading);
31529 else
31530 diff --git a/block/blk-softirq.c b/block/blk-softirq.c
31531 index 467c8de..f3628c5 100644
31532 --- a/block/blk-softirq.c
31533 +++ b/block/blk-softirq.c
31534 @@ -18,7 +18,7 @@ static DEFINE_PER_CPU(struct list_head, blk_cpu_done);
31535 * Softirq action handler - move entries to local list and loop over them
31536 * while passing them to the queue registered handler.
31537 */
31538 -static void blk_done_softirq(struct softirq_action *h)
31539 +static void blk_done_softirq(void)
31540 {
31541 struct list_head *cpu_list, local_list;
31542
31543 @@ -98,7 +98,7 @@ static int __cpuinit blk_cpu_notify(struct notifier_block *self,
31544 return NOTIFY_OK;
31545 }
31546
31547 -static struct notifier_block __cpuinitdata blk_cpu_notifier = {
31548 +static struct notifier_block blk_cpu_notifier = {
31549 .notifier_call = blk_cpu_notify,
31550 };
31551
31552 diff --git a/block/bsg.c b/block/bsg.c
31553 index 420a5a9..23834aa 100644
31554 --- a/block/bsg.c
31555 +++ b/block/bsg.c
31556 @@ -176,16 +176,24 @@ static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
31557 struct sg_io_v4 *hdr, struct bsg_device *bd,
31558 fmode_t has_write_perm)
31559 {
31560 + unsigned char tmpcmd[sizeof(rq->__cmd)];
31561 + unsigned char *cmdptr;
31562 +
31563 if (hdr->request_len > BLK_MAX_CDB) {
31564 rq->cmd = kzalloc(hdr->request_len, GFP_KERNEL);
31565 if (!rq->cmd)
31566 return -ENOMEM;
31567 - }
31568 + cmdptr = rq->cmd;
31569 + } else
31570 + cmdptr = tmpcmd;
31571
31572 - if (copy_from_user(rq->cmd, (void __user *)(unsigned long)hdr->request,
31573 + if (copy_from_user(cmdptr, (void __user *)(unsigned long)hdr->request,
31574 hdr->request_len))
31575 return -EFAULT;
31576
31577 + if (cmdptr != rq->cmd)
31578 + memcpy(rq->cmd, cmdptr, hdr->request_len);
31579 +
31580 if (hdr->subprotocol == BSG_SUB_PROTOCOL_SCSI_CMD) {
31581 if (blk_verify_command(rq->cmd, has_write_perm))
31582 return -EPERM;
31583 diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c
31584 index 7c668c8..db3521c 100644
31585 --- a/block/compat_ioctl.c
31586 +++ b/block/compat_ioctl.c
31587 @@ -340,7 +340,7 @@ static int compat_fd_ioctl(struct block_device *bdev, fmode_t mode,
31588 err |= __get_user(f->spec1, &uf->spec1);
31589 err |= __get_user(f->fmt_gap, &uf->fmt_gap);
31590 err |= __get_user(name, &uf->name);
31591 - f->name = compat_ptr(name);
31592 + f->name = (void __force_kernel *)compat_ptr(name);
31593 if (err) {
31594 err = -EFAULT;
31595 goto out;
31596 diff --git a/block/partitions/efi.c b/block/partitions/efi.c
31597 index ff5804e..a88acad 100644
31598 --- a/block/partitions/efi.c
31599 +++ b/block/partitions/efi.c
31600 @@ -234,14 +234,14 @@ static gpt_entry *alloc_read_gpt_entries(struct parsed_partitions *state,
31601 if (!gpt)
31602 return NULL;
31603
31604 + if (!le32_to_cpu(gpt->num_partition_entries))
31605 + return NULL;
31606 + pte = kcalloc(le32_to_cpu(gpt->num_partition_entries), le32_to_cpu(gpt->sizeof_partition_entry), GFP_KERNEL);
31607 + if (!pte)
31608 + return NULL;
31609 +
31610 count = le32_to_cpu(gpt->num_partition_entries) *
31611 le32_to_cpu(gpt->sizeof_partition_entry);
31612 - if (!count)
31613 - return NULL;
31614 - pte = kzalloc(count, GFP_KERNEL);
31615 - if (!pte)
31616 - return NULL;
31617 -
31618 if (read_lba(state, le64_to_cpu(gpt->partition_entry_lba),
31619 (u8 *) pte,
31620 count) < count) {
31621 diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
31622 index 9a87daa..fb17486 100644
31623 --- a/block/scsi_ioctl.c
31624 +++ b/block/scsi_ioctl.c
31625 @@ -223,8 +223,20 @@ EXPORT_SYMBOL(blk_verify_command);
31626 static int blk_fill_sghdr_rq(struct request_queue *q, struct request *rq,
31627 struct sg_io_hdr *hdr, fmode_t mode)
31628 {
31629 - if (copy_from_user(rq->cmd, hdr->cmdp, hdr->cmd_len))
31630 + unsigned char tmpcmd[sizeof(rq->__cmd)];
31631 + unsigned char *cmdptr;
31632 +
31633 + if (rq->cmd != rq->__cmd)
31634 + cmdptr = rq->cmd;
31635 + else
31636 + cmdptr = tmpcmd;
31637 +
31638 + if (copy_from_user(cmdptr, hdr->cmdp, hdr->cmd_len))
31639 return -EFAULT;
31640 +
31641 + if (cmdptr != rq->cmd)
31642 + memcpy(rq->cmd, cmdptr, hdr->cmd_len);
31643 +
31644 if (blk_verify_command(rq->cmd, mode & FMODE_WRITE))
31645 return -EPERM;
31646
31647 @@ -433,6 +445,8 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
31648 int err;
31649 unsigned int in_len, out_len, bytes, opcode, cmdlen;
31650 char *buffer = NULL, sense[SCSI_SENSE_BUFFERSIZE];
31651 + unsigned char tmpcmd[sizeof(rq->__cmd)];
31652 + unsigned char *cmdptr;
31653
31654 if (!sic)
31655 return -EINVAL;
31656 @@ -466,9 +480,18 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
31657 */
31658 err = -EFAULT;
31659 rq->cmd_len = cmdlen;
31660 - if (copy_from_user(rq->cmd, sic->data, cmdlen))
31661 +
31662 + if (rq->cmd != rq->__cmd)
31663 + cmdptr = rq->cmd;
31664 + else
31665 + cmdptr = tmpcmd;
31666 +
31667 + if (copy_from_user(cmdptr, sic->data, cmdlen))
31668 goto error;
31669
31670 + if (rq->cmd != cmdptr)
31671 + memcpy(rq->cmd, cmdptr, cmdlen);
31672 +
31673 if (in_len && copy_from_user(buffer, sic->data + cmdlen, in_len))
31674 goto error;
31675
31676 diff --git a/crypto/cryptd.c b/crypto/cryptd.c
31677 index 7bdd61b..afec999 100644
31678 --- a/crypto/cryptd.c
31679 +++ b/crypto/cryptd.c
31680 @@ -63,7 +63,7 @@ struct cryptd_blkcipher_ctx {
31681
31682 struct cryptd_blkcipher_request_ctx {
31683 crypto_completion_t complete;
31684 -};
31685 +} __no_const;
31686
31687 struct cryptd_hash_ctx {
31688 struct crypto_shash *child;
31689 @@ -80,7 +80,7 @@ struct cryptd_aead_ctx {
31690
31691 struct cryptd_aead_request_ctx {
31692 crypto_completion_t complete;
31693 -};
31694 +} __no_const;
31695
31696 static void cryptd_queue_worker(struct work_struct *work);
31697
31698 diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h
31699 index f220d64..d359ad6 100644
31700 --- a/drivers/acpi/apei/apei-internal.h
31701 +++ b/drivers/acpi/apei/apei-internal.h
31702 @@ -20,7 +20,7 @@ typedef int (*apei_exec_ins_func_t)(struct apei_exec_context *ctx,
31703 struct apei_exec_ins_type {
31704 u32 flags;
31705 apei_exec_ins_func_t run;
31706 -};
31707 +} __do_const;
31708
31709 struct apei_exec_context {
31710 u32 ip;
31711 diff --git a/drivers/acpi/apei/cper.c b/drivers/acpi/apei/cper.c
31712 index fefc2ca..12a535d 100644
31713 --- a/drivers/acpi/apei/cper.c
31714 +++ b/drivers/acpi/apei/cper.c
31715 @@ -39,12 +39,12 @@
31716 */
31717 u64 cper_next_record_id(void)
31718 {
31719 - static atomic64_t seq;
31720 + static atomic64_unchecked_t seq;
31721
31722 - if (!atomic64_read(&seq))
31723 - atomic64_set(&seq, ((u64)get_seconds()) << 32);
31724 + if (!atomic64_read_unchecked(&seq))
31725 + atomic64_set_unchecked(&seq, ((u64)get_seconds()) << 32);
31726
31727 - return atomic64_inc_return(&seq);
31728 + return atomic64_inc_return_unchecked(&seq);
31729 }
31730 EXPORT_SYMBOL_GPL(cper_next_record_id);
31731
31732 diff --git a/drivers/acpi/bgrt.c b/drivers/acpi/bgrt.c
31733 index be60399..778b33e8 100644
31734 --- a/drivers/acpi/bgrt.c
31735 +++ b/drivers/acpi/bgrt.c
31736 @@ -87,8 +87,10 @@ static int __init bgrt_init(void)
31737 return -ENODEV;
31738
31739 sysfs_bin_attr_init(&image_attr);
31740 - image_attr.private = bgrt_image;
31741 - image_attr.size = bgrt_image_size;
31742 + pax_open_kernel();
31743 + *(void **)&image_attr.private = bgrt_image;
31744 + *(size_t *)&image_attr.size = bgrt_image_size;
31745 + pax_close_kernel();
31746
31747 bgrt_kobj = kobject_create_and_add("bgrt", acpi_kobj);
31748 if (!bgrt_kobj)
31749 diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
31750 index cb96296..b81293b 100644
31751 --- a/drivers/acpi/blacklist.c
31752 +++ b/drivers/acpi/blacklist.c
31753 @@ -52,7 +52,7 @@ struct acpi_blacklist_item {
31754 u32 is_critical_error;
31755 };
31756
31757 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata;
31758 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst;
31759
31760 /*
31761 * POLICY: If *anything* doesn't work, put it on the blacklist.
31762 @@ -193,7 +193,7 @@ static int __init dmi_disable_osi_win7(const struct dmi_system_id *d)
31763 return 0;
31764 }
31765
31766 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
31767 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst = {
31768 {
31769 .callback = dmi_disable_osi_vista,
31770 .ident = "Fujitsu Siemens",
31771 diff --git a/drivers/acpi/ec_sys.c b/drivers/acpi/ec_sys.c
31772 index 7586544..636a2f0 100644
31773 --- a/drivers/acpi/ec_sys.c
31774 +++ b/drivers/acpi/ec_sys.c
31775 @@ -12,6 +12,7 @@
31776 #include <linux/acpi.h>
31777 #include <linux/debugfs.h>
31778 #include <linux/module.h>
31779 +#include <linux/uaccess.h>
31780 #include "internal.h"
31781
31782 MODULE_AUTHOR("Thomas Renninger <trenn@suse.de>");
31783 @@ -34,7 +35,7 @@ static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
31784 * struct acpi_ec *ec = ((struct seq_file *)f->private_data)->private;
31785 */
31786 unsigned int size = EC_SPACE_SIZE;
31787 - u8 *data = (u8 *) buf;
31788 + u8 data;
31789 loff_t init_off = *off;
31790 int err = 0;
31791
31792 @@ -47,9 +48,11 @@ static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
31793 size = count;
31794
31795 while (size) {
31796 - err = ec_read(*off, &data[*off - init_off]);
31797 + err = ec_read(*off, &data);
31798 if (err)
31799 return err;
31800 + if (put_user(data, &buf[*off - init_off]))
31801 + return -EFAULT;
31802 *off += 1;
31803 size--;
31804 }
31805 @@ -65,7 +68,6 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
31806
31807 unsigned int size = count;
31808 loff_t init_off = *off;
31809 - u8 *data = (u8 *) buf;
31810 int err = 0;
31811
31812 if (*off >= EC_SPACE_SIZE)
31813 @@ -76,7 +78,9 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
31814 }
31815
31816 while (size) {
31817 - u8 byte_write = data[*off - init_off];
31818 + u8 byte_write;
31819 + if (get_user(byte_write, &buf[*off - init_off]))
31820 + return -EFAULT;
31821 err = ec_write(*off, byte_write);
31822 if (err)
31823 return err;
31824 diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
31825 index ee255c6..747c68b 100644
31826 --- a/drivers/acpi/processor_idle.c
31827 +++ b/drivers/acpi/processor_idle.c
31828 @@ -986,7 +986,7 @@ static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr)
31829 {
31830 int i, count = CPUIDLE_DRIVER_STATE_START;
31831 struct acpi_processor_cx *cx;
31832 - struct cpuidle_state *state;
31833 + cpuidle_state_no_const *state;
31834 struct cpuidle_driver *drv = &acpi_idle_driver;
31835
31836 if (!pr->flags.power_setup_done)
31837 diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
31838 index 41c0504..f8c0836 100644
31839 --- a/drivers/acpi/sysfs.c
31840 +++ b/drivers/acpi/sysfs.c
31841 @@ -420,11 +420,11 @@ static u32 num_counters;
31842 static struct attribute **all_attrs;
31843 static u32 acpi_gpe_count;
31844
31845 -static struct attribute_group interrupt_stats_attr_group = {
31846 +static attribute_group_no_const interrupt_stats_attr_group = {
31847 .name = "interrupts",
31848 };
31849
31850 -static struct kobj_attribute *counter_attrs;
31851 +static kobj_attribute_no_const *counter_attrs;
31852
31853 static void delete_gpe_attr_array(void)
31854 {
31855 diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
31856 index 34c8216..f56c828 100644
31857 --- a/drivers/ata/libahci.c
31858 +++ b/drivers/ata/libahci.c
31859 @@ -1230,7 +1230,7 @@ int ahci_kick_engine(struct ata_port *ap)
31860 }
31861 EXPORT_SYMBOL_GPL(ahci_kick_engine);
31862
31863 -static int ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
31864 +static int __intentional_overflow(-1) ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
31865 struct ata_taskfile *tf, int is_cmd, u16 flags,
31866 unsigned long timeout_msec)
31867 {
31868 diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
31869 index 63c743b..0422dc6 100644
31870 --- a/drivers/ata/libata-core.c
31871 +++ b/drivers/ata/libata-core.c
31872 @@ -4786,7 +4786,7 @@ void ata_qc_free(struct ata_queued_cmd *qc)
31873 struct ata_port *ap;
31874 unsigned int tag;
31875
31876 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
31877 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
31878 ap = qc->ap;
31879
31880 qc->flags = 0;
31881 @@ -4802,7 +4802,7 @@ void __ata_qc_complete(struct ata_queued_cmd *qc)
31882 struct ata_port *ap;
31883 struct ata_link *link;
31884
31885 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
31886 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
31887 WARN_ON_ONCE(!(qc->flags & ATA_QCFLAG_ACTIVE));
31888 ap = qc->ap;
31889 link = qc->dev->link;
31890 @@ -5920,6 +5920,7 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
31891 return;
31892
31893 spin_lock(&lock);
31894 + pax_open_kernel();
31895
31896 for (cur = ops->inherits; cur; cur = cur->inherits) {
31897 void **inherit = (void **)cur;
31898 @@ -5933,8 +5934,9 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
31899 if (IS_ERR(*pp))
31900 *pp = NULL;
31901
31902 - ops->inherits = NULL;
31903 + *(struct ata_port_operations **)&ops->inherits = NULL;
31904
31905 + pax_close_kernel();
31906 spin_unlock(&lock);
31907 }
31908
31909 diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
31910 index 405022d..fb70e53 100644
31911 --- a/drivers/ata/pata_arasan_cf.c
31912 +++ b/drivers/ata/pata_arasan_cf.c
31913 @@ -864,7 +864,9 @@ static int arasan_cf_probe(struct platform_device *pdev)
31914 /* Handle platform specific quirks */
31915 if (pdata->quirk) {
31916 if (pdata->quirk & CF_BROKEN_PIO) {
31917 - ap->ops->set_piomode = NULL;
31918 + pax_open_kernel();
31919 + *(void **)&ap->ops->set_piomode = NULL;
31920 + pax_close_kernel();
31921 ap->pio_mask = 0;
31922 }
31923 if (pdata->quirk & CF_BROKEN_MWDMA)
31924 diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
31925 index f9b983a..887b9d8 100644
31926 --- a/drivers/atm/adummy.c
31927 +++ b/drivers/atm/adummy.c
31928 @@ -114,7 +114,7 @@ adummy_send(struct atm_vcc *vcc, struct sk_buff *skb)
31929 vcc->pop(vcc, skb);
31930 else
31931 dev_kfree_skb_any(skb);
31932 - atomic_inc(&vcc->stats->tx);
31933 + atomic_inc_unchecked(&vcc->stats->tx);
31934
31935 return 0;
31936 }
31937 diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
31938 index 77a7480..05cde58 100644
31939 --- a/drivers/atm/ambassador.c
31940 +++ b/drivers/atm/ambassador.c
31941 @@ -454,7 +454,7 @@ static void tx_complete (amb_dev * dev, tx_out * tx) {
31942 PRINTD (DBG_FLOW|DBG_TX, "tx_complete %p %p", dev, tx);
31943
31944 // VC layer stats
31945 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
31946 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
31947
31948 // free the descriptor
31949 kfree (tx_descr);
31950 @@ -495,7 +495,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
31951 dump_skb ("<<<", vc, skb);
31952
31953 // VC layer stats
31954 - atomic_inc(&atm_vcc->stats->rx);
31955 + atomic_inc_unchecked(&atm_vcc->stats->rx);
31956 __net_timestamp(skb);
31957 // end of our responsibility
31958 atm_vcc->push (atm_vcc, skb);
31959 @@ -510,7 +510,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
31960 } else {
31961 PRINTK (KERN_INFO, "dropped over-size frame");
31962 // should we count this?
31963 - atomic_inc(&atm_vcc->stats->rx_drop);
31964 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
31965 }
31966
31967 } else {
31968 @@ -1338,7 +1338,7 @@ static int amb_send (struct atm_vcc * atm_vcc, struct sk_buff * skb) {
31969 }
31970
31971 if (check_area (skb->data, skb->len)) {
31972 - atomic_inc(&atm_vcc->stats->tx_err);
31973 + atomic_inc_unchecked(&atm_vcc->stats->tx_err);
31974 return -ENOMEM; // ?
31975 }
31976
31977 diff --git a/drivers/atm/atmtcp.c b/drivers/atm/atmtcp.c
31978 index 0e3f8f9..765a7a5 100644
31979 --- a/drivers/atm/atmtcp.c
31980 +++ b/drivers/atm/atmtcp.c
31981 @@ -206,7 +206,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
31982 if (vcc->pop) vcc->pop(vcc,skb);
31983 else dev_kfree_skb(skb);
31984 if (dev_data) return 0;
31985 - atomic_inc(&vcc->stats->tx_err);
31986 + atomic_inc_unchecked(&vcc->stats->tx_err);
31987 return -ENOLINK;
31988 }
31989 size = skb->len+sizeof(struct atmtcp_hdr);
31990 @@ -214,7 +214,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
31991 if (!new_skb) {
31992 if (vcc->pop) vcc->pop(vcc,skb);
31993 else dev_kfree_skb(skb);
31994 - atomic_inc(&vcc->stats->tx_err);
31995 + atomic_inc_unchecked(&vcc->stats->tx_err);
31996 return -ENOBUFS;
31997 }
31998 hdr = (void *) skb_put(new_skb,sizeof(struct atmtcp_hdr));
31999 @@ -225,8 +225,8 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
32000 if (vcc->pop) vcc->pop(vcc,skb);
32001 else dev_kfree_skb(skb);
32002 out_vcc->push(out_vcc,new_skb);
32003 - atomic_inc(&vcc->stats->tx);
32004 - atomic_inc(&out_vcc->stats->rx);
32005 + atomic_inc_unchecked(&vcc->stats->tx);
32006 + atomic_inc_unchecked(&out_vcc->stats->rx);
32007 return 0;
32008 }
32009
32010 @@ -299,7 +299,7 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
32011 out_vcc = find_vcc(dev, ntohs(hdr->vpi), ntohs(hdr->vci));
32012 read_unlock(&vcc_sklist_lock);
32013 if (!out_vcc) {
32014 - atomic_inc(&vcc->stats->tx_err);
32015 + atomic_inc_unchecked(&vcc->stats->tx_err);
32016 goto done;
32017 }
32018 skb_pull(skb,sizeof(struct atmtcp_hdr));
32019 @@ -311,8 +311,8 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
32020 __net_timestamp(new_skb);
32021 skb_copy_from_linear_data(skb, skb_put(new_skb, skb->len), skb->len);
32022 out_vcc->push(out_vcc,new_skb);
32023 - atomic_inc(&vcc->stats->tx);
32024 - atomic_inc(&out_vcc->stats->rx);
32025 + atomic_inc_unchecked(&vcc->stats->tx);
32026 + atomic_inc_unchecked(&out_vcc->stats->rx);
32027 done:
32028 if (vcc->pop) vcc->pop(vcc,skb);
32029 else dev_kfree_skb(skb);
32030 diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c
32031 index b1955ba..b179940 100644
32032 --- a/drivers/atm/eni.c
32033 +++ b/drivers/atm/eni.c
32034 @@ -522,7 +522,7 @@ static int rx_aal0(struct atm_vcc *vcc)
32035 DPRINTK(DEV_LABEL "(itf %d): trashing empty cell\n",
32036 vcc->dev->number);
32037 length = 0;
32038 - atomic_inc(&vcc->stats->rx_err);
32039 + atomic_inc_unchecked(&vcc->stats->rx_err);
32040 }
32041 else {
32042 length = ATM_CELL_SIZE-1; /* no HEC */
32043 @@ -577,7 +577,7 @@ static int rx_aal5(struct atm_vcc *vcc)
32044 size);
32045 }
32046 eff = length = 0;
32047 - atomic_inc(&vcc->stats->rx_err);
32048 + atomic_inc_unchecked(&vcc->stats->rx_err);
32049 }
32050 else {
32051 size = (descr & MID_RED_COUNT)*(ATM_CELL_PAYLOAD >> 2);
32052 @@ -594,7 +594,7 @@ static int rx_aal5(struct atm_vcc *vcc)
32053 "(VCI=%d,length=%ld,size=%ld (descr 0x%lx))\n",
32054 vcc->dev->number,vcc->vci,length,size << 2,descr);
32055 length = eff = 0;
32056 - atomic_inc(&vcc->stats->rx_err);
32057 + atomic_inc_unchecked(&vcc->stats->rx_err);
32058 }
32059 }
32060 skb = eff ? atm_alloc_charge(vcc,eff << 2,GFP_ATOMIC) : NULL;
32061 @@ -767,7 +767,7 @@ rx_dequeued++;
32062 vcc->push(vcc,skb);
32063 pushed++;
32064 }
32065 - atomic_inc(&vcc->stats->rx);
32066 + atomic_inc_unchecked(&vcc->stats->rx);
32067 }
32068 wake_up(&eni_dev->rx_wait);
32069 }
32070 @@ -1227,7 +1227,7 @@ static void dequeue_tx(struct atm_dev *dev)
32071 PCI_DMA_TODEVICE);
32072 if (vcc->pop) vcc->pop(vcc,skb);
32073 else dev_kfree_skb_irq(skb);
32074 - atomic_inc(&vcc->stats->tx);
32075 + atomic_inc_unchecked(&vcc->stats->tx);
32076 wake_up(&eni_dev->tx_wait);
32077 dma_complete++;
32078 }
32079 diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
32080 index b41c948..a002b17 100644
32081 --- a/drivers/atm/firestream.c
32082 +++ b/drivers/atm/firestream.c
32083 @@ -749,7 +749,7 @@ static void process_txdone_queue (struct fs_dev *dev, struct queue *q)
32084 }
32085 }
32086
32087 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
32088 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
32089
32090 fs_dprintk (FS_DEBUG_TXMEM, "i");
32091 fs_dprintk (FS_DEBUG_ALLOC, "Free t-skb: %p\n", skb);
32092 @@ -816,7 +816,7 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
32093 #endif
32094 skb_put (skb, qe->p1 & 0xffff);
32095 ATM_SKB(skb)->vcc = atm_vcc;
32096 - atomic_inc(&atm_vcc->stats->rx);
32097 + atomic_inc_unchecked(&atm_vcc->stats->rx);
32098 __net_timestamp(skb);
32099 fs_dprintk (FS_DEBUG_ALLOC, "Free rec-skb: %p (pushed)\n", skb);
32100 atm_vcc->push (atm_vcc, skb);
32101 @@ -837,12 +837,12 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
32102 kfree (pe);
32103 }
32104 if (atm_vcc)
32105 - atomic_inc(&atm_vcc->stats->rx_drop);
32106 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
32107 break;
32108 case 0x1f: /* Reassembly abort: no buffers. */
32109 /* Silently increment error counter. */
32110 if (atm_vcc)
32111 - atomic_inc(&atm_vcc->stats->rx_drop);
32112 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
32113 break;
32114 default: /* Hmm. Haven't written the code to handle the others yet... -- REW */
32115 printk (KERN_WARNING "Don't know what to do with RX status %x: %s.\n",
32116 diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
32117 index 204814e..cede831 100644
32118 --- a/drivers/atm/fore200e.c
32119 +++ b/drivers/atm/fore200e.c
32120 @@ -931,9 +931,9 @@ fore200e_tx_irq(struct fore200e* fore200e)
32121 #endif
32122 /* check error condition */
32123 if (*entry->status & STATUS_ERROR)
32124 - atomic_inc(&vcc->stats->tx_err);
32125 + atomic_inc_unchecked(&vcc->stats->tx_err);
32126 else
32127 - atomic_inc(&vcc->stats->tx);
32128 + atomic_inc_unchecked(&vcc->stats->tx);
32129 }
32130 }
32131
32132 @@ -1082,7 +1082,7 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
32133 if (skb == NULL) {
32134 DPRINTK(2, "unable to alloc new skb, rx PDU length = %d\n", pdu_len);
32135
32136 - atomic_inc(&vcc->stats->rx_drop);
32137 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32138 return -ENOMEM;
32139 }
32140
32141 @@ -1125,14 +1125,14 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
32142
32143 dev_kfree_skb_any(skb);
32144
32145 - atomic_inc(&vcc->stats->rx_drop);
32146 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32147 return -ENOMEM;
32148 }
32149
32150 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
32151
32152 vcc->push(vcc, skb);
32153 - atomic_inc(&vcc->stats->rx);
32154 + atomic_inc_unchecked(&vcc->stats->rx);
32155
32156 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
32157
32158 @@ -1210,7 +1210,7 @@ fore200e_rx_irq(struct fore200e* fore200e)
32159 DPRINTK(2, "damaged PDU on %d.%d.%d\n",
32160 fore200e->atm_dev->number,
32161 entry->rpd->atm_header.vpi, entry->rpd->atm_header.vci);
32162 - atomic_inc(&vcc->stats->rx_err);
32163 + atomic_inc_unchecked(&vcc->stats->rx_err);
32164 }
32165 }
32166
32167 @@ -1655,7 +1655,7 @@ fore200e_send(struct atm_vcc *vcc, struct sk_buff *skb)
32168 goto retry_here;
32169 }
32170
32171 - atomic_inc(&vcc->stats->tx_err);
32172 + atomic_inc_unchecked(&vcc->stats->tx_err);
32173
32174 fore200e->tx_sat++;
32175 DPRINTK(2, "tx queue of device %s is saturated, PDU dropped - heartbeat is %08x\n",
32176 diff --git a/drivers/atm/he.c b/drivers/atm/he.c
32177 index d689126..e78e412 100644
32178 --- a/drivers/atm/he.c
32179 +++ b/drivers/atm/he.c
32180 @@ -1698,7 +1698,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32181
32182 if (RBRQ_HBUF_ERR(he_dev->rbrq_head)) {
32183 hprintk("HBUF_ERR! (cid 0x%x)\n", cid);
32184 - atomic_inc(&vcc->stats->rx_drop);
32185 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32186 goto return_host_buffers;
32187 }
32188
32189 @@ -1725,7 +1725,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32190 RBRQ_LEN_ERR(he_dev->rbrq_head)
32191 ? "LEN_ERR" : "",
32192 vcc->vpi, vcc->vci);
32193 - atomic_inc(&vcc->stats->rx_err);
32194 + atomic_inc_unchecked(&vcc->stats->rx_err);
32195 goto return_host_buffers;
32196 }
32197
32198 @@ -1777,7 +1777,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32199 vcc->push(vcc, skb);
32200 spin_lock(&he_dev->global_lock);
32201
32202 - atomic_inc(&vcc->stats->rx);
32203 + atomic_inc_unchecked(&vcc->stats->rx);
32204
32205 return_host_buffers:
32206 ++pdus_assembled;
32207 @@ -2103,7 +2103,7 @@ __enqueue_tpd(struct he_dev *he_dev, struct he_tpd *tpd, unsigned cid)
32208 tpd->vcc->pop(tpd->vcc, tpd->skb);
32209 else
32210 dev_kfree_skb_any(tpd->skb);
32211 - atomic_inc(&tpd->vcc->stats->tx_err);
32212 + atomic_inc_unchecked(&tpd->vcc->stats->tx_err);
32213 }
32214 pci_pool_free(he_dev->tpd_pool, tpd, TPD_ADDR(tpd->status));
32215 return;
32216 @@ -2515,7 +2515,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32217 vcc->pop(vcc, skb);
32218 else
32219 dev_kfree_skb_any(skb);
32220 - atomic_inc(&vcc->stats->tx_err);
32221 + atomic_inc_unchecked(&vcc->stats->tx_err);
32222 return -EINVAL;
32223 }
32224
32225 @@ -2526,7 +2526,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32226 vcc->pop(vcc, skb);
32227 else
32228 dev_kfree_skb_any(skb);
32229 - atomic_inc(&vcc->stats->tx_err);
32230 + atomic_inc_unchecked(&vcc->stats->tx_err);
32231 return -EINVAL;
32232 }
32233 #endif
32234 @@ -2538,7 +2538,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32235 vcc->pop(vcc, skb);
32236 else
32237 dev_kfree_skb_any(skb);
32238 - atomic_inc(&vcc->stats->tx_err);
32239 + atomic_inc_unchecked(&vcc->stats->tx_err);
32240 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32241 return -ENOMEM;
32242 }
32243 @@ -2580,7 +2580,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32244 vcc->pop(vcc, skb);
32245 else
32246 dev_kfree_skb_any(skb);
32247 - atomic_inc(&vcc->stats->tx_err);
32248 + atomic_inc_unchecked(&vcc->stats->tx_err);
32249 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32250 return -ENOMEM;
32251 }
32252 @@ -2611,7 +2611,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32253 __enqueue_tpd(he_dev, tpd, cid);
32254 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32255
32256 - atomic_inc(&vcc->stats->tx);
32257 + atomic_inc_unchecked(&vcc->stats->tx);
32258
32259 return 0;
32260 }
32261 diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c
32262 index 1dc0519..1aadaf7 100644
32263 --- a/drivers/atm/horizon.c
32264 +++ b/drivers/atm/horizon.c
32265 @@ -1034,7 +1034,7 @@ static void rx_schedule (hrz_dev * dev, int irq) {
32266 {
32267 struct atm_vcc * vcc = ATM_SKB(skb)->vcc;
32268 // VC layer stats
32269 - atomic_inc(&vcc->stats->rx);
32270 + atomic_inc_unchecked(&vcc->stats->rx);
32271 __net_timestamp(skb);
32272 // end of our responsibility
32273 vcc->push (vcc, skb);
32274 @@ -1186,7 +1186,7 @@ static void tx_schedule (hrz_dev * const dev, int irq) {
32275 dev->tx_iovec = NULL;
32276
32277 // VC layer stats
32278 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
32279 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
32280
32281 // free the skb
32282 hrz_kfree_skb (skb);
32283 diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
32284 index 272f009..a18ba55 100644
32285 --- a/drivers/atm/idt77252.c
32286 +++ b/drivers/atm/idt77252.c
32287 @@ -812,7 +812,7 @@ drain_scq(struct idt77252_dev *card, struct vc_map *vc)
32288 else
32289 dev_kfree_skb(skb);
32290
32291 - atomic_inc(&vcc->stats->tx);
32292 + atomic_inc_unchecked(&vcc->stats->tx);
32293 }
32294
32295 atomic_dec(&scq->used);
32296 @@ -1075,13 +1075,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32297 if ((sb = dev_alloc_skb(64)) == NULL) {
32298 printk("%s: Can't allocate buffers for aal0.\n",
32299 card->name);
32300 - atomic_add(i, &vcc->stats->rx_drop);
32301 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
32302 break;
32303 }
32304 if (!atm_charge(vcc, sb->truesize)) {
32305 RXPRINTK("%s: atm_charge() dropped aal0 packets.\n",
32306 card->name);
32307 - atomic_add(i - 1, &vcc->stats->rx_drop);
32308 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop);
32309 dev_kfree_skb(sb);
32310 break;
32311 }
32312 @@ -1098,7 +1098,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32313 ATM_SKB(sb)->vcc = vcc;
32314 __net_timestamp(sb);
32315 vcc->push(vcc, sb);
32316 - atomic_inc(&vcc->stats->rx);
32317 + atomic_inc_unchecked(&vcc->stats->rx);
32318
32319 cell += ATM_CELL_PAYLOAD;
32320 }
32321 @@ -1135,13 +1135,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32322 "(CDC: %08x)\n",
32323 card->name, len, rpp->len, readl(SAR_REG_CDC));
32324 recycle_rx_pool_skb(card, rpp);
32325 - atomic_inc(&vcc->stats->rx_err);
32326 + atomic_inc_unchecked(&vcc->stats->rx_err);
32327 return;
32328 }
32329 if (stat & SAR_RSQE_CRC) {
32330 RXPRINTK("%s: AAL5 CRC error.\n", card->name);
32331 recycle_rx_pool_skb(card, rpp);
32332 - atomic_inc(&vcc->stats->rx_err);
32333 + atomic_inc_unchecked(&vcc->stats->rx_err);
32334 return;
32335 }
32336 if (skb_queue_len(&rpp->queue) > 1) {
32337 @@ -1152,7 +1152,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32338 RXPRINTK("%s: Can't alloc RX skb.\n",
32339 card->name);
32340 recycle_rx_pool_skb(card, rpp);
32341 - atomic_inc(&vcc->stats->rx_err);
32342 + atomic_inc_unchecked(&vcc->stats->rx_err);
32343 return;
32344 }
32345 if (!atm_charge(vcc, skb->truesize)) {
32346 @@ -1171,7 +1171,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32347 __net_timestamp(skb);
32348
32349 vcc->push(vcc, skb);
32350 - atomic_inc(&vcc->stats->rx);
32351 + atomic_inc_unchecked(&vcc->stats->rx);
32352
32353 return;
32354 }
32355 @@ -1193,7 +1193,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32356 __net_timestamp(skb);
32357
32358 vcc->push(vcc, skb);
32359 - atomic_inc(&vcc->stats->rx);
32360 + atomic_inc_unchecked(&vcc->stats->rx);
32361
32362 if (skb->truesize > SAR_FB_SIZE_3)
32363 add_rx_skb(card, 3, SAR_FB_SIZE_3, 1);
32364 @@ -1304,14 +1304,14 @@ idt77252_rx_raw(struct idt77252_dev *card)
32365 if (vcc->qos.aal != ATM_AAL0) {
32366 RPRINTK("%s: raw cell for non AAL0 vc %u.%u\n",
32367 card->name, vpi, vci);
32368 - atomic_inc(&vcc->stats->rx_drop);
32369 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32370 goto drop;
32371 }
32372
32373 if ((sb = dev_alloc_skb(64)) == NULL) {
32374 printk("%s: Can't allocate buffers for AAL0.\n",
32375 card->name);
32376 - atomic_inc(&vcc->stats->rx_err);
32377 + atomic_inc_unchecked(&vcc->stats->rx_err);
32378 goto drop;
32379 }
32380
32381 @@ -1330,7 +1330,7 @@ idt77252_rx_raw(struct idt77252_dev *card)
32382 ATM_SKB(sb)->vcc = vcc;
32383 __net_timestamp(sb);
32384 vcc->push(vcc, sb);
32385 - atomic_inc(&vcc->stats->rx);
32386 + atomic_inc_unchecked(&vcc->stats->rx);
32387
32388 drop:
32389 skb_pull(queue, 64);
32390 @@ -1955,13 +1955,13 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32391
32392 if (vc == NULL) {
32393 printk("%s: NULL connection in send().\n", card->name);
32394 - atomic_inc(&vcc->stats->tx_err);
32395 + atomic_inc_unchecked(&vcc->stats->tx_err);
32396 dev_kfree_skb(skb);
32397 return -EINVAL;
32398 }
32399 if (!test_bit(VCF_TX, &vc->flags)) {
32400 printk("%s: Trying to transmit on a non-tx VC.\n", card->name);
32401 - atomic_inc(&vcc->stats->tx_err);
32402 + atomic_inc_unchecked(&vcc->stats->tx_err);
32403 dev_kfree_skb(skb);
32404 return -EINVAL;
32405 }
32406 @@ -1973,14 +1973,14 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32407 break;
32408 default:
32409 printk("%s: Unsupported AAL: %d\n", card->name, vcc->qos.aal);
32410 - atomic_inc(&vcc->stats->tx_err);
32411 + atomic_inc_unchecked(&vcc->stats->tx_err);
32412 dev_kfree_skb(skb);
32413 return -EINVAL;
32414 }
32415
32416 if (skb_shinfo(skb)->nr_frags != 0) {
32417 printk("%s: No scatter-gather yet.\n", card->name);
32418 - atomic_inc(&vcc->stats->tx_err);
32419 + atomic_inc_unchecked(&vcc->stats->tx_err);
32420 dev_kfree_skb(skb);
32421 return -EINVAL;
32422 }
32423 @@ -1988,7 +1988,7 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32424
32425 err = queue_skb(card, vc, skb, oam);
32426 if (err) {
32427 - atomic_inc(&vcc->stats->tx_err);
32428 + atomic_inc_unchecked(&vcc->stats->tx_err);
32429 dev_kfree_skb(skb);
32430 return err;
32431 }
32432 @@ -2011,7 +2011,7 @@ idt77252_send_oam(struct atm_vcc *vcc, void *cell, int flags)
32433 skb = dev_alloc_skb(64);
32434 if (!skb) {
32435 printk("%s: Out of memory in send_oam().\n", card->name);
32436 - atomic_inc(&vcc->stats->tx_err);
32437 + atomic_inc_unchecked(&vcc->stats->tx_err);
32438 return -ENOMEM;
32439 }
32440 atomic_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc);
32441 diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
32442 index 4217f29..88f547a 100644
32443 --- a/drivers/atm/iphase.c
32444 +++ b/drivers/atm/iphase.c
32445 @@ -1145,7 +1145,7 @@ static int rx_pkt(struct atm_dev *dev)
32446 status = (u_short) (buf_desc_ptr->desc_mode);
32447 if (status & (RX_CER | RX_PTE | RX_OFL))
32448 {
32449 - atomic_inc(&vcc->stats->rx_err);
32450 + atomic_inc_unchecked(&vcc->stats->rx_err);
32451 IF_ERR(printk("IA: bad packet, dropping it");)
32452 if (status & RX_CER) {
32453 IF_ERR(printk(" cause: packet CRC error\n");)
32454 @@ -1168,7 +1168,7 @@ static int rx_pkt(struct atm_dev *dev)
32455 len = dma_addr - buf_addr;
32456 if (len > iadev->rx_buf_sz) {
32457 printk("Over %d bytes sdu received, dropped!!!\n", iadev->rx_buf_sz);
32458 - atomic_inc(&vcc->stats->rx_err);
32459 + atomic_inc_unchecked(&vcc->stats->rx_err);
32460 goto out_free_desc;
32461 }
32462
32463 @@ -1318,7 +1318,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32464 ia_vcc = INPH_IA_VCC(vcc);
32465 if (ia_vcc == NULL)
32466 {
32467 - atomic_inc(&vcc->stats->rx_err);
32468 + atomic_inc_unchecked(&vcc->stats->rx_err);
32469 atm_return(vcc, skb->truesize);
32470 dev_kfree_skb_any(skb);
32471 goto INCR_DLE;
32472 @@ -1330,7 +1330,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32473 if ((length > iadev->rx_buf_sz) || (length >
32474 (skb->len - sizeof(struct cpcs_trailer))))
32475 {
32476 - atomic_inc(&vcc->stats->rx_err);
32477 + atomic_inc_unchecked(&vcc->stats->rx_err);
32478 IF_ERR(printk("rx_dle_intr: Bad AAL5 trailer %d (skb len %d)",
32479 length, skb->len);)
32480 atm_return(vcc, skb->truesize);
32481 @@ -1346,7 +1346,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32482
32483 IF_RX(printk("rx_dle_intr: skb push");)
32484 vcc->push(vcc,skb);
32485 - atomic_inc(&vcc->stats->rx);
32486 + atomic_inc_unchecked(&vcc->stats->rx);
32487 iadev->rx_pkt_cnt++;
32488 }
32489 INCR_DLE:
32490 @@ -2826,15 +2826,15 @@ static int ia_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg)
32491 {
32492 struct k_sonet_stats *stats;
32493 stats = &PRIV(_ia_dev[board])->sonet_stats;
32494 - printk("section_bip: %d\n", atomic_read(&stats->section_bip));
32495 - printk("line_bip : %d\n", atomic_read(&stats->line_bip));
32496 - printk("path_bip : %d\n", atomic_read(&stats->path_bip));
32497 - printk("line_febe : %d\n", atomic_read(&stats->line_febe));
32498 - printk("path_febe : %d\n", atomic_read(&stats->path_febe));
32499 - printk("corr_hcs : %d\n", atomic_read(&stats->corr_hcs));
32500 - printk("uncorr_hcs : %d\n", atomic_read(&stats->uncorr_hcs));
32501 - printk("tx_cells : %d\n", atomic_read(&stats->tx_cells));
32502 - printk("rx_cells : %d\n", atomic_read(&stats->rx_cells));
32503 + printk("section_bip: %d\n", atomic_read_unchecked(&stats->section_bip));
32504 + printk("line_bip : %d\n", atomic_read_unchecked(&stats->line_bip));
32505 + printk("path_bip : %d\n", atomic_read_unchecked(&stats->path_bip));
32506 + printk("line_febe : %d\n", atomic_read_unchecked(&stats->line_febe));
32507 + printk("path_febe : %d\n", atomic_read_unchecked(&stats->path_febe));
32508 + printk("corr_hcs : %d\n", atomic_read_unchecked(&stats->corr_hcs));
32509 + printk("uncorr_hcs : %d\n", atomic_read_unchecked(&stats->uncorr_hcs));
32510 + printk("tx_cells : %d\n", atomic_read_unchecked(&stats->tx_cells));
32511 + printk("rx_cells : %d\n", atomic_read_unchecked(&stats->rx_cells));
32512 }
32513 ia_cmds.status = 0;
32514 break;
32515 @@ -2939,7 +2939,7 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
32516 if ((desc == 0) || (desc > iadev->num_tx_desc))
32517 {
32518 IF_ERR(printk(DEV_LABEL "invalid desc for send: %d\n", desc);)
32519 - atomic_inc(&vcc->stats->tx);
32520 + atomic_inc_unchecked(&vcc->stats->tx);
32521 if (vcc->pop)
32522 vcc->pop(vcc, skb);
32523 else
32524 @@ -3044,14 +3044,14 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
32525 ATM_DESC(skb) = vcc->vci;
32526 skb_queue_tail(&iadev->tx_dma_q, skb);
32527
32528 - atomic_inc(&vcc->stats->tx);
32529 + atomic_inc_unchecked(&vcc->stats->tx);
32530 iadev->tx_pkt_cnt++;
32531 /* Increment transaction counter */
32532 writel(2, iadev->dma+IPHASE5575_TX_COUNTER);
32533
32534 #if 0
32535 /* add flow control logic */
32536 - if (atomic_read(&vcc->stats->tx) % 20 == 0) {
32537 + if (atomic_read_unchecked(&vcc->stats->tx) % 20 == 0) {
32538 if (iavcc->vc_desc_cnt > 10) {
32539 vcc->tx_quota = vcc->tx_quota * 3 / 4;
32540 printk("Tx1: vcc->tx_quota = %d \n", (u32)vcc->tx_quota );
32541 diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
32542 index fa7d701..1e404c7 100644
32543 --- a/drivers/atm/lanai.c
32544 +++ b/drivers/atm/lanai.c
32545 @@ -1303,7 +1303,7 @@ static void lanai_send_one_aal5(struct lanai_dev *lanai,
32546 vcc_tx_add_aal5_trailer(lvcc, skb->len, 0, 0);
32547 lanai_endtx(lanai, lvcc);
32548 lanai_free_skb(lvcc->tx.atmvcc, skb);
32549 - atomic_inc(&lvcc->tx.atmvcc->stats->tx);
32550 + atomic_inc_unchecked(&lvcc->tx.atmvcc->stats->tx);
32551 }
32552
32553 /* Try to fill the buffer - don't call unless there is backlog */
32554 @@ -1426,7 +1426,7 @@ static void vcc_rx_aal5(struct lanai_vcc *lvcc, int endptr)
32555 ATM_SKB(skb)->vcc = lvcc->rx.atmvcc;
32556 __net_timestamp(skb);
32557 lvcc->rx.atmvcc->push(lvcc->rx.atmvcc, skb);
32558 - atomic_inc(&lvcc->rx.atmvcc->stats->rx);
32559 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx);
32560 out:
32561 lvcc->rx.buf.ptr = end;
32562 cardvcc_write(lvcc, endptr, vcc_rxreadptr);
32563 @@ -1667,7 +1667,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32564 DPRINTK("(itf %d) got RX service entry 0x%X for non-AAL5 "
32565 "vcc %d\n", lanai->number, (unsigned int) s, vci);
32566 lanai->stats.service_rxnotaal5++;
32567 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32568 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32569 return 0;
32570 }
32571 if (likely(!(s & (SERVICE_TRASH | SERVICE_STREAM | SERVICE_CRCERR)))) {
32572 @@ -1679,7 +1679,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32573 int bytes;
32574 read_unlock(&vcc_sklist_lock);
32575 DPRINTK("got trashed rx pdu on vci %d\n", vci);
32576 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32577 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32578 lvcc->stats.x.aal5.service_trash++;
32579 bytes = (SERVICE_GET_END(s) * 16) -
32580 (((unsigned long) lvcc->rx.buf.ptr) -
32581 @@ -1691,7 +1691,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32582 }
32583 if (s & SERVICE_STREAM) {
32584 read_unlock(&vcc_sklist_lock);
32585 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32586 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32587 lvcc->stats.x.aal5.service_stream++;
32588 printk(KERN_ERR DEV_LABEL "(itf %d): Got AAL5 stream "
32589 "PDU on VCI %d!\n", lanai->number, vci);
32590 @@ -1699,7 +1699,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32591 return 0;
32592 }
32593 DPRINTK("got rx crc error on vci %d\n", vci);
32594 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32595 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32596 lvcc->stats.x.aal5.service_rxcrc++;
32597 lvcc->rx.buf.ptr = &lvcc->rx.buf.start[SERVICE_GET_END(s) * 4];
32598 cardvcc_write(lvcc, SERVICE_GET_END(s), vcc_rxreadptr);
32599 diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
32600 index 6587dc2..149833d 100644
32601 --- a/drivers/atm/nicstar.c
32602 +++ b/drivers/atm/nicstar.c
32603 @@ -1641,7 +1641,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32604 if ((vc = (vc_map *) vcc->dev_data) == NULL) {
32605 printk("nicstar%d: vcc->dev_data == NULL on ns_send().\n",
32606 card->index);
32607 - atomic_inc(&vcc->stats->tx_err);
32608 + atomic_inc_unchecked(&vcc->stats->tx_err);
32609 dev_kfree_skb_any(skb);
32610 return -EINVAL;
32611 }
32612 @@ -1649,7 +1649,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32613 if (!vc->tx) {
32614 printk("nicstar%d: Trying to transmit on a non-tx VC.\n",
32615 card->index);
32616 - atomic_inc(&vcc->stats->tx_err);
32617 + atomic_inc_unchecked(&vcc->stats->tx_err);
32618 dev_kfree_skb_any(skb);
32619 return -EINVAL;
32620 }
32621 @@ -1657,14 +1657,14 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32622 if (vcc->qos.aal != ATM_AAL5 && vcc->qos.aal != ATM_AAL0) {
32623 printk("nicstar%d: Only AAL0 and AAL5 are supported.\n",
32624 card->index);
32625 - atomic_inc(&vcc->stats->tx_err);
32626 + atomic_inc_unchecked(&vcc->stats->tx_err);
32627 dev_kfree_skb_any(skb);
32628 return -EINVAL;
32629 }
32630
32631 if (skb_shinfo(skb)->nr_frags != 0) {
32632 printk("nicstar%d: No scatter-gather yet.\n", card->index);
32633 - atomic_inc(&vcc->stats->tx_err);
32634 + atomic_inc_unchecked(&vcc->stats->tx_err);
32635 dev_kfree_skb_any(skb);
32636 return -EINVAL;
32637 }
32638 @@ -1712,11 +1712,11 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32639 }
32640
32641 if (push_scqe(card, vc, scq, &scqe, skb) != 0) {
32642 - atomic_inc(&vcc->stats->tx_err);
32643 + atomic_inc_unchecked(&vcc->stats->tx_err);
32644 dev_kfree_skb_any(skb);
32645 return -EIO;
32646 }
32647 - atomic_inc(&vcc->stats->tx);
32648 + atomic_inc_unchecked(&vcc->stats->tx);
32649
32650 return 0;
32651 }
32652 @@ -2033,14 +2033,14 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32653 printk
32654 ("nicstar%d: Can't allocate buffers for aal0.\n",
32655 card->index);
32656 - atomic_add(i, &vcc->stats->rx_drop);
32657 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
32658 break;
32659 }
32660 if (!atm_charge(vcc, sb->truesize)) {
32661 RXPRINTK
32662 ("nicstar%d: atm_charge() dropped aal0 packets.\n",
32663 card->index);
32664 - atomic_add(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
32665 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
32666 dev_kfree_skb_any(sb);
32667 break;
32668 }
32669 @@ -2055,7 +2055,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32670 ATM_SKB(sb)->vcc = vcc;
32671 __net_timestamp(sb);
32672 vcc->push(vcc, sb);
32673 - atomic_inc(&vcc->stats->rx);
32674 + atomic_inc_unchecked(&vcc->stats->rx);
32675 cell += ATM_CELL_PAYLOAD;
32676 }
32677
32678 @@ -2072,7 +2072,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32679 if (iovb == NULL) {
32680 printk("nicstar%d: Out of iovec buffers.\n",
32681 card->index);
32682 - atomic_inc(&vcc->stats->rx_drop);
32683 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32684 recycle_rx_buf(card, skb);
32685 return;
32686 }
32687 @@ -2096,7 +2096,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32688 small or large buffer itself. */
32689 } else if (NS_PRV_IOVCNT(iovb) >= NS_MAX_IOVECS) {
32690 printk("nicstar%d: received too big AAL5 SDU.\n", card->index);
32691 - atomic_inc(&vcc->stats->rx_err);
32692 + atomic_inc_unchecked(&vcc->stats->rx_err);
32693 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
32694 NS_MAX_IOVECS);
32695 NS_PRV_IOVCNT(iovb) = 0;
32696 @@ -2116,7 +2116,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32697 ("nicstar%d: Expected a small buffer, and this is not one.\n",
32698 card->index);
32699 which_list(card, skb);
32700 - atomic_inc(&vcc->stats->rx_err);
32701 + atomic_inc_unchecked(&vcc->stats->rx_err);
32702 recycle_rx_buf(card, skb);
32703 vc->rx_iov = NULL;
32704 recycle_iov_buf(card, iovb);
32705 @@ -2129,7 +2129,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32706 ("nicstar%d: Expected a large buffer, and this is not one.\n",
32707 card->index);
32708 which_list(card, skb);
32709 - atomic_inc(&vcc->stats->rx_err);
32710 + atomic_inc_unchecked(&vcc->stats->rx_err);
32711 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
32712 NS_PRV_IOVCNT(iovb));
32713 vc->rx_iov = NULL;
32714 @@ -2152,7 +2152,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32715 printk(" - PDU size mismatch.\n");
32716 else
32717 printk(".\n");
32718 - atomic_inc(&vcc->stats->rx_err);
32719 + atomic_inc_unchecked(&vcc->stats->rx_err);
32720 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
32721 NS_PRV_IOVCNT(iovb));
32722 vc->rx_iov = NULL;
32723 @@ -2166,7 +2166,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32724 /* skb points to a small buffer */
32725 if (!atm_charge(vcc, skb->truesize)) {
32726 push_rxbufs(card, skb);
32727 - atomic_inc(&vcc->stats->rx_drop);
32728 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32729 } else {
32730 skb_put(skb, len);
32731 dequeue_sm_buf(card, skb);
32732 @@ -2176,7 +2176,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32733 ATM_SKB(skb)->vcc = vcc;
32734 __net_timestamp(skb);
32735 vcc->push(vcc, skb);
32736 - atomic_inc(&vcc->stats->rx);
32737 + atomic_inc_unchecked(&vcc->stats->rx);
32738 }
32739 } else if (NS_PRV_IOVCNT(iovb) == 2) { /* One small plus one large buffer */
32740 struct sk_buff *sb;
32741 @@ -2187,7 +2187,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32742 if (len <= NS_SMBUFSIZE) {
32743 if (!atm_charge(vcc, sb->truesize)) {
32744 push_rxbufs(card, sb);
32745 - atomic_inc(&vcc->stats->rx_drop);
32746 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32747 } else {
32748 skb_put(sb, len);
32749 dequeue_sm_buf(card, sb);
32750 @@ -2197,7 +2197,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32751 ATM_SKB(sb)->vcc = vcc;
32752 __net_timestamp(sb);
32753 vcc->push(vcc, sb);
32754 - atomic_inc(&vcc->stats->rx);
32755 + atomic_inc_unchecked(&vcc->stats->rx);
32756 }
32757
32758 push_rxbufs(card, skb);
32759 @@ -2206,7 +2206,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32760
32761 if (!atm_charge(vcc, skb->truesize)) {
32762 push_rxbufs(card, skb);
32763 - atomic_inc(&vcc->stats->rx_drop);
32764 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32765 } else {
32766 dequeue_lg_buf(card, skb);
32767 #ifdef NS_USE_DESTRUCTORS
32768 @@ -2219,7 +2219,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32769 ATM_SKB(skb)->vcc = vcc;
32770 __net_timestamp(skb);
32771 vcc->push(vcc, skb);
32772 - atomic_inc(&vcc->stats->rx);
32773 + atomic_inc_unchecked(&vcc->stats->rx);
32774 }
32775
32776 push_rxbufs(card, sb);
32777 @@ -2240,7 +2240,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32778 printk
32779 ("nicstar%d: Out of huge buffers.\n",
32780 card->index);
32781 - atomic_inc(&vcc->stats->rx_drop);
32782 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32783 recycle_iovec_rx_bufs(card,
32784 (struct iovec *)
32785 iovb->data,
32786 @@ -2291,7 +2291,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32787 card->hbpool.count++;
32788 } else
32789 dev_kfree_skb_any(hb);
32790 - atomic_inc(&vcc->stats->rx_drop);
32791 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32792 } else {
32793 /* Copy the small buffer to the huge buffer */
32794 sb = (struct sk_buff *)iov->iov_base;
32795 @@ -2328,7 +2328,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32796 #endif /* NS_USE_DESTRUCTORS */
32797 __net_timestamp(hb);
32798 vcc->push(vcc, hb);
32799 - atomic_inc(&vcc->stats->rx);
32800 + atomic_inc_unchecked(&vcc->stats->rx);
32801 }
32802 }
32803
32804 diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
32805 index 32784d1..4a8434a 100644
32806 --- a/drivers/atm/solos-pci.c
32807 +++ b/drivers/atm/solos-pci.c
32808 @@ -838,7 +838,7 @@ void solos_bh(unsigned long card_arg)
32809 }
32810 atm_charge(vcc, skb->truesize);
32811 vcc->push(vcc, skb);
32812 - atomic_inc(&vcc->stats->rx);
32813 + atomic_inc_unchecked(&vcc->stats->rx);
32814 break;
32815
32816 case PKT_STATUS:
32817 @@ -1116,7 +1116,7 @@ static uint32_t fpga_tx(struct solos_card *card)
32818 vcc = SKB_CB(oldskb)->vcc;
32819
32820 if (vcc) {
32821 - atomic_inc(&vcc->stats->tx);
32822 + atomic_inc_unchecked(&vcc->stats->tx);
32823 solos_pop(vcc, oldskb);
32824 } else {
32825 dev_kfree_skb_irq(oldskb);
32826 diff --git a/drivers/atm/suni.c b/drivers/atm/suni.c
32827 index 0215934..ce9f5b1 100644
32828 --- a/drivers/atm/suni.c
32829 +++ b/drivers/atm/suni.c
32830 @@ -49,8 +49,8 @@ static DEFINE_SPINLOCK(sunis_lock);
32831
32832
32833 #define ADD_LIMITED(s,v) \
32834 - atomic_add((v),&stats->s); \
32835 - if (atomic_read(&stats->s) < 0) atomic_set(&stats->s,INT_MAX);
32836 + atomic_add_unchecked((v),&stats->s); \
32837 + if (atomic_read_unchecked(&stats->s) < 0) atomic_set_unchecked(&stats->s,INT_MAX);
32838
32839
32840 static void suni_hz(unsigned long from_timer)
32841 diff --git a/drivers/atm/uPD98402.c b/drivers/atm/uPD98402.c
32842 index 5120a96..e2572bd 100644
32843 --- a/drivers/atm/uPD98402.c
32844 +++ b/drivers/atm/uPD98402.c
32845 @@ -42,7 +42,7 @@ static int fetch_stats(struct atm_dev *dev,struct sonet_stats __user *arg,int ze
32846 struct sonet_stats tmp;
32847 int error = 0;
32848
32849 - atomic_add(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
32850 + atomic_add_unchecked(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
32851 sonet_copy_stats(&PRIV(dev)->sonet_stats,&tmp);
32852 if (arg) error = copy_to_user(arg,&tmp,sizeof(tmp));
32853 if (zero && !error) {
32854 @@ -161,9 +161,9 @@ static int uPD98402_ioctl(struct atm_dev *dev,unsigned int cmd,void __user *arg)
32855
32856
32857 #define ADD_LIMITED(s,v) \
32858 - { atomic_add(GET(v),&PRIV(dev)->sonet_stats.s); \
32859 - if (atomic_read(&PRIV(dev)->sonet_stats.s) < 0) \
32860 - atomic_set(&PRIV(dev)->sonet_stats.s,INT_MAX); }
32861 + { atomic_add_unchecked(GET(v),&PRIV(dev)->sonet_stats.s); \
32862 + if (atomic_read_unchecked(&PRIV(dev)->sonet_stats.s) < 0) \
32863 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.s,INT_MAX); }
32864
32865
32866 static void stat_event(struct atm_dev *dev)
32867 @@ -194,7 +194,7 @@ static void uPD98402_int(struct atm_dev *dev)
32868 if (reason & uPD98402_INT_PFM) stat_event(dev);
32869 if (reason & uPD98402_INT_PCO) {
32870 (void) GET(PCOCR); /* clear interrupt cause */
32871 - atomic_add(GET(HECCT),
32872 + atomic_add_unchecked(GET(HECCT),
32873 &PRIV(dev)->sonet_stats.uncorr_hcs);
32874 }
32875 if ((reason & uPD98402_INT_RFO) &&
32876 @@ -222,9 +222,9 @@ static int uPD98402_start(struct atm_dev *dev)
32877 PUT(~(uPD98402_INT_PFM | uPD98402_INT_ALM | uPD98402_INT_RFO |
32878 uPD98402_INT_LOS),PIMR); /* enable them */
32879 (void) fetch_stats(dev,NULL,1); /* clear kernel counters */
32880 - atomic_set(&PRIV(dev)->sonet_stats.corr_hcs,-1);
32881 - atomic_set(&PRIV(dev)->sonet_stats.tx_cells,-1);
32882 - atomic_set(&PRIV(dev)->sonet_stats.rx_cells,-1);
32883 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.corr_hcs,-1);
32884 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.tx_cells,-1);
32885 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.rx_cells,-1);
32886 return 0;
32887 }
32888
32889 diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
32890 index 969c3c2..9b72956 100644
32891 --- a/drivers/atm/zatm.c
32892 +++ b/drivers/atm/zatm.c
32893 @@ -459,7 +459,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
32894 }
32895 if (!size) {
32896 dev_kfree_skb_irq(skb);
32897 - if (vcc) atomic_inc(&vcc->stats->rx_err);
32898 + if (vcc) atomic_inc_unchecked(&vcc->stats->rx_err);
32899 continue;
32900 }
32901 if (!atm_charge(vcc,skb->truesize)) {
32902 @@ -469,7 +469,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
32903 skb->len = size;
32904 ATM_SKB(skb)->vcc = vcc;
32905 vcc->push(vcc,skb);
32906 - atomic_inc(&vcc->stats->rx);
32907 + atomic_inc_unchecked(&vcc->stats->rx);
32908 }
32909 zout(pos & 0xffff,MTA(mbx));
32910 #if 0 /* probably a stupid idea */
32911 @@ -733,7 +733,7 @@ if (*ZATM_PRV_DSC(skb) != (uPD98401_TXPD_V | uPD98401_TXPD_DP |
32912 skb_queue_head(&zatm_vcc->backlog,skb);
32913 break;
32914 }
32915 - atomic_inc(&vcc->stats->tx);
32916 + atomic_inc_unchecked(&vcc->stats->tx);
32917 wake_up(&zatm_vcc->tx_wait);
32918 }
32919
32920 diff --git a/drivers/base/bus.c b/drivers/base/bus.c
32921 index 519865b..e540db3 100644
32922 --- a/drivers/base/bus.c
32923 +++ b/drivers/base/bus.c
32924 @@ -1163,7 +1163,7 @@ int subsys_interface_register(struct subsys_interface *sif)
32925 return -EINVAL;
32926
32927 mutex_lock(&subsys->p->mutex);
32928 - list_add_tail(&sif->node, &subsys->p->interfaces);
32929 + pax_list_add_tail((struct list_head *)&sif->node, &subsys->p->interfaces);
32930 if (sif->add_dev) {
32931 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
32932 while ((dev = subsys_dev_iter_next(&iter)))
32933 @@ -1188,7 +1188,7 @@ void subsys_interface_unregister(struct subsys_interface *sif)
32934 subsys = sif->subsys;
32935
32936 mutex_lock(&subsys->p->mutex);
32937 - list_del_init(&sif->node);
32938 + pax_list_del_init((struct list_head *)&sif->node);
32939 if (sif->remove_dev) {
32940 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
32941 while ((dev = subsys_dev_iter_next(&iter)))
32942 diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
32943 index 01fc5b0..d0ed716 100644
32944 --- a/drivers/base/devtmpfs.c
32945 +++ b/drivers/base/devtmpfs.c
32946 @@ -348,7 +348,7 @@ int devtmpfs_mount(const char *mntdir)
32947 if (!thread)
32948 return 0;
32949
32950 - err = sys_mount("devtmpfs", (char *)mntdir, "devtmpfs", MS_SILENT, NULL);
32951 + err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)mntdir, (char __force_user *)"devtmpfs", MS_SILENT, NULL);
32952 if (err)
32953 printk(KERN_INFO "devtmpfs: error mounting %i\n", err);
32954 else
32955 diff --git a/drivers/base/node.c b/drivers/base/node.c
32956 index fac124a..66bd4ab 100644
32957 --- a/drivers/base/node.c
32958 +++ b/drivers/base/node.c
32959 @@ -625,7 +625,7 @@ static ssize_t print_nodes_state(enum node_states state, char *buf)
32960 struct node_attr {
32961 struct device_attribute attr;
32962 enum node_states state;
32963 -};
32964 +} __do_const;
32965
32966 static ssize_t show_node_state(struct device *dev,
32967 struct device_attribute *attr, char *buf)
32968 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
32969 index 9a6b05a..2fc8fb9 100644
32970 --- a/drivers/base/power/domain.c
32971 +++ b/drivers/base/power/domain.c
32972 @@ -1850,7 +1850,7 @@ int pm_genpd_attach_cpuidle(struct generic_pm_domain *genpd, int state)
32973 {
32974 struct cpuidle_driver *cpuidle_drv;
32975 struct gpd_cpu_data *cpu_data;
32976 - struct cpuidle_state *idle_state;
32977 + cpuidle_state_no_const *idle_state;
32978 int ret = 0;
32979
32980 if (IS_ERR_OR_NULL(genpd) || state < 0)
32981 @@ -1918,7 +1918,7 @@ int pm_genpd_name_attach_cpuidle(const char *name, int state)
32982 int pm_genpd_detach_cpuidle(struct generic_pm_domain *genpd)
32983 {
32984 struct gpd_cpu_data *cpu_data;
32985 - struct cpuidle_state *idle_state;
32986 + cpuidle_state_no_const *idle_state;
32987 int ret = 0;
32988
32989 if (IS_ERR_OR_NULL(genpd))
32990 diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
32991 index 79715e7..df06b3b 100644
32992 --- a/drivers/base/power/wakeup.c
32993 +++ b/drivers/base/power/wakeup.c
32994 @@ -29,14 +29,14 @@ bool events_check_enabled __read_mostly;
32995 * They need to be modified together atomically, so it's better to use one
32996 * atomic variable to hold them both.
32997 */
32998 -static atomic_t combined_event_count = ATOMIC_INIT(0);
32999 +static atomic_unchecked_t combined_event_count = ATOMIC_INIT(0);
33000
33001 #define IN_PROGRESS_BITS (sizeof(int) * 4)
33002 #define MAX_IN_PROGRESS ((1 << IN_PROGRESS_BITS) - 1)
33003
33004 static void split_counters(unsigned int *cnt, unsigned int *inpr)
33005 {
33006 - unsigned int comb = atomic_read(&combined_event_count);
33007 + unsigned int comb = atomic_read_unchecked(&combined_event_count);
33008
33009 *cnt = (comb >> IN_PROGRESS_BITS);
33010 *inpr = comb & MAX_IN_PROGRESS;
33011 @@ -395,7 +395,7 @@ static void wakeup_source_activate(struct wakeup_source *ws)
33012 ws->start_prevent_time = ws->last_time;
33013
33014 /* Increment the counter of events in progress. */
33015 - cec = atomic_inc_return(&combined_event_count);
33016 + cec = atomic_inc_return_unchecked(&combined_event_count);
33017
33018 trace_wakeup_source_activate(ws->name, cec);
33019 }
33020 @@ -521,7 +521,7 @@ static void wakeup_source_deactivate(struct wakeup_source *ws)
33021 * Increment the counter of registered wakeup events and decrement the
33022 * couter of wakeup events in progress simultaneously.
33023 */
33024 - cec = atomic_add_return(MAX_IN_PROGRESS, &combined_event_count);
33025 + cec = atomic_add_return_unchecked(MAX_IN_PROGRESS, &combined_event_count);
33026 trace_wakeup_source_deactivate(ws->name, cec);
33027
33028 split_counters(&cnt, &inpr);
33029 diff --git a/drivers/base/syscore.c b/drivers/base/syscore.c
33030 index e8d11b6..7b1b36f 100644
33031 --- a/drivers/base/syscore.c
33032 +++ b/drivers/base/syscore.c
33033 @@ -21,7 +21,7 @@ static DEFINE_MUTEX(syscore_ops_lock);
33034 void register_syscore_ops(struct syscore_ops *ops)
33035 {
33036 mutex_lock(&syscore_ops_lock);
33037 - list_add_tail(&ops->node, &syscore_ops_list);
33038 + pax_list_add_tail((struct list_head *)&ops->node, &syscore_ops_list);
33039 mutex_unlock(&syscore_ops_lock);
33040 }
33041 EXPORT_SYMBOL_GPL(register_syscore_ops);
33042 @@ -33,7 +33,7 @@ EXPORT_SYMBOL_GPL(register_syscore_ops);
33043 void unregister_syscore_ops(struct syscore_ops *ops)
33044 {
33045 mutex_lock(&syscore_ops_lock);
33046 - list_del(&ops->node);
33047 + pax_list_del((struct list_head *)&ops->node);
33048 mutex_unlock(&syscore_ops_lock);
33049 }
33050 EXPORT_SYMBOL_GPL(unregister_syscore_ops);
33051 diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
33052 index 1c1b8e5..b7fc681 100644
33053 --- a/drivers/block/cciss.c
33054 +++ b/drivers/block/cciss.c
33055 @@ -1196,6 +1196,8 @@ static int cciss_ioctl32_passthru(struct block_device *bdev, fmode_t mode,
33056 int err;
33057 u32 cp;
33058
33059 + memset(&arg64, 0, sizeof(arg64));
33060 +
33061 err = 0;
33062 err |=
33063 copy_from_user(&arg64.LUN_info, &arg32->LUN_info,
33064 @@ -3005,7 +3007,7 @@ static void start_io(ctlr_info_t *h)
33065 while (!list_empty(&h->reqQ)) {
33066 c = list_entry(h->reqQ.next, CommandList_struct, list);
33067 /* can't do anything if fifo is full */
33068 - if ((h->access.fifo_full(h))) {
33069 + if ((h->access->fifo_full(h))) {
33070 dev_warn(&h->pdev->dev, "fifo full\n");
33071 break;
33072 }
33073 @@ -3015,7 +3017,7 @@ static void start_io(ctlr_info_t *h)
33074 h->Qdepth--;
33075
33076 /* Tell the controller execute command */
33077 - h->access.submit_command(h, c);
33078 + h->access->submit_command(h, c);
33079
33080 /* Put job onto the completed Q */
33081 addQ(&h->cmpQ, c);
33082 @@ -3441,17 +3443,17 @@ startio:
33083
33084 static inline unsigned long get_next_completion(ctlr_info_t *h)
33085 {
33086 - return h->access.command_completed(h);
33087 + return h->access->command_completed(h);
33088 }
33089
33090 static inline int interrupt_pending(ctlr_info_t *h)
33091 {
33092 - return h->access.intr_pending(h);
33093 + return h->access->intr_pending(h);
33094 }
33095
33096 static inline long interrupt_not_for_us(ctlr_info_t *h)
33097 {
33098 - return ((h->access.intr_pending(h) == 0) ||
33099 + return ((h->access->intr_pending(h) == 0) ||
33100 (h->interrupts_enabled == 0));
33101 }
33102
33103 @@ -3484,7 +3486,7 @@ static inline u32 next_command(ctlr_info_t *h)
33104 u32 a;
33105
33106 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
33107 - return h->access.command_completed(h);
33108 + return h->access->command_completed(h);
33109
33110 if ((*(h->reply_pool_head) & 1) == (h->reply_pool_wraparound)) {
33111 a = *(h->reply_pool_head); /* Next cmd in ring buffer */
33112 @@ -4041,7 +4043,7 @@ static void cciss_put_controller_into_performant_mode(ctlr_info_t *h)
33113 trans_support & CFGTBL_Trans_use_short_tags);
33114
33115 /* Change the access methods to the performant access methods */
33116 - h->access = SA5_performant_access;
33117 + h->access = &SA5_performant_access;
33118 h->transMethod = CFGTBL_Trans_Performant;
33119
33120 return;
33121 @@ -4310,7 +4312,7 @@ static int cciss_pci_init(ctlr_info_t *h)
33122 if (prod_index < 0)
33123 return -ENODEV;
33124 h->product_name = products[prod_index].product_name;
33125 - h->access = *(products[prod_index].access);
33126 + h->access = products[prod_index].access;
33127
33128 if (cciss_board_disabled(h)) {
33129 dev_warn(&h->pdev->dev, "controller appears to be disabled\n");
33130 @@ -5032,7 +5034,7 @@ reinit_after_soft_reset:
33131 }
33132
33133 /* make sure the board interrupts are off */
33134 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33135 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33136 rc = cciss_request_irq(h, do_cciss_msix_intr, do_cciss_intx);
33137 if (rc)
33138 goto clean2;
33139 @@ -5082,7 +5084,7 @@ reinit_after_soft_reset:
33140 * fake ones to scoop up any residual completions.
33141 */
33142 spin_lock_irqsave(&h->lock, flags);
33143 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33144 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33145 spin_unlock_irqrestore(&h->lock, flags);
33146 free_irq(h->intr[h->intr_mode], h);
33147 rc = cciss_request_irq(h, cciss_msix_discard_completions,
33148 @@ -5102,9 +5104,9 @@ reinit_after_soft_reset:
33149 dev_info(&h->pdev->dev, "Board READY.\n");
33150 dev_info(&h->pdev->dev,
33151 "Waiting for stale completions to drain.\n");
33152 - h->access.set_intr_mask(h, CCISS_INTR_ON);
33153 + h->access->set_intr_mask(h, CCISS_INTR_ON);
33154 msleep(10000);
33155 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33156 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33157
33158 rc = controller_reset_failed(h->cfgtable);
33159 if (rc)
33160 @@ -5127,7 +5129,7 @@ reinit_after_soft_reset:
33161 cciss_scsi_setup(h);
33162
33163 /* Turn the interrupts on so we can service requests */
33164 - h->access.set_intr_mask(h, CCISS_INTR_ON);
33165 + h->access->set_intr_mask(h, CCISS_INTR_ON);
33166
33167 /* Get the firmware version */
33168 inq_buff = kzalloc(sizeof(InquiryData_struct), GFP_KERNEL);
33169 @@ -5199,7 +5201,7 @@ static void cciss_shutdown(struct pci_dev *pdev)
33170 kfree(flush_buf);
33171 if (return_code != IO_OK)
33172 dev_warn(&h->pdev->dev, "Error flushing cache\n");
33173 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33174 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33175 free_irq(h->intr[h->intr_mode], h);
33176 }
33177
33178 diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
33179 index 7fda30e..eb5dfe0 100644
33180 --- a/drivers/block/cciss.h
33181 +++ b/drivers/block/cciss.h
33182 @@ -101,7 +101,7 @@ struct ctlr_info
33183 /* information about each logical volume */
33184 drive_info_struct *drv[CISS_MAX_LUN];
33185
33186 - struct access_method access;
33187 + struct access_method *access;
33188
33189 /* queue and queue Info */
33190 struct list_head reqQ;
33191 diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
33192 index 3f08713..56a586a 100644
33193 --- a/drivers/block/cpqarray.c
33194 +++ b/drivers/block/cpqarray.c
33195 @@ -404,7 +404,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
33196 if (register_blkdev(COMPAQ_SMART2_MAJOR+i, hba[i]->devname)) {
33197 goto Enomem4;
33198 }
33199 - hba[i]->access.set_intr_mask(hba[i], 0);
33200 + hba[i]->access->set_intr_mask(hba[i], 0);
33201 if (request_irq(hba[i]->intr, do_ida_intr,
33202 IRQF_DISABLED|IRQF_SHARED, hba[i]->devname, hba[i]))
33203 {
33204 @@ -459,7 +459,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
33205 add_timer(&hba[i]->timer);
33206
33207 /* Enable IRQ now that spinlock and rate limit timer are set up */
33208 - hba[i]->access.set_intr_mask(hba[i], FIFO_NOT_EMPTY);
33209 + hba[i]->access->set_intr_mask(hba[i], FIFO_NOT_EMPTY);
33210
33211 for(j=0; j<NWD; j++) {
33212 struct gendisk *disk = ida_gendisk[i][j];
33213 @@ -694,7 +694,7 @@ DBGINFO(
33214 for(i=0; i<NR_PRODUCTS; i++) {
33215 if (board_id == products[i].board_id) {
33216 c->product_name = products[i].product_name;
33217 - c->access = *(products[i].access);
33218 + c->access = products[i].access;
33219 break;
33220 }
33221 }
33222 @@ -792,7 +792,7 @@ static int cpqarray_eisa_detect(void)
33223 hba[ctlr]->intr = intr;
33224 sprintf(hba[ctlr]->devname, "ida%d", nr_ctlr);
33225 hba[ctlr]->product_name = products[j].product_name;
33226 - hba[ctlr]->access = *(products[j].access);
33227 + hba[ctlr]->access = products[j].access;
33228 hba[ctlr]->ctlr = ctlr;
33229 hba[ctlr]->board_id = board_id;
33230 hba[ctlr]->pci_dev = NULL; /* not PCI */
33231 @@ -980,7 +980,7 @@ static void start_io(ctlr_info_t *h)
33232
33233 while((c = h->reqQ) != NULL) {
33234 /* Can't do anything if we're busy */
33235 - if (h->access.fifo_full(h) == 0)
33236 + if (h->access->fifo_full(h) == 0)
33237 return;
33238
33239 /* Get the first entry from the request Q */
33240 @@ -988,7 +988,7 @@ static void start_io(ctlr_info_t *h)
33241 h->Qdepth--;
33242
33243 /* Tell the controller to do our bidding */
33244 - h->access.submit_command(h, c);
33245 + h->access->submit_command(h, c);
33246
33247 /* Get onto the completion Q */
33248 addQ(&h->cmpQ, c);
33249 @@ -1050,7 +1050,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
33250 unsigned long flags;
33251 __u32 a,a1;
33252
33253 - istat = h->access.intr_pending(h);
33254 + istat = h->access->intr_pending(h);
33255 /* Is this interrupt for us? */
33256 if (istat == 0)
33257 return IRQ_NONE;
33258 @@ -1061,7 +1061,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
33259 */
33260 spin_lock_irqsave(IDA_LOCK(h->ctlr), flags);
33261 if (istat & FIFO_NOT_EMPTY) {
33262 - while((a = h->access.command_completed(h))) {
33263 + while((a = h->access->command_completed(h))) {
33264 a1 = a; a &= ~3;
33265 if ((c = h->cmpQ) == NULL)
33266 {
33267 @@ -1449,11 +1449,11 @@ static int sendcmd(
33268 /*
33269 * Disable interrupt
33270 */
33271 - info_p->access.set_intr_mask(info_p, 0);
33272 + info_p->access->set_intr_mask(info_p, 0);
33273 /* Make sure there is room in the command FIFO */
33274 /* Actually it should be completely empty at this time. */
33275 for (i = 200000; i > 0; i--) {
33276 - temp = info_p->access.fifo_full(info_p);
33277 + temp = info_p->access->fifo_full(info_p);
33278 if (temp != 0) {
33279 break;
33280 }
33281 @@ -1466,7 +1466,7 @@ DBG(
33282 /*
33283 * Send the cmd
33284 */
33285 - info_p->access.submit_command(info_p, c);
33286 + info_p->access->submit_command(info_p, c);
33287 complete = pollcomplete(ctlr);
33288
33289 pci_unmap_single(info_p->pci_dev, (dma_addr_t) c->req.sg[0].addr,
33290 @@ -1549,9 +1549,9 @@ static int revalidate_allvol(ctlr_info_t *host)
33291 * we check the new geometry. Then turn interrupts back on when
33292 * we're done.
33293 */
33294 - host->access.set_intr_mask(host, 0);
33295 + host->access->set_intr_mask(host, 0);
33296 getgeometry(ctlr);
33297 - host->access.set_intr_mask(host, FIFO_NOT_EMPTY);
33298 + host->access->set_intr_mask(host, FIFO_NOT_EMPTY);
33299
33300 for(i=0; i<NWD; i++) {
33301 struct gendisk *disk = ida_gendisk[ctlr][i];
33302 @@ -1591,7 +1591,7 @@ static int pollcomplete(int ctlr)
33303 /* Wait (up to 2 seconds) for a command to complete */
33304
33305 for (i = 200000; i > 0; i--) {
33306 - done = hba[ctlr]->access.command_completed(hba[ctlr]);
33307 + done = hba[ctlr]->access->command_completed(hba[ctlr]);
33308 if (done == 0) {
33309 udelay(10); /* a short fixed delay */
33310 } else
33311 diff --git a/drivers/block/cpqarray.h b/drivers/block/cpqarray.h
33312 index be73e9d..7fbf140 100644
33313 --- a/drivers/block/cpqarray.h
33314 +++ b/drivers/block/cpqarray.h
33315 @@ -99,7 +99,7 @@ struct ctlr_info {
33316 drv_info_t drv[NWD];
33317 struct proc_dir_entry *proc;
33318
33319 - struct access_method access;
33320 + struct access_method *access;
33321
33322 cmdlist_t *reqQ;
33323 cmdlist_t *cmpQ;
33324 diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
33325 index 6b51afa..17e1191 100644
33326 --- a/drivers/block/drbd/drbd_int.h
33327 +++ b/drivers/block/drbd/drbd_int.h
33328 @@ -582,7 +582,7 @@ struct drbd_epoch {
33329 struct drbd_tconn *tconn;
33330 struct list_head list;
33331 unsigned int barrier_nr;
33332 - atomic_t epoch_size; /* increased on every request added. */
33333 + atomic_unchecked_t epoch_size; /* increased on every request added. */
33334 atomic_t active; /* increased on every req. added, and dec on every finished. */
33335 unsigned long flags;
33336 };
33337 @@ -1011,7 +1011,7 @@ struct drbd_conf {
33338 int al_tr_cycle;
33339 int al_tr_pos; /* position of the next transaction in the journal */
33340 wait_queue_head_t seq_wait;
33341 - atomic_t packet_seq;
33342 + atomic_unchecked_t packet_seq;
33343 unsigned int peer_seq;
33344 spinlock_t peer_seq_lock;
33345 unsigned int minor;
33346 @@ -1527,7 +1527,7 @@ static inline int drbd_setsockopt(struct socket *sock, int level, int optname,
33347 char __user *uoptval;
33348 int err;
33349
33350 - uoptval = (char __user __force *)optval;
33351 + uoptval = (char __force_user *)optval;
33352
33353 set_fs(KERNEL_DS);
33354 if (level == SOL_SOCKET)
33355 diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
33356 index 54d03d4..332f311 100644
33357 --- a/drivers/block/drbd/drbd_main.c
33358 +++ b/drivers/block/drbd/drbd_main.c
33359 @@ -1317,7 +1317,7 @@ static int _drbd_send_ack(struct drbd_conf *mdev, enum drbd_packet cmd,
33360 p->sector = sector;
33361 p->block_id = block_id;
33362 p->blksize = blksize;
33363 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
33364 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
33365 return drbd_send_command(mdev, sock, cmd, sizeof(*p), NULL, 0);
33366 }
33367
33368 @@ -1619,7 +1619,7 @@ int drbd_send_dblock(struct drbd_conf *mdev, struct drbd_request *req)
33369 return -EIO;
33370 p->sector = cpu_to_be64(req->i.sector);
33371 p->block_id = (unsigned long)req;
33372 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
33373 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
33374 dp_flags = bio_flags_to_wire(mdev, req->master_bio->bi_rw);
33375 if (mdev->state.conn >= C_SYNC_SOURCE &&
33376 mdev->state.conn <= C_PAUSED_SYNC_T)
33377 @@ -2574,8 +2574,8 @@ void conn_destroy(struct kref *kref)
33378 {
33379 struct drbd_tconn *tconn = container_of(kref, struct drbd_tconn, kref);
33380
33381 - if (atomic_read(&tconn->current_epoch->epoch_size) != 0)
33382 - conn_err(tconn, "epoch_size:%d\n", atomic_read(&tconn->current_epoch->epoch_size));
33383 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size) != 0)
33384 + conn_err(tconn, "epoch_size:%d\n", atomic_read_unchecked(&tconn->current_epoch->epoch_size));
33385 kfree(tconn->current_epoch);
33386
33387 idr_destroy(&tconn->volumes);
33388 diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
33389 index 2f5fffd..b22a1ae 100644
33390 --- a/drivers/block/drbd/drbd_receiver.c
33391 +++ b/drivers/block/drbd/drbd_receiver.c
33392 @@ -833,7 +833,7 @@ int drbd_connected(struct drbd_conf *mdev)
33393 {
33394 int err;
33395
33396 - atomic_set(&mdev->packet_seq, 0);
33397 + atomic_set_unchecked(&mdev->packet_seq, 0);
33398 mdev->peer_seq = 0;
33399
33400 mdev->state_mutex = mdev->tconn->agreed_pro_version < 100 ?
33401 @@ -1191,7 +1191,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
33402 do {
33403 next_epoch = NULL;
33404
33405 - epoch_size = atomic_read(&epoch->epoch_size);
33406 + epoch_size = atomic_read_unchecked(&epoch->epoch_size);
33407
33408 switch (ev & ~EV_CLEANUP) {
33409 case EV_PUT:
33410 @@ -1231,7 +1231,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
33411 rv = FE_DESTROYED;
33412 } else {
33413 epoch->flags = 0;
33414 - atomic_set(&epoch->epoch_size, 0);
33415 + atomic_set_unchecked(&epoch->epoch_size, 0);
33416 /* atomic_set(&epoch->active, 0); is already zero */
33417 if (rv == FE_STILL_LIVE)
33418 rv = FE_RECYCLED;
33419 @@ -1449,7 +1449,7 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
33420 conn_wait_active_ee_empty(tconn);
33421 drbd_flush(tconn);
33422
33423 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
33424 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
33425 epoch = kmalloc(sizeof(struct drbd_epoch), GFP_NOIO);
33426 if (epoch)
33427 break;
33428 @@ -1462,11 +1462,11 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
33429 }
33430
33431 epoch->flags = 0;
33432 - atomic_set(&epoch->epoch_size, 0);
33433 + atomic_set_unchecked(&epoch->epoch_size, 0);
33434 atomic_set(&epoch->active, 0);
33435
33436 spin_lock(&tconn->epoch_lock);
33437 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
33438 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
33439 list_add(&epoch->list, &tconn->current_epoch->list);
33440 tconn->current_epoch = epoch;
33441 tconn->epochs++;
33442 @@ -2170,7 +2170,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
33443
33444 err = wait_for_and_update_peer_seq(mdev, peer_seq);
33445 drbd_send_ack_dp(mdev, P_NEG_ACK, p, pi->size);
33446 - atomic_inc(&tconn->current_epoch->epoch_size);
33447 + atomic_inc_unchecked(&tconn->current_epoch->epoch_size);
33448 err2 = drbd_drain_block(mdev, pi->size);
33449 if (!err)
33450 err = err2;
33451 @@ -2204,7 +2204,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
33452
33453 spin_lock(&tconn->epoch_lock);
33454 peer_req->epoch = tconn->current_epoch;
33455 - atomic_inc(&peer_req->epoch->epoch_size);
33456 + atomic_inc_unchecked(&peer_req->epoch->epoch_size);
33457 atomic_inc(&peer_req->epoch->active);
33458 spin_unlock(&tconn->epoch_lock);
33459
33460 @@ -4345,7 +4345,7 @@ struct data_cmd {
33461 int expect_payload;
33462 size_t pkt_size;
33463 int (*fn)(struct drbd_tconn *, struct packet_info *);
33464 -};
33465 +} __do_const;
33466
33467 static struct data_cmd drbd_cmd_handler[] = {
33468 [P_DATA] = { 1, sizeof(struct p_data), receive_Data },
33469 @@ -4465,7 +4465,7 @@ static void conn_disconnect(struct drbd_tconn *tconn)
33470 if (!list_empty(&tconn->current_epoch->list))
33471 conn_err(tconn, "ASSERTION FAILED: tconn->current_epoch->list not empty\n");
33472 /* ok, no more ee's on the fly, it is safe to reset the epoch_size */
33473 - atomic_set(&tconn->current_epoch->epoch_size, 0);
33474 + atomic_set_unchecked(&tconn->current_epoch->epoch_size, 0);
33475 tconn->send.seen_any_write_yet = false;
33476
33477 conn_info(tconn, "Connection closed\n");
33478 @@ -5221,7 +5221,7 @@ static int tconn_finish_peer_reqs(struct drbd_tconn *tconn)
33479 struct asender_cmd {
33480 size_t pkt_size;
33481 int (*fn)(struct drbd_tconn *tconn, struct packet_info *);
33482 -};
33483 +} __do_const;
33484
33485 static struct asender_cmd asender_tbl[] = {
33486 [P_PING] = { 0, got_Ping },
33487 diff --git a/drivers/block/loop.c b/drivers/block/loop.c
33488 index dfe7583..83768bb 100644
33489 --- a/drivers/block/loop.c
33490 +++ b/drivers/block/loop.c
33491 @@ -231,7 +231,7 @@ static int __do_lo_send_write(struct file *file,
33492 mm_segment_t old_fs = get_fs();
33493
33494 set_fs(get_ds());
33495 - bw = file->f_op->write(file, buf, len, &pos);
33496 + bw = file->f_op->write(file, (const char __force_user *)buf, len, &pos);
33497 set_fs(old_fs);
33498 if (likely(bw == len))
33499 return 0;
33500 diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
33501 index 2e7de7a..ed86dc0 100644
33502 --- a/drivers/block/pktcdvd.c
33503 +++ b/drivers/block/pktcdvd.c
33504 @@ -83,7 +83,7 @@
33505
33506 #define MAX_SPEED 0xffff
33507
33508 -#define ZONE(sector, pd) (((sector) + (pd)->offset) & ~((pd)->settings.size - 1))
33509 +#define ZONE(sector, pd) (((sector) + (pd)->offset) & ~((pd)->settings.size - 1UL))
33510
33511 static DEFINE_MUTEX(pktcdvd_mutex);
33512 static struct pktcdvd_device *pkt_devs[MAX_WRITERS];
33513 diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
33514 index d620b44..587561e 100644
33515 --- a/drivers/cdrom/cdrom.c
33516 +++ b/drivers/cdrom/cdrom.c
33517 @@ -416,7 +416,6 @@ int register_cdrom(struct cdrom_device_info *cdi)
33518 ENSURE(reset, CDC_RESET);
33519 ENSURE(generic_packet, CDC_GENERIC_PACKET);
33520 cdi->mc_flags = 0;
33521 - cdo->n_minors = 0;
33522 cdi->options = CDO_USE_FFLAGS;
33523
33524 if (autoclose==1 && CDROM_CAN(CDC_CLOSE_TRAY))
33525 @@ -436,8 +435,11 @@ int register_cdrom(struct cdrom_device_info *cdi)
33526 else
33527 cdi->cdda_method = CDDA_OLD;
33528
33529 - if (!cdo->generic_packet)
33530 - cdo->generic_packet = cdrom_dummy_generic_packet;
33531 + if (!cdo->generic_packet) {
33532 + pax_open_kernel();
33533 + *(void **)&cdo->generic_packet = cdrom_dummy_generic_packet;
33534 + pax_close_kernel();
33535 + }
33536
33537 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" registered\n", cdi->name);
33538 mutex_lock(&cdrom_mutex);
33539 @@ -458,7 +460,6 @@ void unregister_cdrom(struct cdrom_device_info *cdi)
33540 if (cdi->exit)
33541 cdi->exit(cdi);
33542
33543 - cdi->ops->n_minors--;
33544 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" unregistered\n", cdi->name);
33545 }
33546
33547 diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
33548 index d59cdcb..11afddf 100644
33549 --- a/drivers/cdrom/gdrom.c
33550 +++ b/drivers/cdrom/gdrom.c
33551 @@ -491,7 +491,6 @@ static struct cdrom_device_ops gdrom_ops = {
33552 .audio_ioctl = gdrom_audio_ioctl,
33553 .capability = CDC_MULTI_SESSION | CDC_MEDIA_CHANGED |
33554 CDC_RESET | CDC_DRIVE_STATUS | CDC_CD_R,
33555 - .n_minors = 1,
33556 };
33557
33558 static int gdrom_bdops_open(struct block_device *bdev, fmode_t mode)
33559 diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
33560 index 3bb6fa3..34013fb 100644
33561 --- a/drivers/char/Kconfig
33562 +++ b/drivers/char/Kconfig
33563 @@ -8,7 +8,8 @@ source "drivers/tty/Kconfig"
33564
33565 config DEVKMEM
33566 bool "/dev/kmem virtual device support"
33567 - default y
33568 + default n
33569 + depends on !GRKERNSEC_KMEM
33570 help
33571 Say Y here if you want to support the /dev/kmem device. The
33572 /dev/kmem device is rarely used, but can be used for certain
33573 @@ -582,6 +583,7 @@ config DEVPORT
33574 bool
33575 depends on !M68K
33576 depends on ISA || PCI
33577 + depends on !GRKERNSEC_KMEM
33578 default y
33579
33580 source "drivers/s390/char/Kconfig"
33581 diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
33582 index 2e04433..22afc64 100644
33583 --- a/drivers/char/agp/frontend.c
33584 +++ b/drivers/char/agp/frontend.c
33585 @@ -817,7 +817,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
33586 if (copy_from_user(&reserve, arg, sizeof(struct agp_region)))
33587 return -EFAULT;
33588
33589 - if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment))
33590 + if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment_priv))
33591 return -EFAULT;
33592
33593 client = agp_find_client_by_pid(reserve.pid);
33594 diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
33595 index 21cb980..f15107c 100644
33596 --- a/drivers/char/genrtc.c
33597 +++ b/drivers/char/genrtc.c
33598 @@ -272,6 +272,7 @@ static int gen_rtc_ioctl(struct file *file,
33599 switch (cmd) {
33600
33601 case RTC_PLL_GET:
33602 + memset(&pll, 0, sizeof(pll));
33603 if (get_rtc_pll(&pll))
33604 return -EINVAL;
33605 else
33606 diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
33607 index d784650..e8bfd69 100644
33608 --- a/drivers/char/hpet.c
33609 +++ b/drivers/char/hpet.c
33610 @@ -559,7 +559,7 @@ static inline unsigned long hpet_time_div(struct hpets *hpets,
33611 }
33612
33613 static int
33614 -hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg,
33615 +hpet_ioctl_common(struct hpet_dev *devp, unsigned int cmd, unsigned long arg,
33616 struct hpet_info *info)
33617 {
33618 struct hpet_timer __iomem *timer;
33619 diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
33620 index 053201b0..8335cce 100644
33621 --- a/drivers/char/ipmi/ipmi_msghandler.c
33622 +++ b/drivers/char/ipmi/ipmi_msghandler.c
33623 @@ -420,7 +420,7 @@ struct ipmi_smi {
33624 struct proc_dir_entry *proc_dir;
33625 char proc_dir_name[10];
33626
33627 - atomic_t stats[IPMI_NUM_STATS];
33628 + atomic_unchecked_t stats[IPMI_NUM_STATS];
33629
33630 /*
33631 * run_to_completion duplicate of smb_info, smi_info
33632 @@ -453,9 +453,9 @@ static DEFINE_MUTEX(smi_watchers_mutex);
33633
33634
33635 #define ipmi_inc_stat(intf, stat) \
33636 - atomic_inc(&(intf)->stats[IPMI_STAT_ ## stat])
33637 + atomic_inc_unchecked(&(intf)->stats[IPMI_STAT_ ## stat])
33638 #define ipmi_get_stat(intf, stat) \
33639 - ((unsigned int) atomic_read(&(intf)->stats[IPMI_STAT_ ## stat]))
33640 + ((unsigned int) atomic_read_unchecked(&(intf)->stats[IPMI_STAT_ ## stat]))
33641
33642 static int is_lan_addr(struct ipmi_addr *addr)
33643 {
33644 @@ -2884,7 +2884,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
33645 INIT_LIST_HEAD(&intf->cmd_rcvrs);
33646 init_waitqueue_head(&intf->waitq);
33647 for (i = 0; i < IPMI_NUM_STATS; i++)
33648 - atomic_set(&intf->stats[i], 0);
33649 + atomic_set_unchecked(&intf->stats[i], 0);
33650
33651 intf->proc_dir = NULL;
33652
33653 diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
33654 index 0ac9b45..6179fb5 100644
33655 --- a/drivers/char/ipmi/ipmi_si_intf.c
33656 +++ b/drivers/char/ipmi/ipmi_si_intf.c
33657 @@ -275,7 +275,7 @@ struct smi_info {
33658 unsigned char slave_addr;
33659
33660 /* Counters and things for the proc filesystem. */
33661 - atomic_t stats[SI_NUM_STATS];
33662 + atomic_unchecked_t stats[SI_NUM_STATS];
33663
33664 struct task_struct *thread;
33665
33666 @@ -284,9 +284,9 @@ struct smi_info {
33667 };
33668
33669 #define smi_inc_stat(smi, stat) \
33670 - atomic_inc(&(smi)->stats[SI_STAT_ ## stat])
33671 + atomic_inc_unchecked(&(smi)->stats[SI_STAT_ ## stat])
33672 #define smi_get_stat(smi, stat) \
33673 - ((unsigned int) atomic_read(&(smi)->stats[SI_STAT_ ## stat]))
33674 + ((unsigned int) atomic_read_unchecked(&(smi)->stats[SI_STAT_ ## stat]))
33675
33676 #define SI_MAX_PARMS 4
33677
33678 @@ -3254,7 +3254,7 @@ static int try_smi_init(struct smi_info *new_smi)
33679 atomic_set(&new_smi->req_events, 0);
33680 new_smi->run_to_completion = 0;
33681 for (i = 0; i < SI_NUM_STATS; i++)
33682 - atomic_set(&new_smi->stats[i], 0);
33683 + atomic_set_unchecked(&new_smi->stats[i], 0);
33684
33685 new_smi->interrupt_disabled = 1;
33686 atomic_set(&new_smi->stop_operation, 0);
33687 diff --git a/drivers/char/mem.c b/drivers/char/mem.c
33688 index 2c644af..b867b3e 100644
33689 --- a/drivers/char/mem.c
33690 +++ b/drivers/char/mem.c
33691 @@ -18,6 +18,7 @@
33692 #include <linux/raw.h>
33693 #include <linux/tty.h>
33694 #include <linux/capability.h>
33695 +#include <linux/security.h>
33696 #include <linux/ptrace.h>
33697 #include <linux/device.h>
33698 #include <linux/highmem.h>
33699 @@ -37,6 +38,10 @@
33700
33701 #define DEVPORT_MINOR 4
33702
33703 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
33704 +extern const struct file_operations grsec_fops;
33705 +#endif
33706 +
33707 static inline unsigned long size_inside_page(unsigned long start,
33708 unsigned long size)
33709 {
33710 @@ -68,9 +73,13 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
33711
33712 while (cursor < to) {
33713 if (!devmem_is_allowed(pfn)) {
33714 +#ifdef CONFIG_GRKERNSEC_KMEM
33715 + gr_handle_mem_readwrite(from, to);
33716 +#else
33717 printk(KERN_INFO
33718 "Program %s tried to access /dev/mem between %Lx->%Lx.\n",
33719 current->comm, from, to);
33720 +#endif
33721 return 0;
33722 }
33723 cursor += PAGE_SIZE;
33724 @@ -78,6 +87,11 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
33725 }
33726 return 1;
33727 }
33728 +#elif defined(CONFIG_GRKERNSEC_KMEM)
33729 +static inline int range_is_allowed(unsigned long pfn, unsigned long size)
33730 +{
33731 + return 0;
33732 +}
33733 #else
33734 static inline int range_is_allowed(unsigned long pfn, unsigned long size)
33735 {
33736 @@ -120,6 +134,7 @@ static ssize_t read_mem(struct file *file, char __user *buf,
33737
33738 while (count > 0) {
33739 unsigned long remaining;
33740 + char *temp;
33741
33742 sz = size_inside_page(p, count);
33743
33744 @@ -135,7 +150,23 @@ static ssize_t read_mem(struct file *file, char __user *buf,
33745 if (!ptr)
33746 return -EFAULT;
33747
33748 - remaining = copy_to_user(buf, ptr, sz);
33749 +#ifdef CONFIG_PAX_USERCOPY
33750 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
33751 + if (!temp) {
33752 + unxlate_dev_mem_ptr(p, ptr);
33753 + return -ENOMEM;
33754 + }
33755 + memcpy(temp, ptr, sz);
33756 +#else
33757 + temp = ptr;
33758 +#endif
33759 +
33760 + remaining = copy_to_user(buf, temp, sz);
33761 +
33762 +#ifdef CONFIG_PAX_USERCOPY
33763 + kfree(temp);
33764 +#endif
33765 +
33766 unxlate_dev_mem_ptr(p, ptr);
33767 if (remaining)
33768 return -EFAULT;
33769 @@ -398,9 +429,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
33770 size_t count, loff_t *ppos)
33771 {
33772 unsigned long p = *ppos;
33773 - ssize_t low_count, read, sz;
33774 + ssize_t low_count, read, sz, err = 0;
33775 char *kbuf; /* k-addr because vread() takes vmlist_lock rwlock */
33776 - int err = 0;
33777
33778 read = 0;
33779 if (p < (unsigned long) high_memory) {
33780 @@ -422,6 +452,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
33781 }
33782 #endif
33783 while (low_count > 0) {
33784 + char *temp;
33785 +
33786 sz = size_inside_page(p, low_count);
33787
33788 /*
33789 @@ -431,7 +463,22 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
33790 */
33791 kbuf = xlate_dev_kmem_ptr((char *)p);
33792
33793 - if (copy_to_user(buf, kbuf, sz))
33794 +#ifdef CONFIG_PAX_USERCOPY
33795 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
33796 + if (!temp)
33797 + return -ENOMEM;
33798 + memcpy(temp, kbuf, sz);
33799 +#else
33800 + temp = kbuf;
33801 +#endif
33802 +
33803 + err = copy_to_user(buf, temp, sz);
33804 +
33805 +#ifdef CONFIG_PAX_USERCOPY
33806 + kfree(temp);
33807 +#endif
33808 +
33809 + if (err)
33810 return -EFAULT;
33811 buf += sz;
33812 p += sz;
33813 @@ -833,6 +880,9 @@ static const struct memdev {
33814 #ifdef CONFIG_CRASH_DUMP
33815 [12] = { "oldmem", 0, &oldmem_fops, NULL },
33816 #endif
33817 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
33818 + [13] = { "grsec",S_IRUSR | S_IWUGO, &grsec_fops, NULL },
33819 +#endif
33820 };
33821
33822 static int memory_open(struct inode *inode, struct file *filp)
33823 diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
33824 index 9df78e2..01ba9ae 100644
33825 --- a/drivers/char/nvram.c
33826 +++ b/drivers/char/nvram.c
33827 @@ -247,7 +247,7 @@ static ssize_t nvram_read(struct file *file, char __user *buf,
33828
33829 spin_unlock_irq(&rtc_lock);
33830
33831 - if (copy_to_user(buf, contents, tmp - contents))
33832 + if (tmp - contents > sizeof(contents) || copy_to_user(buf, contents, tmp - contents))
33833 return -EFAULT;
33834
33835 *ppos = i;
33836 diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
33837 index 5c5cc00..ac9edb7 100644
33838 --- a/drivers/char/pcmcia/synclink_cs.c
33839 +++ b/drivers/char/pcmcia/synclink_cs.c
33840 @@ -2345,9 +2345,9 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
33841
33842 if (debug_level >= DEBUG_LEVEL_INFO)
33843 printk("%s(%d):mgslpc_close(%s) entry, count=%d\n",
33844 - __FILE__, __LINE__, info->device_name, port->count);
33845 + __FILE__, __LINE__, info->device_name, atomic_read(&port->count));
33846
33847 - WARN_ON(!port->count);
33848 + WARN_ON(!atomic_read(&port->count));
33849
33850 if (tty_port_close_start(port, tty, filp) == 0)
33851 goto cleanup;
33852 @@ -2365,7 +2365,7 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
33853 cleanup:
33854 if (debug_level >= DEBUG_LEVEL_INFO)
33855 printk("%s(%d):mgslpc_close(%s) exit, count=%d\n", __FILE__, __LINE__,
33856 - tty->driver->name, port->count);
33857 + tty->driver->name, atomic_read(&port->count));
33858 }
33859
33860 /* Wait until the transmitter is empty.
33861 @@ -2507,7 +2507,7 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
33862
33863 if (debug_level >= DEBUG_LEVEL_INFO)
33864 printk("%s(%d):mgslpc_open(%s), old ref count = %d\n",
33865 - __FILE__, __LINE__, tty->driver->name, port->count);
33866 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
33867
33868 /* If port is closing, signal caller to try again */
33869 if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING){
33870 @@ -2527,11 +2527,11 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
33871 goto cleanup;
33872 }
33873 spin_lock(&port->lock);
33874 - port->count++;
33875 + atomic_inc(&port->count);
33876 spin_unlock(&port->lock);
33877 spin_unlock_irqrestore(&info->netlock, flags);
33878
33879 - if (port->count == 1) {
33880 + if (atomic_read(&port->count) == 1) {
33881 /* 1st open on this device, init hardware */
33882 retval = startup(info, tty);
33883 if (retval < 0)
33884 @@ -3920,7 +3920,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
33885 unsigned short new_crctype;
33886
33887 /* return error if TTY interface open */
33888 - if (info->port.count)
33889 + if (atomic_read(&info->port.count))
33890 return -EBUSY;
33891
33892 switch (encoding)
33893 @@ -4024,7 +4024,7 @@ static int hdlcdev_open(struct net_device *dev)
33894
33895 /* arbitrate between network and tty opens */
33896 spin_lock_irqsave(&info->netlock, flags);
33897 - if (info->port.count != 0 || info->netcount != 0) {
33898 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
33899 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
33900 spin_unlock_irqrestore(&info->netlock, flags);
33901 return -EBUSY;
33902 @@ -4114,7 +4114,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
33903 printk("%s:hdlcdev_ioctl(%s)\n", __FILE__, dev->name);
33904
33905 /* return error if TTY interface open */
33906 - if (info->port.count)
33907 + if (atomic_read(&info->port.count))
33908 return -EBUSY;
33909
33910 if (cmd != SIOCWANDEV)
33911 diff --git a/drivers/char/random.c b/drivers/char/random.c
33912 index 32a6c57..e7f0f7b 100644
33913 --- a/drivers/char/random.c
33914 +++ b/drivers/char/random.c
33915 @@ -272,8 +272,13 @@
33916 /*
33917 * Configuration information
33918 */
33919 +#ifdef CONFIG_GRKERNSEC_RANDNET
33920 +#define INPUT_POOL_WORDS 512
33921 +#define OUTPUT_POOL_WORDS 128
33922 +#else
33923 #define INPUT_POOL_WORDS 128
33924 #define OUTPUT_POOL_WORDS 32
33925 +#endif
33926 #define SEC_XFER_SIZE 512
33927 #define EXTRACT_SIZE 10
33928
33929 @@ -313,10 +318,17 @@ static struct poolinfo {
33930 int poolwords;
33931 int tap1, tap2, tap3, tap4, tap5;
33932 } poolinfo_table[] = {
33933 +#ifdef CONFIG_GRKERNSEC_RANDNET
33934 + /* x^512 + x^411 + x^308 + x^208 +x^104 + x + 1 -- 225 */
33935 + { 512, 411, 308, 208, 104, 1 },
33936 + /* x^128 + x^103 + x^76 + x^51 + x^25 + x + 1 -- 105 */
33937 + { 128, 103, 76, 51, 25, 1 },
33938 +#else
33939 /* x^128 + x^103 + x^76 + x^51 +x^25 + x + 1 -- 105 */
33940 { 128, 103, 76, 51, 25, 1 },
33941 /* x^32 + x^26 + x^20 + x^14 + x^7 + x + 1 -- 15 */
33942 { 32, 26, 20, 14, 7, 1 },
33943 +#endif
33944 #if 0
33945 /* x^2048 + x^1638 + x^1231 + x^819 + x^411 + x + 1 -- 115 */
33946 { 2048, 1638, 1231, 819, 411, 1 },
33947 @@ -524,8 +536,8 @@ static void _mix_pool_bytes(struct entropy_store *r, const void *in,
33948 input_rotate += i ? 7 : 14;
33949 }
33950
33951 - ACCESS_ONCE(r->input_rotate) = input_rotate;
33952 - ACCESS_ONCE(r->add_ptr) = i;
33953 + ACCESS_ONCE_RW(r->input_rotate) = input_rotate;
33954 + ACCESS_ONCE_RW(r->add_ptr) = i;
33955 smp_wmb();
33956
33957 if (out)
33958 @@ -1024,7 +1036,7 @@ static ssize_t extract_entropy_user(struct entropy_store *r, void __user *buf,
33959
33960 extract_buf(r, tmp);
33961 i = min_t(int, nbytes, EXTRACT_SIZE);
33962 - if (copy_to_user(buf, tmp, i)) {
33963 + if (i > sizeof(tmp) || copy_to_user(buf, tmp, i)) {
33964 ret = -EFAULT;
33965 break;
33966 }
33967 @@ -1360,7 +1372,7 @@ EXPORT_SYMBOL(generate_random_uuid);
33968 #include <linux/sysctl.h>
33969
33970 static int min_read_thresh = 8, min_write_thresh;
33971 -static int max_read_thresh = INPUT_POOL_WORDS * 32;
33972 +static int max_read_thresh = OUTPUT_POOL_WORDS * 32;
33973 static int max_write_thresh = INPUT_POOL_WORDS * 32;
33974 static char sysctl_bootid[16];
33975
33976 @@ -1376,7 +1388,7 @@ static char sysctl_bootid[16];
33977 static int proc_do_uuid(ctl_table *table, int write,
33978 void __user *buffer, size_t *lenp, loff_t *ppos)
33979 {
33980 - ctl_table fake_table;
33981 + ctl_table_no_const fake_table;
33982 unsigned char buf[64], tmp_uuid[16], *uuid;
33983
33984 uuid = table->data;
33985 diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
33986 index bf2349db..5456d53 100644
33987 --- a/drivers/char/sonypi.c
33988 +++ b/drivers/char/sonypi.c
33989 @@ -54,6 +54,7 @@
33990
33991 #include <asm/uaccess.h>
33992 #include <asm/io.h>
33993 +#include <asm/local.h>
33994
33995 #include <linux/sonypi.h>
33996
33997 @@ -490,7 +491,7 @@ static struct sonypi_device {
33998 spinlock_t fifo_lock;
33999 wait_queue_head_t fifo_proc_list;
34000 struct fasync_struct *fifo_async;
34001 - int open_count;
34002 + local_t open_count;
34003 int model;
34004 struct input_dev *input_jog_dev;
34005 struct input_dev *input_key_dev;
34006 @@ -897,7 +898,7 @@ static int sonypi_misc_fasync(int fd, struct file *filp, int on)
34007 static int sonypi_misc_release(struct inode *inode, struct file *file)
34008 {
34009 mutex_lock(&sonypi_device.lock);
34010 - sonypi_device.open_count--;
34011 + local_dec(&sonypi_device.open_count);
34012 mutex_unlock(&sonypi_device.lock);
34013 return 0;
34014 }
34015 @@ -906,9 +907,9 @@ static int sonypi_misc_open(struct inode *inode, struct file *file)
34016 {
34017 mutex_lock(&sonypi_device.lock);
34018 /* Flush input queue on first open */
34019 - if (!sonypi_device.open_count)
34020 + if (!local_read(&sonypi_device.open_count))
34021 kfifo_reset(&sonypi_device.fifo);
34022 - sonypi_device.open_count++;
34023 + local_inc(&sonypi_device.open_count);
34024 mutex_unlock(&sonypi_device.lock);
34025
34026 return 0;
34027 diff --git a/drivers/char/tpm/tpm_acpi.c b/drivers/char/tpm/tpm_acpi.c
34028 index 64420b3..5c40b56 100644
34029 --- a/drivers/char/tpm/tpm_acpi.c
34030 +++ b/drivers/char/tpm/tpm_acpi.c
34031 @@ -98,11 +98,12 @@ int read_log(struct tpm_bios_log *log)
34032 virt = acpi_os_map_memory(start, len);
34033 if (!virt) {
34034 kfree(log->bios_event_log);
34035 + log->bios_event_log = NULL;
34036 printk("%s: ERROR - Unable to map memory\n", __func__);
34037 return -EIO;
34038 }
34039
34040 - memcpy_fromio(log->bios_event_log, virt, len);
34041 + memcpy_fromio(log->bios_event_log, (const char __force_kernel *)virt, len);
34042
34043 acpi_os_unmap_memory(virt, len);
34044 return 0;
34045 diff --git a/drivers/char/tpm/tpm_eventlog.c b/drivers/char/tpm/tpm_eventlog.c
34046 index 84ddc55..1d32f1e 100644
34047 --- a/drivers/char/tpm/tpm_eventlog.c
34048 +++ b/drivers/char/tpm/tpm_eventlog.c
34049 @@ -95,7 +95,7 @@ static void *tpm_bios_measurements_start(struct seq_file *m, loff_t *pos)
34050 event = addr;
34051
34052 if ((event->event_type == 0 && event->event_size == 0) ||
34053 - ((addr + sizeof(struct tcpa_event) + event->event_size) >= limit))
34054 + (event->event_size >= limit - addr - sizeof(struct tcpa_event)))
34055 return NULL;
34056
34057 return addr;
34058 @@ -120,7 +120,7 @@ static void *tpm_bios_measurements_next(struct seq_file *m, void *v,
34059 return NULL;
34060
34061 if ((event->event_type == 0 && event->event_size == 0) ||
34062 - ((v + sizeof(struct tcpa_event) + event->event_size) >= limit))
34063 + (event->event_size >= limit - v - sizeof(struct tcpa_event)))
34064 return NULL;
34065
34066 (*pos)++;
34067 @@ -213,7 +213,8 @@ static int tpm_binary_bios_measurements_show(struct seq_file *m, void *v)
34068 int i;
34069
34070 for (i = 0; i < sizeof(struct tcpa_event) + event->event_size; i++)
34071 - seq_putc(m, data[i]);
34072 + if (!seq_putc(m, data[i]))
34073 + return -EFAULT;
34074
34075 return 0;
34076 }
34077 diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
34078 index ce5f3fc..e2d3e55 100644
34079 --- a/drivers/char/virtio_console.c
34080 +++ b/drivers/char/virtio_console.c
34081 @@ -679,7 +679,7 @@ static ssize_t fill_readbuf(struct port *port, char *out_buf, size_t out_count,
34082 if (to_user) {
34083 ssize_t ret;
34084
34085 - ret = copy_to_user(out_buf, buf->buf + buf->offset, out_count);
34086 + ret = copy_to_user((char __force_user *)out_buf, buf->buf + buf->offset, out_count);
34087 if (ret)
34088 return -EFAULT;
34089 } else {
34090 @@ -778,7 +778,7 @@ static ssize_t port_fops_read(struct file *filp, char __user *ubuf,
34091 if (!port_has_data(port) && !port->host_connected)
34092 return 0;
34093
34094 - return fill_readbuf(port, ubuf, count, true);
34095 + return fill_readbuf(port, (char __force_kernel *)ubuf, count, true);
34096 }
34097
34098 static int wait_port_writable(struct port *port, bool nonblock)
34099 diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
34100 index d7ad425..3e3f81f 100644
34101 --- a/drivers/clocksource/arm_arch_timer.c
34102 +++ b/drivers/clocksource/arm_arch_timer.c
34103 @@ -262,7 +262,7 @@ static int __cpuinit arch_timer_cpu_notify(struct notifier_block *self,
34104 return NOTIFY_OK;
34105 }
34106
34107 -static struct notifier_block arch_timer_cpu_nb __cpuinitdata = {
34108 +static struct notifier_block arch_timer_cpu_nb = {
34109 .notifier_call = arch_timer_cpu_notify,
34110 };
34111
34112 diff --git a/drivers/clocksource/metag_generic.c b/drivers/clocksource/metag_generic.c
34113 index ade7513..069445f 100644
34114 --- a/drivers/clocksource/metag_generic.c
34115 +++ b/drivers/clocksource/metag_generic.c
34116 @@ -169,7 +169,7 @@ static int __cpuinit arch_timer_cpu_notify(struct notifier_block *self,
34117 return NOTIFY_OK;
34118 }
34119
34120 -static struct notifier_block __cpuinitdata arch_timer_cpu_nb = {
34121 +static struct notifier_block arch_timer_cpu_nb = {
34122 .notifier_call = arch_timer_cpu_notify,
34123 };
34124
34125 diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
34126 index 57a8774..545e993 100644
34127 --- a/drivers/cpufreq/acpi-cpufreq.c
34128 +++ b/drivers/cpufreq/acpi-cpufreq.c
34129 @@ -172,7 +172,7 @@ static ssize_t show_global_boost(struct kobject *kobj,
34130 return sprintf(buf, "%u\n", boost_enabled);
34131 }
34132
34133 -static struct global_attr global_boost = __ATTR(boost, 0644,
34134 +static global_attr_no_const global_boost = __ATTR(boost, 0644,
34135 show_global_boost,
34136 store_global_boost);
34137
34138 @@ -712,8 +712,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34139 data->acpi_data = per_cpu_ptr(acpi_perf_data, cpu);
34140 per_cpu(acfreq_data, cpu) = data;
34141
34142 - if (cpu_has(c, X86_FEATURE_CONSTANT_TSC))
34143 - acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
34144 + if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) {
34145 + pax_open_kernel();
34146 + *(u8 *)&acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
34147 + pax_close_kernel();
34148 + }
34149
34150 result = acpi_processor_register_performance(data->acpi_data, cpu);
34151 if (result)
34152 @@ -839,7 +842,9 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34153 policy->cur = acpi_cpufreq_guess_freq(data, policy->cpu);
34154 break;
34155 case ACPI_ADR_SPACE_FIXED_HARDWARE:
34156 - acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
34157 + pax_open_kernel();
34158 + *(void **)&acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
34159 + pax_close_kernel();
34160 policy->cur = get_cur_freq_on_cpu(cpu);
34161 break;
34162 default:
34163 @@ -850,8 +855,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34164 acpi_processor_notify_smm(THIS_MODULE);
34165
34166 /* Check for APERF/MPERF support in hardware */
34167 - if (boot_cpu_has(X86_FEATURE_APERFMPERF))
34168 - acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
34169 + if (boot_cpu_has(X86_FEATURE_APERFMPERF)) {
34170 + pax_open_kernel();
34171 + *(void **)&acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
34172 + pax_close_kernel();
34173 + }
34174
34175 pr_debug("CPU%u - ACPI performance management activated.\n", cpu);
34176 for (i = 0; i < perf->state_count; i++)
34177 diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
34178 index b02824d..51e44aa 100644
34179 --- a/drivers/cpufreq/cpufreq.c
34180 +++ b/drivers/cpufreq/cpufreq.c
34181 @@ -1813,7 +1813,7 @@ static int __cpuinit cpufreq_cpu_callback(struct notifier_block *nfb,
34182 return NOTIFY_OK;
34183 }
34184
34185 -static struct notifier_block __refdata cpufreq_cpu_notifier = {
34186 +static struct notifier_block cpufreq_cpu_notifier = {
34187 .notifier_call = cpufreq_cpu_callback,
34188 };
34189
34190 @@ -1845,8 +1845,11 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
34191
34192 pr_debug("trying to register driver %s\n", driver_data->name);
34193
34194 - if (driver_data->setpolicy)
34195 - driver_data->flags |= CPUFREQ_CONST_LOOPS;
34196 + if (driver_data->setpolicy) {
34197 + pax_open_kernel();
34198 + *(u8 *)&driver_data->flags |= CPUFREQ_CONST_LOOPS;
34199 + pax_close_kernel();
34200 + }
34201
34202 spin_lock_irqsave(&cpufreq_driver_lock, flags);
34203 if (cpufreq_driver) {
34204 diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
34205 index 5a76086..0f4d394 100644
34206 --- a/drivers/cpufreq/cpufreq_governor.c
34207 +++ b/drivers/cpufreq/cpufreq_governor.c
34208 @@ -201,8 +201,8 @@ int cpufreq_governor_dbs(struct dbs_data *dbs_data,
34209 {
34210 struct od_cpu_dbs_info_s *od_dbs_info = NULL;
34211 struct cs_cpu_dbs_info_s *cs_dbs_info = NULL;
34212 - struct cs_ops *cs_ops = NULL;
34213 - struct od_ops *od_ops = NULL;
34214 + const struct cs_ops *cs_ops = NULL;
34215 + const struct od_ops *od_ops = NULL;
34216 struct od_dbs_tuners *od_tuners = dbs_data->tuners;
34217 struct cs_dbs_tuners *cs_tuners = dbs_data->tuners;
34218 struct cpu_dbs_common_info *cpu_cdbs;
34219 diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h
34220 index cc4bd2f..ad142bc 100644
34221 --- a/drivers/cpufreq/cpufreq_governor.h
34222 +++ b/drivers/cpufreq/cpufreq_governor.h
34223 @@ -142,7 +142,7 @@ struct dbs_data {
34224 void (*gov_check_cpu)(int cpu, unsigned int load);
34225
34226 /* Governor specific ops, see below */
34227 - void *gov_ops;
34228 + const void *gov_ops;
34229 };
34230
34231 /* Governor specific ops, will be passed to dbs_data->gov_ops */
34232 diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
34233 index bfd6273..e39dd63 100644
34234 --- a/drivers/cpufreq/cpufreq_stats.c
34235 +++ b/drivers/cpufreq/cpufreq_stats.c
34236 @@ -365,7 +365,7 @@ static int __cpuinit cpufreq_stat_cpu_callback(struct notifier_block *nfb,
34237 }
34238
34239 /* priority=1 so this will get called before cpufreq_remove_dev */
34240 -static struct notifier_block cpufreq_stat_cpu_notifier __refdata = {
34241 +static struct notifier_block cpufreq_stat_cpu_notifier = {
34242 .notifier_call = cpufreq_stat_cpu_callback,
34243 .priority = 1,
34244 };
34245 diff --git a/drivers/cpufreq/p4-clockmod.c b/drivers/cpufreq/p4-clockmod.c
34246 index 827629c9..0bc6a03 100644
34247 --- a/drivers/cpufreq/p4-clockmod.c
34248 +++ b/drivers/cpufreq/p4-clockmod.c
34249 @@ -167,10 +167,14 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
34250 case 0x0F: /* Core Duo */
34251 case 0x16: /* Celeron Core */
34252 case 0x1C: /* Atom */
34253 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34254 + pax_open_kernel();
34255 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34256 + pax_close_kernel();
34257 return speedstep_get_frequency(SPEEDSTEP_CPU_PCORE);
34258 case 0x0D: /* Pentium M (Dothan) */
34259 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34260 + pax_open_kernel();
34261 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34262 + pax_close_kernel();
34263 /* fall through */
34264 case 0x09: /* Pentium M (Banias) */
34265 return speedstep_get_frequency(SPEEDSTEP_CPU_PM);
34266 @@ -182,7 +186,9 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
34267
34268 /* on P-4s, the TSC runs with constant frequency independent whether
34269 * throttling is active or not. */
34270 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34271 + pax_open_kernel();
34272 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34273 + pax_close_kernel();
34274
34275 if (speedstep_detect_processor() == SPEEDSTEP_CPU_P4M) {
34276 printk(KERN_WARNING PFX "Warning: Pentium 4-M detected. "
34277 diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c
34278 index 3a953d5..f5993f6 100644
34279 --- a/drivers/cpufreq/speedstep-centrino.c
34280 +++ b/drivers/cpufreq/speedstep-centrino.c
34281 @@ -353,8 +353,11 @@ static int centrino_cpu_init(struct cpufreq_policy *policy)
34282 !cpu_has(cpu, X86_FEATURE_EST))
34283 return -ENODEV;
34284
34285 - if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC))
34286 - centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
34287 + if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC)) {
34288 + pax_open_kernel();
34289 + *(u8 *)&centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
34290 + pax_close_kernel();
34291 + }
34292
34293 if (policy->cpu != 0)
34294 return -ENODEV;
34295 diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
34296 index eba6929..0f53baf 100644
34297 --- a/drivers/cpuidle/cpuidle.c
34298 +++ b/drivers/cpuidle/cpuidle.c
34299 @@ -277,7 +277,7 @@ static int poll_idle(struct cpuidle_device *dev,
34300
34301 static void poll_idle_init(struct cpuidle_driver *drv)
34302 {
34303 - struct cpuidle_state *state = &drv->states[0];
34304 + cpuidle_state_no_const *state = &drv->states[0];
34305
34306 snprintf(state->name, CPUIDLE_NAME_LEN, "POLL");
34307 snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE");
34308 diff --git a/drivers/cpuidle/governor.c b/drivers/cpuidle/governor.c
34309 index ea2f8e7..70ac501 100644
34310 --- a/drivers/cpuidle/governor.c
34311 +++ b/drivers/cpuidle/governor.c
34312 @@ -87,7 +87,7 @@ int cpuidle_register_governor(struct cpuidle_governor *gov)
34313 mutex_lock(&cpuidle_lock);
34314 if (__cpuidle_find_governor(gov->name) == NULL) {
34315 ret = 0;
34316 - list_add_tail(&gov->governor_list, &cpuidle_governors);
34317 + pax_list_add_tail((struct list_head *)&gov->governor_list, &cpuidle_governors);
34318 if (!cpuidle_curr_governor ||
34319 cpuidle_curr_governor->rating < gov->rating)
34320 cpuidle_switch_governor(gov);
34321 @@ -135,7 +135,7 @@ void cpuidle_unregister_governor(struct cpuidle_governor *gov)
34322 new_gov = cpuidle_replace_governor(gov->rating);
34323 cpuidle_switch_governor(new_gov);
34324 }
34325 - list_del(&gov->governor_list);
34326 + pax_list_del((struct list_head *)&gov->governor_list);
34327 mutex_unlock(&cpuidle_lock);
34328 }
34329
34330 diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
34331 index 428754a..8bdf9cc 100644
34332 --- a/drivers/cpuidle/sysfs.c
34333 +++ b/drivers/cpuidle/sysfs.c
34334 @@ -131,7 +131,7 @@ static struct attribute *cpuidle_switch_attrs[] = {
34335 NULL
34336 };
34337
34338 -static struct attribute_group cpuidle_attr_group = {
34339 +static attribute_group_no_const cpuidle_attr_group = {
34340 .attrs = cpuidle_default_attrs,
34341 .name = "cpuidle",
34342 };
34343 diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
34344 index 3b36797..289c16a 100644
34345 --- a/drivers/devfreq/devfreq.c
34346 +++ b/drivers/devfreq/devfreq.c
34347 @@ -588,7 +588,7 @@ int devfreq_add_governor(struct devfreq_governor *governor)
34348 goto err_out;
34349 }
34350
34351 - list_add(&governor->node, &devfreq_governor_list);
34352 + pax_list_add((struct list_head *)&governor->node, &devfreq_governor_list);
34353
34354 list_for_each_entry(devfreq, &devfreq_list, node) {
34355 int ret = 0;
34356 @@ -676,7 +676,7 @@ int devfreq_remove_governor(struct devfreq_governor *governor)
34357 }
34358 }
34359
34360 - list_del(&governor->node);
34361 + pax_list_del((struct list_head *)&governor->node);
34362 err_out:
34363 mutex_unlock(&devfreq_list_lock);
34364
34365 diff --git a/drivers/dma/sh/shdma.c b/drivers/dma/sh/shdma.c
34366 index b70709b..1d8d02a 100644
34367 --- a/drivers/dma/sh/shdma.c
34368 +++ b/drivers/dma/sh/shdma.c
34369 @@ -476,7 +476,7 @@ static int sh_dmae_nmi_handler(struct notifier_block *self,
34370 return ret;
34371 }
34372
34373 -static struct notifier_block sh_dmae_nmi_notifier __read_mostly = {
34374 +static struct notifier_block sh_dmae_nmi_notifier = {
34375 .notifier_call = sh_dmae_nmi_handler,
34376
34377 /* Run before NMI debug handler and KGDB */
34378 diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
34379 index 769d92e..a3dcc1e 100644
34380 --- a/drivers/edac/edac_mc_sysfs.c
34381 +++ b/drivers/edac/edac_mc_sysfs.c
34382 @@ -148,7 +148,7 @@ static const char *edac_caps[] = {
34383 struct dev_ch_attribute {
34384 struct device_attribute attr;
34385 int channel;
34386 -};
34387 +} __do_const;
34388
34389 #define DEVICE_CHANNEL(_name, _mode, _show, _store, _var) \
34390 struct dev_ch_attribute dev_attr_legacy_##_name = \
34391 @@ -1003,14 +1003,16 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
34392 }
34393
34394 if (mci->set_sdram_scrub_rate || mci->get_sdram_scrub_rate) {
34395 + pax_open_kernel();
34396 if (mci->get_sdram_scrub_rate) {
34397 - dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
34398 - dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
34399 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
34400 + *(void **)&dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
34401 }
34402 if (mci->set_sdram_scrub_rate) {
34403 - dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
34404 - dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
34405 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
34406 + *(void **)&dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
34407 }
34408 + pax_close_kernel();
34409 err = device_create_file(&mci->dev,
34410 &dev_attr_sdram_scrub_rate);
34411 if (err) {
34412 diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
34413 index e8658e4..22746d6 100644
34414 --- a/drivers/edac/edac_pci_sysfs.c
34415 +++ b/drivers/edac/edac_pci_sysfs.c
34416 @@ -26,8 +26,8 @@ static int edac_pci_log_pe = 1; /* log PCI parity errors */
34417 static int edac_pci_log_npe = 1; /* log PCI non-parity error errors */
34418 static int edac_pci_poll_msec = 1000; /* one second workq period */
34419
34420 -static atomic_t pci_parity_count = ATOMIC_INIT(0);
34421 -static atomic_t pci_nonparity_count = ATOMIC_INIT(0);
34422 +static atomic_unchecked_t pci_parity_count = ATOMIC_INIT(0);
34423 +static atomic_unchecked_t pci_nonparity_count = ATOMIC_INIT(0);
34424
34425 static struct kobject *edac_pci_top_main_kobj;
34426 static atomic_t edac_pci_sysfs_refcount = ATOMIC_INIT(0);
34427 @@ -235,7 +235,7 @@ struct edac_pci_dev_attribute {
34428 void *value;
34429 ssize_t(*show) (void *, char *);
34430 ssize_t(*store) (void *, const char *, size_t);
34431 -};
34432 +} __do_const;
34433
34434 /* Set of show/store abstract level functions for PCI Parity object */
34435 static ssize_t edac_pci_dev_show(struct kobject *kobj, struct attribute *attr,
34436 @@ -579,7 +579,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34437 edac_printk(KERN_CRIT, EDAC_PCI,
34438 "Signaled System Error on %s\n",
34439 pci_name(dev));
34440 - atomic_inc(&pci_nonparity_count);
34441 + atomic_inc_unchecked(&pci_nonparity_count);
34442 }
34443
34444 if (status & (PCI_STATUS_PARITY)) {
34445 @@ -587,7 +587,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34446 "Master Data Parity Error on %s\n",
34447 pci_name(dev));
34448
34449 - atomic_inc(&pci_parity_count);
34450 + atomic_inc_unchecked(&pci_parity_count);
34451 }
34452
34453 if (status & (PCI_STATUS_DETECTED_PARITY)) {
34454 @@ -595,7 +595,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34455 "Detected Parity Error on %s\n",
34456 pci_name(dev));
34457
34458 - atomic_inc(&pci_parity_count);
34459 + atomic_inc_unchecked(&pci_parity_count);
34460 }
34461 }
34462
34463 @@ -618,7 +618,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34464 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
34465 "Signaled System Error on %s\n",
34466 pci_name(dev));
34467 - atomic_inc(&pci_nonparity_count);
34468 + atomic_inc_unchecked(&pci_nonparity_count);
34469 }
34470
34471 if (status & (PCI_STATUS_PARITY)) {
34472 @@ -626,7 +626,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34473 "Master Data Parity Error on "
34474 "%s\n", pci_name(dev));
34475
34476 - atomic_inc(&pci_parity_count);
34477 + atomic_inc_unchecked(&pci_parity_count);
34478 }
34479
34480 if (status & (PCI_STATUS_DETECTED_PARITY)) {
34481 @@ -634,7 +634,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34482 "Detected Parity Error on %s\n",
34483 pci_name(dev));
34484
34485 - atomic_inc(&pci_parity_count);
34486 + atomic_inc_unchecked(&pci_parity_count);
34487 }
34488 }
34489 }
34490 @@ -672,7 +672,7 @@ void edac_pci_do_parity_check(void)
34491 if (!check_pci_errors)
34492 return;
34493
34494 - before_count = atomic_read(&pci_parity_count);
34495 + before_count = atomic_read_unchecked(&pci_parity_count);
34496
34497 /* scan all PCI devices looking for a Parity Error on devices and
34498 * bridges.
34499 @@ -684,7 +684,7 @@ void edac_pci_do_parity_check(void)
34500 /* Only if operator has selected panic on PCI Error */
34501 if (edac_pci_get_panic_on_pe()) {
34502 /* If the count is different 'after' from 'before' */
34503 - if (before_count != atomic_read(&pci_parity_count))
34504 + if (before_count != atomic_read_unchecked(&pci_parity_count))
34505 panic("EDAC: PCI Parity Error");
34506 }
34507 }
34508 diff --git a/drivers/edac/mce_amd.h b/drivers/edac/mce_amd.h
34509 index 51b7e3a..aa8a3e8 100644
34510 --- a/drivers/edac/mce_amd.h
34511 +++ b/drivers/edac/mce_amd.h
34512 @@ -77,7 +77,7 @@ struct amd_decoder_ops {
34513 bool (*mc0_mce)(u16, u8);
34514 bool (*mc1_mce)(u16, u8);
34515 bool (*mc2_mce)(u16, u8);
34516 -};
34517 +} __no_const;
34518
34519 void amd_report_gart_errors(bool);
34520 void amd_register_ecc_decoder(void (*f)(int, struct mce *));
34521 diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c
34522 index 57ea7f4..789e3c3 100644
34523 --- a/drivers/firewire/core-card.c
34524 +++ b/drivers/firewire/core-card.c
34525 @@ -680,7 +680,7 @@ EXPORT_SYMBOL_GPL(fw_card_release);
34526
34527 void fw_core_remove_card(struct fw_card *card)
34528 {
34529 - struct fw_card_driver dummy_driver = dummy_driver_template;
34530 + fw_card_driver_no_const dummy_driver = dummy_driver_template;
34531
34532 card->driver->update_phy_reg(card, 4,
34533 PHY_LINK_ACTIVE | PHY_CONTENDER, 0);
34534 diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c
34535 index 27ac423..13573e8 100644
34536 --- a/drivers/firewire/core-cdev.c
34537 +++ b/drivers/firewire/core-cdev.c
34538 @@ -1366,8 +1366,7 @@ static int init_iso_resource(struct client *client,
34539 int ret;
34540
34541 if ((request->channels == 0 && request->bandwidth == 0) ||
34542 - request->bandwidth > BANDWIDTH_AVAILABLE_INITIAL ||
34543 - request->bandwidth < 0)
34544 + request->bandwidth > BANDWIDTH_AVAILABLE_INITIAL)
34545 return -EINVAL;
34546
34547 r = kmalloc(sizeof(*r), GFP_KERNEL);
34548 diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
34549 index 03ce7d9..b70f5da 100644
34550 --- a/drivers/firewire/core-device.c
34551 +++ b/drivers/firewire/core-device.c
34552 @@ -232,7 +232,7 @@ EXPORT_SYMBOL(fw_device_enable_phys_dma);
34553 struct config_rom_attribute {
34554 struct device_attribute attr;
34555 u32 key;
34556 -};
34557 +} __do_const;
34558
34559 static ssize_t show_immediate(struct device *dev,
34560 struct device_attribute *dattr, char *buf)
34561 diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
34562 index 28a94c7..58da63a 100644
34563 --- a/drivers/firewire/core-transaction.c
34564 +++ b/drivers/firewire/core-transaction.c
34565 @@ -38,6 +38,7 @@
34566 #include <linux/timer.h>
34567 #include <linux/types.h>
34568 #include <linux/workqueue.h>
34569 +#include <linux/sched.h>
34570
34571 #include <asm/byteorder.h>
34572
34573 diff --git a/drivers/firewire/core.h b/drivers/firewire/core.h
34574 index 515a42c..5ecf3ba 100644
34575 --- a/drivers/firewire/core.h
34576 +++ b/drivers/firewire/core.h
34577 @@ -111,6 +111,7 @@ struct fw_card_driver {
34578
34579 int (*stop_iso)(struct fw_iso_context *ctx);
34580 };
34581 +typedef struct fw_card_driver __no_const fw_card_driver_no_const;
34582
34583 void fw_card_initialize(struct fw_card *card,
34584 const struct fw_card_driver *driver, struct device *device);
34585 diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c
34586 index 94a58a0..f5eba42 100644
34587 --- a/drivers/firmware/dmi-id.c
34588 +++ b/drivers/firmware/dmi-id.c
34589 @@ -16,7 +16,7 @@
34590 struct dmi_device_attribute{
34591 struct device_attribute dev_attr;
34592 int field;
34593 -};
34594 +} __do_const;
34595 #define to_dmi_dev_attr(_dev_attr) \
34596 container_of(_dev_attr, struct dmi_device_attribute, dev_attr)
34597
34598 diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
34599 index 4cd392d..4b629e1 100644
34600 --- a/drivers/firmware/dmi_scan.c
34601 +++ b/drivers/firmware/dmi_scan.c
34602 @@ -490,11 +490,6 @@ void __init dmi_scan_machine(void)
34603 }
34604 }
34605 else {
34606 - /*
34607 - * no iounmap() for that ioremap(); it would be a no-op, but
34608 - * it's so early in setup that sucker gets confused into doing
34609 - * what it shouldn't if we actually call it.
34610 - */
34611 p = dmi_ioremap(0xF0000, 0x10000);
34612 if (p == NULL)
34613 goto error;
34614 @@ -769,7 +764,7 @@ int dmi_walk(void (*decode)(const struct dmi_header *, void *),
34615 if (buf == NULL)
34616 return -1;
34617
34618 - dmi_table(buf, dmi_len, dmi_num, decode, private_data);
34619 + dmi_table((char __force_kernel *)buf, dmi_len, dmi_num, decode, private_data);
34620
34621 iounmap(buf);
34622 return 0;
34623 diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c
34624 index f4baa11..7970c3a 100644
34625 --- a/drivers/firmware/efivars.c
34626 +++ b/drivers/firmware/efivars.c
34627 @@ -139,7 +139,7 @@ struct efivar_attribute {
34628 };
34629
34630 static struct efivars __efivars;
34631 -static struct efivar_operations ops;
34632 +static efivar_operations_no_const ops __read_only;
34633
34634 #define PSTORE_EFI_ATTRIBUTES \
34635 (EFI_VARIABLE_NON_VOLATILE | \
34636 @@ -1844,7 +1844,7 @@ efivar_create_sysfs_entry(struct efivars *efivars,
34637 static int
34638 create_efivars_bin_attributes(struct efivars *efivars)
34639 {
34640 - struct bin_attribute *attr;
34641 + bin_attribute_no_const *attr;
34642 int error;
34643
34644 /* new_var */
34645 diff --git a/drivers/firmware/google/memconsole.c b/drivers/firmware/google/memconsole.c
34646 index 2a90ba6..07f3733 100644
34647 --- a/drivers/firmware/google/memconsole.c
34648 +++ b/drivers/firmware/google/memconsole.c
34649 @@ -147,7 +147,9 @@ static int __init memconsole_init(void)
34650 if (!found_memconsole())
34651 return -ENODEV;
34652
34653 - memconsole_bin_attr.size = memconsole_length;
34654 + pax_open_kernel();
34655 + *(size_t *)&memconsole_bin_attr.size = memconsole_length;
34656 + pax_close_kernel();
34657
34658 ret = sysfs_create_bin_file(firmware_kobj, &memconsole_bin_attr);
34659
34660 diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
34661 index de3c317..b7cd029 100644
34662 --- a/drivers/gpio/gpio-ich.c
34663 +++ b/drivers/gpio/gpio-ich.c
34664 @@ -69,7 +69,7 @@ struct ichx_desc {
34665 /* Some chipsets have quirks, let these use their own request/get */
34666 int (*request)(struct gpio_chip *chip, unsigned offset);
34667 int (*get)(struct gpio_chip *chip, unsigned offset);
34668 -};
34669 +} __do_const;
34670
34671 static struct {
34672 spinlock_t lock;
34673 diff --git a/drivers/gpio/gpio-vr41xx.c b/drivers/gpio/gpio-vr41xx.c
34674 index 9902732..64b62dd 100644
34675 --- a/drivers/gpio/gpio-vr41xx.c
34676 +++ b/drivers/gpio/gpio-vr41xx.c
34677 @@ -204,7 +204,7 @@ static int giu_get_irq(unsigned int irq)
34678 printk(KERN_ERR "spurious GIU interrupt: %04x(%04x),%04x(%04x)\n",
34679 maskl, pendl, maskh, pendh);
34680
34681 - atomic_inc(&irq_err_count);
34682 + atomic_inc_unchecked(&irq_err_count);
34683
34684 return -EINVAL;
34685 }
34686 diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
34687 index 7b2d378..cc947ea 100644
34688 --- a/drivers/gpu/drm/drm_crtc_helper.c
34689 +++ b/drivers/gpu/drm/drm_crtc_helper.c
34690 @@ -319,7 +319,7 @@ static bool drm_encoder_crtc_ok(struct drm_encoder *encoder,
34691 struct drm_crtc *tmp;
34692 int crtc_mask = 1;
34693
34694 - WARN(!crtc, "checking null crtc?\n");
34695 + BUG_ON(!crtc);
34696
34697 dev = crtc->dev;
34698
34699 diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
34700 index 25f91cd..a376f55 100644
34701 --- a/drivers/gpu/drm/drm_drv.c
34702 +++ b/drivers/gpu/drm/drm_drv.c
34703 @@ -306,7 +306,7 @@ module_exit(drm_core_exit);
34704 /**
34705 * Copy and IOCTL return string to user space
34706 */
34707 -static int drm_copy_field(char *buf, size_t *buf_len, const char *value)
34708 +static int drm_copy_field(char __user *buf, size_t *buf_len, const char *value)
34709 {
34710 int len;
34711
34712 @@ -376,7 +376,7 @@ long drm_ioctl(struct file *filp,
34713 struct drm_file *file_priv = filp->private_data;
34714 struct drm_device *dev;
34715 struct drm_ioctl_desc *ioctl;
34716 - drm_ioctl_t *func;
34717 + drm_ioctl_no_const_t func;
34718 unsigned int nr = DRM_IOCTL_NR(cmd);
34719 int retcode = -EINVAL;
34720 char stack_kdata[128];
34721 @@ -389,7 +389,7 @@ long drm_ioctl(struct file *filp,
34722 return -ENODEV;
34723
34724 atomic_inc(&dev->ioctl_count);
34725 - atomic_inc(&dev->counts[_DRM_STAT_IOCTLS]);
34726 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_IOCTLS]);
34727 ++file_priv->ioctl_count;
34728
34729 DRM_DEBUG("pid=%d, cmd=0x%02x, nr=0x%02x, dev 0x%lx, auth=%d\n",
34730 diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
34731 index 429e07d..e681a2c 100644
34732 --- a/drivers/gpu/drm/drm_fops.c
34733 +++ b/drivers/gpu/drm/drm_fops.c
34734 @@ -71,7 +71,7 @@ static int drm_setup(struct drm_device * dev)
34735 }
34736
34737 for (i = 0; i < ARRAY_SIZE(dev->counts); i++)
34738 - atomic_set(&dev->counts[i], 0);
34739 + atomic_set_unchecked(&dev->counts[i], 0);
34740
34741 dev->sigdata.lock = NULL;
34742
34743 @@ -135,7 +135,7 @@ int drm_open(struct inode *inode, struct file *filp)
34744 if (drm_device_is_unplugged(dev))
34745 return -ENODEV;
34746
34747 - if (!dev->open_count++)
34748 + if (local_inc_return(&dev->open_count) == 1)
34749 need_setup = 1;
34750 mutex_lock(&dev->struct_mutex);
34751 old_imapping = inode->i_mapping;
34752 @@ -151,7 +151,7 @@ int drm_open(struct inode *inode, struct file *filp)
34753 retcode = drm_open_helper(inode, filp, dev);
34754 if (retcode)
34755 goto err_undo;
34756 - atomic_inc(&dev->counts[_DRM_STAT_OPENS]);
34757 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_OPENS]);
34758 if (need_setup) {
34759 retcode = drm_setup(dev);
34760 if (retcode)
34761 @@ -166,7 +166,7 @@ err_undo:
34762 iput(container_of(dev->dev_mapping, struct inode, i_data));
34763 dev->dev_mapping = old_mapping;
34764 mutex_unlock(&dev->struct_mutex);
34765 - dev->open_count--;
34766 + local_dec(&dev->open_count);
34767 return retcode;
34768 }
34769 EXPORT_SYMBOL(drm_open);
34770 @@ -441,7 +441,7 @@ int drm_release(struct inode *inode, struct file *filp)
34771
34772 mutex_lock(&drm_global_mutex);
34773
34774 - DRM_DEBUG("open_count = %d\n", dev->open_count);
34775 + DRM_DEBUG("open_count = %ld\n", local_read(&dev->open_count));
34776
34777 if (dev->driver->preclose)
34778 dev->driver->preclose(dev, file_priv);
34779 @@ -450,10 +450,10 @@ int drm_release(struct inode *inode, struct file *filp)
34780 * Begin inline drm_release
34781 */
34782
34783 - DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n",
34784 + DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %ld\n",
34785 task_pid_nr(current),
34786 (long)old_encode_dev(file_priv->minor->device),
34787 - dev->open_count);
34788 + local_read(&dev->open_count));
34789
34790 /* Release any auth tokens that might point to this file_priv,
34791 (do that under the drm_global_mutex) */
34792 @@ -550,8 +550,8 @@ int drm_release(struct inode *inode, struct file *filp)
34793 * End inline drm_release
34794 */
34795
34796 - atomic_inc(&dev->counts[_DRM_STAT_CLOSES]);
34797 - if (!--dev->open_count) {
34798 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_CLOSES]);
34799 + if (local_dec_and_test(&dev->open_count)) {
34800 if (atomic_read(&dev->ioctl_count)) {
34801 DRM_ERROR("Device busy: %d\n",
34802 atomic_read(&dev->ioctl_count));
34803 diff --git a/drivers/gpu/drm/drm_global.c b/drivers/gpu/drm/drm_global.c
34804 index f731116..629842c 100644
34805 --- a/drivers/gpu/drm/drm_global.c
34806 +++ b/drivers/gpu/drm/drm_global.c
34807 @@ -36,7 +36,7 @@
34808 struct drm_global_item {
34809 struct mutex mutex;
34810 void *object;
34811 - int refcount;
34812 + atomic_t refcount;
34813 };
34814
34815 static struct drm_global_item glob[DRM_GLOBAL_NUM];
34816 @@ -49,7 +49,7 @@ void drm_global_init(void)
34817 struct drm_global_item *item = &glob[i];
34818 mutex_init(&item->mutex);
34819 item->object = NULL;
34820 - item->refcount = 0;
34821 + atomic_set(&item->refcount, 0);
34822 }
34823 }
34824
34825 @@ -59,7 +59,7 @@ void drm_global_release(void)
34826 for (i = 0; i < DRM_GLOBAL_NUM; ++i) {
34827 struct drm_global_item *item = &glob[i];
34828 BUG_ON(item->object != NULL);
34829 - BUG_ON(item->refcount != 0);
34830 + BUG_ON(atomic_read(&item->refcount) != 0);
34831 }
34832 }
34833
34834 @@ -70,7 +70,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
34835 void *object;
34836
34837 mutex_lock(&item->mutex);
34838 - if (item->refcount == 0) {
34839 + if (atomic_read(&item->refcount) == 0) {
34840 item->object = kzalloc(ref->size, GFP_KERNEL);
34841 if (unlikely(item->object == NULL)) {
34842 ret = -ENOMEM;
34843 @@ -83,7 +83,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
34844 goto out_err;
34845
34846 }
34847 - ++item->refcount;
34848 + atomic_inc(&item->refcount);
34849 ref->object = item->object;
34850 object = item->object;
34851 mutex_unlock(&item->mutex);
34852 @@ -100,9 +100,9 @@ void drm_global_item_unref(struct drm_global_reference *ref)
34853 struct drm_global_item *item = &glob[ref->global_type];
34854
34855 mutex_lock(&item->mutex);
34856 - BUG_ON(item->refcount == 0);
34857 + BUG_ON(atomic_read(&item->refcount) == 0);
34858 BUG_ON(ref->object != item->object);
34859 - if (--item->refcount == 0) {
34860 + if (atomic_dec_and_test(&item->refcount)) {
34861 ref->release(ref);
34862 item->object = NULL;
34863 }
34864 diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
34865 index d4b20ce..77a8d41 100644
34866 --- a/drivers/gpu/drm/drm_info.c
34867 +++ b/drivers/gpu/drm/drm_info.c
34868 @@ -75,10 +75,14 @@ int drm_vm_info(struct seq_file *m, void *data)
34869 struct drm_local_map *map;
34870 struct drm_map_list *r_list;
34871
34872 - /* Hardcoded from _DRM_FRAME_BUFFER,
34873 - _DRM_REGISTERS, _DRM_SHM, _DRM_AGP, and
34874 - _DRM_SCATTER_GATHER and _DRM_CONSISTENT */
34875 - const char *types[] = { "FB", "REG", "SHM", "AGP", "SG", "PCI" };
34876 + static const char * const types[] = {
34877 + [_DRM_FRAME_BUFFER] = "FB",
34878 + [_DRM_REGISTERS] = "REG",
34879 + [_DRM_SHM] = "SHM",
34880 + [_DRM_AGP] = "AGP",
34881 + [_DRM_SCATTER_GATHER] = "SG",
34882 + [_DRM_CONSISTENT] = "PCI",
34883 + [_DRM_GEM] = "GEM" };
34884 const char *type;
34885 int i;
34886
34887 @@ -89,7 +93,7 @@ int drm_vm_info(struct seq_file *m, void *data)
34888 map = r_list->map;
34889 if (!map)
34890 continue;
34891 - if (map->type < 0 || map->type > 5)
34892 + if (map->type >= ARRAY_SIZE(types))
34893 type = "??";
34894 else
34895 type = types[map->type];
34896 @@ -253,7 +257,11 @@ int drm_vma_info(struct seq_file *m, void *data)
34897 vma->vm_flags & VM_MAYSHARE ? 's' : 'p',
34898 vma->vm_flags & VM_LOCKED ? 'l' : '-',
34899 vma->vm_flags & VM_IO ? 'i' : '-',
34900 +#ifdef CONFIG_GRKERNSEC_HIDESYM
34901 + 0);
34902 +#else
34903 vma->vm_pgoff);
34904 +#endif
34905
34906 #if defined(__i386__)
34907 pgprot = pgprot_val(vma->vm_page_prot);
34908 diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
34909 index 2f4c434..dd12cd2 100644
34910 --- a/drivers/gpu/drm/drm_ioc32.c
34911 +++ b/drivers/gpu/drm/drm_ioc32.c
34912 @@ -457,7 +457,7 @@ static int compat_drm_infobufs(struct file *file, unsigned int cmd,
34913 request = compat_alloc_user_space(nbytes);
34914 if (!access_ok(VERIFY_WRITE, request, nbytes))
34915 return -EFAULT;
34916 - list = (struct drm_buf_desc *) (request + 1);
34917 + list = (struct drm_buf_desc __user *) (request + 1);
34918
34919 if (__put_user(count, &request->count)
34920 || __put_user(list, &request->list))
34921 @@ -518,7 +518,7 @@ static int compat_drm_mapbufs(struct file *file, unsigned int cmd,
34922 request = compat_alloc_user_space(nbytes);
34923 if (!access_ok(VERIFY_WRITE, request, nbytes))
34924 return -EFAULT;
34925 - list = (struct drm_buf_pub *) (request + 1);
34926 + list = (struct drm_buf_pub __user *) (request + 1);
34927
34928 if (__put_user(count, &request->count)
34929 || __put_user(list, &request->list))
34930 @@ -1016,7 +1016,7 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
34931 return 0;
34932 }
34933
34934 -drm_ioctl_compat_t *drm_compat_ioctls[] = {
34935 +drm_ioctl_compat_t drm_compat_ioctls[] = {
34936 [DRM_IOCTL_NR(DRM_IOCTL_VERSION32)] = compat_drm_version,
34937 [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE32)] = compat_drm_getunique,
34938 [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP32)] = compat_drm_getmap,
34939 @@ -1062,7 +1062,6 @@ drm_ioctl_compat_t *drm_compat_ioctls[] = {
34940 long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
34941 {
34942 unsigned int nr = DRM_IOCTL_NR(cmd);
34943 - drm_ioctl_compat_t *fn;
34944 int ret;
34945
34946 /* Assume that ioctls without an explicit compat routine will just
34947 @@ -1072,10 +1071,8 @@ long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
34948 if (nr >= ARRAY_SIZE(drm_compat_ioctls))
34949 return drm_ioctl(filp, cmd, arg);
34950
34951 - fn = drm_compat_ioctls[nr];
34952 -
34953 - if (fn != NULL)
34954 - ret = (*fn) (filp, cmd, arg);
34955 + if (drm_compat_ioctls[nr] != NULL)
34956 + ret = (*drm_compat_ioctls[nr]) (filp, cmd, arg);
34957 else
34958 ret = drm_ioctl(filp, cmd, arg);
34959
34960 diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
34961 index e77bd8b..1571b85 100644
34962 --- a/drivers/gpu/drm/drm_ioctl.c
34963 +++ b/drivers/gpu/drm/drm_ioctl.c
34964 @@ -252,7 +252,7 @@ int drm_getstats(struct drm_device *dev, void *data,
34965 stats->data[i].value =
34966 (file_priv->master->lock.hw_lock ? file_priv->master->lock.hw_lock->lock : 0);
34967 else
34968 - stats->data[i].value = atomic_read(&dev->counts[i]);
34969 + stats->data[i].value = atomic_read_unchecked(&dev->counts[i]);
34970 stats->data[i].type = dev->types[i];
34971 }
34972
34973 diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
34974 index d752c96..fe08455 100644
34975 --- a/drivers/gpu/drm/drm_lock.c
34976 +++ b/drivers/gpu/drm/drm_lock.c
34977 @@ -86,7 +86,7 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv)
34978 if (drm_lock_take(&master->lock, lock->context)) {
34979 master->lock.file_priv = file_priv;
34980 master->lock.lock_time = jiffies;
34981 - atomic_inc(&dev->counts[_DRM_STAT_LOCKS]);
34982 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_LOCKS]);
34983 break; /* Got lock */
34984 }
34985
34986 @@ -157,7 +157,7 @@ int drm_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv)
34987 return -EINVAL;
34988 }
34989
34990 - atomic_inc(&dev->counts[_DRM_STAT_UNLOCKS]);
34991 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_UNLOCKS]);
34992
34993 if (drm_lock_free(&master->lock, lock->context)) {
34994 /* FIXME: Should really bail out here. */
34995 diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
34996 index 7d30802..42c6cbb 100644
34997 --- a/drivers/gpu/drm/drm_stub.c
34998 +++ b/drivers/gpu/drm/drm_stub.c
34999 @@ -501,7 +501,7 @@ void drm_unplug_dev(struct drm_device *dev)
35000
35001 drm_device_set_unplugged(dev);
35002
35003 - if (dev->open_count == 0) {
35004 + if (local_read(&dev->open_count) == 0) {
35005 drm_put_dev(dev);
35006 }
35007 mutex_unlock(&drm_global_mutex);
35008 diff --git a/drivers/gpu/drm/i810/i810_dma.c b/drivers/gpu/drm/i810/i810_dma.c
35009 index 004ecdf..db1f6e0 100644
35010 --- a/drivers/gpu/drm/i810/i810_dma.c
35011 +++ b/drivers/gpu/drm/i810/i810_dma.c
35012 @@ -945,8 +945,8 @@ static int i810_dma_vertex(struct drm_device *dev, void *data,
35013 dma->buflist[vertex->idx],
35014 vertex->discard, vertex->used);
35015
35016 - atomic_add(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
35017 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
35018 + atomic_add_unchecked(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
35019 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
35020 sarea_priv->last_enqueue = dev_priv->counter - 1;
35021 sarea_priv->last_dispatch = (int)hw_status[5];
35022
35023 @@ -1106,8 +1106,8 @@ static int i810_dma_mc(struct drm_device *dev, void *data,
35024 i810_dma_dispatch_mc(dev, dma->buflist[mc->idx], mc->used,
35025 mc->last_render);
35026
35027 - atomic_add(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
35028 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
35029 + atomic_add_unchecked(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
35030 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
35031 sarea_priv->last_enqueue = dev_priv->counter - 1;
35032 sarea_priv->last_dispatch = (int)hw_status[5];
35033
35034 diff --git a/drivers/gpu/drm/i810/i810_drv.h b/drivers/gpu/drm/i810/i810_drv.h
35035 index 6e0acad..93c8289 100644
35036 --- a/drivers/gpu/drm/i810/i810_drv.h
35037 +++ b/drivers/gpu/drm/i810/i810_drv.h
35038 @@ -108,8 +108,8 @@ typedef struct drm_i810_private {
35039 int page_flipping;
35040
35041 wait_queue_head_t irq_queue;
35042 - atomic_t irq_received;
35043 - atomic_t irq_emitted;
35044 + atomic_unchecked_t irq_received;
35045 + atomic_unchecked_t irq_emitted;
35046
35047 int front_offset;
35048 } drm_i810_private_t;
35049 diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
35050 index 7299ea4..5314487 100644
35051 --- a/drivers/gpu/drm/i915/i915_debugfs.c
35052 +++ b/drivers/gpu/drm/i915/i915_debugfs.c
35053 @@ -499,7 +499,7 @@ static int i915_interrupt_info(struct seq_file *m, void *data)
35054 I915_READ(GTIMR));
35055 }
35056 seq_printf(m, "Interrupts received: %d\n",
35057 - atomic_read(&dev_priv->irq_received));
35058 + atomic_read_unchecked(&dev_priv->irq_received));
35059 for_each_ring(ring, dev_priv, i) {
35060 if (IS_GEN6(dev) || IS_GEN7(dev)) {
35061 seq_printf(m,
35062 diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
35063 index 4fa6beb..f930fec 100644
35064 --- a/drivers/gpu/drm/i915/i915_dma.c
35065 +++ b/drivers/gpu/drm/i915/i915_dma.c
35066 @@ -1259,7 +1259,7 @@ static bool i915_switcheroo_can_switch(struct pci_dev *pdev)
35067 bool can_switch;
35068
35069 spin_lock(&dev->count_lock);
35070 - can_switch = (dev->open_count == 0);
35071 + can_switch = (local_read(&dev->open_count) == 0);
35072 spin_unlock(&dev->count_lock);
35073 return can_switch;
35074 }
35075 diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
35076 index ef99b1c..09ce7fb 100644
35077 --- a/drivers/gpu/drm/i915/i915_drv.h
35078 +++ b/drivers/gpu/drm/i915/i915_drv.h
35079 @@ -893,7 +893,7 @@ typedef struct drm_i915_private {
35080 drm_dma_handle_t *status_page_dmah;
35081 struct resource mch_res;
35082
35083 - atomic_t irq_received;
35084 + atomic_unchecked_t irq_received;
35085
35086 /* protects the irq masks */
35087 spinlock_t irq_lock;
35088 @@ -1775,7 +1775,7 @@ extern struct i2c_adapter *intel_gmbus_get_adapter(
35089 struct drm_i915_private *dev_priv, unsigned port);
35090 extern void intel_gmbus_set_speed(struct i2c_adapter *adapter, int speed);
35091 extern void intel_gmbus_force_bit(struct i2c_adapter *adapter, bool force_bit);
35092 -extern inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
35093 +static inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
35094 {
35095 return container_of(adapter, struct intel_gmbus, adapter)->force_bit;
35096 }
35097 diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35098 index 9a48e1a..f0cbc3e 100644
35099 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35100 +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35101 @@ -729,9 +729,9 @@ i915_gem_check_execbuffer(struct drm_i915_gem_execbuffer2 *exec)
35102
35103 static int
35104 validate_exec_list(struct drm_i915_gem_exec_object2 *exec,
35105 - int count)
35106 + unsigned int count)
35107 {
35108 - int i;
35109 + unsigned int i;
35110 int relocs_total = 0;
35111 int relocs_max = INT_MAX / sizeof(struct drm_i915_gem_relocation_entry);
35112
35113 @@ -1195,7 +1195,7 @@ i915_gem_execbuffer2(struct drm_device *dev, void *data,
35114 return -ENOMEM;
35115 }
35116 ret = copy_from_user(exec2_list,
35117 - (struct drm_i915_relocation_entry __user *)
35118 + (struct drm_i915_gem_exec_object2 __user *)
35119 (uintptr_t) args->buffers_ptr,
35120 sizeof(*exec2_list) * args->buffer_count);
35121 if (ret != 0) {
35122 diff --git a/drivers/gpu/drm/i915/i915_ioc32.c b/drivers/gpu/drm/i915/i915_ioc32.c
35123 index 3c59584..500f2e9 100644
35124 --- a/drivers/gpu/drm/i915/i915_ioc32.c
35125 +++ b/drivers/gpu/drm/i915/i915_ioc32.c
35126 @@ -181,7 +181,7 @@ static int compat_i915_alloc(struct file *file, unsigned int cmd,
35127 (unsigned long)request);
35128 }
35129
35130 -static drm_ioctl_compat_t *i915_compat_ioctls[] = {
35131 +static drm_ioctl_compat_t i915_compat_ioctls[] = {
35132 [DRM_I915_BATCHBUFFER] = compat_i915_batchbuffer,
35133 [DRM_I915_CMDBUFFER] = compat_i915_cmdbuffer,
35134 [DRM_I915_GETPARAM] = compat_i915_getparam,
35135 @@ -202,18 +202,15 @@ static drm_ioctl_compat_t *i915_compat_ioctls[] = {
35136 long i915_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35137 {
35138 unsigned int nr = DRM_IOCTL_NR(cmd);
35139 - drm_ioctl_compat_t *fn = NULL;
35140 int ret;
35141
35142 if (nr < DRM_COMMAND_BASE)
35143 return drm_compat_ioctl(filp, cmd, arg);
35144
35145 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls))
35146 - fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
35147 -
35148 - if (fn != NULL)
35149 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls)) {
35150 + drm_ioctl_compat_t fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
35151 ret = (*fn) (filp, cmd, arg);
35152 - else
35153 + } else
35154 ret = drm_ioctl(filp, cmd, arg);
35155
35156 return ret;
35157 diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
35158 index 3c7bb04..182e049 100644
35159 --- a/drivers/gpu/drm/i915/i915_irq.c
35160 +++ b/drivers/gpu/drm/i915/i915_irq.c
35161 @@ -549,7 +549,7 @@ static irqreturn_t valleyview_irq_handler(int irq, void *arg)
35162 int pipe;
35163 u32 pipe_stats[I915_MAX_PIPES];
35164
35165 - atomic_inc(&dev_priv->irq_received);
35166 + atomic_inc_unchecked(&dev_priv->irq_received);
35167
35168 while (true) {
35169 iir = I915_READ(VLV_IIR);
35170 @@ -705,7 +705,7 @@ static irqreturn_t ivybridge_irq_handler(int irq, void *arg)
35171 irqreturn_t ret = IRQ_NONE;
35172 int i;
35173
35174 - atomic_inc(&dev_priv->irq_received);
35175 + atomic_inc_unchecked(&dev_priv->irq_received);
35176
35177 /* disable master interrupt before clearing iir */
35178 de_ier = I915_READ(DEIER);
35179 @@ -791,7 +791,7 @@ static irqreturn_t ironlake_irq_handler(int irq, void *arg)
35180 int ret = IRQ_NONE;
35181 u32 de_iir, gt_iir, de_ier, pm_iir, sde_ier;
35182
35183 - atomic_inc(&dev_priv->irq_received);
35184 + atomic_inc_unchecked(&dev_priv->irq_received);
35185
35186 /* disable master interrupt before clearing iir */
35187 de_ier = I915_READ(DEIER);
35188 @@ -1886,7 +1886,7 @@ static void ironlake_irq_preinstall(struct drm_device *dev)
35189 {
35190 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35191
35192 - atomic_set(&dev_priv->irq_received, 0);
35193 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35194
35195 I915_WRITE(HWSTAM, 0xeffe);
35196
35197 @@ -1912,7 +1912,7 @@ static void valleyview_irq_preinstall(struct drm_device *dev)
35198 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35199 int pipe;
35200
35201 - atomic_set(&dev_priv->irq_received, 0);
35202 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35203
35204 /* VLV magic */
35205 I915_WRITE(VLV_IMR, 0);
35206 @@ -2208,7 +2208,7 @@ static void i8xx_irq_preinstall(struct drm_device * dev)
35207 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35208 int pipe;
35209
35210 - atomic_set(&dev_priv->irq_received, 0);
35211 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35212
35213 for_each_pipe(pipe)
35214 I915_WRITE(PIPESTAT(pipe), 0);
35215 @@ -2259,7 +2259,7 @@ static irqreturn_t i8xx_irq_handler(int irq, void *arg)
35216 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
35217 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
35218
35219 - atomic_inc(&dev_priv->irq_received);
35220 + atomic_inc_unchecked(&dev_priv->irq_received);
35221
35222 iir = I915_READ16(IIR);
35223 if (iir == 0)
35224 @@ -2344,7 +2344,7 @@ static void i915_irq_preinstall(struct drm_device * dev)
35225 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35226 int pipe;
35227
35228 - atomic_set(&dev_priv->irq_received, 0);
35229 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35230
35231 if (I915_HAS_HOTPLUG(dev)) {
35232 I915_WRITE(PORT_HOTPLUG_EN, 0);
35233 @@ -2448,7 +2448,7 @@ static irqreturn_t i915_irq_handler(int irq, void *arg)
35234 };
35235 int pipe, ret = IRQ_NONE;
35236
35237 - atomic_inc(&dev_priv->irq_received);
35238 + atomic_inc_unchecked(&dev_priv->irq_received);
35239
35240 iir = I915_READ(IIR);
35241 do {
35242 @@ -2574,7 +2574,7 @@ static void i965_irq_preinstall(struct drm_device * dev)
35243 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35244 int pipe;
35245
35246 - atomic_set(&dev_priv->irq_received, 0);
35247 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35248
35249 I915_WRITE(PORT_HOTPLUG_EN, 0);
35250 I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT));
35251 @@ -2690,7 +2690,7 @@ static irqreturn_t i965_irq_handler(int irq, void *arg)
35252 int irq_received;
35253 int ret = IRQ_NONE, pipe;
35254
35255 - atomic_inc(&dev_priv->irq_received);
35256 + atomic_inc_unchecked(&dev_priv->irq_received);
35257
35258 iir = I915_READ(IIR);
35259
35260 diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
35261 index c2d173a..f4357cc 100644
35262 --- a/drivers/gpu/drm/i915/intel_display.c
35263 +++ b/drivers/gpu/drm/i915/intel_display.c
35264 @@ -8722,13 +8722,13 @@ struct intel_quirk {
35265 int subsystem_vendor;
35266 int subsystem_device;
35267 void (*hook)(struct drm_device *dev);
35268 -};
35269 +} __do_const;
35270
35271 /* For systems that don't have a meaningful PCI subdevice/subvendor ID */
35272 struct intel_dmi_quirk {
35273 void (*hook)(struct drm_device *dev);
35274 const struct dmi_system_id (*dmi_id_list)[];
35275 -};
35276 +} __do_const;
35277
35278 static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
35279 {
35280 @@ -8736,18 +8736,20 @@ static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
35281 return 1;
35282 }
35283
35284 -static const struct intel_dmi_quirk intel_dmi_quirks[] = {
35285 +static const struct dmi_system_id intel_dmi_quirks_table[] = {
35286 {
35287 - .dmi_id_list = &(const struct dmi_system_id[]) {
35288 - {
35289 - .callback = intel_dmi_reverse_brightness,
35290 - .ident = "NCR Corporation",
35291 - .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
35292 - DMI_MATCH(DMI_PRODUCT_NAME, ""),
35293 - },
35294 - },
35295 - { } /* terminating entry */
35296 + .callback = intel_dmi_reverse_brightness,
35297 + .ident = "NCR Corporation",
35298 + .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
35299 + DMI_MATCH(DMI_PRODUCT_NAME, ""),
35300 },
35301 + },
35302 + { } /* terminating entry */
35303 +};
35304 +
35305 +static const struct intel_dmi_quirk intel_dmi_quirks[] = {
35306 + {
35307 + .dmi_id_list = &intel_dmi_quirks_table,
35308 .hook = quirk_invert_brightness,
35309 },
35310 };
35311 diff --git a/drivers/gpu/drm/mga/mga_drv.h b/drivers/gpu/drm/mga/mga_drv.h
35312 index 54558a0..2d97005 100644
35313 --- a/drivers/gpu/drm/mga/mga_drv.h
35314 +++ b/drivers/gpu/drm/mga/mga_drv.h
35315 @@ -120,9 +120,9 @@ typedef struct drm_mga_private {
35316 u32 clear_cmd;
35317 u32 maccess;
35318
35319 - atomic_t vbl_received; /**< Number of vblanks received. */
35320 + atomic_unchecked_t vbl_received; /**< Number of vblanks received. */
35321 wait_queue_head_t fence_queue;
35322 - atomic_t last_fence_retired;
35323 + atomic_unchecked_t last_fence_retired;
35324 u32 next_fence_to_post;
35325
35326 unsigned int fb_cpp;
35327 diff --git a/drivers/gpu/drm/mga/mga_ioc32.c b/drivers/gpu/drm/mga/mga_ioc32.c
35328 index 709e90d..89a1c0d 100644
35329 --- a/drivers/gpu/drm/mga/mga_ioc32.c
35330 +++ b/drivers/gpu/drm/mga/mga_ioc32.c
35331 @@ -189,7 +189,7 @@ static int compat_mga_dma_bootstrap(struct file *file, unsigned int cmd,
35332 return 0;
35333 }
35334
35335 -drm_ioctl_compat_t *mga_compat_ioctls[] = {
35336 +drm_ioctl_compat_t mga_compat_ioctls[] = {
35337 [DRM_MGA_INIT] = compat_mga_init,
35338 [DRM_MGA_GETPARAM] = compat_mga_getparam,
35339 [DRM_MGA_DMA_BOOTSTRAP] = compat_mga_dma_bootstrap,
35340 @@ -207,18 +207,15 @@ drm_ioctl_compat_t *mga_compat_ioctls[] = {
35341 long mga_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35342 {
35343 unsigned int nr = DRM_IOCTL_NR(cmd);
35344 - drm_ioctl_compat_t *fn = NULL;
35345 int ret;
35346
35347 if (nr < DRM_COMMAND_BASE)
35348 return drm_compat_ioctl(filp, cmd, arg);
35349
35350 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls))
35351 - fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
35352 -
35353 - if (fn != NULL)
35354 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls)) {
35355 + drm_ioctl_compat_t fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
35356 ret = (*fn) (filp, cmd, arg);
35357 - else
35358 + } else
35359 ret = drm_ioctl(filp, cmd, arg);
35360
35361 return ret;
35362 diff --git a/drivers/gpu/drm/mga/mga_irq.c b/drivers/gpu/drm/mga/mga_irq.c
35363 index 598c281..60d590e 100644
35364 --- a/drivers/gpu/drm/mga/mga_irq.c
35365 +++ b/drivers/gpu/drm/mga/mga_irq.c
35366 @@ -43,7 +43,7 @@ u32 mga_get_vblank_counter(struct drm_device *dev, int crtc)
35367 if (crtc != 0)
35368 return 0;
35369
35370 - return atomic_read(&dev_priv->vbl_received);
35371 + return atomic_read_unchecked(&dev_priv->vbl_received);
35372 }
35373
35374
35375 @@ -59,7 +59,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
35376 /* VBLANK interrupt */
35377 if (status & MGA_VLINEPEN) {
35378 MGA_WRITE(MGA_ICLEAR, MGA_VLINEICLR);
35379 - atomic_inc(&dev_priv->vbl_received);
35380 + atomic_inc_unchecked(&dev_priv->vbl_received);
35381 drm_handle_vblank(dev, 0);
35382 handled = 1;
35383 }
35384 @@ -78,7 +78,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
35385 if ((prim_start & ~0x03) != (prim_end & ~0x03))
35386 MGA_WRITE(MGA_PRIMEND, prim_end);
35387
35388 - atomic_inc(&dev_priv->last_fence_retired);
35389 + atomic_inc_unchecked(&dev_priv->last_fence_retired);
35390 DRM_WAKEUP(&dev_priv->fence_queue);
35391 handled = 1;
35392 }
35393 @@ -129,7 +129,7 @@ int mga_driver_fence_wait(struct drm_device *dev, unsigned int *sequence)
35394 * using fences.
35395 */
35396 DRM_WAIT_ON(ret, dev_priv->fence_queue, 3 * DRM_HZ,
35397 - (((cur_fence = atomic_read(&dev_priv->last_fence_retired))
35398 + (((cur_fence = atomic_read_unchecked(&dev_priv->last_fence_retired))
35399 - *sequence) <= (1 << 23)));
35400
35401 *sequence = cur_fence;
35402 diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c
35403 index 50a6dd0..ea66ed8 100644
35404 --- a/drivers/gpu/drm/nouveau/nouveau_bios.c
35405 +++ b/drivers/gpu/drm/nouveau/nouveau_bios.c
35406 @@ -965,7 +965,7 @@ static int parse_bit_tmds_tbl_entry(struct drm_device *dev, struct nvbios *bios,
35407 struct bit_table {
35408 const char id;
35409 int (* const parse_fn)(struct drm_device *, struct nvbios *, struct bit_entry *);
35410 -};
35411 +} __no_const;
35412
35413 #define BIT_TABLE(id, funcid) ((struct bit_table){ id, parse_bit_##funcid##_tbl_entry })
35414
35415 diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.h b/drivers/gpu/drm/nouveau/nouveau_drm.h
35416 index 9c39baf..30a22be 100644
35417 --- a/drivers/gpu/drm/nouveau/nouveau_drm.h
35418 +++ b/drivers/gpu/drm/nouveau/nouveau_drm.h
35419 @@ -81,7 +81,7 @@ struct nouveau_drm {
35420 struct drm_global_reference mem_global_ref;
35421 struct ttm_bo_global_ref bo_global_ref;
35422 struct ttm_bo_device bdev;
35423 - atomic_t validate_sequence;
35424 + atomic_unchecked_t validate_sequence;
35425 int (*move)(struct nouveau_channel *,
35426 struct ttm_buffer_object *,
35427 struct ttm_mem_reg *, struct ttm_mem_reg *);
35428 diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
35429 index b4b4d0c..b7edc15 100644
35430 --- a/drivers/gpu/drm/nouveau/nouveau_gem.c
35431 +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
35432 @@ -322,7 +322,7 @@ validate_init(struct nouveau_channel *chan, struct drm_file *file_priv,
35433 int ret, i;
35434 struct nouveau_bo *res_bo = NULL;
35435
35436 - sequence = atomic_add_return(1, &drm->ttm.validate_sequence);
35437 + sequence = atomic_add_return_unchecked(1, &drm->ttm.validate_sequence);
35438 retry:
35439 if (++trycnt > 100000) {
35440 NV_ERROR(cli, "%s failed and gave up.\n", __func__);
35441 @@ -359,7 +359,7 @@ retry:
35442 if (ret) {
35443 validate_fini(op, NULL);
35444 if (unlikely(ret == -EAGAIN)) {
35445 - sequence = atomic_add_return(1, &drm->ttm.validate_sequence);
35446 + sequence = atomic_add_return_unchecked(1, &drm->ttm.validate_sequence);
35447 ret = ttm_bo_reserve_slowpath(&nvbo->bo, true,
35448 sequence);
35449 if (!ret)
35450 diff --git a/drivers/gpu/drm/nouveau/nouveau_ioc32.c b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
35451 index 08214bc..9208577 100644
35452 --- a/drivers/gpu/drm/nouveau/nouveau_ioc32.c
35453 +++ b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
35454 @@ -50,7 +50,7 @@ long nouveau_compat_ioctl(struct file *filp, unsigned int cmd,
35455 unsigned long arg)
35456 {
35457 unsigned int nr = DRM_IOCTL_NR(cmd);
35458 - drm_ioctl_compat_t *fn = NULL;
35459 + drm_ioctl_compat_t fn = NULL;
35460 int ret;
35461
35462 if (nr < DRM_COMMAND_BASE)
35463 diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c
35464 index 25d3495..d81aaf6 100644
35465 --- a/drivers/gpu/drm/nouveau/nouveau_vga.c
35466 +++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
35467 @@ -62,7 +62,7 @@ nouveau_switcheroo_can_switch(struct pci_dev *pdev)
35468 bool can_switch;
35469
35470 spin_lock(&dev->count_lock);
35471 - can_switch = (dev->open_count == 0);
35472 + can_switch = (local_read(&dev->open_count) == 0);
35473 spin_unlock(&dev->count_lock);
35474 return can_switch;
35475 }
35476 diff --git a/drivers/gpu/drm/r128/r128_cce.c b/drivers/gpu/drm/r128/r128_cce.c
35477 index d4660cf..70dbe65 100644
35478 --- a/drivers/gpu/drm/r128/r128_cce.c
35479 +++ b/drivers/gpu/drm/r128/r128_cce.c
35480 @@ -377,7 +377,7 @@ static int r128_do_init_cce(struct drm_device *dev, drm_r128_init_t *init)
35481
35482 /* GH: Simple idle check.
35483 */
35484 - atomic_set(&dev_priv->idle_count, 0);
35485 + atomic_set_unchecked(&dev_priv->idle_count, 0);
35486
35487 /* We don't support anything other than bus-mastering ring mode,
35488 * but the ring can be in either AGP or PCI space for the ring
35489 diff --git a/drivers/gpu/drm/r128/r128_drv.h b/drivers/gpu/drm/r128/r128_drv.h
35490 index 930c71b..499aded 100644
35491 --- a/drivers/gpu/drm/r128/r128_drv.h
35492 +++ b/drivers/gpu/drm/r128/r128_drv.h
35493 @@ -90,14 +90,14 @@ typedef struct drm_r128_private {
35494 int is_pci;
35495 unsigned long cce_buffers_offset;
35496
35497 - atomic_t idle_count;
35498 + atomic_unchecked_t idle_count;
35499
35500 int page_flipping;
35501 int current_page;
35502 u32 crtc_offset;
35503 u32 crtc_offset_cntl;
35504
35505 - atomic_t vbl_received;
35506 + atomic_unchecked_t vbl_received;
35507
35508 u32 color_fmt;
35509 unsigned int front_offset;
35510 diff --git a/drivers/gpu/drm/r128/r128_ioc32.c b/drivers/gpu/drm/r128/r128_ioc32.c
35511 index a954c54..9cc595c 100644
35512 --- a/drivers/gpu/drm/r128/r128_ioc32.c
35513 +++ b/drivers/gpu/drm/r128/r128_ioc32.c
35514 @@ -177,7 +177,7 @@ static int compat_r128_getparam(struct file *file, unsigned int cmd,
35515 return drm_ioctl(file, DRM_IOCTL_R128_GETPARAM, (unsigned long)getparam);
35516 }
35517
35518 -drm_ioctl_compat_t *r128_compat_ioctls[] = {
35519 +drm_ioctl_compat_t r128_compat_ioctls[] = {
35520 [DRM_R128_INIT] = compat_r128_init,
35521 [DRM_R128_DEPTH] = compat_r128_depth,
35522 [DRM_R128_STIPPLE] = compat_r128_stipple,
35523 @@ -196,18 +196,15 @@ drm_ioctl_compat_t *r128_compat_ioctls[] = {
35524 long r128_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35525 {
35526 unsigned int nr = DRM_IOCTL_NR(cmd);
35527 - drm_ioctl_compat_t *fn = NULL;
35528 int ret;
35529
35530 if (nr < DRM_COMMAND_BASE)
35531 return drm_compat_ioctl(filp, cmd, arg);
35532
35533 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls))
35534 - fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
35535 -
35536 - if (fn != NULL)
35537 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls)) {
35538 + drm_ioctl_compat_t fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
35539 ret = (*fn) (filp, cmd, arg);
35540 - else
35541 + } else
35542 ret = drm_ioctl(filp, cmd, arg);
35543
35544 return ret;
35545 diff --git a/drivers/gpu/drm/r128/r128_irq.c b/drivers/gpu/drm/r128/r128_irq.c
35546 index 2ea4f09..d391371 100644
35547 --- a/drivers/gpu/drm/r128/r128_irq.c
35548 +++ b/drivers/gpu/drm/r128/r128_irq.c
35549 @@ -41,7 +41,7 @@ u32 r128_get_vblank_counter(struct drm_device *dev, int crtc)
35550 if (crtc != 0)
35551 return 0;
35552
35553 - return atomic_read(&dev_priv->vbl_received);
35554 + return atomic_read_unchecked(&dev_priv->vbl_received);
35555 }
35556
35557 irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
35558 @@ -55,7 +55,7 @@ irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
35559 /* VBLANK interrupt */
35560 if (status & R128_CRTC_VBLANK_INT) {
35561 R128_WRITE(R128_GEN_INT_STATUS, R128_CRTC_VBLANK_INT_AK);
35562 - atomic_inc(&dev_priv->vbl_received);
35563 + atomic_inc_unchecked(&dev_priv->vbl_received);
35564 drm_handle_vblank(dev, 0);
35565 return IRQ_HANDLED;
35566 }
35567 diff --git a/drivers/gpu/drm/r128/r128_state.c b/drivers/gpu/drm/r128/r128_state.c
35568 index 19bb7e6..de7e2a2 100644
35569 --- a/drivers/gpu/drm/r128/r128_state.c
35570 +++ b/drivers/gpu/drm/r128/r128_state.c
35571 @@ -320,10 +320,10 @@ static void r128_clear_box(drm_r128_private_t *dev_priv,
35572
35573 static void r128_cce_performance_boxes(drm_r128_private_t *dev_priv)
35574 {
35575 - if (atomic_read(&dev_priv->idle_count) == 0)
35576 + if (atomic_read_unchecked(&dev_priv->idle_count) == 0)
35577 r128_clear_box(dev_priv, 64, 4, 8, 8, 0, 255, 0);
35578 else
35579 - atomic_set(&dev_priv->idle_count, 0);
35580 + atomic_set_unchecked(&dev_priv->idle_count, 0);
35581 }
35582
35583 #endif
35584 diff --git a/drivers/gpu/drm/radeon/mkregtable.c b/drivers/gpu/drm/radeon/mkregtable.c
35585 index 5a82b6b..9e69c73 100644
35586 --- a/drivers/gpu/drm/radeon/mkregtable.c
35587 +++ b/drivers/gpu/drm/radeon/mkregtable.c
35588 @@ -637,14 +637,14 @@ static int parser_auth(struct table *t, const char *filename)
35589 regex_t mask_rex;
35590 regmatch_t match[4];
35591 char buf[1024];
35592 - size_t end;
35593 + long end;
35594 int len;
35595 int done = 0;
35596 int r;
35597 unsigned o;
35598 struct offset *offset;
35599 char last_reg_s[10];
35600 - int last_reg;
35601 + unsigned long last_reg;
35602
35603 if (regcomp
35604 (&mask_rex, "(0x[0-9a-fA-F]*) *([_a-zA-Z0-9]*)", REG_EXTENDED)) {
35605 diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
35606 index 44b8034..cc722fd 100644
35607 --- a/drivers/gpu/drm/radeon/radeon_device.c
35608 +++ b/drivers/gpu/drm/radeon/radeon_device.c
35609 @@ -977,7 +977,7 @@ static bool radeon_switcheroo_can_switch(struct pci_dev *pdev)
35610 bool can_switch;
35611
35612 spin_lock(&dev->count_lock);
35613 - can_switch = (dev->open_count == 0);
35614 + can_switch = (local_read(&dev->open_count) == 0);
35615 spin_unlock(&dev->count_lock);
35616 return can_switch;
35617 }
35618 diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h
35619 index b369d42..8dd04eb 100644
35620 --- a/drivers/gpu/drm/radeon/radeon_drv.h
35621 +++ b/drivers/gpu/drm/radeon/radeon_drv.h
35622 @@ -258,7 +258,7 @@ typedef struct drm_radeon_private {
35623
35624 /* SW interrupt */
35625 wait_queue_head_t swi_queue;
35626 - atomic_t swi_emitted;
35627 + atomic_unchecked_t swi_emitted;
35628 int vblank_crtc;
35629 uint32_t irq_enable_reg;
35630 uint32_t r500_disp_irq_reg;
35631 diff --git a/drivers/gpu/drm/radeon/radeon_ioc32.c b/drivers/gpu/drm/radeon/radeon_ioc32.c
35632 index c180df8..5fd8186 100644
35633 --- a/drivers/gpu/drm/radeon/radeon_ioc32.c
35634 +++ b/drivers/gpu/drm/radeon/radeon_ioc32.c
35635 @@ -358,7 +358,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
35636 request = compat_alloc_user_space(sizeof(*request));
35637 if (!access_ok(VERIFY_WRITE, request, sizeof(*request))
35638 || __put_user(req32.param, &request->param)
35639 - || __put_user((void __user *)(unsigned long)req32.value,
35640 + || __put_user((unsigned long)req32.value,
35641 &request->value))
35642 return -EFAULT;
35643
35644 @@ -368,7 +368,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
35645 #define compat_radeon_cp_setparam NULL
35646 #endif /* X86_64 || IA64 */
35647
35648 -static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
35649 +static drm_ioctl_compat_t radeon_compat_ioctls[] = {
35650 [DRM_RADEON_CP_INIT] = compat_radeon_cp_init,
35651 [DRM_RADEON_CLEAR] = compat_radeon_cp_clear,
35652 [DRM_RADEON_STIPPLE] = compat_radeon_cp_stipple,
35653 @@ -393,18 +393,15 @@ static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
35654 long radeon_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35655 {
35656 unsigned int nr = DRM_IOCTL_NR(cmd);
35657 - drm_ioctl_compat_t *fn = NULL;
35658 int ret;
35659
35660 if (nr < DRM_COMMAND_BASE)
35661 return drm_compat_ioctl(filp, cmd, arg);
35662
35663 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls))
35664 - fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
35665 -
35666 - if (fn != NULL)
35667 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls)) {
35668 + drm_ioctl_compat_t fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
35669 ret = (*fn) (filp, cmd, arg);
35670 - else
35671 + } else
35672 ret = drm_ioctl(filp, cmd, arg);
35673
35674 return ret;
35675 diff --git a/drivers/gpu/drm/radeon/radeon_irq.c b/drivers/gpu/drm/radeon/radeon_irq.c
35676 index 8d68e97..9dcfed8 100644
35677 --- a/drivers/gpu/drm/radeon/radeon_irq.c
35678 +++ b/drivers/gpu/drm/radeon/radeon_irq.c
35679 @@ -226,8 +226,8 @@ static int radeon_emit_irq(struct drm_device * dev)
35680 unsigned int ret;
35681 RING_LOCALS;
35682
35683 - atomic_inc(&dev_priv->swi_emitted);
35684 - ret = atomic_read(&dev_priv->swi_emitted);
35685 + atomic_inc_unchecked(&dev_priv->swi_emitted);
35686 + ret = atomic_read_unchecked(&dev_priv->swi_emitted);
35687
35688 BEGIN_RING(4);
35689 OUT_RING_REG(RADEON_LAST_SWI_REG, ret);
35690 @@ -353,7 +353,7 @@ int radeon_driver_irq_postinstall(struct drm_device *dev)
35691 drm_radeon_private_t *dev_priv =
35692 (drm_radeon_private_t *) dev->dev_private;
35693
35694 - atomic_set(&dev_priv->swi_emitted, 0);
35695 + atomic_set_unchecked(&dev_priv->swi_emitted, 0);
35696 DRM_INIT_WAITQUEUE(&dev_priv->swi_queue);
35697
35698 dev->max_vblank_count = 0x001fffff;
35699 diff --git a/drivers/gpu/drm/radeon/radeon_state.c b/drivers/gpu/drm/radeon/radeon_state.c
35700 index 4d20910..6726b6d 100644
35701 --- a/drivers/gpu/drm/radeon/radeon_state.c
35702 +++ b/drivers/gpu/drm/radeon/radeon_state.c
35703 @@ -2168,7 +2168,7 @@ static int radeon_cp_clear(struct drm_device *dev, void *data, struct drm_file *
35704 if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS)
35705 sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS;
35706
35707 - if (DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
35708 + if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS || DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
35709 sarea_priv->nbox * sizeof(depth_boxes[0])))
35710 return -EFAULT;
35711
35712 @@ -3031,7 +3031,7 @@ static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_fil
35713 {
35714 drm_radeon_private_t *dev_priv = dev->dev_private;
35715 drm_radeon_getparam_t *param = data;
35716 - int value;
35717 + int value = 0;
35718
35719 DRM_DEBUG("pid=%d\n", DRM_CURRENTPID);
35720
35721 diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
35722 index 6c0ce89..66f6d65 100644
35723 --- a/drivers/gpu/drm/radeon/radeon_ttm.c
35724 +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
35725 @@ -782,7 +782,7 @@ void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size)
35726 man->size = size >> PAGE_SHIFT;
35727 }
35728
35729 -static struct vm_operations_struct radeon_ttm_vm_ops;
35730 +static vm_operations_struct_no_const radeon_ttm_vm_ops __read_only;
35731 static const struct vm_operations_struct *ttm_vm_ops = NULL;
35732
35733 static int radeon_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
35734 @@ -823,8 +823,10 @@ int radeon_mmap(struct file *filp, struct vm_area_struct *vma)
35735 }
35736 if (unlikely(ttm_vm_ops == NULL)) {
35737 ttm_vm_ops = vma->vm_ops;
35738 + pax_open_kernel();
35739 radeon_ttm_vm_ops = *ttm_vm_ops;
35740 radeon_ttm_vm_ops.fault = &radeon_ttm_fault;
35741 + pax_close_kernel();
35742 }
35743 vma->vm_ops = &radeon_ttm_vm_ops;
35744 return 0;
35745 @@ -862,28 +864,33 @@ static int radeon_ttm_debugfs_init(struct radeon_device *rdev)
35746 sprintf(radeon_mem_types_names[i], "radeon_vram_mm");
35747 else
35748 sprintf(radeon_mem_types_names[i], "radeon_gtt_mm");
35749 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
35750 - radeon_mem_types_list[i].show = &radeon_mm_dump_table;
35751 - radeon_mem_types_list[i].driver_features = 0;
35752 + pax_open_kernel();
35753 + *(const char **)&radeon_mem_types_list[i].name = radeon_mem_types_names[i];
35754 + *(void **)&radeon_mem_types_list[i].show = &radeon_mm_dump_table;
35755 + *(u32 *)&radeon_mem_types_list[i].driver_features = 0;
35756 if (i == 0)
35757 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
35758 + *(void **)&radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
35759 else
35760 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
35761 -
35762 + *(void **)&radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
35763 + pax_close_kernel();
35764 }
35765 /* Add ttm page pool to debugfs */
35766 sprintf(radeon_mem_types_names[i], "ttm_page_pool");
35767 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
35768 - radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs;
35769 - radeon_mem_types_list[i].driver_features = 0;
35770 - radeon_mem_types_list[i++].data = NULL;
35771 + pax_open_kernel();
35772 + *(const char **)&radeon_mem_types_list[i].name = radeon_mem_types_names[i];
35773 + *(void **)&radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs;
35774 + *(u32 *)&radeon_mem_types_list[i].driver_features = 0;
35775 + *(void **)&radeon_mem_types_list[i++].data = NULL;
35776 + pax_close_kernel();
35777 #ifdef CONFIG_SWIOTLB
35778 if (swiotlb_nr_tbl()) {
35779 sprintf(radeon_mem_types_names[i], "ttm_dma_page_pool");
35780 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
35781 - radeon_mem_types_list[i].show = &ttm_dma_page_alloc_debugfs;
35782 - radeon_mem_types_list[i].driver_features = 0;
35783 - radeon_mem_types_list[i++].data = NULL;
35784 + pax_open_kernel();
35785 + *(const char **)&radeon_mem_types_list[i].name = radeon_mem_types_names[i];
35786 + *(void **)&radeon_mem_types_list[i].show = &ttm_dma_page_alloc_debugfs;
35787 + *(u32 *)&radeon_mem_types_list[i].driver_features = 0;
35788 + *(void **)&radeon_mem_types_list[i++].data = NULL;
35789 + pax_close_kernel();
35790 }
35791 #endif
35792 return radeon_debugfs_add_files(rdev, radeon_mem_types_list, i);
35793 diff --git a/drivers/gpu/drm/radeon/rs690.c b/drivers/gpu/drm/radeon/rs690.c
35794 index 5706d2a..17aedaa 100644
35795 --- a/drivers/gpu/drm/radeon/rs690.c
35796 +++ b/drivers/gpu/drm/radeon/rs690.c
35797 @@ -304,9 +304,11 @@ static void rs690_crtc_bandwidth_compute(struct radeon_device *rdev,
35798 if (rdev->pm.max_bandwidth.full > rdev->pm.sideport_bandwidth.full &&
35799 rdev->pm.sideport_bandwidth.full)
35800 rdev->pm.max_bandwidth = rdev->pm.sideport_bandwidth;
35801 - read_delay_latency.full = dfixed_const(370 * 800 * 1000);
35802 + read_delay_latency.full = dfixed_const(800 * 1000);
35803 read_delay_latency.full = dfixed_div(read_delay_latency,
35804 rdev->pm.igp_sideport_mclk);
35805 + a.full = dfixed_const(370);
35806 + read_delay_latency.full = dfixed_mul(read_delay_latency, a);
35807 } else {
35808 if (rdev->pm.max_bandwidth.full > rdev->pm.k8_bandwidth.full &&
35809 rdev->pm.k8_bandwidth.full)
35810 diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
35811 index bd2a3b4..122d9ad 100644
35812 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
35813 +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
35814 @@ -394,9 +394,9 @@ static int ttm_pool_get_num_unused_pages(void)
35815 static int ttm_pool_mm_shrink(struct shrinker *shrink,
35816 struct shrink_control *sc)
35817 {
35818 - static atomic_t start_pool = ATOMIC_INIT(0);
35819 + static atomic_unchecked_t start_pool = ATOMIC_INIT(0);
35820 unsigned i;
35821 - unsigned pool_offset = atomic_add_return(1, &start_pool);
35822 + unsigned pool_offset = atomic_add_return_unchecked(1, &start_pool);
35823 struct ttm_page_pool *pool;
35824 int shrink_pages = sc->nr_to_scan;
35825
35826 diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
35827 index 9f4be3d..cbc9fcc 100644
35828 --- a/drivers/gpu/drm/udl/udl_fb.c
35829 +++ b/drivers/gpu/drm/udl/udl_fb.c
35830 @@ -367,7 +367,6 @@ static int udl_fb_release(struct fb_info *info, int user)
35831 fb_deferred_io_cleanup(info);
35832 kfree(info->fbdefio);
35833 info->fbdefio = NULL;
35834 - info->fbops->fb_mmap = udl_fb_mmap;
35835 }
35836
35837 pr_warn("released /dev/fb%d user=%d count=%d\n",
35838 diff --git a/drivers/gpu/drm/via/via_drv.h b/drivers/gpu/drm/via/via_drv.h
35839 index 893a650..6190d3b 100644
35840 --- a/drivers/gpu/drm/via/via_drv.h
35841 +++ b/drivers/gpu/drm/via/via_drv.h
35842 @@ -51,7 +51,7 @@ typedef struct drm_via_ring_buffer {
35843 typedef uint32_t maskarray_t[5];
35844
35845 typedef struct drm_via_irq {
35846 - atomic_t irq_received;
35847 + atomic_unchecked_t irq_received;
35848 uint32_t pending_mask;
35849 uint32_t enable_mask;
35850 wait_queue_head_t irq_queue;
35851 @@ -75,7 +75,7 @@ typedef struct drm_via_private {
35852 struct timeval last_vblank;
35853 int last_vblank_valid;
35854 unsigned usec_per_vblank;
35855 - atomic_t vbl_received;
35856 + atomic_unchecked_t vbl_received;
35857 drm_via_state_t hc_state;
35858 char pci_buf[VIA_PCI_BUF_SIZE];
35859 const uint32_t *fire_offsets[VIA_FIRE_BUF_SIZE];
35860 diff --git a/drivers/gpu/drm/via/via_irq.c b/drivers/gpu/drm/via/via_irq.c
35861 index ac98964..5dbf512 100644
35862 --- a/drivers/gpu/drm/via/via_irq.c
35863 +++ b/drivers/gpu/drm/via/via_irq.c
35864 @@ -101,7 +101,7 @@ u32 via_get_vblank_counter(struct drm_device *dev, int crtc)
35865 if (crtc != 0)
35866 return 0;
35867
35868 - return atomic_read(&dev_priv->vbl_received);
35869 + return atomic_read_unchecked(&dev_priv->vbl_received);
35870 }
35871
35872 irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
35873 @@ -116,8 +116,8 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
35874
35875 status = VIA_READ(VIA_REG_INTERRUPT);
35876 if (status & VIA_IRQ_VBLANK_PENDING) {
35877 - atomic_inc(&dev_priv->vbl_received);
35878 - if (!(atomic_read(&dev_priv->vbl_received) & 0x0F)) {
35879 + atomic_inc_unchecked(&dev_priv->vbl_received);
35880 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0x0F)) {
35881 do_gettimeofday(&cur_vblank);
35882 if (dev_priv->last_vblank_valid) {
35883 dev_priv->usec_per_vblank =
35884 @@ -127,7 +127,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
35885 dev_priv->last_vblank = cur_vblank;
35886 dev_priv->last_vblank_valid = 1;
35887 }
35888 - if (!(atomic_read(&dev_priv->vbl_received) & 0xFF)) {
35889 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0xFF)) {
35890 DRM_DEBUG("US per vblank is: %u\n",
35891 dev_priv->usec_per_vblank);
35892 }
35893 @@ -137,7 +137,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
35894
35895 for (i = 0; i < dev_priv->num_irqs; ++i) {
35896 if (status & cur_irq->pending_mask) {
35897 - atomic_inc(&cur_irq->irq_received);
35898 + atomic_inc_unchecked(&cur_irq->irq_received);
35899 DRM_WAKEUP(&cur_irq->irq_queue);
35900 handled = 1;
35901 if (dev_priv->irq_map[drm_via_irq_dma0_td] == i)
35902 @@ -242,11 +242,11 @@ via_driver_irq_wait(struct drm_device *dev, unsigned int irq, int force_sequence
35903 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
35904 ((VIA_READ(masks[irq][2]) & masks[irq][3]) ==
35905 masks[irq][4]));
35906 - cur_irq_sequence = atomic_read(&cur_irq->irq_received);
35907 + cur_irq_sequence = atomic_read_unchecked(&cur_irq->irq_received);
35908 } else {
35909 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
35910 (((cur_irq_sequence =
35911 - atomic_read(&cur_irq->irq_received)) -
35912 + atomic_read_unchecked(&cur_irq->irq_received)) -
35913 *sequence) <= (1 << 23)));
35914 }
35915 *sequence = cur_irq_sequence;
35916 @@ -284,7 +284,7 @@ void via_driver_irq_preinstall(struct drm_device *dev)
35917 }
35918
35919 for (i = 0; i < dev_priv->num_irqs; ++i) {
35920 - atomic_set(&cur_irq->irq_received, 0);
35921 + atomic_set_unchecked(&cur_irq->irq_received, 0);
35922 cur_irq->enable_mask = dev_priv->irq_masks[i][0];
35923 cur_irq->pending_mask = dev_priv->irq_masks[i][1];
35924 DRM_INIT_WAITQUEUE(&cur_irq->irq_queue);
35925 @@ -366,7 +366,7 @@ int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv)
35926 switch (irqwait->request.type & ~VIA_IRQ_FLAGS_MASK) {
35927 case VIA_IRQ_RELATIVE:
35928 irqwait->request.sequence +=
35929 - atomic_read(&cur_irq->irq_received);
35930 + atomic_read_unchecked(&cur_irq->irq_received);
35931 irqwait->request.type &= ~_DRM_VBLANK_RELATIVE;
35932 case VIA_IRQ_ABSOLUTE:
35933 break;
35934 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
35935 index 13aeda7..4a952d1 100644
35936 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
35937 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
35938 @@ -290,7 +290,7 @@ struct vmw_private {
35939 * Fencing and IRQs.
35940 */
35941
35942 - atomic_t marker_seq;
35943 + atomic_unchecked_t marker_seq;
35944 wait_queue_head_t fence_queue;
35945 wait_queue_head_t fifo_queue;
35946 int fence_queue_waiters; /* Protected by hw_mutex */
35947 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
35948 index 3eb1486..0a47ee9 100644
35949 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
35950 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
35951 @@ -137,7 +137,7 @@ int vmw_fifo_init(struct vmw_private *dev_priv, struct vmw_fifo_state *fifo)
35952 (unsigned int) min,
35953 (unsigned int) fifo->capabilities);
35954
35955 - atomic_set(&dev_priv->marker_seq, dev_priv->last_read_seqno);
35956 + atomic_set_unchecked(&dev_priv->marker_seq, dev_priv->last_read_seqno);
35957 iowrite32(dev_priv->last_read_seqno, fifo_mem + SVGA_FIFO_FENCE);
35958 vmw_marker_queue_init(&fifo->marker_queue);
35959 return vmw_fifo_send_fence(dev_priv, &dummy);
35960 @@ -355,7 +355,7 @@ void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes)
35961 if (reserveable)
35962 iowrite32(bytes, fifo_mem +
35963 SVGA_FIFO_RESERVED);
35964 - return fifo_mem + (next_cmd >> 2);
35965 + return (__le32 __force_kernel *)fifo_mem + (next_cmd >> 2);
35966 } else {
35967 need_bounce = true;
35968 }
35969 @@ -475,7 +475,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
35970
35971 fm = vmw_fifo_reserve(dev_priv, bytes);
35972 if (unlikely(fm == NULL)) {
35973 - *seqno = atomic_read(&dev_priv->marker_seq);
35974 + *seqno = atomic_read_unchecked(&dev_priv->marker_seq);
35975 ret = -ENOMEM;
35976 (void)vmw_fallback_wait(dev_priv, false, true, *seqno,
35977 false, 3*HZ);
35978 @@ -483,7 +483,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
35979 }
35980
35981 do {
35982 - *seqno = atomic_add_return(1, &dev_priv->marker_seq);
35983 + *seqno = atomic_add_return_unchecked(1, &dev_priv->marker_seq);
35984 } while (*seqno == 0);
35985
35986 if (!(fifo_state->capabilities & SVGA_FIFO_CAP_FENCE)) {
35987 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
35988 index 4640adb..e1384ed 100644
35989 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
35990 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
35991 @@ -107,7 +107,7 @@ bool vmw_seqno_passed(struct vmw_private *dev_priv,
35992 * emitted. Then the fence is stale and signaled.
35993 */
35994
35995 - ret = ((atomic_read(&dev_priv->marker_seq) - seqno)
35996 + ret = ((atomic_read_unchecked(&dev_priv->marker_seq) - seqno)
35997 > VMW_FENCE_WRAP);
35998
35999 return ret;
36000 @@ -138,7 +138,7 @@ int vmw_fallback_wait(struct vmw_private *dev_priv,
36001
36002 if (fifo_idle)
36003 down_read(&fifo_state->rwsem);
36004 - signal_seq = atomic_read(&dev_priv->marker_seq);
36005 + signal_seq = atomic_read_unchecked(&dev_priv->marker_seq);
36006 ret = 0;
36007
36008 for (;;) {
36009 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
36010 index 8a8725c2..afed796 100644
36011 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
36012 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
36013 @@ -151,7 +151,7 @@ int vmw_wait_lag(struct vmw_private *dev_priv,
36014 while (!vmw_lag_lt(queue, us)) {
36015 spin_lock(&queue->lock);
36016 if (list_empty(&queue->head))
36017 - seqno = atomic_read(&dev_priv->marker_seq);
36018 + seqno = atomic_read_unchecked(&dev_priv->marker_seq);
36019 else {
36020 marker = list_first_entry(&queue->head,
36021 struct vmw_marker, head);
36022 diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
36023 index e6dbf09..3dd2540 100644
36024 --- a/drivers/hid/hid-core.c
36025 +++ b/drivers/hid/hid-core.c
36026 @@ -2268,7 +2268,7 @@ EXPORT_SYMBOL_GPL(hid_ignore);
36027
36028 int hid_add_device(struct hid_device *hdev)
36029 {
36030 - static atomic_t id = ATOMIC_INIT(0);
36031 + static atomic_unchecked_t id = ATOMIC_INIT(0);
36032 int ret;
36033
36034 if (WARN_ON(hdev->status & HID_STAT_ADDED))
36035 @@ -2302,7 +2302,7 @@ int hid_add_device(struct hid_device *hdev)
36036 /* XXX hack, any other cleaner solution after the driver core
36037 * is converted to allow more than 20 bytes as the device name? */
36038 dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus,
36039 - hdev->vendor, hdev->product, atomic_inc_return(&id));
36040 + hdev->vendor, hdev->product, atomic_inc_return_unchecked(&id));
36041
36042 hid_debug_register(hdev, dev_name(&hdev->dev));
36043 ret = device_add(&hdev->dev);
36044 diff --git a/drivers/hid/hid-wiimote-debug.c b/drivers/hid/hid-wiimote-debug.c
36045 index 90124ff..3761764 100644
36046 --- a/drivers/hid/hid-wiimote-debug.c
36047 +++ b/drivers/hid/hid-wiimote-debug.c
36048 @@ -66,7 +66,7 @@ static ssize_t wiidebug_eeprom_read(struct file *f, char __user *u, size_t s,
36049 else if (size == 0)
36050 return -EIO;
36051
36052 - if (copy_to_user(u, buf, size))
36053 + if (size > sizeof(buf) || copy_to_user(u, buf, size))
36054 return -EFAULT;
36055
36056 *off += size;
36057 diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
36058 index 0b122f8..b1d8160 100644
36059 --- a/drivers/hv/channel.c
36060 +++ b/drivers/hv/channel.c
36061 @@ -394,8 +394,8 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
36062 int ret = 0;
36063 int t;
36064
36065 - next_gpadl_handle = atomic_read(&vmbus_connection.next_gpadl_handle);
36066 - atomic_inc(&vmbus_connection.next_gpadl_handle);
36067 + next_gpadl_handle = atomic_read_unchecked(&vmbus_connection.next_gpadl_handle);
36068 + atomic_inc_unchecked(&vmbus_connection.next_gpadl_handle);
36069
36070 ret = create_gpadl_header(kbuffer, size, &msginfo, &msgcount);
36071 if (ret)
36072 diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
36073 index 7311589..861e9ef 100644
36074 --- a/drivers/hv/hv.c
36075 +++ b/drivers/hv/hv.c
36076 @@ -112,7 +112,7 @@ static u64 do_hypercall(u64 control, void *input, void *output)
36077 u64 output_address = (output) ? virt_to_phys(output) : 0;
36078 u32 output_address_hi = output_address >> 32;
36079 u32 output_address_lo = output_address & 0xFFFFFFFF;
36080 - void *hypercall_page = hv_context.hypercall_page;
36081 + void *hypercall_page = ktva_ktla(hv_context.hypercall_page);
36082
36083 __asm__ __volatile__ ("call *%8" : "=d"(hv_status_hi),
36084 "=a"(hv_status_lo) : "d" (control_hi),
36085 diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
36086 index 12f2f9e..679603c 100644
36087 --- a/drivers/hv/hyperv_vmbus.h
36088 +++ b/drivers/hv/hyperv_vmbus.h
36089 @@ -591,7 +591,7 @@ enum vmbus_connect_state {
36090 struct vmbus_connection {
36091 enum vmbus_connect_state conn_state;
36092
36093 - atomic_t next_gpadl_handle;
36094 + atomic_unchecked_t next_gpadl_handle;
36095
36096 /*
36097 * Represents channel interrupts. Each bit position represents a
36098 diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
36099 index bf421e0..ce2c897 100644
36100 --- a/drivers/hv/vmbus_drv.c
36101 +++ b/drivers/hv/vmbus_drv.c
36102 @@ -668,10 +668,10 @@ int vmbus_device_register(struct hv_device *child_device_obj)
36103 {
36104 int ret = 0;
36105
36106 - static atomic_t device_num = ATOMIC_INIT(0);
36107 + static atomic_unchecked_t device_num = ATOMIC_INIT(0);
36108
36109 dev_set_name(&child_device_obj->device, "vmbus_0_%d",
36110 - atomic_inc_return(&device_num));
36111 + atomic_inc_return_unchecked(&device_num));
36112
36113 child_device_obj->device.bus = &hv_bus;
36114 child_device_obj->device.parent = &hv_acpi_dev->dev;
36115 diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
36116 index 6351aba..dc4aaf4 100644
36117 --- a/drivers/hwmon/acpi_power_meter.c
36118 +++ b/drivers/hwmon/acpi_power_meter.c
36119 @@ -117,7 +117,7 @@ struct sensor_template {
36120 struct device_attribute *devattr,
36121 const char *buf, size_t count);
36122 int index;
36123 -};
36124 +} __do_const;
36125
36126 /* Averaging interval */
36127 static int update_avg_interval(struct acpi_power_meter_resource *resource)
36128 @@ -629,7 +629,7 @@ static int register_attrs(struct acpi_power_meter_resource *resource,
36129 struct sensor_template *attrs)
36130 {
36131 struct device *dev = &resource->acpi_dev->dev;
36132 - struct sensor_device_attribute *sensors =
36133 + sensor_device_attribute_no_const *sensors =
36134 &resource->sensors[resource->num_sensors];
36135 int res = 0;
36136
36137 diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
36138 index b41baff..4953e4d 100644
36139 --- a/drivers/hwmon/applesmc.c
36140 +++ b/drivers/hwmon/applesmc.c
36141 @@ -1084,7 +1084,7 @@ static int applesmc_create_nodes(struct applesmc_node_group *groups, int num)
36142 {
36143 struct applesmc_node_group *grp;
36144 struct applesmc_dev_attr *node;
36145 - struct attribute *attr;
36146 + attribute_no_const *attr;
36147 int ret, i;
36148
36149 for (grp = groups; grp->format; grp++) {
36150 diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c
36151 index b25c643..a13460d 100644
36152 --- a/drivers/hwmon/asus_atk0110.c
36153 +++ b/drivers/hwmon/asus_atk0110.c
36154 @@ -152,10 +152,10 @@ MODULE_DEVICE_TABLE(acpi, atk_ids);
36155 struct atk_sensor_data {
36156 struct list_head list;
36157 struct atk_data *data;
36158 - struct device_attribute label_attr;
36159 - struct device_attribute input_attr;
36160 - struct device_attribute limit1_attr;
36161 - struct device_attribute limit2_attr;
36162 + device_attribute_no_const label_attr;
36163 + device_attribute_no_const input_attr;
36164 + device_attribute_no_const limit1_attr;
36165 + device_attribute_no_const limit2_attr;
36166 char label_attr_name[ATTR_NAME_SIZE];
36167 char input_attr_name[ATTR_NAME_SIZE];
36168 char limit1_attr_name[ATTR_NAME_SIZE];
36169 @@ -275,7 +275,7 @@ static ssize_t atk_name_show(struct device *dev,
36170 static struct device_attribute atk_name_attr =
36171 __ATTR(name, 0444, atk_name_show, NULL);
36172
36173 -static void atk_init_attribute(struct device_attribute *attr, char *name,
36174 +static void atk_init_attribute(device_attribute_no_const *attr, char *name,
36175 sysfs_show_func show)
36176 {
36177 sysfs_attr_init(&attr->attr);
36178 diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
36179 index 3f1e297..a6cafb5 100644
36180 --- a/drivers/hwmon/coretemp.c
36181 +++ b/drivers/hwmon/coretemp.c
36182 @@ -791,7 +791,7 @@ static int __cpuinit coretemp_cpu_callback(struct notifier_block *nfb,
36183 return NOTIFY_OK;
36184 }
36185
36186 -static struct notifier_block coretemp_cpu_notifier __refdata = {
36187 +static struct notifier_block coretemp_cpu_notifier = {
36188 .notifier_call = coretemp_cpu_callback,
36189 };
36190
36191 diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
36192 index a14f634..2916ee2 100644
36193 --- a/drivers/hwmon/ibmaem.c
36194 +++ b/drivers/hwmon/ibmaem.c
36195 @@ -925,7 +925,7 @@ static int aem_register_sensors(struct aem_data *data,
36196 struct aem_rw_sensor_template *rw)
36197 {
36198 struct device *dev = &data->pdev->dev;
36199 - struct sensor_device_attribute *sensors = data->sensors;
36200 + sensor_device_attribute_no_const *sensors = data->sensors;
36201 int err;
36202
36203 /* Set up read-only sensors */
36204 diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
36205 index 9add6092..ee7ba3f 100644
36206 --- a/drivers/hwmon/pmbus/pmbus_core.c
36207 +++ b/drivers/hwmon/pmbus/pmbus_core.c
36208 @@ -781,7 +781,7 @@ static int pmbus_add_attribute(struct pmbus_data *data, struct attribute *attr)
36209 return 0;
36210 }
36211
36212 -static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
36213 +static void pmbus_dev_attr_init(device_attribute_no_const *dev_attr,
36214 const char *name,
36215 umode_t mode,
36216 ssize_t (*show)(struct device *dev,
36217 @@ -798,7 +798,7 @@ static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
36218 dev_attr->store = store;
36219 }
36220
36221 -static void pmbus_attr_init(struct sensor_device_attribute *a,
36222 +static void pmbus_attr_init(sensor_device_attribute_no_const *a,
36223 const char *name,
36224 umode_t mode,
36225 ssize_t (*show)(struct device *dev,
36226 @@ -820,7 +820,7 @@ static int pmbus_add_boolean(struct pmbus_data *data,
36227 u16 reg, u8 mask)
36228 {
36229 struct pmbus_boolean *boolean;
36230 - struct sensor_device_attribute *a;
36231 + sensor_device_attribute_no_const *a;
36232
36233 boolean = devm_kzalloc(data->dev, sizeof(*boolean), GFP_KERNEL);
36234 if (!boolean)
36235 @@ -845,7 +845,7 @@ static struct pmbus_sensor *pmbus_add_sensor(struct pmbus_data *data,
36236 bool update, bool readonly)
36237 {
36238 struct pmbus_sensor *sensor;
36239 - struct device_attribute *a;
36240 + device_attribute_no_const *a;
36241
36242 sensor = devm_kzalloc(data->dev, sizeof(*sensor), GFP_KERNEL);
36243 if (!sensor)
36244 @@ -876,7 +876,7 @@ static int pmbus_add_label(struct pmbus_data *data,
36245 const char *lstring, int index)
36246 {
36247 struct pmbus_label *label;
36248 - struct device_attribute *a;
36249 + device_attribute_no_const *a;
36250
36251 label = devm_kzalloc(data->dev, sizeof(*label), GFP_KERNEL);
36252 if (!label)
36253 diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
36254 index 2507f90..1645765 100644
36255 --- a/drivers/hwmon/sht15.c
36256 +++ b/drivers/hwmon/sht15.c
36257 @@ -169,7 +169,7 @@ struct sht15_data {
36258 int supply_uv;
36259 bool supply_uv_valid;
36260 struct work_struct update_supply_work;
36261 - atomic_t interrupt_handled;
36262 + atomic_unchecked_t interrupt_handled;
36263 };
36264
36265 /**
36266 @@ -542,13 +542,13 @@ static int sht15_measurement(struct sht15_data *data,
36267 ret = gpio_direction_input(data->pdata->gpio_data);
36268 if (ret)
36269 return ret;
36270 - atomic_set(&data->interrupt_handled, 0);
36271 + atomic_set_unchecked(&data->interrupt_handled, 0);
36272
36273 enable_irq(gpio_to_irq(data->pdata->gpio_data));
36274 if (gpio_get_value(data->pdata->gpio_data) == 0) {
36275 disable_irq_nosync(gpio_to_irq(data->pdata->gpio_data));
36276 /* Only relevant if the interrupt hasn't occurred. */
36277 - if (!atomic_read(&data->interrupt_handled))
36278 + if (!atomic_read_unchecked(&data->interrupt_handled))
36279 schedule_work(&data->read_work);
36280 }
36281 ret = wait_event_timeout(data->wait_queue,
36282 @@ -820,7 +820,7 @@ static irqreturn_t sht15_interrupt_fired(int irq, void *d)
36283
36284 /* First disable the interrupt */
36285 disable_irq_nosync(irq);
36286 - atomic_inc(&data->interrupt_handled);
36287 + atomic_inc_unchecked(&data->interrupt_handled);
36288 /* Then schedule a reading work struct */
36289 if (data->state != SHT15_READING_NOTHING)
36290 schedule_work(&data->read_work);
36291 @@ -842,11 +842,11 @@ static void sht15_bh_read_data(struct work_struct *work_s)
36292 * If not, then start the interrupt again - care here as could
36293 * have gone low in meantime so verify it hasn't!
36294 */
36295 - atomic_set(&data->interrupt_handled, 0);
36296 + atomic_set_unchecked(&data->interrupt_handled, 0);
36297 enable_irq(gpio_to_irq(data->pdata->gpio_data));
36298 /* If still not occurred or another handler was scheduled */
36299 if (gpio_get_value(data->pdata->gpio_data)
36300 - || atomic_read(&data->interrupt_handled))
36301 + || atomic_read_unchecked(&data->interrupt_handled))
36302 return;
36303 }
36304
36305 diff --git a/drivers/hwmon/via-cputemp.c b/drivers/hwmon/via-cputemp.c
36306 index 76f157b..9c0db1b 100644
36307 --- a/drivers/hwmon/via-cputemp.c
36308 +++ b/drivers/hwmon/via-cputemp.c
36309 @@ -296,7 +296,7 @@ static int __cpuinit via_cputemp_cpu_callback(struct notifier_block *nfb,
36310 return NOTIFY_OK;
36311 }
36312
36313 -static struct notifier_block via_cputemp_cpu_notifier __refdata = {
36314 +static struct notifier_block via_cputemp_cpu_notifier = {
36315 .notifier_call = via_cputemp_cpu_callback,
36316 };
36317
36318 diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c
36319 index 378fcb5..5e91fa8 100644
36320 --- a/drivers/i2c/busses/i2c-amd756-s4882.c
36321 +++ b/drivers/i2c/busses/i2c-amd756-s4882.c
36322 @@ -43,7 +43,7 @@
36323 extern struct i2c_adapter amd756_smbus;
36324
36325 static struct i2c_adapter *s4882_adapter;
36326 -static struct i2c_algorithm *s4882_algo;
36327 +static i2c_algorithm_no_const *s4882_algo;
36328
36329 /* Wrapper access functions for multiplexed SMBus */
36330 static DEFINE_MUTEX(amd756_lock);
36331 diff --git a/drivers/i2c/busses/i2c-nforce2-s4985.c b/drivers/i2c/busses/i2c-nforce2-s4985.c
36332 index 29015eb..af2d8e9 100644
36333 --- a/drivers/i2c/busses/i2c-nforce2-s4985.c
36334 +++ b/drivers/i2c/busses/i2c-nforce2-s4985.c
36335 @@ -41,7 +41,7 @@
36336 extern struct i2c_adapter *nforce2_smbus;
36337
36338 static struct i2c_adapter *s4985_adapter;
36339 -static struct i2c_algorithm *s4985_algo;
36340 +static i2c_algorithm_no_const *s4985_algo;
36341
36342 /* Wrapper access functions for multiplexed SMBus */
36343 static DEFINE_MUTEX(nforce2_lock);
36344 diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
36345 index 8126824..55a2798 100644
36346 --- a/drivers/ide/ide-cd.c
36347 +++ b/drivers/ide/ide-cd.c
36348 @@ -768,7 +768,7 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
36349 alignment = queue_dma_alignment(q) | q->dma_pad_mask;
36350 if ((unsigned long)buf & alignment
36351 || blk_rq_bytes(rq) & q->dma_pad_mask
36352 - || object_is_on_stack(buf))
36353 + || object_starts_on_stack(buf))
36354 drive->dma = 0;
36355 }
36356 }
36357 diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
36358 index 8848f16..f8e6dd8 100644
36359 --- a/drivers/iio/industrialio-core.c
36360 +++ b/drivers/iio/industrialio-core.c
36361 @@ -506,7 +506,7 @@ static ssize_t iio_write_channel_info(struct device *dev,
36362 }
36363
36364 static
36365 -int __iio_device_attr_init(struct device_attribute *dev_attr,
36366 +int __iio_device_attr_init(device_attribute_no_const *dev_attr,
36367 const char *postfix,
36368 struct iio_chan_spec const *chan,
36369 ssize_t (*readfunc)(struct device *dev,
36370 diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
36371 index 784b97c..c9ceadf 100644
36372 --- a/drivers/infiniband/core/cm.c
36373 +++ b/drivers/infiniband/core/cm.c
36374 @@ -114,7 +114,7 @@ static char const counter_group_names[CM_COUNTER_GROUPS]
36375
36376 struct cm_counter_group {
36377 struct kobject obj;
36378 - atomic_long_t counter[CM_ATTR_COUNT];
36379 + atomic_long_unchecked_t counter[CM_ATTR_COUNT];
36380 };
36381
36382 struct cm_counter_attribute {
36383 @@ -1395,7 +1395,7 @@ static void cm_dup_req_handler(struct cm_work *work,
36384 struct ib_mad_send_buf *msg = NULL;
36385 int ret;
36386
36387 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36388 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36389 counter[CM_REQ_COUNTER]);
36390
36391 /* Quick state check to discard duplicate REQs. */
36392 @@ -1779,7 +1779,7 @@ static void cm_dup_rep_handler(struct cm_work *work)
36393 if (!cm_id_priv)
36394 return;
36395
36396 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36397 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36398 counter[CM_REP_COUNTER]);
36399 ret = cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg);
36400 if (ret)
36401 @@ -1946,7 +1946,7 @@ static int cm_rtu_handler(struct cm_work *work)
36402 if (cm_id_priv->id.state != IB_CM_REP_SENT &&
36403 cm_id_priv->id.state != IB_CM_MRA_REP_RCVD) {
36404 spin_unlock_irq(&cm_id_priv->lock);
36405 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36406 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36407 counter[CM_RTU_COUNTER]);
36408 goto out;
36409 }
36410 @@ -2129,7 +2129,7 @@ static int cm_dreq_handler(struct cm_work *work)
36411 cm_id_priv = cm_acquire_id(dreq_msg->remote_comm_id,
36412 dreq_msg->local_comm_id);
36413 if (!cm_id_priv) {
36414 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36415 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36416 counter[CM_DREQ_COUNTER]);
36417 cm_issue_drep(work->port, work->mad_recv_wc);
36418 return -EINVAL;
36419 @@ -2154,7 +2154,7 @@ static int cm_dreq_handler(struct cm_work *work)
36420 case IB_CM_MRA_REP_RCVD:
36421 break;
36422 case IB_CM_TIMEWAIT:
36423 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36424 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36425 counter[CM_DREQ_COUNTER]);
36426 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
36427 goto unlock;
36428 @@ -2168,7 +2168,7 @@ static int cm_dreq_handler(struct cm_work *work)
36429 cm_free_msg(msg);
36430 goto deref;
36431 case IB_CM_DREQ_RCVD:
36432 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36433 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36434 counter[CM_DREQ_COUNTER]);
36435 goto unlock;
36436 default:
36437 @@ -2535,7 +2535,7 @@ static int cm_mra_handler(struct cm_work *work)
36438 ib_modify_mad(cm_id_priv->av.port->mad_agent,
36439 cm_id_priv->msg, timeout)) {
36440 if (cm_id_priv->id.lap_state == IB_CM_MRA_LAP_RCVD)
36441 - atomic_long_inc(&work->port->
36442 + atomic_long_inc_unchecked(&work->port->
36443 counter_group[CM_RECV_DUPLICATES].
36444 counter[CM_MRA_COUNTER]);
36445 goto out;
36446 @@ -2544,7 +2544,7 @@ static int cm_mra_handler(struct cm_work *work)
36447 break;
36448 case IB_CM_MRA_REQ_RCVD:
36449 case IB_CM_MRA_REP_RCVD:
36450 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36451 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36452 counter[CM_MRA_COUNTER]);
36453 /* fall through */
36454 default:
36455 @@ -2706,7 +2706,7 @@ static int cm_lap_handler(struct cm_work *work)
36456 case IB_CM_LAP_IDLE:
36457 break;
36458 case IB_CM_MRA_LAP_SENT:
36459 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36460 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36461 counter[CM_LAP_COUNTER]);
36462 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
36463 goto unlock;
36464 @@ -2722,7 +2722,7 @@ static int cm_lap_handler(struct cm_work *work)
36465 cm_free_msg(msg);
36466 goto deref;
36467 case IB_CM_LAP_RCVD:
36468 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36469 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36470 counter[CM_LAP_COUNTER]);
36471 goto unlock;
36472 default:
36473 @@ -3006,7 +3006,7 @@ static int cm_sidr_req_handler(struct cm_work *work)
36474 cur_cm_id_priv = cm_insert_remote_sidr(cm_id_priv);
36475 if (cur_cm_id_priv) {
36476 spin_unlock_irq(&cm.lock);
36477 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36478 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36479 counter[CM_SIDR_REQ_COUNTER]);
36480 goto out; /* Duplicate message. */
36481 }
36482 @@ -3218,10 +3218,10 @@ static void cm_send_handler(struct ib_mad_agent *mad_agent,
36483 if (!msg->context[0] && (attr_index != CM_REJ_COUNTER))
36484 msg->retries = 1;
36485
36486 - atomic_long_add(1 + msg->retries,
36487 + atomic_long_add_unchecked(1 + msg->retries,
36488 &port->counter_group[CM_XMIT].counter[attr_index]);
36489 if (msg->retries)
36490 - atomic_long_add(msg->retries,
36491 + atomic_long_add_unchecked(msg->retries,
36492 &port->counter_group[CM_XMIT_RETRIES].
36493 counter[attr_index]);
36494
36495 @@ -3431,7 +3431,7 @@ static void cm_recv_handler(struct ib_mad_agent *mad_agent,
36496 }
36497
36498 attr_id = be16_to_cpu(mad_recv_wc->recv_buf.mad->mad_hdr.attr_id);
36499 - atomic_long_inc(&port->counter_group[CM_RECV].
36500 + atomic_long_inc_unchecked(&port->counter_group[CM_RECV].
36501 counter[attr_id - CM_ATTR_ID_OFFSET]);
36502
36503 work = kmalloc(sizeof *work + sizeof(struct ib_sa_path_rec) * paths,
36504 @@ -3636,7 +3636,7 @@ static ssize_t cm_show_counter(struct kobject *obj, struct attribute *attr,
36505 cm_attr = container_of(attr, struct cm_counter_attribute, attr);
36506
36507 return sprintf(buf, "%ld\n",
36508 - atomic_long_read(&group->counter[cm_attr->index]));
36509 + atomic_long_read_unchecked(&group->counter[cm_attr->index]));
36510 }
36511
36512 static const struct sysfs_ops cm_counter_ops = {
36513 diff --git a/drivers/infiniband/core/fmr_pool.c b/drivers/infiniband/core/fmr_pool.c
36514 index 9f5ad7c..588cd84 100644
36515 --- a/drivers/infiniband/core/fmr_pool.c
36516 +++ b/drivers/infiniband/core/fmr_pool.c
36517 @@ -98,8 +98,8 @@ struct ib_fmr_pool {
36518
36519 struct task_struct *thread;
36520
36521 - atomic_t req_ser;
36522 - atomic_t flush_ser;
36523 + atomic_unchecked_t req_ser;
36524 + atomic_unchecked_t flush_ser;
36525
36526 wait_queue_head_t force_wait;
36527 };
36528 @@ -179,10 +179,10 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
36529 struct ib_fmr_pool *pool = pool_ptr;
36530
36531 do {
36532 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) < 0) {
36533 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) < 0) {
36534 ib_fmr_batch_release(pool);
36535
36536 - atomic_inc(&pool->flush_ser);
36537 + atomic_inc_unchecked(&pool->flush_ser);
36538 wake_up_interruptible(&pool->force_wait);
36539
36540 if (pool->flush_function)
36541 @@ -190,7 +190,7 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
36542 }
36543
36544 set_current_state(TASK_INTERRUPTIBLE);
36545 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) >= 0 &&
36546 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) >= 0 &&
36547 !kthread_should_stop())
36548 schedule();
36549 __set_current_state(TASK_RUNNING);
36550 @@ -282,8 +282,8 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
36551 pool->dirty_watermark = params->dirty_watermark;
36552 pool->dirty_len = 0;
36553 spin_lock_init(&pool->pool_lock);
36554 - atomic_set(&pool->req_ser, 0);
36555 - atomic_set(&pool->flush_ser, 0);
36556 + atomic_set_unchecked(&pool->req_ser, 0);
36557 + atomic_set_unchecked(&pool->flush_ser, 0);
36558 init_waitqueue_head(&pool->force_wait);
36559
36560 pool->thread = kthread_run(ib_fmr_cleanup_thread,
36561 @@ -411,11 +411,11 @@ int ib_flush_fmr_pool(struct ib_fmr_pool *pool)
36562 }
36563 spin_unlock_irq(&pool->pool_lock);
36564
36565 - serial = atomic_inc_return(&pool->req_ser);
36566 + serial = atomic_inc_return_unchecked(&pool->req_ser);
36567 wake_up_process(pool->thread);
36568
36569 if (wait_event_interruptible(pool->force_wait,
36570 - atomic_read(&pool->flush_ser) - serial >= 0))
36571 + atomic_read_unchecked(&pool->flush_ser) - serial >= 0))
36572 return -EINTR;
36573
36574 return 0;
36575 @@ -525,7 +525,7 @@ int ib_fmr_pool_unmap(struct ib_pool_fmr *fmr)
36576 } else {
36577 list_add_tail(&fmr->list, &pool->dirty_list);
36578 if (++pool->dirty_len >= pool->dirty_watermark) {
36579 - atomic_inc(&pool->req_ser);
36580 + atomic_inc_unchecked(&pool->req_ser);
36581 wake_up_process(pool->thread);
36582 }
36583 }
36584 diff --git a/drivers/infiniband/hw/cxgb4/mem.c b/drivers/infiniband/hw/cxgb4/mem.c
36585 index 903a92d..9262548 100644
36586 --- a/drivers/infiniband/hw/cxgb4/mem.c
36587 +++ b/drivers/infiniband/hw/cxgb4/mem.c
36588 @@ -122,7 +122,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
36589 int err;
36590 struct fw_ri_tpte tpt;
36591 u32 stag_idx;
36592 - static atomic_t key;
36593 + static atomic_unchecked_t key;
36594
36595 if (c4iw_fatal_error(rdev))
36596 return -EIO;
36597 @@ -139,7 +139,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
36598 if (rdev->stats.stag.cur > rdev->stats.stag.max)
36599 rdev->stats.stag.max = rdev->stats.stag.cur;
36600 mutex_unlock(&rdev->stats.lock);
36601 - *stag = (stag_idx << 8) | (atomic_inc_return(&key) & 0xff);
36602 + *stag = (stag_idx << 8) | (atomic_inc_return_unchecked(&key) & 0xff);
36603 }
36604 PDBG("%s stag_state 0x%0x type 0x%0x pdid 0x%0x, stag_idx 0x%x\n",
36605 __func__, stag_state, type, pdid, stag_idx);
36606 diff --git a/drivers/infiniband/hw/ipath/ipath_rc.c b/drivers/infiniband/hw/ipath/ipath_rc.c
36607 index 79b3dbc..96e5fcc 100644
36608 --- a/drivers/infiniband/hw/ipath/ipath_rc.c
36609 +++ b/drivers/infiniband/hw/ipath/ipath_rc.c
36610 @@ -1868,7 +1868,7 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
36611 struct ib_atomic_eth *ateth;
36612 struct ipath_ack_entry *e;
36613 u64 vaddr;
36614 - atomic64_t *maddr;
36615 + atomic64_unchecked_t *maddr;
36616 u64 sdata;
36617 u32 rkey;
36618 u8 next;
36619 @@ -1903,11 +1903,11 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
36620 IB_ACCESS_REMOTE_ATOMIC)))
36621 goto nack_acc_unlck;
36622 /* Perform atomic OP and save result. */
36623 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
36624 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
36625 sdata = be64_to_cpu(ateth->swap_data);
36626 e = &qp->s_ack_queue[qp->r_head_ack_queue];
36627 e->atomic_data = (opcode == OP(FETCH_ADD)) ?
36628 - (u64) atomic64_add_return(sdata, maddr) - sdata :
36629 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
36630 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
36631 be64_to_cpu(ateth->compare_data),
36632 sdata);
36633 diff --git a/drivers/infiniband/hw/ipath/ipath_ruc.c b/drivers/infiniband/hw/ipath/ipath_ruc.c
36634 index 1f95bba..9530f87 100644
36635 --- a/drivers/infiniband/hw/ipath/ipath_ruc.c
36636 +++ b/drivers/infiniband/hw/ipath/ipath_ruc.c
36637 @@ -266,7 +266,7 @@ static void ipath_ruc_loopback(struct ipath_qp *sqp)
36638 unsigned long flags;
36639 struct ib_wc wc;
36640 u64 sdata;
36641 - atomic64_t *maddr;
36642 + atomic64_unchecked_t *maddr;
36643 enum ib_wc_status send_status;
36644
36645 /*
36646 @@ -382,11 +382,11 @@ again:
36647 IB_ACCESS_REMOTE_ATOMIC)))
36648 goto acc_err;
36649 /* Perform atomic OP and save result. */
36650 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
36651 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
36652 sdata = wqe->wr.wr.atomic.compare_add;
36653 *(u64 *) sqp->s_sge.sge.vaddr =
36654 (wqe->wr.opcode == IB_WR_ATOMIC_FETCH_AND_ADD) ?
36655 - (u64) atomic64_add_return(sdata, maddr) - sdata :
36656 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
36657 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
36658 sdata, wqe->wr.wr.atomic.swap);
36659 goto send_comp;
36660 diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c
36661 index 9d3e5c1..d9afe4a 100644
36662 --- a/drivers/infiniband/hw/mthca/mthca_cmd.c
36663 +++ b/drivers/infiniband/hw/mthca/mthca_cmd.c
36664 @@ -772,7 +772,7 @@ static void mthca_setup_cmd_doorbells(struct mthca_dev *dev, u64 base)
36665 mthca_dbg(dev, "Mapped doorbell page for posting FW commands\n");
36666 }
36667
36668 -int mthca_QUERY_FW(struct mthca_dev *dev)
36669 +int __intentional_overflow(-1) mthca_QUERY_FW(struct mthca_dev *dev)
36670 {
36671 struct mthca_mailbox *mailbox;
36672 u32 *outbox;
36673 diff --git a/drivers/infiniband/hw/mthca/mthca_mr.c b/drivers/infiniband/hw/mthca/mthca_mr.c
36674 index ed9a989..e0c5871 100644
36675 --- a/drivers/infiniband/hw/mthca/mthca_mr.c
36676 +++ b/drivers/infiniband/hw/mthca/mthca_mr.c
36677 @@ -426,7 +426,7 @@ static inline u32 adjust_key(struct mthca_dev *dev, u32 key)
36678 return key;
36679 }
36680
36681 -int mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
36682 +int __intentional_overflow(-1) mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
36683 u64 iova, u64 total_size, u32 access, struct mthca_mr *mr)
36684 {
36685 struct mthca_mailbox *mailbox;
36686 diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
36687 index 4291410..d2ab1fb 100644
36688 --- a/drivers/infiniband/hw/nes/nes.c
36689 +++ b/drivers/infiniband/hw/nes/nes.c
36690 @@ -98,7 +98,7 @@ MODULE_PARM_DESC(limit_maxrdreqsz, "Limit max read request size to 256 Bytes");
36691 LIST_HEAD(nes_adapter_list);
36692 static LIST_HEAD(nes_dev_list);
36693
36694 -atomic_t qps_destroyed;
36695 +atomic_unchecked_t qps_destroyed;
36696
36697 static unsigned int ee_flsh_adapter;
36698 static unsigned int sysfs_nonidx_addr;
36699 @@ -269,7 +269,7 @@ static void nes_cqp_rem_ref_callback(struct nes_device *nesdev, struct nes_cqp_r
36700 struct nes_qp *nesqp = cqp_request->cqp_callback_pointer;
36701 struct nes_adapter *nesadapter = nesdev->nesadapter;
36702
36703 - atomic_inc(&qps_destroyed);
36704 + atomic_inc_unchecked(&qps_destroyed);
36705
36706 /* Free the control structures */
36707
36708 diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h
36709 index 33cc589..3bd6538 100644
36710 --- a/drivers/infiniband/hw/nes/nes.h
36711 +++ b/drivers/infiniband/hw/nes/nes.h
36712 @@ -177,17 +177,17 @@ extern unsigned int nes_debug_level;
36713 extern unsigned int wqm_quanta;
36714 extern struct list_head nes_adapter_list;
36715
36716 -extern atomic_t cm_connects;
36717 -extern atomic_t cm_accepts;
36718 -extern atomic_t cm_disconnects;
36719 -extern atomic_t cm_closes;
36720 -extern atomic_t cm_connecteds;
36721 -extern atomic_t cm_connect_reqs;
36722 -extern atomic_t cm_rejects;
36723 -extern atomic_t mod_qp_timouts;
36724 -extern atomic_t qps_created;
36725 -extern atomic_t qps_destroyed;
36726 -extern atomic_t sw_qps_destroyed;
36727 +extern atomic_unchecked_t cm_connects;
36728 +extern atomic_unchecked_t cm_accepts;
36729 +extern atomic_unchecked_t cm_disconnects;
36730 +extern atomic_unchecked_t cm_closes;
36731 +extern atomic_unchecked_t cm_connecteds;
36732 +extern atomic_unchecked_t cm_connect_reqs;
36733 +extern atomic_unchecked_t cm_rejects;
36734 +extern atomic_unchecked_t mod_qp_timouts;
36735 +extern atomic_unchecked_t qps_created;
36736 +extern atomic_unchecked_t qps_destroyed;
36737 +extern atomic_unchecked_t sw_qps_destroyed;
36738 extern u32 mh_detected;
36739 extern u32 mh_pauses_sent;
36740 extern u32 cm_packets_sent;
36741 @@ -196,16 +196,16 @@ extern u32 cm_packets_created;
36742 extern u32 cm_packets_received;
36743 extern u32 cm_packets_dropped;
36744 extern u32 cm_packets_retrans;
36745 -extern atomic_t cm_listens_created;
36746 -extern atomic_t cm_listens_destroyed;
36747 +extern atomic_unchecked_t cm_listens_created;
36748 +extern atomic_unchecked_t cm_listens_destroyed;
36749 extern u32 cm_backlog_drops;
36750 -extern atomic_t cm_loopbacks;
36751 -extern atomic_t cm_nodes_created;
36752 -extern atomic_t cm_nodes_destroyed;
36753 -extern atomic_t cm_accel_dropped_pkts;
36754 -extern atomic_t cm_resets_recvd;
36755 -extern atomic_t pau_qps_created;
36756 -extern atomic_t pau_qps_destroyed;
36757 +extern atomic_unchecked_t cm_loopbacks;
36758 +extern atomic_unchecked_t cm_nodes_created;
36759 +extern atomic_unchecked_t cm_nodes_destroyed;
36760 +extern atomic_unchecked_t cm_accel_dropped_pkts;
36761 +extern atomic_unchecked_t cm_resets_recvd;
36762 +extern atomic_unchecked_t pau_qps_created;
36763 +extern atomic_unchecked_t pau_qps_destroyed;
36764
36765 extern u32 int_mod_timer_init;
36766 extern u32 int_mod_cq_depth_256;
36767 diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
36768 index 24b9f1a..00fd004 100644
36769 --- a/drivers/infiniband/hw/nes/nes_cm.c
36770 +++ b/drivers/infiniband/hw/nes/nes_cm.c
36771 @@ -68,14 +68,14 @@ u32 cm_packets_dropped;
36772 u32 cm_packets_retrans;
36773 u32 cm_packets_created;
36774 u32 cm_packets_received;
36775 -atomic_t cm_listens_created;
36776 -atomic_t cm_listens_destroyed;
36777 +atomic_unchecked_t cm_listens_created;
36778 +atomic_unchecked_t cm_listens_destroyed;
36779 u32 cm_backlog_drops;
36780 -atomic_t cm_loopbacks;
36781 -atomic_t cm_nodes_created;
36782 -atomic_t cm_nodes_destroyed;
36783 -atomic_t cm_accel_dropped_pkts;
36784 -atomic_t cm_resets_recvd;
36785 +atomic_unchecked_t cm_loopbacks;
36786 +atomic_unchecked_t cm_nodes_created;
36787 +atomic_unchecked_t cm_nodes_destroyed;
36788 +atomic_unchecked_t cm_accel_dropped_pkts;
36789 +atomic_unchecked_t cm_resets_recvd;
36790
36791 static inline int mini_cm_accelerated(struct nes_cm_core *, struct nes_cm_node *);
36792 static struct nes_cm_listener *mini_cm_listen(struct nes_cm_core *, struct nes_vnic *, struct nes_cm_info *);
36793 @@ -148,13 +148,13 @@ static struct nes_cm_ops nes_cm_api = {
36794
36795 static struct nes_cm_core *g_cm_core;
36796
36797 -atomic_t cm_connects;
36798 -atomic_t cm_accepts;
36799 -atomic_t cm_disconnects;
36800 -atomic_t cm_closes;
36801 -atomic_t cm_connecteds;
36802 -atomic_t cm_connect_reqs;
36803 -atomic_t cm_rejects;
36804 +atomic_unchecked_t cm_connects;
36805 +atomic_unchecked_t cm_accepts;
36806 +atomic_unchecked_t cm_disconnects;
36807 +atomic_unchecked_t cm_closes;
36808 +atomic_unchecked_t cm_connecteds;
36809 +atomic_unchecked_t cm_connect_reqs;
36810 +atomic_unchecked_t cm_rejects;
36811
36812 int nes_add_ref_cm_node(struct nes_cm_node *cm_node)
36813 {
36814 @@ -1272,7 +1272,7 @@ static int mini_cm_dec_refcnt_listen(struct nes_cm_core *cm_core,
36815 kfree(listener);
36816 listener = NULL;
36817 ret = 0;
36818 - atomic_inc(&cm_listens_destroyed);
36819 + atomic_inc_unchecked(&cm_listens_destroyed);
36820 } else {
36821 spin_unlock_irqrestore(&cm_core->listen_list_lock, flags);
36822 }
36823 @@ -1466,7 +1466,7 @@ static struct nes_cm_node *make_cm_node(struct nes_cm_core *cm_core,
36824 cm_node->rem_mac);
36825
36826 add_hte_node(cm_core, cm_node);
36827 - atomic_inc(&cm_nodes_created);
36828 + atomic_inc_unchecked(&cm_nodes_created);
36829
36830 return cm_node;
36831 }
36832 @@ -1524,7 +1524,7 @@ static int rem_ref_cm_node(struct nes_cm_core *cm_core,
36833 }
36834
36835 atomic_dec(&cm_core->node_cnt);
36836 - atomic_inc(&cm_nodes_destroyed);
36837 + atomic_inc_unchecked(&cm_nodes_destroyed);
36838 nesqp = cm_node->nesqp;
36839 if (nesqp) {
36840 nesqp->cm_node = NULL;
36841 @@ -1588,7 +1588,7 @@ static int process_options(struct nes_cm_node *cm_node, u8 *optionsloc,
36842
36843 static void drop_packet(struct sk_buff *skb)
36844 {
36845 - atomic_inc(&cm_accel_dropped_pkts);
36846 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
36847 dev_kfree_skb_any(skb);
36848 }
36849
36850 @@ -1651,7 +1651,7 @@ static void handle_rst_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb,
36851 {
36852
36853 int reset = 0; /* whether to send reset in case of err.. */
36854 - atomic_inc(&cm_resets_recvd);
36855 + atomic_inc_unchecked(&cm_resets_recvd);
36856 nes_debug(NES_DBG_CM, "Received Reset, cm_node = %p, state = %u."
36857 " refcnt=%d\n", cm_node, cm_node->state,
36858 atomic_read(&cm_node->ref_count));
36859 @@ -2292,7 +2292,7 @@ static struct nes_cm_node *mini_cm_connect(struct nes_cm_core *cm_core,
36860 rem_ref_cm_node(cm_node->cm_core, cm_node);
36861 return NULL;
36862 }
36863 - atomic_inc(&cm_loopbacks);
36864 + atomic_inc_unchecked(&cm_loopbacks);
36865 loopbackremotenode->loopbackpartner = cm_node;
36866 loopbackremotenode->tcp_cntxt.rcv_wscale =
36867 NES_CM_DEFAULT_RCV_WND_SCALE;
36868 @@ -2567,7 +2567,7 @@ static int mini_cm_recv_pkt(struct nes_cm_core *cm_core,
36869 nes_queue_mgt_skbs(skb, nesvnic, cm_node->nesqp);
36870 else {
36871 rem_ref_cm_node(cm_core, cm_node);
36872 - atomic_inc(&cm_accel_dropped_pkts);
36873 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
36874 dev_kfree_skb_any(skb);
36875 }
36876 break;
36877 @@ -2875,7 +2875,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
36878
36879 if ((cm_id) && (cm_id->event_handler)) {
36880 if (issue_disconn) {
36881 - atomic_inc(&cm_disconnects);
36882 + atomic_inc_unchecked(&cm_disconnects);
36883 cm_event.event = IW_CM_EVENT_DISCONNECT;
36884 cm_event.status = disconn_status;
36885 cm_event.local_addr = cm_id->local_addr;
36886 @@ -2897,7 +2897,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
36887 }
36888
36889 if (issue_close) {
36890 - atomic_inc(&cm_closes);
36891 + atomic_inc_unchecked(&cm_closes);
36892 nes_disconnect(nesqp, 1);
36893
36894 cm_id->provider_data = nesqp;
36895 @@ -3033,7 +3033,7 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
36896
36897 nes_debug(NES_DBG_CM, "QP%u, cm_node=%p, jiffies = %lu listener = %p\n",
36898 nesqp->hwqp.qp_id, cm_node, jiffies, cm_node->listener);
36899 - atomic_inc(&cm_accepts);
36900 + atomic_inc_unchecked(&cm_accepts);
36901
36902 nes_debug(NES_DBG_CM, "netdev refcnt = %u.\n",
36903 netdev_refcnt_read(nesvnic->netdev));
36904 @@ -3228,7 +3228,7 @@ int nes_reject(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len)
36905 struct nes_cm_core *cm_core;
36906 u8 *start_buff;
36907
36908 - atomic_inc(&cm_rejects);
36909 + atomic_inc_unchecked(&cm_rejects);
36910 cm_node = (struct nes_cm_node *)cm_id->provider_data;
36911 loopback = cm_node->loopbackpartner;
36912 cm_core = cm_node->cm_core;
36913 @@ -3288,7 +3288,7 @@ int nes_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
36914 ntohl(cm_id->local_addr.sin_addr.s_addr),
36915 ntohs(cm_id->local_addr.sin_port));
36916
36917 - atomic_inc(&cm_connects);
36918 + atomic_inc_unchecked(&cm_connects);
36919 nesqp->active_conn = 1;
36920
36921 /* cache the cm_id in the qp */
36922 @@ -3398,7 +3398,7 @@ int nes_create_listen(struct iw_cm_id *cm_id, int backlog)
36923 g_cm_core->api->stop_listener(g_cm_core, (void *)cm_node);
36924 return err;
36925 }
36926 - atomic_inc(&cm_listens_created);
36927 + atomic_inc_unchecked(&cm_listens_created);
36928 }
36929
36930 cm_id->add_ref(cm_id);
36931 @@ -3499,7 +3499,7 @@ static void cm_event_connected(struct nes_cm_event *event)
36932
36933 if (nesqp->destroyed)
36934 return;
36935 - atomic_inc(&cm_connecteds);
36936 + atomic_inc_unchecked(&cm_connecteds);
36937 nes_debug(NES_DBG_CM, "QP%u attempting to connect to 0x%08X:0x%04X on"
36938 " local port 0x%04X. jiffies = %lu.\n",
36939 nesqp->hwqp.qp_id,
36940 @@ -3679,7 +3679,7 @@ static void cm_event_reset(struct nes_cm_event *event)
36941
36942 cm_id->add_ref(cm_id);
36943 ret = cm_id->event_handler(cm_id, &cm_event);
36944 - atomic_inc(&cm_closes);
36945 + atomic_inc_unchecked(&cm_closes);
36946 cm_event.event = IW_CM_EVENT_CLOSE;
36947 cm_event.status = 0;
36948 cm_event.provider_data = cm_id->provider_data;
36949 @@ -3715,7 +3715,7 @@ static void cm_event_mpa_req(struct nes_cm_event *event)
36950 return;
36951 cm_id = cm_node->cm_id;
36952
36953 - atomic_inc(&cm_connect_reqs);
36954 + atomic_inc_unchecked(&cm_connect_reqs);
36955 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
36956 cm_node, cm_id, jiffies);
36957
36958 @@ -3755,7 +3755,7 @@ static void cm_event_mpa_reject(struct nes_cm_event *event)
36959 return;
36960 cm_id = cm_node->cm_id;
36961
36962 - atomic_inc(&cm_connect_reqs);
36963 + atomic_inc_unchecked(&cm_connect_reqs);
36964 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
36965 cm_node, cm_id, jiffies);
36966
36967 diff --git a/drivers/infiniband/hw/nes/nes_mgt.c b/drivers/infiniband/hw/nes/nes_mgt.c
36968 index 4166452..fc952c3 100644
36969 --- a/drivers/infiniband/hw/nes/nes_mgt.c
36970 +++ b/drivers/infiniband/hw/nes/nes_mgt.c
36971 @@ -40,8 +40,8 @@
36972 #include "nes.h"
36973 #include "nes_mgt.h"
36974
36975 -atomic_t pau_qps_created;
36976 -atomic_t pau_qps_destroyed;
36977 +atomic_unchecked_t pau_qps_created;
36978 +atomic_unchecked_t pau_qps_destroyed;
36979
36980 static void nes_replenish_mgt_rq(struct nes_vnic_mgt *mgtvnic)
36981 {
36982 @@ -621,7 +621,7 @@ void nes_destroy_pau_qp(struct nes_device *nesdev, struct nes_qp *nesqp)
36983 {
36984 struct sk_buff *skb;
36985 unsigned long flags;
36986 - atomic_inc(&pau_qps_destroyed);
36987 + atomic_inc_unchecked(&pau_qps_destroyed);
36988
36989 /* Free packets that have not yet been forwarded */
36990 /* Lock is acquired by skb_dequeue when removing the skb */
36991 @@ -810,7 +810,7 @@ static void nes_mgt_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *
36992 cq->cq_vbase[head].cqe_words[NES_NIC_CQE_HASH_RCVNXT]);
36993 skb_queue_head_init(&nesqp->pau_list);
36994 spin_lock_init(&nesqp->pau_lock);
36995 - atomic_inc(&pau_qps_created);
36996 + atomic_inc_unchecked(&pau_qps_created);
36997 nes_change_quad_hash(nesdev, mgtvnic->nesvnic, nesqp);
36998 }
36999
37000 diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c
37001 index 85cf4d1..05d8e71 100644
37002 --- a/drivers/infiniband/hw/nes/nes_nic.c
37003 +++ b/drivers/infiniband/hw/nes/nes_nic.c
37004 @@ -1273,39 +1273,39 @@ static void nes_netdev_get_ethtool_stats(struct net_device *netdev,
37005 target_stat_values[++index] = mh_detected;
37006 target_stat_values[++index] = mh_pauses_sent;
37007 target_stat_values[++index] = nesvnic->endnode_ipv4_tcp_retransmits;
37008 - target_stat_values[++index] = atomic_read(&cm_connects);
37009 - target_stat_values[++index] = atomic_read(&cm_accepts);
37010 - target_stat_values[++index] = atomic_read(&cm_disconnects);
37011 - target_stat_values[++index] = atomic_read(&cm_connecteds);
37012 - target_stat_values[++index] = atomic_read(&cm_connect_reqs);
37013 - target_stat_values[++index] = atomic_read(&cm_rejects);
37014 - target_stat_values[++index] = atomic_read(&mod_qp_timouts);
37015 - target_stat_values[++index] = atomic_read(&qps_created);
37016 - target_stat_values[++index] = atomic_read(&sw_qps_destroyed);
37017 - target_stat_values[++index] = atomic_read(&qps_destroyed);
37018 - target_stat_values[++index] = atomic_read(&cm_closes);
37019 + target_stat_values[++index] = atomic_read_unchecked(&cm_connects);
37020 + target_stat_values[++index] = atomic_read_unchecked(&cm_accepts);
37021 + target_stat_values[++index] = atomic_read_unchecked(&cm_disconnects);
37022 + target_stat_values[++index] = atomic_read_unchecked(&cm_connecteds);
37023 + target_stat_values[++index] = atomic_read_unchecked(&cm_connect_reqs);
37024 + target_stat_values[++index] = atomic_read_unchecked(&cm_rejects);
37025 + target_stat_values[++index] = atomic_read_unchecked(&mod_qp_timouts);
37026 + target_stat_values[++index] = atomic_read_unchecked(&qps_created);
37027 + target_stat_values[++index] = atomic_read_unchecked(&sw_qps_destroyed);
37028 + target_stat_values[++index] = atomic_read_unchecked(&qps_destroyed);
37029 + target_stat_values[++index] = atomic_read_unchecked(&cm_closes);
37030 target_stat_values[++index] = cm_packets_sent;
37031 target_stat_values[++index] = cm_packets_bounced;
37032 target_stat_values[++index] = cm_packets_created;
37033 target_stat_values[++index] = cm_packets_received;
37034 target_stat_values[++index] = cm_packets_dropped;
37035 target_stat_values[++index] = cm_packets_retrans;
37036 - target_stat_values[++index] = atomic_read(&cm_listens_created);
37037 - target_stat_values[++index] = atomic_read(&cm_listens_destroyed);
37038 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_created);
37039 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_destroyed);
37040 target_stat_values[++index] = cm_backlog_drops;
37041 - target_stat_values[++index] = atomic_read(&cm_loopbacks);
37042 - target_stat_values[++index] = atomic_read(&cm_nodes_created);
37043 - target_stat_values[++index] = atomic_read(&cm_nodes_destroyed);
37044 - target_stat_values[++index] = atomic_read(&cm_accel_dropped_pkts);
37045 - target_stat_values[++index] = atomic_read(&cm_resets_recvd);
37046 + target_stat_values[++index] = atomic_read_unchecked(&cm_loopbacks);
37047 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_created);
37048 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_destroyed);
37049 + target_stat_values[++index] = atomic_read_unchecked(&cm_accel_dropped_pkts);
37050 + target_stat_values[++index] = atomic_read_unchecked(&cm_resets_recvd);
37051 target_stat_values[++index] = nesadapter->free_4kpbl;
37052 target_stat_values[++index] = nesadapter->free_256pbl;
37053 target_stat_values[++index] = int_mod_timer_init;
37054 target_stat_values[++index] = nesvnic->lro_mgr.stats.aggregated;
37055 target_stat_values[++index] = nesvnic->lro_mgr.stats.flushed;
37056 target_stat_values[++index] = nesvnic->lro_mgr.stats.no_desc;
37057 - target_stat_values[++index] = atomic_read(&pau_qps_created);
37058 - target_stat_values[++index] = atomic_read(&pau_qps_destroyed);
37059 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_created);
37060 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_destroyed);
37061 }
37062
37063 /**
37064 diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
37065 index 8f67fe2..8960859 100644
37066 --- a/drivers/infiniband/hw/nes/nes_verbs.c
37067 +++ b/drivers/infiniband/hw/nes/nes_verbs.c
37068 @@ -46,9 +46,9 @@
37069
37070 #include <rdma/ib_umem.h>
37071
37072 -atomic_t mod_qp_timouts;
37073 -atomic_t qps_created;
37074 -atomic_t sw_qps_destroyed;
37075 +atomic_unchecked_t mod_qp_timouts;
37076 +atomic_unchecked_t qps_created;
37077 +atomic_unchecked_t sw_qps_destroyed;
37078
37079 static void nes_unregister_ofa_device(struct nes_ib_device *nesibdev);
37080
37081 @@ -1134,7 +1134,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
37082 if (init_attr->create_flags)
37083 return ERR_PTR(-EINVAL);
37084
37085 - atomic_inc(&qps_created);
37086 + atomic_inc_unchecked(&qps_created);
37087 switch (init_attr->qp_type) {
37088 case IB_QPT_RC:
37089 if (nes_drv_opt & NES_DRV_OPT_NO_INLINE_DATA) {
37090 @@ -1465,7 +1465,7 @@ static int nes_destroy_qp(struct ib_qp *ibqp)
37091 struct iw_cm_event cm_event;
37092 int ret = 0;
37093
37094 - atomic_inc(&sw_qps_destroyed);
37095 + atomic_inc_unchecked(&sw_qps_destroyed);
37096 nesqp->destroyed = 1;
37097
37098 /* Blow away the connection if it exists. */
37099 diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h
37100 index 4d11575..3e890e5 100644
37101 --- a/drivers/infiniband/hw/qib/qib.h
37102 +++ b/drivers/infiniband/hw/qib/qib.h
37103 @@ -51,6 +51,7 @@
37104 #include <linux/completion.h>
37105 #include <linux/kref.h>
37106 #include <linux/sched.h>
37107 +#include <linux/slab.h>
37108
37109 #include "qib_common.h"
37110 #include "qib_verbs.h"
37111 diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
37112 index da739d9..da1c7f4 100644
37113 --- a/drivers/input/gameport/gameport.c
37114 +++ b/drivers/input/gameport/gameport.c
37115 @@ -487,14 +487,14 @@ EXPORT_SYMBOL(gameport_set_phys);
37116 */
37117 static void gameport_init_port(struct gameport *gameport)
37118 {
37119 - static atomic_t gameport_no = ATOMIC_INIT(0);
37120 + static atomic_unchecked_t gameport_no = ATOMIC_INIT(0);
37121
37122 __module_get(THIS_MODULE);
37123
37124 mutex_init(&gameport->drv_mutex);
37125 device_initialize(&gameport->dev);
37126 dev_set_name(&gameport->dev, "gameport%lu",
37127 - (unsigned long)atomic_inc_return(&gameport_no) - 1);
37128 + (unsigned long)atomic_inc_return_unchecked(&gameport_no) - 1);
37129 gameport->dev.bus = &gameport_bus;
37130 gameport->dev.release = gameport_release_port;
37131 if (gameport->parent)
37132 diff --git a/drivers/input/input.c b/drivers/input/input.c
37133 index c044699..174d71a 100644
37134 --- a/drivers/input/input.c
37135 +++ b/drivers/input/input.c
37136 @@ -2019,7 +2019,7 @@ static void devm_input_device_unregister(struct device *dev, void *res)
37137 */
37138 int input_register_device(struct input_dev *dev)
37139 {
37140 - static atomic_t input_no = ATOMIC_INIT(0);
37141 + static atomic_unchecked_t input_no = ATOMIC_INIT(0);
37142 struct input_devres *devres = NULL;
37143 struct input_handler *handler;
37144 unsigned int packet_size;
37145 @@ -2074,7 +2074,7 @@ int input_register_device(struct input_dev *dev)
37146 dev->setkeycode = input_default_setkeycode;
37147
37148 dev_set_name(&dev->dev, "input%ld",
37149 - (unsigned long) atomic_inc_return(&input_no) - 1);
37150 + (unsigned long) atomic_inc_return_unchecked(&input_no) - 1);
37151
37152 error = device_add(&dev->dev);
37153 if (error)
37154 diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
37155 index 04c69af..5f92d00 100644
37156 --- a/drivers/input/joystick/sidewinder.c
37157 +++ b/drivers/input/joystick/sidewinder.c
37158 @@ -30,6 +30,7 @@
37159 #include <linux/kernel.h>
37160 #include <linux/module.h>
37161 #include <linux/slab.h>
37162 +#include <linux/sched.h>
37163 #include <linux/init.h>
37164 #include <linux/input.h>
37165 #include <linux/gameport.h>
37166 diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
37167 index d6cbfe9..6225402 100644
37168 --- a/drivers/input/joystick/xpad.c
37169 +++ b/drivers/input/joystick/xpad.c
37170 @@ -735,7 +735,7 @@ static void xpad_led_set(struct led_classdev *led_cdev,
37171
37172 static int xpad_led_probe(struct usb_xpad *xpad)
37173 {
37174 - static atomic_t led_seq = ATOMIC_INIT(0);
37175 + static atomic_unchecked_t led_seq = ATOMIC_INIT(0);
37176 long led_no;
37177 struct xpad_led *led;
37178 struct led_classdev *led_cdev;
37179 @@ -748,7 +748,7 @@ static int xpad_led_probe(struct usb_xpad *xpad)
37180 if (!led)
37181 return -ENOMEM;
37182
37183 - led_no = (long)atomic_inc_return(&led_seq) - 1;
37184 + led_no = (long)atomic_inc_return_unchecked(&led_seq) - 1;
37185
37186 snprintf(led->name, sizeof(led->name), "xpad%ld", led_no);
37187 led->xpad = xpad;
37188 diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
37189 index 2f0b39d..7370f13 100644
37190 --- a/drivers/input/mouse/psmouse.h
37191 +++ b/drivers/input/mouse/psmouse.h
37192 @@ -116,7 +116,7 @@ struct psmouse_attribute {
37193 ssize_t (*set)(struct psmouse *psmouse, void *data,
37194 const char *buf, size_t count);
37195 bool protect;
37196 -};
37197 +} __do_const;
37198 #define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr)
37199
37200 ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *attr,
37201 diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
37202 index 4c842c3..590b0bf 100644
37203 --- a/drivers/input/mousedev.c
37204 +++ b/drivers/input/mousedev.c
37205 @@ -738,7 +738,7 @@ static ssize_t mousedev_read(struct file *file, char __user *buffer,
37206
37207 spin_unlock_irq(&client->packet_lock);
37208
37209 - if (copy_to_user(buffer, data, count))
37210 + if (count > sizeof(data) || copy_to_user(buffer, data, count))
37211 return -EFAULT;
37212
37213 return count;
37214 diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
37215 index 25fc597..558bf3b3 100644
37216 --- a/drivers/input/serio/serio.c
37217 +++ b/drivers/input/serio/serio.c
37218 @@ -496,7 +496,7 @@ static void serio_release_port(struct device *dev)
37219 */
37220 static void serio_init_port(struct serio *serio)
37221 {
37222 - static atomic_t serio_no = ATOMIC_INIT(0);
37223 + static atomic_unchecked_t serio_no = ATOMIC_INIT(0);
37224
37225 __module_get(THIS_MODULE);
37226
37227 @@ -507,7 +507,7 @@ static void serio_init_port(struct serio *serio)
37228 mutex_init(&serio->drv_mutex);
37229 device_initialize(&serio->dev);
37230 dev_set_name(&serio->dev, "serio%ld",
37231 - (long)atomic_inc_return(&serio_no) - 1);
37232 + (long)atomic_inc_return_unchecked(&serio_no) - 1);
37233 serio->dev.bus = &serio_bus;
37234 serio->dev.release = serio_release_port;
37235 serio->dev.groups = serio_device_attr_groups;
37236 diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
37237 index b972d43..8943713 100644
37238 --- a/drivers/iommu/iommu.c
37239 +++ b/drivers/iommu/iommu.c
37240 @@ -554,7 +554,7 @@ static struct notifier_block iommu_bus_nb = {
37241 static void iommu_bus_init(struct bus_type *bus, struct iommu_ops *ops)
37242 {
37243 bus_register_notifier(bus, &iommu_bus_nb);
37244 - bus_for_each_dev(bus, NULL, ops, add_iommu_group);
37245 + bus_for_each_dev(bus, NULL, (void *)ops, add_iommu_group);
37246 }
37247
37248 /**
37249 diff --git a/drivers/iommu/irq_remapping.c b/drivers/iommu/irq_remapping.c
37250 index 7c11ff3..5b2d7a7 100644
37251 --- a/drivers/iommu/irq_remapping.c
37252 +++ b/drivers/iommu/irq_remapping.c
37253 @@ -369,10 +369,12 @@ static void ir_print_prefix(struct irq_data *data, struct seq_file *p)
37254
37255 void irq_remap_modify_chip_defaults(struct irq_chip *chip)
37256 {
37257 - chip->irq_print_chip = ir_print_prefix;
37258 - chip->irq_ack = ir_ack_apic_edge;
37259 - chip->irq_eoi = ir_ack_apic_level;
37260 - chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
37261 + pax_open_kernel();
37262 + *(void **)&chip->irq_print_chip = ir_print_prefix;
37263 + *(void **)&chip->irq_ack = ir_ack_apic_edge;
37264 + *(void **)&chip->irq_eoi = ir_ack_apic_level;
37265 + *(void **)&chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
37266 + pax_close_kernel();
37267 }
37268
37269 bool setup_remapped_irq(int irq, struct irq_cfg *cfg, struct irq_chip *chip)
37270 diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
37271 index fc6aebf..762c5f5 100644
37272 --- a/drivers/irqchip/irq-gic.c
37273 +++ b/drivers/irqchip/irq-gic.c
37274 @@ -83,7 +83,7 @@ static u8 gic_cpu_map[NR_GIC_CPU_IF] __read_mostly;
37275 * Supported arch specific GIC irq extension.
37276 * Default make them NULL.
37277 */
37278 -struct irq_chip gic_arch_extn = {
37279 +irq_chip_no_const gic_arch_extn = {
37280 .irq_eoi = NULL,
37281 .irq_mask = NULL,
37282 .irq_unmask = NULL,
37283 @@ -332,7 +332,7 @@ static void gic_handle_cascade_irq(unsigned int irq, struct irq_desc *desc)
37284 chained_irq_exit(chip, desc);
37285 }
37286
37287 -static struct irq_chip gic_chip = {
37288 +static irq_chip_no_const gic_chip __read_only = {
37289 .name = "GIC",
37290 .irq_mask = gic_mask_irq,
37291 .irq_unmask = gic_unmask_irq,
37292 diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
37293 index 89562a8..218999b 100644
37294 --- a/drivers/isdn/capi/capi.c
37295 +++ b/drivers/isdn/capi/capi.c
37296 @@ -81,8 +81,8 @@ struct capiminor {
37297
37298 struct capi20_appl *ap;
37299 u32 ncci;
37300 - atomic_t datahandle;
37301 - atomic_t msgid;
37302 + atomic_unchecked_t datahandle;
37303 + atomic_unchecked_t msgid;
37304
37305 struct tty_port port;
37306 int ttyinstop;
37307 @@ -391,7 +391,7 @@ gen_data_b3_resp_for(struct capiminor *mp, struct sk_buff *skb)
37308 capimsg_setu16(s, 2, mp->ap->applid);
37309 capimsg_setu8 (s, 4, CAPI_DATA_B3);
37310 capimsg_setu8 (s, 5, CAPI_RESP);
37311 - capimsg_setu16(s, 6, atomic_inc_return(&mp->msgid));
37312 + capimsg_setu16(s, 6, atomic_inc_return_unchecked(&mp->msgid));
37313 capimsg_setu32(s, 8, mp->ncci);
37314 capimsg_setu16(s, 12, datahandle);
37315 }
37316 @@ -512,14 +512,14 @@ static void handle_minor_send(struct capiminor *mp)
37317 mp->outbytes -= len;
37318 spin_unlock_bh(&mp->outlock);
37319
37320 - datahandle = atomic_inc_return(&mp->datahandle);
37321 + datahandle = atomic_inc_return_unchecked(&mp->datahandle);
37322 skb_push(skb, CAPI_DATA_B3_REQ_LEN);
37323 memset(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
37324 capimsg_setu16(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
37325 capimsg_setu16(skb->data, 2, mp->ap->applid);
37326 capimsg_setu8 (skb->data, 4, CAPI_DATA_B3);
37327 capimsg_setu8 (skb->data, 5, CAPI_REQ);
37328 - capimsg_setu16(skb->data, 6, atomic_inc_return(&mp->msgid));
37329 + capimsg_setu16(skb->data, 6, atomic_inc_return_unchecked(&mp->msgid));
37330 capimsg_setu32(skb->data, 8, mp->ncci); /* NCCI */
37331 capimsg_setu32(skb->data, 12, (u32)(long)skb->data);/* Data32 */
37332 capimsg_setu16(skb->data, 16, len); /* Data length */
37333 diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
37334 index e2b5396..c5486dc 100644
37335 --- a/drivers/isdn/gigaset/interface.c
37336 +++ b/drivers/isdn/gigaset/interface.c
37337 @@ -130,9 +130,9 @@ static int if_open(struct tty_struct *tty, struct file *filp)
37338 }
37339 tty->driver_data = cs;
37340
37341 - ++cs->port.count;
37342 + atomic_inc(&cs->port.count);
37343
37344 - if (cs->port.count == 1) {
37345 + if (atomic_read(&cs->port.count) == 1) {
37346 tty_port_tty_set(&cs->port, tty);
37347 cs->port.low_latency = 1;
37348 }
37349 @@ -156,9 +156,9 @@ static void if_close(struct tty_struct *tty, struct file *filp)
37350
37351 if (!cs->connected)
37352 gig_dbg(DEBUG_IF, "not connected"); /* nothing to do */
37353 - else if (!cs->port.count)
37354 + else if (!atomic_read(&cs->port.count))
37355 dev_warn(cs->dev, "%s: device not opened\n", __func__);
37356 - else if (!--cs->port.count)
37357 + else if (!atomic_dec_return(&cs->port.count))
37358 tty_port_tty_set(&cs->port, NULL);
37359
37360 mutex_unlock(&cs->mutex);
37361 diff --git a/drivers/isdn/hardware/avm/b1.c b/drivers/isdn/hardware/avm/b1.c
37362 index 821f7ac..28d4030 100644
37363 --- a/drivers/isdn/hardware/avm/b1.c
37364 +++ b/drivers/isdn/hardware/avm/b1.c
37365 @@ -176,7 +176,7 @@ int b1_load_t4file(avmcard *card, capiloaddatapart *t4file)
37366 }
37367 if (left) {
37368 if (t4file->user) {
37369 - if (copy_from_user(buf, dp, left))
37370 + if (left > sizeof buf || copy_from_user(buf, dp, left))
37371 return -EFAULT;
37372 } else {
37373 memcpy(buf, dp, left);
37374 @@ -224,7 +224,7 @@ int b1_load_config(avmcard *card, capiloaddatapart *config)
37375 }
37376 if (left) {
37377 if (config->user) {
37378 - if (copy_from_user(buf, dp, left))
37379 + if (left > sizeof buf || copy_from_user(buf, dp, left))
37380 return -EFAULT;
37381 } else {
37382 memcpy(buf, dp, left);
37383 diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
37384 index ebaebdf..acd4405 100644
37385 --- a/drivers/isdn/i4l/isdn_tty.c
37386 +++ b/drivers/isdn/i4l/isdn_tty.c
37387 @@ -1511,9 +1511,9 @@ isdn_tty_open(struct tty_struct *tty, struct file *filp)
37388
37389 #ifdef ISDN_DEBUG_MODEM_OPEN
37390 printk(KERN_DEBUG "isdn_tty_open %s, count = %d\n", tty->name,
37391 - port->count);
37392 + atomic_read(&port->count));
37393 #endif
37394 - port->count++;
37395 + atomic_inc(&port->count);
37396 port->tty = tty;
37397 /*
37398 * Start up serial port
37399 @@ -1557,7 +1557,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
37400 #endif
37401 return;
37402 }
37403 - if ((tty->count == 1) && (port->count != 1)) {
37404 + if ((tty->count == 1) && (atomic_read(&port->count) != 1)) {
37405 /*
37406 * Uh, oh. tty->count is 1, which means that the tty
37407 * structure will be freed. Info->count should always
37408 @@ -1566,15 +1566,15 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
37409 * serial port won't be shutdown.
37410 */
37411 printk(KERN_ERR "isdn_tty_close: bad port count; tty->count is 1, "
37412 - "info->count is %d\n", port->count);
37413 - port->count = 1;
37414 + "info->count is %d\n", atomic_read(&port->count));
37415 + atomic_set(&port->count, 1);
37416 }
37417 - if (--port->count < 0) {
37418 + if (atomic_dec_return(&port->count) < 0) {
37419 printk(KERN_ERR "isdn_tty_close: bad port count for ttyi%d: %d\n",
37420 - info->line, port->count);
37421 - port->count = 0;
37422 + info->line, atomic_read(&port->count));
37423 + atomic_set(&port->count, 0);
37424 }
37425 - if (port->count) {
37426 + if (atomic_read(&port->count)) {
37427 #ifdef ISDN_DEBUG_MODEM_OPEN
37428 printk(KERN_DEBUG "isdn_tty_close after info->count != 0\n");
37429 #endif
37430 @@ -1628,7 +1628,7 @@ isdn_tty_hangup(struct tty_struct *tty)
37431 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_hangup"))
37432 return;
37433 isdn_tty_shutdown(info);
37434 - port->count = 0;
37435 + atomic_set(&port->count, 0);
37436 port->flags &= ~ASYNC_NORMAL_ACTIVE;
37437 port->tty = NULL;
37438 wake_up_interruptible(&port->open_wait);
37439 @@ -1973,7 +1973,7 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup)
37440 for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
37441 modem_info *info = &dev->mdm.info[i];
37442
37443 - if (info->port.count == 0)
37444 + if (atomic_read(&info->port.count) == 0)
37445 continue;
37446 if ((info->emu.mdmreg[REG_SI1] & si2bit[si1]) && /* SI1 is matching */
37447 (info->emu.mdmreg[REG_SI2] == si2)) { /* SI2 is matching */
37448 diff --git a/drivers/isdn/icn/icn.c b/drivers/isdn/icn/icn.c
37449 index e74df7c..03a03ba 100644
37450 --- a/drivers/isdn/icn/icn.c
37451 +++ b/drivers/isdn/icn/icn.c
37452 @@ -1045,7 +1045,7 @@ icn_writecmd(const u_char *buf, int len, int user, icn_card *card)
37453 if (count > len)
37454 count = len;
37455 if (user) {
37456 - if (copy_from_user(msg, buf, count))
37457 + if (count > sizeof msg || copy_from_user(msg, buf, count))
37458 return -EFAULT;
37459 } else
37460 memcpy(msg, buf, count);
37461 diff --git a/drivers/leds/leds-clevo-mail.c b/drivers/leds/leds-clevo-mail.c
37462 index 6a8405d..0bd1c7e 100644
37463 --- a/drivers/leds/leds-clevo-mail.c
37464 +++ b/drivers/leds/leds-clevo-mail.c
37465 @@ -40,7 +40,7 @@ static int __init clevo_mail_led_dmi_callback(const struct dmi_system_id *id)
37466 * detected as working, but in reality it is not) as low as
37467 * possible.
37468 */
37469 -static struct dmi_system_id __initdata clevo_mail_led_dmi_table[] = {
37470 +static const struct dmi_system_id __initconst clevo_mail_led_dmi_table[] = {
37471 {
37472 .callback = clevo_mail_led_dmi_callback,
37473 .ident = "Clevo D410J",
37474 diff --git a/drivers/leds/leds-ss4200.c b/drivers/leds/leds-ss4200.c
37475 index 64e204e..c6bf189 100644
37476 --- a/drivers/leds/leds-ss4200.c
37477 +++ b/drivers/leds/leds-ss4200.c
37478 @@ -91,7 +91,7 @@ MODULE_PARM_DESC(nodetect, "Skip DMI-based hardware detection");
37479 * detected as working, but in reality it is not) as low as
37480 * possible.
37481 */
37482 -static struct dmi_system_id __initdata nas_led_whitelist[] = {
37483 +static const struct dmi_system_id __initconst nas_led_whitelist[] = {
37484 {
37485 .callback = ss4200_led_dmi_callback,
37486 .ident = "Intel SS4200-E",
37487 diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c
37488 index a5ebc00..982886f 100644
37489 --- a/drivers/lguest/core.c
37490 +++ b/drivers/lguest/core.c
37491 @@ -92,9 +92,17 @@ static __init int map_switcher(void)
37492 * it's worked so far. The end address needs +1 because __get_vm_area
37493 * allocates an extra guard page, so we need space for that.
37494 */
37495 +
37496 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
37497 + switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
37498 + VM_ALLOC | VM_KERNEXEC, SWITCHER_ADDR, SWITCHER_ADDR
37499 + + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
37500 +#else
37501 switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
37502 VM_ALLOC, SWITCHER_ADDR, SWITCHER_ADDR
37503 + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
37504 +#endif
37505 +
37506 if (!switcher_vma) {
37507 err = -ENOMEM;
37508 printk("lguest: could not map switcher pages high\n");
37509 @@ -119,7 +127,7 @@ static __init int map_switcher(void)
37510 * Now the Switcher is mapped at the right address, we can't fail!
37511 * Copy in the compiled-in Switcher code (from x86/switcher_32.S).
37512 */
37513 - memcpy(switcher_vma->addr, start_switcher_text,
37514 + memcpy(switcher_vma->addr, ktla_ktva(start_switcher_text),
37515 end_switcher_text - start_switcher_text);
37516
37517 printk(KERN_INFO "lguest: mapped switcher at %p\n",
37518 diff --git a/drivers/lguest/page_tables.c b/drivers/lguest/page_tables.c
37519 index 3b62be16..e33134a 100644
37520 --- a/drivers/lguest/page_tables.c
37521 +++ b/drivers/lguest/page_tables.c
37522 @@ -532,7 +532,7 @@ void pin_page(struct lg_cpu *cpu, unsigned long vaddr)
37523 /*:*/
37524
37525 #ifdef CONFIG_X86_PAE
37526 -static void release_pmd(pmd_t *spmd)
37527 +static void __intentional_overflow(-1) release_pmd(pmd_t *spmd)
37528 {
37529 /* If the entry's not present, there's nothing to release. */
37530 if (pmd_flags(*spmd) & _PAGE_PRESENT) {
37531 diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
37532 index 4af12e1..0e89afe 100644
37533 --- a/drivers/lguest/x86/core.c
37534 +++ b/drivers/lguest/x86/core.c
37535 @@ -59,7 +59,7 @@ static struct {
37536 /* Offset from where switcher.S was compiled to where we've copied it */
37537 static unsigned long switcher_offset(void)
37538 {
37539 - return SWITCHER_ADDR - (unsigned long)start_switcher_text;
37540 + return SWITCHER_ADDR - (unsigned long)ktla_ktva(start_switcher_text);
37541 }
37542
37543 /* This cpu's struct lguest_pages. */
37544 @@ -100,7 +100,13 @@ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages)
37545 * These copies are pretty cheap, so we do them unconditionally: */
37546 /* Save the current Host top-level page directory.
37547 */
37548 +
37549 +#ifdef CONFIG_PAX_PER_CPU_PGD
37550 + pages->state.host_cr3 = read_cr3();
37551 +#else
37552 pages->state.host_cr3 = __pa(current->mm->pgd);
37553 +#endif
37554 +
37555 /*
37556 * Set up the Guest's page tables to see this CPU's pages (and no
37557 * other CPU's pages).
37558 @@ -476,7 +482,7 @@ void __init lguest_arch_host_init(void)
37559 * compiled-in switcher code and the high-mapped copy we just made.
37560 */
37561 for (i = 0; i < IDT_ENTRIES; i++)
37562 - default_idt_entries[i] += switcher_offset();
37563 + default_idt_entries[i] = ktla_ktva(default_idt_entries[i]) + switcher_offset();
37564
37565 /*
37566 * Set up the Switcher's per-cpu areas.
37567 @@ -559,7 +565,7 @@ void __init lguest_arch_host_init(void)
37568 * it will be undisturbed when we switch. To change %cs and jump we
37569 * need this structure to feed to Intel's "lcall" instruction.
37570 */
37571 - lguest_entry.offset = (long)switch_to_guest + switcher_offset();
37572 + lguest_entry.offset = (long)ktla_ktva(switch_to_guest) + switcher_offset();
37573 lguest_entry.segment = LGUEST_CS;
37574
37575 /*
37576 diff --git a/drivers/lguest/x86/switcher_32.S b/drivers/lguest/x86/switcher_32.S
37577 index 40634b0..4f5855e 100644
37578 --- a/drivers/lguest/x86/switcher_32.S
37579 +++ b/drivers/lguest/x86/switcher_32.S
37580 @@ -87,6 +87,7 @@
37581 #include <asm/page.h>
37582 #include <asm/segment.h>
37583 #include <asm/lguest.h>
37584 +#include <asm/processor-flags.h>
37585
37586 // We mark the start of the code to copy
37587 // It's placed in .text tho it's never run here
37588 @@ -149,6 +150,13 @@ ENTRY(switch_to_guest)
37589 // Changes type when we load it: damn Intel!
37590 // For after we switch over our page tables
37591 // That entry will be read-only: we'd crash.
37592 +
37593 +#ifdef CONFIG_PAX_KERNEXEC
37594 + mov %cr0, %edx
37595 + xor $X86_CR0_WP, %edx
37596 + mov %edx, %cr0
37597 +#endif
37598 +
37599 movl $(GDT_ENTRY_TSS*8), %edx
37600 ltr %dx
37601
37602 @@ -157,9 +165,15 @@ ENTRY(switch_to_guest)
37603 // Let's clear it again for our return.
37604 // The GDT descriptor of the Host
37605 // Points to the table after two "size" bytes
37606 - movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %edx
37607 + movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %eax
37608 // Clear "used" from type field (byte 5, bit 2)
37609 - andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%edx)
37610 + andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%eax)
37611 +
37612 +#ifdef CONFIG_PAX_KERNEXEC
37613 + mov %cr0, %eax
37614 + xor $X86_CR0_WP, %eax
37615 + mov %eax, %cr0
37616 +#endif
37617
37618 // Once our page table's switched, the Guest is live!
37619 // The Host fades as we run this final step.
37620 @@ -295,13 +309,12 @@ deliver_to_host:
37621 // I consulted gcc, and it gave
37622 // These instructions, which I gladly credit:
37623 leal (%edx,%ebx,8), %eax
37624 - movzwl (%eax),%edx
37625 - movl 4(%eax), %eax
37626 - xorw %ax, %ax
37627 - orl %eax, %edx
37628 + movl 4(%eax), %edx
37629 + movw (%eax), %dx
37630 // Now the address of the handler's in %edx
37631 // We call it now: its "iret" drops us home.
37632 - jmp *%edx
37633 + ljmp $__KERNEL_CS, $1f
37634 +1: jmp *%edx
37635
37636 // Every interrupt can come to us here
37637 // But we must truly tell each apart.
37638 diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
37639 index 4fd9d6a..834fa03 100644
37640 --- a/drivers/md/bitmap.c
37641 +++ b/drivers/md/bitmap.c
37642 @@ -1779,7 +1779,7 @@ void bitmap_status(struct seq_file *seq, struct bitmap *bitmap)
37643 chunk_kb ? "KB" : "B");
37644 if (bitmap->storage.file) {
37645 seq_printf(seq, ", file: ");
37646 - seq_path(seq, &bitmap->storage.file->f_path, " \t\n");
37647 + seq_path(seq, &bitmap->storage.file->f_path, " \t\n\\");
37648 }
37649
37650 seq_printf(seq, "\n");
37651 diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
37652 index aa04f02..2a1309e 100644
37653 --- a/drivers/md/dm-ioctl.c
37654 +++ b/drivers/md/dm-ioctl.c
37655 @@ -1694,7 +1694,7 @@ static int validate_params(uint cmd, struct dm_ioctl *param)
37656 cmd == DM_LIST_VERSIONS_CMD)
37657 return 0;
37658
37659 - if ((cmd == DM_DEV_CREATE_CMD)) {
37660 + if (cmd == DM_DEV_CREATE_CMD) {
37661 if (!*param->name) {
37662 DMWARN("name not supplied when creating device");
37663 return -EINVAL;
37664 diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
37665 index d053098..05cc375 100644
37666 --- a/drivers/md/dm-raid1.c
37667 +++ b/drivers/md/dm-raid1.c
37668 @@ -40,7 +40,7 @@ enum dm_raid1_error {
37669
37670 struct mirror {
37671 struct mirror_set *ms;
37672 - atomic_t error_count;
37673 + atomic_unchecked_t error_count;
37674 unsigned long error_type;
37675 struct dm_dev *dev;
37676 sector_t offset;
37677 @@ -186,7 +186,7 @@ static struct mirror *get_valid_mirror(struct mirror_set *ms)
37678 struct mirror *m;
37679
37680 for (m = ms->mirror; m < ms->mirror + ms->nr_mirrors; m++)
37681 - if (!atomic_read(&m->error_count))
37682 + if (!atomic_read_unchecked(&m->error_count))
37683 return m;
37684
37685 return NULL;
37686 @@ -218,7 +218,7 @@ static void fail_mirror(struct mirror *m, enum dm_raid1_error error_type)
37687 * simple way to tell if a device has encountered
37688 * errors.
37689 */
37690 - atomic_inc(&m->error_count);
37691 + atomic_inc_unchecked(&m->error_count);
37692
37693 if (test_and_set_bit(error_type, &m->error_type))
37694 return;
37695 @@ -409,7 +409,7 @@ static struct mirror *choose_mirror(struct mirror_set *ms, sector_t sector)
37696 struct mirror *m = get_default_mirror(ms);
37697
37698 do {
37699 - if (likely(!atomic_read(&m->error_count)))
37700 + if (likely(!atomic_read_unchecked(&m->error_count)))
37701 return m;
37702
37703 if (m-- == ms->mirror)
37704 @@ -423,7 +423,7 @@ static int default_ok(struct mirror *m)
37705 {
37706 struct mirror *default_mirror = get_default_mirror(m->ms);
37707
37708 - return !atomic_read(&default_mirror->error_count);
37709 + return !atomic_read_unchecked(&default_mirror->error_count);
37710 }
37711
37712 static int mirror_available(struct mirror_set *ms, struct bio *bio)
37713 @@ -560,7 +560,7 @@ static void do_reads(struct mirror_set *ms, struct bio_list *reads)
37714 */
37715 if (likely(region_in_sync(ms, region, 1)))
37716 m = choose_mirror(ms, bio->bi_sector);
37717 - else if (m && atomic_read(&m->error_count))
37718 + else if (m && atomic_read_unchecked(&m->error_count))
37719 m = NULL;
37720
37721 if (likely(m))
37722 @@ -927,7 +927,7 @@ static int get_mirror(struct mirror_set *ms, struct dm_target *ti,
37723 }
37724
37725 ms->mirror[mirror].ms = ms;
37726 - atomic_set(&(ms->mirror[mirror].error_count), 0);
37727 + atomic_set_unchecked(&(ms->mirror[mirror].error_count), 0);
37728 ms->mirror[mirror].error_type = 0;
37729 ms->mirror[mirror].offset = offset;
37730
37731 @@ -1340,7 +1340,7 @@ static void mirror_resume(struct dm_target *ti)
37732 */
37733 static char device_status_char(struct mirror *m)
37734 {
37735 - if (!atomic_read(&(m->error_count)))
37736 + if (!atomic_read_unchecked(&(m->error_count)))
37737 return 'A';
37738
37739 return (test_bit(DM_RAID1_FLUSH_ERROR, &(m->error_type))) ? 'F' :
37740 diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
37741 index 7b8b2b9..9c7d145 100644
37742 --- a/drivers/md/dm-stripe.c
37743 +++ b/drivers/md/dm-stripe.c
37744 @@ -20,7 +20,7 @@ struct stripe {
37745 struct dm_dev *dev;
37746 sector_t physical_start;
37747
37748 - atomic_t error_count;
37749 + atomic_unchecked_t error_count;
37750 };
37751
37752 struct stripe_c {
37753 @@ -185,7 +185,7 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
37754 kfree(sc);
37755 return r;
37756 }
37757 - atomic_set(&(sc->stripe[i].error_count), 0);
37758 + atomic_set_unchecked(&(sc->stripe[i].error_count), 0);
37759 }
37760
37761 ti->private = sc;
37762 @@ -326,7 +326,7 @@ static void stripe_status(struct dm_target *ti, status_type_t type,
37763 DMEMIT("%d ", sc->stripes);
37764 for (i = 0; i < sc->stripes; i++) {
37765 DMEMIT("%s ", sc->stripe[i].dev->name);
37766 - buffer[i] = atomic_read(&(sc->stripe[i].error_count)) ?
37767 + buffer[i] = atomic_read_unchecked(&(sc->stripe[i].error_count)) ?
37768 'D' : 'A';
37769 }
37770 buffer[i] = '\0';
37771 @@ -371,8 +371,8 @@ static int stripe_end_io(struct dm_target *ti, struct bio *bio, int error)
37772 */
37773 for (i = 0; i < sc->stripes; i++)
37774 if (!strcmp(sc->stripe[i].dev->name, major_minor)) {
37775 - atomic_inc(&(sc->stripe[i].error_count));
37776 - if (atomic_read(&(sc->stripe[i].error_count)) <
37777 + atomic_inc_unchecked(&(sc->stripe[i].error_count));
37778 + if (atomic_read_unchecked(&(sc->stripe[i].error_count)) <
37779 DM_IO_ERROR_THRESHOLD)
37780 schedule_work(&sc->trigger_event);
37781 }
37782 diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
37783 index 1ff252a..ee384c1 100644
37784 --- a/drivers/md/dm-table.c
37785 +++ b/drivers/md/dm-table.c
37786 @@ -389,7 +389,7 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
37787 if (!dev_size)
37788 return 0;
37789
37790 - if ((start >= dev_size) || (start + len > dev_size)) {
37791 + if ((start >= dev_size) || (len > dev_size - start)) {
37792 DMWARN("%s: %s too small for target: "
37793 "start=%llu, len=%llu, dev_size=%llu",
37794 dm_device_name(ti->table->md), bdevname(bdev, b),
37795 diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c
37796 index 00cee02..b89a29d 100644
37797 --- a/drivers/md/dm-thin-metadata.c
37798 +++ b/drivers/md/dm-thin-metadata.c
37799 @@ -397,7 +397,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
37800 {
37801 pmd->info.tm = pmd->tm;
37802 pmd->info.levels = 2;
37803 - pmd->info.value_type.context = pmd->data_sm;
37804 + pmd->info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
37805 pmd->info.value_type.size = sizeof(__le64);
37806 pmd->info.value_type.inc = data_block_inc;
37807 pmd->info.value_type.dec = data_block_dec;
37808 @@ -416,7 +416,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
37809
37810 pmd->bl_info.tm = pmd->tm;
37811 pmd->bl_info.levels = 1;
37812 - pmd->bl_info.value_type.context = pmd->data_sm;
37813 + pmd->bl_info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
37814 pmd->bl_info.value_type.size = sizeof(__le64);
37815 pmd->bl_info.value_type.inc = data_block_inc;
37816 pmd->bl_info.value_type.dec = data_block_dec;
37817 diff --git a/drivers/md/dm.c b/drivers/md/dm.c
37818 index 9a0bdad..4df9543 100644
37819 --- a/drivers/md/dm.c
37820 +++ b/drivers/md/dm.c
37821 @@ -169,9 +169,9 @@ struct mapped_device {
37822 /*
37823 * Event handling.
37824 */
37825 - atomic_t event_nr;
37826 + atomic_unchecked_t event_nr;
37827 wait_queue_head_t eventq;
37828 - atomic_t uevent_seq;
37829 + atomic_unchecked_t uevent_seq;
37830 struct list_head uevent_list;
37831 spinlock_t uevent_lock; /* Protect access to uevent_list */
37832
37833 @@ -1879,8 +1879,8 @@ static struct mapped_device *alloc_dev(int minor)
37834 rwlock_init(&md->map_lock);
37835 atomic_set(&md->holders, 1);
37836 atomic_set(&md->open_count, 0);
37837 - atomic_set(&md->event_nr, 0);
37838 - atomic_set(&md->uevent_seq, 0);
37839 + atomic_set_unchecked(&md->event_nr, 0);
37840 + atomic_set_unchecked(&md->uevent_seq, 0);
37841 INIT_LIST_HEAD(&md->uevent_list);
37842 spin_lock_init(&md->uevent_lock);
37843
37844 @@ -2028,7 +2028,7 @@ static void event_callback(void *context)
37845
37846 dm_send_uevents(&uevents, &disk_to_dev(md->disk)->kobj);
37847
37848 - atomic_inc(&md->event_nr);
37849 + atomic_inc_unchecked(&md->event_nr);
37850 wake_up(&md->eventq);
37851 }
37852
37853 @@ -2685,18 +2685,18 @@ int dm_kobject_uevent(struct mapped_device *md, enum kobject_action action,
37854
37855 uint32_t dm_next_uevent_seq(struct mapped_device *md)
37856 {
37857 - return atomic_add_return(1, &md->uevent_seq);
37858 + return atomic_add_return_unchecked(1, &md->uevent_seq);
37859 }
37860
37861 uint32_t dm_get_event_nr(struct mapped_device *md)
37862 {
37863 - return atomic_read(&md->event_nr);
37864 + return atomic_read_unchecked(&md->event_nr);
37865 }
37866
37867 int dm_wait_event(struct mapped_device *md, int event_nr)
37868 {
37869 return wait_event_interruptible(md->eventq,
37870 - (event_nr != atomic_read(&md->event_nr)));
37871 + (event_nr != atomic_read_unchecked(&md->event_nr)));
37872 }
37873
37874 void dm_uevent_add(struct mapped_device *md, struct list_head *elist)
37875 diff --git a/drivers/md/md.c b/drivers/md/md.c
37876 index a4a93b9..4747b63 100644
37877 --- a/drivers/md/md.c
37878 +++ b/drivers/md/md.c
37879 @@ -240,10 +240,10 @@ EXPORT_SYMBOL_GPL(md_trim_bio);
37880 * start build, activate spare
37881 */
37882 static DECLARE_WAIT_QUEUE_HEAD(md_event_waiters);
37883 -static atomic_t md_event_count;
37884 +static atomic_unchecked_t md_event_count;
37885 void md_new_event(struct mddev *mddev)
37886 {
37887 - atomic_inc(&md_event_count);
37888 + atomic_inc_unchecked(&md_event_count);
37889 wake_up(&md_event_waiters);
37890 }
37891 EXPORT_SYMBOL_GPL(md_new_event);
37892 @@ -253,7 +253,7 @@ EXPORT_SYMBOL_GPL(md_new_event);
37893 */
37894 static void md_new_event_inintr(struct mddev *mddev)
37895 {
37896 - atomic_inc(&md_event_count);
37897 + atomic_inc_unchecked(&md_event_count);
37898 wake_up(&md_event_waiters);
37899 }
37900
37901 @@ -1507,7 +1507,7 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
37902 if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_RESHAPE_ACTIVE) &&
37903 (le32_to_cpu(sb->feature_map) & MD_FEATURE_NEW_OFFSET))
37904 rdev->new_data_offset += (s32)le32_to_cpu(sb->new_offset);
37905 - atomic_set(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
37906 + atomic_set_unchecked(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
37907
37908 rdev->sb_size = le32_to_cpu(sb->max_dev) * 2 + 256;
37909 bmask = queue_logical_block_size(rdev->bdev->bd_disk->queue)-1;
37910 @@ -1751,7 +1751,7 @@ static void super_1_sync(struct mddev *mddev, struct md_rdev *rdev)
37911 else
37912 sb->resync_offset = cpu_to_le64(0);
37913
37914 - sb->cnt_corrected_read = cpu_to_le32(atomic_read(&rdev->corrected_errors));
37915 + sb->cnt_corrected_read = cpu_to_le32(atomic_read_unchecked(&rdev->corrected_errors));
37916
37917 sb->raid_disks = cpu_to_le32(mddev->raid_disks);
37918 sb->size = cpu_to_le64(mddev->dev_sectors);
37919 @@ -2751,7 +2751,7 @@ __ATTR(state, S_IRUGO|S_IWUSR, state_show, state_store);
37920 static ssize_t
37921 errors_show(struct md_rdev *rdev, char *page)
37922 {
37923 - return sprintf(page, "%d\n", atomic_read(&rdev->corrected_errors));
37924 + return sprintf(page, "%d\n", atomic_read_unchecked(&rdev->corrected_errors));
37925 }
37926
37927 static ssize_t
37928 @@ -2760,7 +2760,7 @@ errors_store(struct md_rdev *rdev, const char *buf, size_t len)
37929 char *e;
37930 unsigned long n = simple_strtoul(buf, &e, 10);
37931 if (*buf && (*e == 0 || *e == '\n')) {
37932 - atomic_set(&rdev->corrected_errors, n);
37933 + atomic_set_unchecked(&rdev->corrected_errors, n);
37934 return len;
37935 }
37936 return -EINVAL;
37937 @@ -3210,8 +3210,8 @@ int md_rdev_init(struct md_rdev *rdev)
37938 rdev->sb_loaded = 0;
37939 rdev->bb_page = NULL;
37940 atomic_set(&rdev->nr_pending, 0);
37941 - atomic_set(&rdev->read_errors, 0);
37942 - atomic_set(&rdev->corrected_errors, 0);
37943 + atomic_set_unchecked(&rdev->read_errors, 0);
37944 + atomic_set_unchecked(&rdev->corrected_errors, 0);
37945
37946 INIT_LIST_HEAD(&rdev->same_set);
37947 init_waitqueue_head(&rdev->blocked_wait);
37948 @@ -6994,7 +6994,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
37949
37950 spin_unlock(&pers_lock);
37951 seq_printf(seq, "\n");
37952 - seq->poll_event = atomic_read(&md_event_count);
37953 + seq->poll_event = atomic_read_unchecked(&md_event_count);
37954 return 0;
37955 }
37956 if (v == (void*)2) {
37957 @@ -7097,7 +7097,7 @@ static int md_seq_open(struct inode *inode, struct file *file)
37958 return error;
37959
37960 seq = file->private_data;
37961 - seq->poll_event = atomic_read(&md_event_count);
37962 + seq->poll_event = atomic_read_unchecked(&md_event_count);
37963 return error;
37964 }
37965
37966 @@ -7111,7 +7111,7 @@ static unsigned int mdstat_poll(struct file *filp, poll_table *wait)
37967 /* always allow read */
37968 mask = POLLIN | POLLRDNORM;
37969
37970 - if (seq->poll_event != atomic_read(&md_event_count))
37971 + if (seq->poll_event != atomic_read_unchecked(&md_event_count))
37972 mask |= POLLERR | POLLPRI;
37973 return mask;
37974 }
37975 @@ -7155,7 +7155,7 @@ static int is_mddev_idle(struct mddev *mddev, int init)
37976 struct gendisk *disk = rdev->bdev->bd_contains->bd_disk;
37977 curr_events = (int)part_stat_read(&disk->part0, sectors[0]) +
37978 (int)part_stat_read(&disk->part0, sectors[1]) -
37979 - atomic_read(&disk->sync_io);
37980 + atomic_read_unchecked(&disk->sync_io);
37981 /* sync IO will cause sync_io to increase before the disk_stats
37982 * as sync_io is counted when a request starts, and
37983 * disk_stats is counted when it completes.
37984 diff --git a/drivers/md/md.h b/drivers/md/md.h
37985 index d90fb1a..4174a2b 100644
37986 --- a/drivers/md/md.h
37987 +++ b/drivers/md/md.h
37988 @@ -94,13 +94,13 @@ struct md_rdev {
37989 * only maintained for arrays that
37990 * support hot removal
37991 */
37992 - atomic_t read_errors; /* number of consecutive read errors that
37993 + atomic_unchecked_t read_errors; /* number of consecutive read errors that
37994 * we have tried to ignore.
37995 */
37996 struct timespec last_read_error; /* monotonic time since our
37997 * last read error
37998 */
37999 - atomic_t corrected_errors; /* number of corrected read errors,
38000 + atomic_unchecked_t corrected_errors; /* number of corrected read errors,
38001 * for reporting to userspace and storing
38002 * in superblock.
38003 */
38004 @@ -434,7 +434,7 @@ static inline void rdev_dec_pending(struct md_rdev *rdev, struct mddev *mddev)
38005
38006 static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sectors)
38007 {
38008 - atomic_add(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
38009 + atomic_add_unchecked(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
38010 }
38011
38012 struct md_personality
38013 diff --git a/drivers/md/persistent-data/dm-space-map.h b/drivers/md/persistent-data/dm-space-map.h
38014 index 1cbfc6b..56e1dbb 100644
38015 --- a/drivers/md/persistent-data/dm-space-map.h
38016 +++ b/drivers/md/persistent-data/dm-space-map.h
38017 @@ -60,6 +60,7 @@ struct dm_space_map {
38018 int (*root_size)(struct dm_space_map *sm, size_t *result);
38019 int (*copy_root)(struct dm_space_map *sm, void *copy_to_here_le, size_t len);
38020 };
38021 +typedef struct dm_space_map __no_const dm_space_map_no_const;
38022
38023 /*----------------------------------------------------------------*/
38024
38025 diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
38026 index 6af167f..40c25a1 100644
38027 --- a/drivers/md/raid1.c
38028 +++ b/drivers/md/raid1.c
38029 @@ -1826,7 +1826,7 @@ static int fix_sync_read_error(struct r1bio *r1_bio)
38030 if (r1_sync_page_io(rdev, sect, s,
38031 bio->bi_io_vec[idx].bv_page,
38032 READ) != 0)
38033 - atomic_add(s, &rdev->corrected_errors);
38034 + atomic_add_unchecked(s, &rdev->corrected_errors);
38035 }
38036 sectors -= s;
38037 sect += s;
38038 @@ -2048,7 +2048,7 @@ static void fix_read_error(struct r1conf *conf, int read_disk,
38039 test_bit(In_sync, &rdev->flags)) {
38040 if (r1_sync_page_io(rdev, sect, s,
38041 conf->tmppage, READ)) {
38042 - atomic_add(s, &rdev->corrected_errors);
38043 + atomic_add_unchecked(s, &rdev->corrected_errors);
38044 printk(KERN_INFO
38045 "md/raid1:%s: read error corrected "
38046 "(%d sectors at %llu on %s)\n",
38047 diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
38048 index 46c14e5..4db5966 100644
38049 --- a/drivers/md/raid10.c
38050 +++ b/drivers/md/raid10.c
38051 @@ -1932,7 +1932,7 @@ static void end_sync_read(struct bio *bio, int error)
38052 /* The write handler will notice the lack of
38053 * R10BIO_Uptodate and record any errors etc
38054 */
38055 - atomic_add(r10_bio->sectors,
38056 + atomic_add_unchecked(r10_bio->sectors,
38057 &conf->mirrors[d].rdev->corrected_errors);
38058
38059 /* for reconstruct, we always reschedule after a read.
38060 @@ -2281,7 +2281,7 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
38061 {
38062 struct timespec cur_time_mon;
38063 unsigned long hours_since_last;
38064 - unsigned int read_errors = atomic_read(&rdev->read_errors);
38065 + unsigned int read_errors = atomic_read_unchecked(&rdev->read_errors);
38066
38067 ktime_get_ts(&cur_time_mon);
38068
38069 @@ -2303,9 +2303,9 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
38070 * overflowing the shift of read_errors by hours_since_last.
38071 */
38072 if (hours_since_last >= 8 * sizeof(read_errors))
38073 - atomic_set(&rdev->read_errors, 0);
38074 + atomic_set_unchecked(&rdev->read_errors, 0);
38075 else
38076 - atomic_set(&rdev->read_errors, read_errors >> hours_since_last);
38077 + atomic_set_unchecked(&rdev->read_errors, read_errors >> hours_since_last);
38078 }
38079
38080 static int r10_sync_page_io(struct md_rdev *rdev, sector_t sector,
38081 @@ -2359,8 +2359,8 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
38082 return;
38083
38084 check_decay_read_errors(mddev, rdev);
38085 - atomic_inc(&rdev->read_errors);
38086 - if (atomic_read(&rdev->read_errors) > max_read_errors) {
38087 + atomic_inc_unchecked(&rdev->read_errors);
38088 + if (atomic_read_unchecked(&rdev->read_errors) > max_read_errors) {
38089 char b[BDEVNAME_SIZE];
38090 bdevname(rdev->bdev, b);
38091
38092 @@ -2368,7 +2368,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
38093 "md/raid10:%s: %s: Raid device exceeded "
38094 "read_error threshold [cur %d:max %d]\n",
38095 mdname(mddev), b,
38096 - atomic_read(&rdev->read_errors), max_read_errors);
38097 + atomic_read_unchecked(&rdev->read_errors), max_read_errors);
38098 printk(KERN_NOTICE
38099 "md/raid10:%s: %s: Failing raid device\n",
38100 mdname(mddev), b);
38101 @@ -2523,7 +2523,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
38102 sect +
38103 choose_data_offset(r10_bio, rdev)),
38104 bdevname(rdev->bdev, b));
38105 - atomic_add(s, &rdev->corrected_errors);
38106 + atomic_add_unchecked(s, &rdev->corrected_errors);
38107 }
38108
38109 rdev_dec_pending(rdev, mddev);
38110 diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
38111 index f4e87bf..0d4ad3f 100644
38112 --- a/drivers/md/raid5.c
38113 +++ b/drivers/md/raid5.c
38114 @@ -1763,21 +1763,21 @@ static void raid5_end_read_request(struct bio * bi, int error)
38115 mdname(conf->mddev), STRIPE_SECTORS,
38116 (unsigned long long)s,
38117 bdevname(rdev->bdev, b));
38118 - atomic_add(STRIPE_SECTORS, &rdev->corrected_errors);
38119 + atomic_add_unchecked(STRIPE_SECTORS, &rdev->corrected_errors);
38120 clear_bit(R5_ReadError, &sh->dev[i].flags);
38121 clear_bit(R5_ReWrite, &sh->dev[i].flags);
38122 } else if (test_bit(R5_ReadNoMerge, &sh->dev[i].flags))
38123 clear_bit(R5_ReadNoMerge, &sh->dev[i].flags);
38124
38125 - if (atomic_read(&rdev->read_errors))
38126 - atomic_set(&rdev->read_errors, 0);
38127 + if (atomic_read_unchecked(&rdev->read_errors))
38128 + atomic_set_unchecked(&rdev->read_errors, 0);
38129 } else {
38130 const char *bdn = bdevname(rdev->bdev, b);
38131 int retry = 0;
38132 int set_bad = 0;
38133
38134 clear_bit(R5_UPTODATE, &sh->dev[i].flags);
38135 - atomic_inc(&rdev->read_errors);
38136 + atomic_inc_unchecked(&rdev->read_errors);
38137 if (test_bit(R5_ReadRepl, &sh->dev[i].flags))
38138 printk_ratelimited(
38139 KERN_WARNING
38140 @@ -1805,7 +1805,7 @@ static void raid5_end_read_request(struct bio * bi, int error)
38141 mdname(conf->mddev),
38142 (unsigned long long)s,
38143 bdn);
38144 - } else if (atomic_read(&rdev->read_errors)
38145 + } else if (atomic_read_unchecked(&rdev->read_errors)
38146 > conf->max_nr_stripes)
38147 printk(KERN_WARNING
38148 "md/raid:%s: Too many read errors, failing device %s.\n",
38149 diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
38150 index 401ef64..836e563 100644
38151 --- a/drivers/media/dvb-core/dvbdev.c
38152 +++ b/drivers/media/dvb-core/dvbdev.c
38153 @@ -192,7 +192,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
38154 const struct dvb_device *template, void *priv, int type)
38155 {
38156 struct dvb_device *dvbdev;
38157 - struct file_operations *dvbdevfops;
38158 + file_operations_no_const *dvbdevfops;
38159 struct device *clsdev;
38160 int minor;
38161 int id;
38162 diff --git a/drivers/media/dvb-frontends/dib3000.h b/drivers/media/dvb-frontends/dib3000.h
38163 index 9b6c3bb..baeb5c7 100644
38164 --- a/drivers/media/dvb-frontends/dib3000.h
38165 +++ b/drivers/media/dvb-frontends/dib3000.h
38166 @@ -39,7 +39,7 @@ struct dib_fe_xfer_ops
38167 int (*fifo_ctrl)(struct dvb_frontend *fe, int onoff);
38168 int (*pid_ctrl)(struct dvb_frontend *fe, int index, int pid, int onoff);
38169 int (*tuner_pass_ctrl)(struct dvb_frontend *fe, int onoff, u8 pll_ctrl);
38170 -};
38171 +} __no_const;
38172
38173 #if IS_ENABLED(CONFIG_DVB_DIB3000MB)
38174 extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
38175 diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c
38176 index bc78354..42c9459 100644
38177 --- a/drivers/media/pci/cx88/cx88-video.c
38178 +++ b/drivers/media/pci/cx88/cx88-video.c
38179 @@ -50,9 +50,9 @@ MODULE_VERSION(CX88_VERSION);
38180
38181 /* ------------------------------------------------------------------ */
38182
38183 -static unsigned int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38184 -static unsigned int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38185 -static unsigned int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38186 +static int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38187 +static int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38188 +static int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38189
38190 module_param_array(video_nr, int, NULL, 0444);
38191 module_param_array(vbi_nr, int, NULL, 0444);
38192 diff --git a/drivers/media/platform/omap/omap_vout.c b/drivers/media/platform/omap/omap_vout.c
38193 index 96c4a17..1305a79 100644
38194 --- a/drivers/media/platform/omap/omap_vout.c
38195 +++ b/drivers/media/platform/omap/omap_vout.c
38196 @@ -63,7 +63,6 @@ enum omap_vout_channels {
38197 OMAP_VIDEO2,
38198 };
38199
38200 -static struct videobuf_queue_ops video_vbq_ops;
38201 /* Variables configurable through module params*/
38202 static u32 video1_numbuffers = 3;
38203 static u32 video2_numbuffers = 3;
38204 @@ -1012,6 +1011,12 @@ static int omap_vout_open(struct file *file)
38205 {
38206 struct videobuf_queue *q;
38207 struct omap_vout_device *vout = NULL;
38208 + static struct videobuf_queue_ops video_vbq_ops = {
38209 + .buf_setup = omap_vout_buffer_setup,
38210 + .buf_prepare = omap_vout_buffer_prepare,
38211 + .buf_release = omap_vout_buffer_release,
38212 + .buf_queue = omap_vout_buffer_queue,
38213 + };
38214
38215 vout = video_drvdata(file);
38216 v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev, "Entering %s\n", __func__);
38217 @@ -1029,10 +1034,6 @@ static int omap_vout_open(struct file *file)
38218 vout->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
38219
38220 q = &vout->vbq;
38221 - video_vbq_ops.buf_setup = omap_vout_buffer_setup;
38222 - video_vbq_ops.buf_prepare = omap_vout_buffer_prepare;
38223 - video_vbq_ops.buf_release = omap_vout_buffer_release;
38224 - video_vbq_ops.buf_queue = omap_vout_buffer_queue;
38225 spin_lock_init(&vout->vbq_lock);
38226
38227 videobuf_queue_dma_contig_init(q, &video_vbq_ops, q->dev,
38228 diff --git a/drivers/media/platform/s5p-tv/mixer.h b/drivers/media/platform/s5p-tv/mixer.h
38229 index 04e6490..2df65bf 100644
38230 --- a/drivers/media/platform/s5p-tv/mixer.h
38231 +++ b/drivers/media/platform/s5p-tv/mixer.h
38232 @@ -156,7 +156,7 @@ struct mxr_layer {
38233 /** layer index (unique identifier) */
38234 int idx;
38235 /** callbacks for layer methods */
38236 - struct mxr_layer_ops ops;
38237 + struct mxr_layer_ops *ops;
38238 /** format array */
38239 const struct mxr_format **fmt_array;
38240 /** size of format array */
38241 diff --git a/drivers/media/platform/s5p-tv/mixer_grp_layer.c b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38242 index b93a21f..2535195 100644
38243 --- a/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38244 +++ b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38245 @@ -235,7 +235,7 @@ struct mxr_layer *mxr_graph_layer_create(struct mxr_device *mdev, int idx)
38246 {
38247 struct mxr_layer *layer;
38248 int ret;
38249 - struct mxr_layer_ops ops = {
38250 + static struct mxr_layer_ops ops = {
38251 .release = mxr_graph_layer_release,
38252 .buffer_set = mxr_graph_buffer_set,
38253 .stream_set = mxr_graph_stream_set,
38254 diff --git a/drivers/media/platform/s5p-tv/mixer_reg.c b/drivers/media/platform/s5p-tv/mixer_reg.c
38255 index b713403..53cb5ad 100644
38256 --- a/drivers/media/platform/s5p-tv/mixer_reg.c
38257 +++ b/drivers/media/platform/s5p-tv/mixer_reg.c
38258 @@ -276,7 +276,7 @@ static void mxr_irq_layer_handle(struct mxr_layer *layer)
38259 layer->update_buf = next;
38260 }
38261
38262 - layer->ops.buffer_set(layer, layer->update_buf);
38263 + layer->ops->buffer_set(layer, layer->update_buf);
38264
38265 if (done && done != layer->shadow_buf)
38266 vb2_buffer_done(&done->vb, VB2_BUF_STATE_DONE);
38267 diff --git a/drivers/media/platform/s5p-tv/mixer_video.c b/drivers/media/platform/s5p-tv/mixer_video.c
38268 index 82142a2..6de47e8 100644
38269 --- a/drivers/media/platform/s5p-tv/mixer_video.c
38270 +++ b/drivers/media/platform/s5p-tv/mixer_video.c
38271 @@ -209,7 +209,7 @@ static void mxr_layer_default_geo(struct mxr_layer *layer)
38272 layer->geo.src.height = layer->geo.src.full_height;
38273
38274 mxr_geometry_dump(mdev, &layer->geo);
38275 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38276 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38277 mxr_geometry_dump(mdev, &layer->geo);
38278 }
38279
38280 @@ -227,7 +227,7 @@ static void mxr_layer_update_output(struct mxr_layer *layer)
38281 layer->geo.dst.full_width = mbus_fmt.width;
38282 layer->geo.dst.full_height = mbus_fmt.height;
38283 layer->geo.dst.field = mbus_fmt.field;
38284 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38285 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38286
38287 mxr_geometry_dump(mdev, &layer->geo);
38288 }
38289 @@ -333,7 +333,7 @@ static int mxr_s_fmt(struct file *file, void *priv,
38290 /* set source size to highest accepted value */
38291 geo->src.full_width = max(geo->dst.full_width, pix->width);
38292 geo->src.full_height = max(geo->dst.full_height, pix->height);
38293 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38294 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38295 mxr_geometry_dump(mdev, &layer->geo);
38296 /* set cropping to total visible screen */
38297 geo->src.width = pix->width;
38298 @@ -341,12 +341,12 @@ static int mxr_s_fmt(struct file *file, void *priv,
38299 geo->src.x_offset = 0;
38300 geo->src.y_offset = 0;
38301 /* assure consistency of geometry */
38302 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
38303 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
38304 mxr_geometry_dump(mdev, &layer->geo);
38305 /* set full size to lowest possible value */
38306 geo->src.full_width = 0;
38307 geo->src.full_height = 0;
38308 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38309 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38310 mxr_geometry_dump(mdev, &layer->geo);
38311
38312 /* returning results */
38313 @@ -473,7 +473,7 @@ static int mxr_s_selection(struct file *file, void *fh,
38314 target->width = s->r.width;
38315 target->height = s->r.height;
38316
38317 - layer->ops.fix_geometry(layer, stage, s->flags);
38318 + layer->ops->fix_geometry(layer, stage, s->flags);
38319
38320 /* retrieve update selection rectangle */
38321 res.left = target->x_offset;
38322 @@ -938,13 +938,13 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
38323 mxr_output_get(mdev);
38324
38325 mxr_layer_update_output(layer);
38326 - layer->ops.format_set(layer);
38327 + layer->ops->format_set(layer);
38328 /* enabling layer in hardware */
38329 spin_lock_irqsave(&layer->enq_slock, flags);
38330 layer->state = MXR_LAYER_STREAMING;
38331 spin_unlock_irqrestore(&layer->enq_slock, flags);
38332
38333 - layer->ops.stream_set(layer, MXR_ENABLE);
38334 + layer->ops->stream_set(layer, MXR_ENABLE);
38335 mxr_streamer_get(mdev);
38336
38337 return 0;
38338 @@ -1014,7 +1014,7 @@ static int stop_streaming(struct vb2_queue *vq)
38339 spin_unlock_irqrestore(&layer->enq_slock, flags);
38340
38341 /* disabling layer in hardware */
38342 - layer->ops.stream_set(layer, MXR_DISABLE);
38343 + layer->ops->stream_set(layer, MXR_DISABLE);
38344 /* remove one streamer */
38345 mxr_streamer_put(mdev);
38346 /* allow changes in output configuration */
38347 @@ -1053,8 +1053,8 @@ void mxr_base_layer_unregister(struct mxr_layer *layer)
38348
38349 void mxr_layer_release(struct mxr_layer *layer)
38350 {
38351 - if (layer->ops.release)
38352 - layer->ops.release(layer);
38353 + if (layer->ops->release)
38354 + layer->ops->release(layer);
38355 }
38356
38357 void mxr_base_layer_release(struct mxr_layer *layer)
38358 @@ -1080,7 +1080,7 @@ struct mxr_layer *mxr_base_layer_create(struct mxr_device *mdev,
38359
38360 layer->mdev = mdev;
38361 layer->idx = idx;
38362 - layer->ops = *ops;
38363 + layer->ops = ops;
38364
38365 spin_lock_init(&layer->enq_slock);
38366 INIT_LIST_HEAD(&layer->enq_list);
38367 diff --git a/drivers/media/platform/s5p-tv/mixer_vp_layer.c b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
38368 index 3d13a63..da31bf1 100644
38369 --- a/drivers/media/platform/s5p-tv/mixer_vp_layer.c
38370 +++ b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
38371 @@ -206,7 +206,7 @@ struct mxr_layer *mxr_vp_layer_create(struct mxr_device *mdev, int idx)
38372 {
38373 struct mxr_layer *layer;
38374 int ret;
38375 - struct mxr_layer_ops ops = {
38376 + static struct mxr_layer_ops ops = {
38377 .release = mxr_vp_layer_release,
38378 .buffer_set = mxr_vp_buffer_set,
38379 .stream_set = mxr_vp_stream_set,
38380 diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
38381 index 643d80a..56bb96b 100644
38382 --- a/drivers/media/radio/radio-cadet.c
38383 +++ b/drivers/media/radio/radio-cadet.c
38384 @@ -302,6 +302,8 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
38385 unsigned char readbuf[RDS_BUFFER];
38386 int i = 0;
38387
38388 + if (count > RDS_BUFFER)
38389 + return -EFAULT;
38390 mutex_lock(&dev->lock);
38391 if (dev->rdsstat == 0)
38392 cadet_start_rds(dev);
38393 @@ -317,7 +319,7 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
38394 while (i < count && dev->rdsin != dev->rdsout)
38395 readbuf[i++] = dev->rdsbuf[dev->rdsout++];
38396
38397 - if (i && copy_to_user(data, readbuf, i))
38398 + if (i > sizeof(readbuf) || copy_to_user(data, readbuf, i))
38399 i = -EFAULT;
38400 unlock:
38401 mutex_unlock(&dev->lock);
38402 diff --git a/drivers/media/usb/dvb-usb/cxusb.c b/drivers/media/usb/dvb-usb/cxusb.c
38403 index 3940bb0..fb3952a 100644
38404 --- a/drivers/media/usb/dvb-usb/cxusb.c
38405 +++ b/drivers/media/usb/dvb-usb/cxusb.c
38406 @@ -1068,7 +1068,7 @@ static struct dib0070_config dib7070p_dib0070_config = {
38407
38408 struct dib0700_adapter_state {
38409 int (*set_param_save) (struct dvb_frontend *);
38410 -};
38411 +} __no_const;
38412
38413 static int dib7070_set_param_override(struct dvb_frontend *fe)
38414 {
38415 diff --git a/drivers/media/usb/dvb-usb/dw2102.c b/drivers/media/usb/dvb-usb/dw2102.c
38416 index 9578a67..31aa652 100644
38417 --- a/drivers/media/usb/dvb-usb/dw2102.c
38418 +++ b/drivers/media/usb/dvb-usb/dw2102.c
38419 @@ -115,7 +115,7 @@ struct su3000_state {
38420
38421 struct s6x0_state {
38422 int (*old_set_voltage)(struct dvb_frontend *f, fe_sec_voltage_t v);
38423 -};
38424 +} __no_const;
38425
38426 /* debug */
38427 static int dvb_usb_dw2102_debug;
38428 diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
38429 index aa6e7c7..4cd8061 100644
38430 --- a/drivers/media/v4l2-core/v4l2-ioctl.c
38431 +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
38432 @@ -1923,7 +1923,8 @@ struct v4l2_ioctl_info {
38433 struct file *file, void *fh, void *p);
38434 } u;
38435 void (*debug)(const void *arg, bool write_only);
38436 -};
38437 +} __do_const;
38438 +typedef struct v4l2_ioctl_info __no_const v4l2_ioctl_info_no_const;
38439
38440 /* This control needs a priority check */
38441 #define INFO_FL_PRIO (1 << 0)
38442 @@ -2108,7 +2109,7 @@ static long __video_do_ioctl(struct file *file,
38443 struct video_device *vfd = video_devdata(file);
38444 const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops;
38445 bool write_only = false;
38446 - struct v4l2_ioctl_info default_info;
38447 + v4l2_ioctl_info_no_const default_info;
38448 const struct v4l2_ioctl_info *info;
38449 void *fh = file->private_data;
38450 struct v4l2_fh *vfh = NULL;
38451 diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
38452 index fb69baa..3aeea2e 100644
38453 --- a/drivers/message/fusion/mptbase.c
38454 +++ b/drivers/message/fusion/mptbase.c
38455 @@ -6755,8 +6755,13 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
38456 seq_printf(m, " MaxChainDepth = 0x%02x frames\n", ioc->facts.MaxChainDepth);
38457 seq_printf(m, " MinBlockSize = 0x%02x bytes\n", 4*ioc->facts.BlockSize);
38458
38459 +#ifdef CONFIG_GRKERNSEC_HIDESYM
38460 + seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n", NULL, NULL);
38461 +#else
38462 seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n",
38463 (void *)ioc->req_frames, (void *)(ulong)ioc->req_frames_dma);
38464 +#endif
38465 +
38466 /*
38467 * Rounding UP to nearest 4-kB boundary here...
38468 */
38469 @@ -6769,7 +6774,11 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
38470 ioc->facts.GlobalCredits);
38471
38472 seq_printf(m, " Frames @ 0x%p (Dma @ 0x%p)\n",
38473 +#ifdef CONFIG_GRKERNSEC_HIDESYM
38474 + NULL, NULL);
38475 +#else
38476 (void *)ioc->alloc, (void *)(ulong)ioc->alloc_dma);
38477 +#endif
38478 sz = (ioc->reply_sz * ioc->reply_depth) + 128;
38479 seq_printf(m, " {CurRepSz=%d} x {CurRepDepth=%d} = %d bytes ^= 0x%x\n",
38480 ioc->reply_sz, ioc->reply_depth, ioc->reply_sz*ioc->reply_depth, sz);
38481 diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
38482 index fa43c39..daeb158 100644
38483 --- a/drivers/message/fusion/mptsas.c
38484 +++ b/drivers/message/fusion/mptsas.c
38485 @@ -446,6 +446,23 @@ mptsas_is_end_device(struct mptsas_devinfo * attached)
38486 return 0;
38487 }
38488
38489 +static inline void
38490 +mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
38491 +{
38492 + if (phy_info->port_details) {
38493 + phy_info->port_details->rphy = rphy;
38494 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
38495 + ioc->name, rphy));
38496 + }
38497 +
38498 + if (rphy) {
38499 + dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
38500 + &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
38501 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
38502 + ioc->name, rphy, rphy->dev.release));
38503 + }
38504 +}
38505 +
38506 /* no mutex */
38507 static void
38508 mptsas_port_delete(MPT_ADAPTER *ioc, struct mptsas_portinfo_details * port_details)
38509 @@ -484,23 +501,6 @@ mptsas_get_rphy(struct mptsas_phyinfo *phy_info)
38510 return NULL;
38511 }
38512
38513 -static inline void
38514 -mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
38515 -{
38516 - if (phy_info->port_details) {
38517 - phy_info->port_details->rphy = rphy;
38518 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
38519 - ioc->name, rphy));
38520 - }
38521 -
38522 - if (rphy) {
38523 - dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
38524 - &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
38525 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
38526 - ioc->name, rphy, rphy->dev.release));
38527 - }
38528 -}
38529 -
38530 static inline struct sas_port *
38531 mptsas_get_port(struct mptsas_phyinfo *phy_info)
38532 {
38533 diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
38534 index 164afa7..b6b2e74 100644
38535 --- a/drivers/message/fusion/mptscsih.c
38536 +++ b/drivers/message/fusion/mptscsih.c
38537 @@ -1271,15 +1271,16 @@ mptscsih_info(struct Scsi_Host *SChost)
38538
38539 h = shost_priv(SChost);
38540
38541 - if (h) {
38542 - if (h->info_kbuf == NULL)
38543 - if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
38544 - return h->info_kbuf;
38545 - h->info_kbuf[0] = '\0';
38546 + if (!h)
38547 + return NULL;
38548
38549 - mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
38550 - h->info_kbuf[size-1] = '\0';
38551 - }
38552 + if (h->info_kbuf == NULL)
38553 + if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
38554 + return h->info_kbuf;
38555 + h->info_kbuf[0] = '\0';
38556 +
38557 + mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
38558 + h->info_kbuf[size-1] = '\0';
38559
38560 return h->info_kbuf;
38561 }
38562 diff --git a/drivers/message/i2o/i2o_proc.c b/drivers/message/i2o/i2o_proc.c
38563 index 8001aa6..b137580 100644
38564 --- a/drivers/message/i2o/i2o_proc.c
38565 +++ b/drivers/message/i2o/i2o_proc.c
38566 @@ -255,12 +255,6 @@ static char *scsi_devices[] = {
38567 "Array Controller Device"
38568 };
38569
38570 -static char *chtostr(char *tmp, u8 *chars, int n)
38571 -{
38572 - tmp[0] = 0;
38573 - return strncat(tmp, (char *)chars, n);
38574 -}
38575 -
38576 static int i2o_report_query_status(struct seq_file *seq, int block_status,
38577 char *group)
38578 {
38579 @@ -790,7 +784,6 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
38580 } *result;
38581
38582 i2o_exec_execute_ddm_table ddm_table;
38583 - char tmp[28 + 1];
38584
38585 result = kmalloc(sizeof(*result), GFP_KERNEL);
38586 if (!result)
38587 @@ -825,8 +818,7 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
38588
38589 seq_printf(seq, "%-#7x", ddm_table.i2o_vendor_id);
38590 seq_printf(seq, "%-#8x", ddm_table.module_id);
38591 - seq_printf(seq, "%-29s",
38592 - chtostr(tmp, ddm_table.module_name_version, 28));
38593 + seq_printf(seq, "%-.28s", ddm_table.module_name_version);
38594 seq_printf(seq, "%9d ", ddm_table.data_size);
38595 seq_printf(seq, "%8d", ddm_table.code_size);
38596
38597 @@ -893,7 +885,6 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
38598
38599 i2o_driver_result_table *result;
38600 i2o_driver_store_table *dst;
38601 - char tmp[28 + 1];
38602
38603 result = kmalloc(sizeof(i2o_driver_result_table), GFP_KERNEL);
38604 if (result == NULL)
38605 @@ -928,9 +919,8 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
38606
38607 seq_printf(seq, "%-#7x", dst->i2o_vendor_id);
38608 seq_printf(seq, "%-#8x", dst->module_id);
38609 - seq_printf(seq, "%-29s",
38610 - chtostr(tmp, dst->module_name_version, 28));
38611 - seq_printf(seq, "%-9s", chtostr(tmp, dst->date, 8));
38612 + seq_printf(seq, "%-.28s", dst->module_name_version);
38613 + seq_printf(seq, "%-.8s", dst->date);
38614 seq_printf(seq, "%8d ", dst->module_size);
38615 seq_printf(seq, "%8d ", dst->mpb_size);
38616 seq_printf(seq, "0x%04x", dst->module_flags);
38617 @@ -1250,7 +1240,6 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
38618 // == (allow) 512d bytes (max)
38619 static u16 *work16 = (u16 *) work32;
38620 int token;
38621 - char tmp[16 + 1];
38622
38623 token = i2o_parm_field_get(d, 0xF100, -1, &work32, sizeof(work32));
38624
38625 @@ -1262,14 +1251,10 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
38626 seq_printf(seq, "Device Class : %s\n", i2o_get_class_name(work16[0]));
38627 seq_printf(seq, "Owner TID : %0#5x\n", work16[2]);
38628 seq_printf(seq, "Parent TID : %0#5x\n", work16[3]);
38629 - seq_printf(seq, "Vendor info : %s\n",
38630 - chtostr(tmp, (u8 *) (work32 + 2), 16));
38631 - seq_printf(seq, "Product info : %s\n",
38632 - chtostr(tmp, (u8 *) (work32 + 6), 16));
38633 - seq_printf(seq, "Description : %s\n",
38634 - chtostr(tmp, (u8 *) (work32 + 10), 16));
38635 - seq_printf(seq, "Product rev. : %s\n",
38636 - chtostr(tmp, (u8 *) (work32 + 14), 8));
38637 + seq_printf(seq, "Vendor info : %.16s\n", (u8 *) (work32 + 2));
38638 + seq_printf(seq, "Product info : %.16s\n", (u8 *) (work32 + 6));
38639 + seq_printf(seq, "Description : %.16s\n", (u8 *) (work32 + 10));
38640 + seq_printf(seq, "Product rev. : %.8s\n", (u8 *) (work32 + 14));
38641
38642 seq_printf(seq, "Serial number : ");
38643 print_serial_number(seq, (u8 *) (work32 + 16),
38644 @@ -1306,8 +1291,6 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
38645 u8 pad[256]; // allow up to 256 byte (max) serial number
38646 } result;
38647
38648 - char tmp[24 + 1];
38649 -
38650 token = i2o_parm_field_get(d, 0xF101, -1, &result, sizeof(result));
38651
38652 if (token < 0) {
38653 @@ -1316,10 +1299,8 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
38654 }
38655
38656 seq_printf(seq, "Registering DDM TID : 0x%03x\n", result.ddm_tid);
38657 - seq_printf(seq, "Module name : %s\n",
38658 - chtostr(tmp, result.module_name, 24));
38659 - seq_printf(seq, "Module revision : %s\n",
38660 - chtostr(tmp, result.module_rev, 8));
38661 + seq_printf(seq, "Module name : %.24s\n", result.module_name);
38662 + seq_printf(seq, "Module revision : %.8s\n", result.module_rev);
38663
38664 seq_printf(seq, "Serial number : ");
38665 print_serial_number(seq, result.serial_number, sizeof(result) - 36);
38666 @@ -1343,8 +1324,6 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
38667 u8 instance_number[4];
38668 } result;
38669
38670 - char tmp[64 + 1];
38671 -
38672 token = i2o_parm_field_get(d, 0xF102, -1, &result, sizeof(result));
38673
38674 if (token < 0) {
38675 @@ -1352,14 +1331,10 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
38676 return 0;
38677 }
38678
38679 - seq_printf(seq, "Device name : %s\n",
38680 - chtostr(tmp, result.device_name, 64));
38681 - seq_printf(seq, "Service name : %s\n",
38682 - chtostr(tmp, result.service_name, 64));
38683 - seq_printf(seq, "Physical name : %s\n",
38684 - chtostr(tmp, result.physical_location, 64));
38685 - seq_printf(seq, "Instance number : %s\n",
38686 - chtostr(tmp, result.instance_number, 4));
38687 + seq_printf(seq, "Device name : %.64s\n", result.device_name);
38688 + seq_printf(seq, "Service name : %.64s\n", result.service_name);
38689 + seq_printf(seq, "Physical name : %.64s\n", result.physical_location);
38690 + seq_printf(seq, "Instance number : %.4s\n", result.instance_number);
38691
38692 return 0;
38693 }
38694 diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
38695 index a8c08f3..155fe3d 100644
38696 --- a/drivers/message/i2o/iop.c
38697 +++ b/drivers/message/i2o/iop.c
38698 @@ -111,10 +111,10 @@ u32 i2o_cntxt_list_add(struct i2o_controller * c, void *ptr)
38699
38700 spin_lock_irqsave(&c->context_list_lock, flags);
38701
38702 - if (unlikely(atomic_inc_and_test(&c->context_list_counter)))
38703 - atomic_inc(&c->context_list_counter);
38704 + if (unlikely(atomic_inc_and_test_unchecked(&c->context_list_counter)))
38705 + atomic_inc_unchecked(&c->context_list_counter);
38706
38707 - entry->context = atomic_read(&c->context_list_counter);
38708 + entry->context = atomic_read_unchecked(&c->context_list_counter);
38709
38710 list_add(&entry->list, &c->context_list);
38711
38712 @@ -1077,7 +1077,7 @@ struct i2o_controller *i2o_iop_alloc(void)
38713
38714 #if BITS_PER_LONG == 64
38715 spin_lock_init(&c->context_list_lock);
38716 - atomic_set(&c->context_list_counter, 0);
38717 + atomic_set_unchecked(&c->context_list_counter, 0);
38718 INIT_LIST_HEAD(&c->context_list);
38719 #endif
38720
38721 diff --git a/drivers/mfd/janz-cmodio.c b/drivers/mfd/janz-cmodio.c
38722 index 45ece11..8efa218 100644
38723 --- a/drivers/mfd/janz-cmodio.c
38724 +++ b/drivers/mfd/janz-cmodio.c
38725 @@ -13,6 +13,7 @@
38726
38727 #include <linux/kernel.h>
38728 #include <linux/module.h>
38729 +#include <linux/slab.h>
38730 #include <linux/init.h>
38731 #include <linux/pci.h>
38732 #include <linux/interrupt.h>
38733 diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
38734 index a5f9888..1c0ed56 100644
38735 --- a/drivers/mfd/twl4030-irq.c
38736 +++ b/drivers/mfd/twl4030-irq.c
38737 @@ -35,6 +35,7 @@
38738 #include <linux/of.h>
38739 #include <linux/irqdomain.h>
38740 #include <linux/i2c/twl.h>
38741 +#include <asm/pgtable.h>
38742
38743 #include "twl-core.h"
38744
38745 @@ -728,10 +729,12 @@ int twl4030_init_irq(struct device *dev, int irq_num)
38746 * Install an irq handler for each of the SIH modules;
38747 * clone dummy irq_chip since PIH can't *do* anything
38748 */
38749 - twl4030_irq_chip = dummy_irq_chip;
38750 - twl4030_irq_chip.name = "twl4030";
38751 + pax_open_kernel();
38752 + memcpy((void *)&twl4030_irq_chip, &dummy_irq_chip, sizeof twl4030_irq_chip);
38753 + *(const char **)&twl4030_irq_chip.name = "twl4030";
38754
38755 - twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
38756 + *(void **)&twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
38757 + pax_close_kernel();
38758
38759 for (i = irq_base; i < irq_end; i++) {
38760 irq_set_chip_and_handler(i, &twl4030_irq_chip,
38761 diff --git a/drivers/mfd/twl6030-irq.c b/drivers/mfd/twl6030-irq.c
38762 index 277a8db..0e0b754 100644
38763 --- a/drivers/mfd/twl6030-irq.c
38764 +++ b/drivers/mfd/twl6030-irq.c
38765 @@ -387,10 +387,12 @@ int twl6030_init_irq(struct device *dev, int irq_num)
38766 * install an irq handler for each of the modules;
38767 * clone dummy irq_chip since PIH can't *do* anything
38768 */
38769 - twl6030_irq_chip = dummy_irq_chip;
38770 - twl6030_irq_chip.name = "twl6030";
38771 - twl6030_irq_chip.irq_set_type = NULL;
38772 - twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
38773 + pax_open_kernel();
38774 + memcpy((void *)&twl6030_irq_chip, &dummy_irq_chip, sizeof twl6030_irq_chip);
38775 + *(const char **)&twl6030_irq_chip.name = "twl6030";
38776 + *(void **)&twl6030_irq_chip.irq_set_type = NULL;
38777 + *(void **)&twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
38778 + pax_close_kernel();
38779
38780 for (i = irq_base; i < irq_end; i++) {
38781 irq_set_chip_and_handler(i, &twl6030_irq_chip,
38782 diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c
38783 index f32550a..e3e52a2 100644
38784 --- a/drivers/misc/c2port/core.c
38785 +++ b/drivers/misc/c2port/core.c
38786 @@ -920,7 +920,9 @@ struct c2port_device *c2port_device_register(char *name,
38787 mutex_init(&c2dev->mutex);
38788
38789 /* Create binary file */
38790 - c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
38791 + pax_open_kernel();
38792 + *(size_t *)&c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
38793 + pax_close_kernel();
38794 ret = device_create_bin_file(c2dev->dev, &c2port_bin_attrs);
38795 if (unlikely(ret))
38796 goto error_device_create_bin_file;
38797 diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
38798 index 36f5d52..32311c3 100644
38799 --- a/drivers/misc/kgdbts.c
38800 +++ b/drivers/misc/kgdbts.c
38801 @@ -834,7 +834,7 @@ static void run_plant_and_detach_test(int is_early)
38802 char before[BREAK_INSTR_SIZE];
38803 char after[BREAK_INSTR_SIZE];
38804
38805 - probe_kernel_read(before, (char *)kgdbts_break_test,
38806 + probe_kernel_read(before, ktla_ktva((char *)kgdbts_break_test),
38807 BREAK_INSTR_SIZE);
38808 init_simple_test();
38809 ts.tst = plant_and_detach_test;
38810 @@ -842,7 +842,7 @@ static void run_plant_and_detach_test(int is_early)
38811 /* Activate test with initial breakpoint */
38812 if (!is_early)
38813 kgdb_breakpoint();
38814 - probe_kernel_read(after, (char *)kgdbts_break_test,
38815 + probe_kernel_read(after, ktla_ktva((char *)kgdbts_break_test),
38816 BREAK_INSTR_SIZE);
38817 if (memcmp(before, after, BREAK_INSTR_SIZE)) {
38818 printk(KERN_CRIT "kgdbts: ERROR kgdb corrupted memory\n");
38819 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c
38820 index 4a87e5c..76bdf5c 100644
38821 --- a/drivers/misc/lis3lv02d/lis3lv02d.c
38822 +++ b/drivers/misc/lis3lv02d/lis3lv02d.c
38823 @@ -498,7 +498,7 @@ static irqreturn_t lis302dl_interrupt(int irq, void *data)
38824 * the lid is closed. This leads to interrupts as soon as a little move
38825 * is done.
38826 */
38827 - atomic_inc(&lis3->count);
38828 + atomic_inc_unchecked(&lis3->count);
38829
38830 wake_up_interruptible(&lis3->misc_wait);
38831 kill_fasync(&lis3->async_queue, SIGIO, POLL_IN);
38832 @@ -584,7 +584,7 @@ static int lis3lv02d_misc_open(struct inode *inode, struct file *file)
38833 if (lis3->pm_dev)
38834 pm_runtime_get_sync(lis3->pm_dev);
38835
38836 - atomic_set(&lis3->count, 0);
38837 + atomic_set_unchecked(&lis3->count, 0);
38838 return 0;
38839 }
38840
38841 @@ -617,7 +617,7 @@ static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf,
38842 add_wait_queue(&lis3->misc_wait, &wait);
38843 while (true) {
38844 set_current_state(TASK_INTERRUPTIBLE);
38845 - data = atomic_xchg(&lis3->count, 0);
38846 + data = atomic_xchg_unchecked(&lis3->count, 0);
38847 if (data)
38848 break;
38849
38850 @@ -658,7 +658,7 @@ static unsigned int lis3lv02d_misc_poll(struct file *file, poll_table *wait)
38851 struct lis3lv02d, miscdev);
38852
38853 poll_wait(file, &lis3->misc_wait, wait);
38854 - if (atomic_read(&lis3->count))
38855 + if (atomic_read_unchecked(&lis3->count))
38856 return POLLIN | POLLRDNORM;
38857 return 0;
38858 }
38859 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.h b/drivers/misc/lis3lv02d/lis3lv02d.h
38860 index c439c82..1f20f57 100644
38861 --- a/drivers/misc/lis3lv02d/lis3lv02d.h
38862 +++ b/drivers/misc/lis3lv02d/lis3lv02d.h
38863 @@ -297,7 +297,7 @@ struct lis3lv02d {
38864 struct input_polled_dev *idev; /* input device */
38865 struct platform_device *pdev; /* platform device */
38866 struct regulator_bulk_data regulators[2];
38867 - atomic_t count; /* interrupt count after last read */
38868 + atomic_unchecked_t count; /* interrupt count after last read */
38869 union axis_conversion ac; /* hw -> logical axis */
38870 int mapped_btns[3];
38871
38872 diff --git a/drivers/misc/sgi-gru/gruhandles.c b/drivers/misc/sgi-gru/gruhandles.c
38873 index 2f30bad..c4c13d0 100644
38874 --- a/drivers/misc/sgi-gru/gruhandles.c
38875 +++ b/drivers/misc/sgi-gru/gruhandles.c
38876 @@ -44,8 +44,8 @@ static void update_mcs_stats(enum mcs_op op, unsigned long clks)
38877 unsigned long nsec;
38878
38879 nsec = CLKS2NSEC(clks);
38880 - atomic_long_inc(&mcs_op_statistics[op].count);
38881 - atomic_long_add(nsec, &mcs_op_statistics[op].total);
38882 + atomic_long_inc_unchecked(&mcs_op_statistics[op].count);
38883 + atomic_long_add_unchecked(nsec, &mcs_op_statistics[op].total);
38884 if (mcs_op_statistics[op].max < nsec)
38885 mcs_op_statistics[op].max = nsec;
38886 }
38887 diff --git a/drivers/misc/sgi-gru/gruprocfs.c b/drivers/misc/sgi-gru/gruprocfs.c
38888 index 950dbe9..eeef0f8 100644
38889 --- a/drivers/misc/sgi-gru/gruprocfs.c
38890 +++ b/drivers/misc/sgi-gru/gruprocfs.c
38891 @@ -32,9 +32,9 @@
38892
38893 #define printstat(s, f) printstat_val(s, &gru_stats.f, #f)
38894
38895 -static void printstat_val(struct seq_file *s, atomic_long_t *v, char *id)
38896 +static void printstat_val(struct seq_file *s, atomic_long_unchecked_t *v, char *id)
38897 {
38898 - unsigned long val = atomic_long_read(v);
38899 + unsigned long val = atomic_long_read_unchecked(v);
38900
38901 seq_printf(s, "%16lu %s\n", val, id);
38902 }
38903 @@ -134,8 +134,8 @@ static int mcs_statistics_show(struct seq_file *s, void *p)
38904
38905 seq_printf(s, "%-20s%12s%12s%12s\n", "#id", "count", "aver-clks", "max-clks");
38906 for (op = 0; op < mcsop_last; op++) {
38907 - count = atomic_long_read(&mcs_op_statistics[op].count);
38908 - total = atomic_long_read(&mcs_op_statistics[op].total);
38909 + count = atomic_long_read_unchecked(&mcs_op_statistics[op].count);
38910 + total = atomic_long_read_unchecked(&mcs_op_statistics[op].total);
38911 max = mcs_op_statistics[op].max;
38912 seq_printf(s, "%-20s%12ld%12ld%12ld\n", id[op], count,
38913 count ? total / count : 0, max);
38914 diff --git a/drivers/misc/sgi-gru/grutables.h b/drivers/misc/sgi-gru/grutables.h
38915 index 5c3ce24..4915ccb 100644
38916 --- a/drivers/misc/sgi-gru/grutables.h
38917 +++ b/drivers/misc/sgi-gru/grutables.h
38918 @@ -167,82 +167,82 @@ extern unsigned int gru_max_gids;
38919 * GRU statistics.
38920 */
38921 struct gru_stats_s {
38922 - atomic_long_t vdata_alloc;
38923 - atomic_long_t vdata_free;
38924 - atomic_long_t gts_alloc;
38925 - atomic_long_t gts_free;
38926 - atomic_long_t gms_alloc;
38927 - atomic_long_t gms_free;
38928 - atomic_long_t gts_double_allocate;
38929 - atomic_long_t assign_context;
38930 - atomic_long_t assign_context_failed;
38931 - atomic_long_t free_context;
38932 - atomic_long_t load_user_context;
38933 - atomic_long_t load_kernel_context;
38934 - atomic_long_t lock_kernel_context;
38935 - atomic_long_t unlock_kernel_context;
38936 - atomic_long_t steal_user_context;
38937 - atomic_long_t steal_kernel_context;
38938 - atomic_long_t steal_context_failed;
38939 - atomic_long_t nopfn;
38940 - atomic_long_t asid_new;
38941 - atomic_long_t asid_next;
38942 - atomic_long_t asid_wrap;
38943 - atomic_long_t asid_reuse;
38944 - atomic_long_t intr;
38945 - atomic_long_t intr_cbr;
38946 - atomic_long_t intr_tfh;
38947 - atomic_long_t intr_spurious;
38948 - atomic_long_t intr_mm_lock_failed;
38949 - atomic_long_t call_os;
38950 - atomic_long_t call_os_wait_queue;
38951 - atomic_long_t user_flush_tlb;
38952 - atomic_long_t user_unload_context;
38953 - atomic_long_t user_exception;
38954 - atomic_long_t set_context_option;
38955 - atomic_long_t check_context_retarget_intr;
38956 - atomic_long_t check_context_unload;
38957 - atomic_long_t tlb_dropin;
38958 - atomic_long_t tlb_preload_page;
38959 - atomic_long_t tlb_dropin_fail_no_asid;
38960 - atomic_long_t tlb_dropin_fail_upm;
38961 - atomic_long_t tlb_dropin_fail_invalid;
38962 - atomic_long_t tlb_dropin_fail_range_active;
38963 - atomic_long_t tlb_dropin_fail_idle;
38964 - atomic_long_t tlb_dropin_fail_fmm;
38965 - atomic_long_t tlb_dropin_fail_no_exception;
38966 - atomic_long_t tfh_stale_on_fault;
38967 - atomic_long_t mmu_invalidate_range;
38968 - atomic_long_t mmu_invalidate_page;
38969 - atomic_long_t flush_tlb;
38970 - atomic_long_t flush_tlb_gru;
38971 - atomic_long_t flush_tlb_gru_tgh;
38972 - atomic_long_t flush_tlb_gru_zero_asid;
38973 + atomic_long_unchecked_t vdata_alloc;
38974 + atomic_long_unchecked_t vdata_free;
38975 + atomic_long_unchecked_t gts_alloc;
38976 + atomic_long_unchecked_t gts_free;
38977 + atomic_long_unchecked_t gms_alloc;
38978 + atomic_long_unchecked_t gms_free;
38979 + atomic_long_unchecked_t gts_double_allocate;
38980 + atomic_long_unchecked_t assign_context;
38981 + atomic_long_unchecked_t assign_context_failed;
38982 + atomic_long_unchecked_t free_context;
38983 + atomic_long_unchecked_t load_user_context;
38984 + atomic_long_unchecked_t load_kernel_context;
38985 + atomic_long_unchecked_t lock_kernel_context;
38986 + atomic_long_unchecked_t unlock_kernel_context;
38987 + atomic_long_unchecked_t steal_user_context;
38988 + atomic_long_unchecked_t steal_kernel_context;
38989 + atomic_long_unchecked_t steal_context_failed;
38990 + atomic_long_unchecked_t nopfn;
38991 + atomic_long_unchecked_t asid_new;
38992 + atomic_long_unchecked_t asid_next;
38993 + atomic_long_unchecked_t asid_wrap;
38994 + atomic_long_unchecked_t asid_reuse;
38995 + atomic_long_unchecked_t intr;
38996 + atomic_long_unchecked_t intr_cbr;
38997 + atomic_long_unchecked_t intr_tfh;
38998 + atomic_long_unchecked_t intr_spurious;
38999 + atomic_long_unchecked_t intr_mm_lock_failed;
39000 + atomic_long_unchecked_t call_os;
39001 + atomic_long_unchecked_t call_os_wait_queue;
39002 + atomic_long_unchecked_t user_flush_tlb;
39003 + atomic_long_unchecked_t user_unload_context;
39004 + atomic_long_unchecked_t user_exception;
39005 + atomic_long_unchecked_t set_context_option;
39006 + atomic_long_unchecked_t check_context_retarget_intr;
39007 + atomic_long_unchecked_t check_context_unload;
39008 + atomic_long_unchecked_t tlb_dropin;
39009 + atomic_long_unchecked_t tlb_preload_page;
39010 + atomic_long_unchecked_t tlb_dropin_fail_no_asid;
39011 + atomic_long_unchecked_t tlb_dropin_fail_upm;
39012 + atomic_long_unchecked_t tlb_dropin_fail_invalid;
39013 + atomic_long_unchecked_t tlb_dropin_fail_range_active;
39014 + atomic_long_unchecked_t tlb_dropin_fail_idle;
39015 + atomic_long_unchecked_t tlb_dropin_fail_fmm;
39016 + atomic_long_unchecked_t tlb_dropin_fail_no_exception;
39017 + atomic_long_unchecked_t tfh_stale_on_fault;
39018 + atomic_long_unchecked_t mmu_invalidate_range;
39019 + atomic_long_unchecked_t mmu_invalidate_page;
39020 + atomic_long_unchecked_t flush_tlb;
39021 + atomic_long_unchecked_t flush_tlb_gru;
39022 + atomic_long_unchecked_t flush_tlb_gru_tgh;
39023 + atomic_long_unchecked_t flush_tlb_gru_zero_asid;
39024
39025 - atomic_long_t copy_gpa;
39026 - atomic_long_t read_gpa;
39027 + atomic_long_unchecked_t copy_gpa;
39028 + atomic_long_unchecked_t read_gpa;
39029
39030 - atomic_long_t mesq_receive;
39031 - atomic_long_t mesq_receive_none;
39032 - atomic_long_t mesq_send;
39033 - atomic_long_t mesq_send_failed;
39034 - atomic_long_t mesq_noop;
39035 - atomic_long_t mesq_send_unexpected_error;
39036 - atomic_long_t mesq_send_lb_overflow;
39037 - atomic_long_t mesq_send_qlimit_reached;
39038 - atomic_long_t mesq_send_amo_nacked;
39039 - atomic_long_t mesq_send_put_nacked;
39040 - atomic_long_t mesq_page_overflow;
39041 - atomic_long_t mesq_qf_locked;
39042 - atomic_long_t mesq_qf_noop_not_full;
39043 - atomic_long_t mesq_qf_switch_head_failed;
39044 - atomic_long_t mesq_qf_unexpected_error;
39045 - atomic_long_t mesq_noop_unexpected_error;
39046 - atomic_long_t mesq_noop_lb_overflow;
39047 - atomic_long_t mesq_noop_qlimit_reached;
39048 - atomic_long_t mesq_noop_amo_nacked;
39049 - atomic_long_t mesq_noop_put_nacked;
39050 - atomic_long_t mesq_noop_page_overflow;
39051 + atomic_long_unchecked_t mesq_receive;
39052 + atomic_long_unchecked_t mesq_receive_none;
39053 + atomic_long_unchecked_t mesq_send;
39054 + atomic_long_unchecked_t mesq_send_failed;
39055 + atomic_long_unchecked_t mesq_noop;
39056 + atomic_long_unchecked_t mesq_send_unexpected_error;
39057 + atomic_long_unchecked_t mesq_send_lb_overflow;
39058 + atomic_long_unchecked_t mesq_send_qlimit_reached;
39059 + atomic_long_unchecked_t mesq_send_amo_nacked;
39060 + atomic_long_unchecked_t mesq_send_put_nacked;
39061 + atomic_long_unchecked_t mesq_page_overflow;
39062 + atomic_long_unchecked_t mesq_qf_locked;
39063 + atomic_long_unchecked_t mesq_qf_noop_not_full;
39064 + atomic_long_unchecked_t mesq_qf_switch_head_failed;
39065 + atomic_long_unchecked_t mesq_qf_unexpected_error;
39066 + atomic_long_unchecked_t mesq_noop_unexpected_error;
39067 + atomic_long_unchecked_t mesq_noop_lb_overflow;
39068 + atomic_long_unchecked_t mesq_noop_qlimit_reached;
39069 + atomic_long_unchecked_t mesq_noop_amo_nacked;
39070 + atomic_long_unchecked_t mesq_noop_put_nacked;
39071 + atomic_long_unchecked_t mesq_noop_page_overflow;
39072
39073 };
39074
39075 @@ -251,8 +251,8 @@ enum mcs_op {cchop_allocate, cchop_start, cchop_interrupt, cchop_interrupt_sync,
39076 tghop_invalidate, mcsop_last};
39077
39078 struct mcs_op_statistic {
39079 - atomic_long_t count;
39080 - atomic_long_t total;
39081 + atomic_long_unchecked_t count;
39082 + atomic_long_unchecked_t total;
39083 unsigned long max;
39084 };
39085
39086 @@ -275,7 +275,7 @@ extern struct mcs_op_statistic mcs_op_statistics[mcsop_last];
39087
39088 #define STAT(id) do { \
39089 if (gru_options & OPT_STATS) \
39090 - atomic_long_inc(&gru_stats.id); \
39091 + atomic_long_inc_unchecked(&gru_stats.id); \
39092 } while (0)
39093
39094 #ifdef CONFIG_SGI_GRU_DEBUG
39095 diff --git a/drivers/misc/sgi-xp/xp.h b/drivers/misc/sgi-xp/xp.h
39096 index c862cd4..0d176fe 100644
39097 --- a/drivers/misc/sgi-xp/xp.h
39098 +++ b/drivers/misc/sgi-xp/xp.h
39099 @@ -288,7 +288,7 @@ struct xpc_interface {
39100 xpc_notify_func, void *);
39101 void (*received) (short, int, void *);
39102 enum xp_retval (*partid_to_nasids) (short, void *);
39103 -};
39104 +} __no_const;
39105
39106 extern struct xpc_interface xpc_interface;
39107
39108 diff --git a/drivers/misc/sgi-xp/xpc.h b/drivers/misc/sgi-xp/xpc.h
39109 index b94d5f7..7f494c5 100644
39110 --- a/drivers/misc/sgi-xp/xpc.h
39111 +++ b/drivers/misc/sgi-xp/xpc.h
39112 @@ -835,6 +835,7 @@ struct xpc_arch_operations {
39113 void (*received_payload) (struct xpc_channel *, void *);
39114 void (*notify_senders_of_disconnect) (struct xpc_channel *);
39115 };
39116 +typedef struct xpc_arch_operations __no_const xpc_arch_operations_no_const;
39117
39118 /* struct xpc_partition act_state values (for XPC HB) */
39119
39120 @@ -876,7 +877,7 @@ extern struct xpc_registration xpc_registrations[];
39121 /* found in xpc_main.c */
39122 extern struct device *xpc_part;
39123 extern struct device *xpc_chan;
39124 -extern struct xpc_arch_operations xpc_arch_ops;
39125 +extern xpc_arch_operations_no_const xpc_arch_ops;
39126 extern int xpc_disengage_timelimit;
39127 extern int xpc_disengage_timedout;
39128 extern int xpc_activate_IRQ_rcvd;
39129 diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c
39130 index d971817..33bdca5 100644
39131 --- a/drivers/misc/sgi-xp/xpc_main.c
39132 +++ b/drivers/misc/sgi-xp/xpc_main.c
39133 @@ -166,7 +166,7 @@ static struct notifier_block xpc_die_notifier = {
39134 .notifier_call = xpc_system_die,
39135 };
39136
39137 -struct xpc_arch_operations xpc_arch_ops;
39138 +xpc_arch_operations_no_const xpc_arch_ops;
39139
39140 /*
39141 * Timer function to enforce the timelimit on the partition disengage.
39142 @@ -1210,7 +1210,7 @@ xpc_system_die(struct notifier_block *nb, unsigned long event, void *_die_args)
39143
39144 if (((die_args->trapnr == X86_TRAP_MF) ||
39145 (die_args->trapnr == X86_TRAP_XF)) &&
39146 - !user_mode_vm(die_args->regs))
39147 + !user_mode(die_args->regs))
39148 xpc_die_deactivate();
39149
39150 break;
39151 diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
39152 index 49f04bc..65660c2 100644
39153 --- a/drivers/mmc/core/mmc_ops.c
39154 +++ b/drivers/mmc/core/mmc_ops.c
39155 @@ -247,7 +247,7 @@ mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host,
39156 void *data_buf;
39157 int is_on_stack;
39158
39159 - is_on_stack = object_is_on_stack(buf);
39160 + is_on_stack = object_starts_on_stack(buf);
39161 if (is_on_stack) {
39162 /*
39163 * dma onto stack is unsafe/nonportable, but callers to this
39164 diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h
39165 index 53b8fd9..615b462 100644
39166 --- a/drivers/mmc/host/dw_mmc.h
39167 +++ b/drivers/mmc/host/dw_mmc.h
39168 @@ -205,5 +205,5 @@ struct dw_mci_drv_data {
39169 int (*parse_dt)(struct dw_mci *host);
39170 int (*setup_bus)(struct dw_mci *host,
39171 struct device_node *slot_np, u8 bus_width);
39172 -};
39173 +} __do_const;
39174 #endif /* _DW_MMC_H_ */
39175 diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
39176 index 7363efe..681558e 100644
39177 --- a/drivers/mmc/host/sdhci-s3c.c
39178 +++ b/drivers/mmc/host/sdhci-s3c.c
39179 @@ -720,9 +720,11 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
39180 * we can use overriding functions instead of default.
39181 */
39182 if (host->quirks & SDHCI_QUIRK_NONSTANDARD_CLOCK) {
39183 - sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
39184 - sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
39185 - sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
39186 + pax_open_kernel();
39187 + *(void **)&sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
39188 + *(void **)&sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
39189 + *(void **)&sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
39190 + pax_close_kernel();
39191 }
39192
39193 /* It supports additional host capabilities if needed */
39194 diff --git a/drivers/mtd/devices/doc2000.c b/drivers/mtd/devices/doc2000.c
39195 index a4eb8b5..8c0628f 100644
39196 --- a/drivers/mtd/devices/doc2000.c
39197 +++ b/drivers/mtd/devices/doc2000.c
39198 @@ -753,7 +753,7 @@ static int doc_write(struct mtd_info *mtd, loff_t to, size_t len,
39199
39200 /* The ECC will not be calculated correctly if less than 512 is written */
39201 /* DBB-
39202 - if (len != 0x200 && eccbuf)
39203 + if (len != 0x200)
39204 printk(KERN_WARNING
39205 "ECC needs a full sector write (adr: %lx size %lx)\n",
39206 (long) to, (long) len);
39207 diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
39208 index 0c8bb6b..6f35deb 100644
39209 --- a/drivers/mtd/nand/denali.c
39210 +++ b/drivers/mtd/nand/denali.c
39211 @@ -24,6 +24,7 @@
39212 #include <linux/slab.h>
39213 #include <linux/mtd/mtd.h>
39214 #include <linux/module.h>
39215 +#include <linux/slab.h>
39216
39217 #include "denali.h"
39218
39219 diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c
39220 index 51b9d6a..52af9a7 100644
39221 --- a/drivers/mtd/nftlmount.c
39222 +++ b/drivers/mtd/nftlmount.c
39223 @@ -24,6 +24,7 @@
39224 #include <asm/errno.h>
39225 #include <linux/delay.h>
39226 #include <linux/slab.h>
39227 +#include <linux/sched.h>
39228 #include <linux/mtd/mtd.h>
39229 #include <linux/mtd/nand.h>
39230 #include <linux/mtd/nftl.h>
39231 diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c
39232 index 8dd6ba5..419cc1d 100644
39233 --- a/drivers/mtd/sm_ftl.c
39234 +++ b/drivers/mtd/sm_ftl.c
39235 @@ -56,7 +56,7 @@ ssize_t sm_attr_show(struct device *dev, struct device_attribute *attr,
39236 #define SM_CIS_VENDOR_OFFSET 0x59
39237 struct attribute_group *sm_create_sysfs_attributes(struct sm_ftl *ftl)
39238 {
39239 - struct attribute_group *attr_group;
39240 + attribute_group_no_const *attr_group;
39241 struct attribute **attributes;
39242 struct sm_sysfs_attribute *vendor_attribute;
39243
39244 diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
39245 index dbbea0e..3f4a0b1 100644
39246 --- a/drivers/net/bonding/bond_main.c
39247 +++ b/drivers/net/bonding/bond_main.c
39248 @@ -4822,7 +4822,7 @@ static unsigned int bond_get_num_tx_queues(void)
39249 return tx_queues;
39250 }
39251
39252 -static struct rtnl_link_ops bond_link_ops __read_mostly = {
39253 +static struct rtnl_link_ops bond_link_ops = {
39254 .kind = "bond",
39255 .priv_size = sizeof(struct bonding),
39256 .setup = bond_setup,
39257 @@ -4947,8 +4947,8 @@ static void __exit bonding_exit(void)
39258
39259 bond_destroy_debugfs();
39260
39261 - rtnl_link_unregister(&bond_link_ops);
39262 unregister_pernet_subsys(&bond_net_ops);
39263 + rtnl_link_unregister(&bond_link_ops);
39264
39265 #ifdef CONFIG_NET_POLL_CONTROLLER
39266 /*
39267 diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
39268 index e1d2643..7f4133b 100644
39269 --- a/drivers/net/ethernet/8390/ax88796.c
39270 +++ b/drivers/net/ethernet/8390/ax88796.c
39271 @@ -872,9 +872,11 @@ static int ax_probe(struct platform_device *pdev)
39272 if (ax->plat->reg_offsets)
39273 ei_local->reg_offset = ax->plat->reg_offsets;
39274 else {
39275 + resource_size_t _mem_size = mem_size;
39276 + do_div(_mem_size, 0x18);
39277 ei_local->reg_offset = ax->reg_offsets;
39278 for (ret = 0; ret < 0x18; ret++)
39279 - ax->reg_offsets[ret] = (mem_size / 0x18) * ret;
39280 + ax->reg_offsets[ret] = _mem_size * ret;
39281 }
39282
39283 if (!request_mem_region(mem->start, mem_size, pdev->name)) {
39284 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
39285 index aee7671..3ca2651 100644
39286 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
39287 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
39288 @@ -1093,7 +1093,7 @@ static inline u8 bnx2x_get_path_func_num(struct bnx2x *bp)
39289 static inline void bnx2x_init_bp_objs(struct bnx2x *bp)
39290 {
39291 /* RX_MODE controlling object */
39292 - bnx2x_init_rx_mode_obj(bp, &bp->rx_mode_obj);
39293 + bnx2x_init_rx_mode_obj(bp);
39294
39295 /* multicast configuration controlling object */
39296 bnx2x_init_mcast_obj(bp, &bp->mcast_obj, bp->fp->cl_id, bp->fp->cid,
39297 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
39298 index 7306416..5fb7fb5 100644
39299 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
39300 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
39301 @@ -2381,15 +2381,14 @@ int bnx2x_config_rx_mode(struct bnx2x *bp,
39302 return rc;
39303 }
39304
39305 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
39306 - struct bnx2x_rx_mode_obj *o)
39307 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp)
39308 {
39309 if (CHIP_IS_E1x(bp)) {
39310 - o->wait_comp = bnx2x_empty_rx_mode_wait;
39311 - o->config_rx_mode = bnx2x_set_rx_mode_e1x;
39312 + bp->rx_mode_obj.wait_comp = bnx2x_empty_rx_mode_wait;
39313 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e1x;
39314 } else {
39315 - o->wait_comp = bnx2x_wait_rx_mode_comp_e2;
39316 - o->config_rx_mode = bnx2x_set_rx_mode_e2;
39317 + bp->rx_mode_obj.wait_comp = bnx2x_wait_rx_mode_comp_e2;
39318 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e2;
39319 }
39320 }
39321
39322 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
39323 index ff90760..08d8aed 100644
39324 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
39325 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
39326 @@ -1306,8 +1306,7 @@ int bnx2x_vlan_mac_move(struct bnx2x *bp,
39327
39328 /********************* RX MODE ****************/
39329
39330 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
39331 - struct bnx2x_rx_mode_obj *o);
39332 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp);
39333
39334 /**
39335 * bnx2x_config_rx_mode - Send and RX_MODE ramrod according to the provided parameters.
39336 diff --git a/drivers/net/ethernet/broadcom/tg3.h b/drivers/net/ethernet/broadcom/tg3.h
39337 index 8d7d4c2..95f7681 100644
39338 --- a/drivers/net/ethernet/broadcom/tg3.h
39339 +++ b/drivers/net/ethernet/broadcom/tg3.h
39340 @@ -147,6 +147,7 @@
39341 #define CHIPREV_ID_5750_A0 0x4000
39342 #define CHIPREV_ID_5750_A1 0x4001
39343 #define CHIPREV_ID_5750_A3 0x4003
39344 +#define CHIPREV_ID_5750_C1 0x4201
39345 #define CHIPREV_ID_5750_C2 0x4202
39346 #define CHIPREV_ID_5752_A0_HW 0x5000
39347 #define CHIPREV_ID_5752_A0 0x6000
39348 diff --git a/drivers/net/ethernet/chelsio/cxgb3/l2t.h b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
39349 index 8cffcdf..aadf043 100644
39350 --- a/drivers/net/ethernet/chelsio/cxgb3/l2t.h
39351 +++ b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
39352 @@ -87,7 +87,7 @@ typedef void (*arp_failure_handler_func)(struct t3cdev * dev,
39353 */
39354 struct l2t_skb_cb {
39355 arp_failure_handler_func arp_failure_handler;
39356 -};
39357 +} __no_const;
39358
39359 #define L2T_SKB_CB(skb) ((struct l2t_skb_cb *)(skb)->cb)
39360
39361 diff --git a/drivers/net/ethernet/dec/tulip/de4x5.c b/drivers/net/ethernet/dec/tulip/de4x5.c
39362 index 4c83003..2a2a5b9 100644
39363 --- a/drivers/net/ethernet/dec/tulip/de4x5.c
39364 +++ b/drivers/net/ethernet/dec/tulip/de4x5.c
39365 @@ -5388,7 +5388,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
39366 for (i=0; i<ETH_ALEN; i++) {
39367 tmp.addr[i] = dev->dev_addr[i];
39368 }
39369 - if (copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
39370 + if (ioc->len > sizeof tmp.addr || copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
39371 break;
39372
39373 case DE4X5_SET_HWADDR: /* Set the hardware address */
39374 @@ -5428,7 +5428,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
39375 spin_lock_irqsave(&lp->lock, flags);
39376 memcpy(&statbuf, &lp->pktStats, ioc->len);
39377 spin_unlock_irqrestore(&lp->lock, flags);
39378 - if (copy_to_user(ioc->data, &statbuf, ioc->len))
39379 + if (ioc->len > sizeof statbuf || copy_to_user(ioc->data, &statbuf, ioc->len))
39380 return -EFAULT;
39381 break;
39382 }
39383 diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
39384 index 2886c9b..db71673 100644
39385 --- a/drivers/net/ethernet/emulex/benet/be_main.c
39386 +++ b/drivers/net/ethernet/emulex/benet/be_main.c
39387 @@ -455,7 +455,7 @@ static void accumulate_16bit_val(u32 *acc, u16 val)
39388
39389 if (wrapped)
39390 newacc += 65536;
39391 - ACCESS_ONCE(*acc) = newacc;
39392 + ACCESS_ONCE_RW(*acc) = newacc;
39393 }
39394
39395 void be_parse_stats(struct be_adapter *adapter)
39396 diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
39397 index 7c361d1..57e3ff1 100644
39398 --- a/drivers/net/ethernet/faraday/ftgmac100.c
39399 +++ b/drivers/net/ethernet/faraday/ftgmac100.c
39400 @@ -31,6 +31,8 @@
39401 #include <linux/netdevice.h>
39402 #include <linux/phy.h>
39403 #include <linux/platform_device.h>
39404 +#include <linux/interrupt.h>
39405 +#include <linux/irqreturn.h>
39406 #include <net/ip.h>
39407
39408 #include "ftgmac100.h"
39409 diff --git a/drivers/net/ethernet/faraday/ftmac100.c b/drivers/net/ethernet/faraday/ftmac100.c
39410 index b5ea8fb..bd25e9a 100644
39411 --- a/drivers/net/ethernet/faraday/ftmac100.c
39412 +++ b/drivers/net/ethernet/faraday/ftmac100.c
39413 @@ -31,6 +31,8 @@
39414 #include <linux/module.h>
39415 #include <linux/netdevice.h>
39416 #include <linux/platform_device.h>
39417 +#include <linux/interrupt.h>
39418 +#include <linux/irqreturn.h>
39419
39420 #include "ftmac100.h"
39421
39422 diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
39423 index 331987d..3be1135 100644
39424 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
39425 +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
39426 @@ -776,7 +776,7 @@ void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter)
39427 }
39428
39429 /* update the base incval used to calculate frequency adjustment */
39430 - ACCESS_ONCE(adapter->base_incval) = incval;
39431 + ACCESS_ONCE_RW(adapter->base_incval) = incval;
39432 smp_mb();
39433
39434 /* need lock to prevent incorrect read while modifying cyclecounter */
39435 diff --git a/drivers/net/ethernet/neterion/vxge/vxge-config.c b/drivers/net/ethernet/neterion/vxge/vxge-config.c
39436 index fbe5363..266b4e3 100644
39437 --- a/drivers/net/ethernet/neterion/vxge/vxge-config.c
39438 +++ b/drivers/net/ethernet/neterion/vxge/vxge-config.c
39439 @@ -3461,7 +3461,10 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
39440 struct __vxge_hw_fifo *fifo;
39441 struct vxge_hw_fifo_config *config;
39442 u32 txdl_size, txdl_per_memblock;
39443 - struct vxge_hw_mempool_cbs fifo_mp_callback;
39444 + static struct vxge_hw_mempool_cbs fifo_mp_callback = {
39445 + .item_func_alloc = __vxge_hw_fifo_mempool_item_alloc,
39446 + };
39447 +
39448 struct __vxge_hw_virtualpath *vpath;
39449
39450 if ((vp == NULL) || (attr == NULL)) {
39451 @@ -3544,8 +3547,6 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
39452 goto exit;
39453 }
39454
39455 - fifo_mp_callback.item_func_alloc = __vxge_hw_fifo_mempool_item_alloc;
39456 -
39457 fifo->mempool =
39458 __vxge_hw_mempool_create(vpath->hldev,
39459 fifo->config->memblock_size,
39460 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
39461 index 5c033f2..7bbb0d8 100644
39462 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
39463 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
39464 @@ -1894,7 +1894,9 @@ int qlcnic_83xx_config_default_opmode(struct qlcnic_adapter *adapter)
39465 op_mode = QLCRDX(ahw, QLC_83XX_DRV_OP_MODE);
39466
39467 if (op_mode == QLC_83XX_DEFAULT_OPMODE) {
39468 - adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
39469 + pax_open_kernel();
39470 + *(void **)&adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
39471 + pax_close_kernel();
39472 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
39473 } else {
39474 return -EIO;
39475 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
39476 index b0c3de9..fc5857e 100644
39477 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
39478 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
39479 @@ -200,15 +200,21 @@ int qlcnic_83xx_config_vnic_opmode(struct qlcnic_adapter *adapter)
39480 if (priv_level == QLCNIC_NON_PRIV_FUNC) {
39481 ahw->op_mode = QLCNIC_NON_PRIV_FUNC;
39482 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
39483 - nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
39484 + pax_open_kernel();
39485 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
39486 + pax_close_kernel();
39487 } else if (priv_level == QLCNIC_PRIV_FUNC) {
39488 ahw->op_mode = QLCNIC_PRIV_FUNC;
39489 ahw->idc.state_entry = qlcnic_83xx_idc_vnic_pf_entry;
39490 - nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
39491 + pax_open_kernel();
39492 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
39493 + pax_close_kernel();
39494 } else if (priv_level == QLCNIC_MGMT_FUNC) {
39495 ahw->op_mode = QLCNIC_MGMT_FUNC;
39496 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
39497 - nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
39498 + pax_open_kernel();
39499 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
39500 + pax_close_kernel();
39501 } else {
39502 return -EIO;
39503 }
39504 diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
39505 index 15ba8c4..3f56838 100644
39506 --- a/drivers/net/ethernet/realtek/r8169.c
39507 +++ b/drivers/net/ethernet/realtek/r8169.c
39508 @@ -740,22 +740,22 @@ struct rtl8169_private {
39509 struct mdio_ops {
39510 void (*write)(struct rtl8169_private *, int, int);
39511 int (*read)(struct rtl8169_private *, int);
39512 - } mdio_ops;
39513 + } __no_const mdio_ops;
39514
39515 struct pll_power_ops {
39516 void (*down)(struct rtl8169_private *);
39517 void (*up)(struct rtl8169_private *);
39518 - } pll_power_ops;
39519 + } __no_const pll_power_ops;
39520
39521 struct jumbo_ops {
39522 void (*enable)(struct rtl8169_private *);
39523 void (*disable)(struct rtl8169_private *);
39524 - } jumbo_ops;
39525 + } __no_const jumbo_ops;
39526
39527 struct csi_ops {
39528 void (*write)(struct rtl8169_private *, int, int);
39529 u32 (*read)(struct rtl8169_private *, int);
39530 - } csi_ops;
39531 + } __no_const csi_ops;
39532
39533 int (*set_speed)(struct net_device *, u8 aneg, u16 sp, u8 dpx, u32 adv);
39534 int (*get_settings)(struct net_device *, struct ethtool_cmd *);
39535 diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c
39536 index 3f93624..cf01144 100644
39537 --- a/drivers/net/ethernet/sfc/ptp.c
39538 +++ b/drivers/net/ethernet/sfc/ptp.c
39539 @@ -553,7 +553,7 @@ static int efx_ptp_synchronize(struct efx_nic *efx, unsigned int num_readings)
39540 (u32)((u64)ptp->start.dma_addr >> 32));
39541
39542 /* Clear flag that signals MC ready */
39543 - ACCESS_ONCE(*start) = 0;
39544 + ACCESS_ONCE_RW(*start) = 0;
39545 efx_mcdi_rpc_start(efx, MC_CMD_PTP, synch_buf,
39546 MC_CMD_PTP_IN_SYNCHRONIZE_LEN);
39547
39548 diff --git a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
39549 index 50617c5..b13724c 100644
39550 --- a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
39551 +++ b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
39552 @@ -140,8 +140,8 @@ void dwmac_mmc_ctrl(void __iomem *ioaddr, unsigned int mode)
39553
39554 writel(value, ioaddr + MMC_CNTRL);
39555
39556 - pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
39557 - MMC_CNTRL, value);
39558 +// pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
39559 +// MMC_CNTRL, value);
39560 }
39561
39562 /* To mask all all interrupts.*/
39563 diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
39564 index e6fe0d8..2b7d752 100644
39565 --- a/drivers/net/hyperv/hyperv_net.h
39566 +++ b/drivers/net/hyperv/hyperv_net.h
39567 @@ -101,7 +101,7 @@ struct rndis_device {
39568
39569 enum rndis_device_state state;
39570 bool link_state;
39571 - atomic_t new_req_id;
39572 + atomic_unchecked_t new_req_id;
39573
39574 spinlock_t request_lock;
39575 struct list_head req_list;
39576 diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
39577 index 0775f0a..d4fb316 100644
39578 --- a/drivers/net/hyperv/rndis_filter.c
39579 +++ b/drivers/net/hyperv/rndis_filter.c
39580 @@ -104,7 +104,7 @@ static struct rndis_request *get_rndis_request(struct rndis_device *dev,
39581 * template
39582 */
39583 set = &rndis_msg->msg.set_req;
39584 - set->req_id = atomic_inc_return(&dev->new_req_id);
39585 + set->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
39586
39587 /* Add to the request list */
39588 spin_lock_irqsave(&dev->request_lock, flags);
39589 @@ -752,7 +752,7 @@ static void rndis_filter_halt_device(struct rndis_device *dev)
39590
39591 /* Setup the rndis set */
39592 halt = &request->request_msg.msg.halt_req;
39593 - halt->req_id = atomic_inc_return(&dev->new_req_id);
39594 + halt->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
39595
39596 /* Ignore return since this msg is optional. */
39597 rndis_filter_send_request(dev, request);
39598 diff --git a/drivers/net/ieee802154/fakehard.c b/drivers/net/ieee802154/fakehard.c
39599 index 8f1c256..a2991d1 100644
39600 --- a/drivers/net/ieee802154/fakehard.c
39601 +++ b/drivers/net/ieee802154/fakehard.c
39602 @@ -385,7 +385,7 @@ static int ieee802154fake_probe(struct platform_device *pdev)
39603 phy->transmit_power = 0xbf;
39604
39605 dev->netdev_ops = &fake_ops;
39606 - dev->ml_priv = &fake_mlme;
39607 + dev->ml_priv = (void *)&fake_mlme;
39608
39609 priv = netdev_priv(dev);
39610 priv->phy = phy;
39611 diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
39612 index 011062e..ada88e9 100644
39613 --- a/drivers/net/macvlan.c
39614 +++ b/drivers/net/macvlan.c
39615 @@ -892,13 +892,15 @@ static const struct nla_policy macvlan_policy[IFLA_MACVLAN_MAX + 1] = {
39616 int macvlan_link_register(struct rtnl_link_ops *ops)
39617 {
39618 /* common fields */
39619 - ops->priv_size = sizeof(struct macvlan_dev);
39620 - ops->validate = macvlan_validate;
39621 - ops->maxtype = IFLA_MACVLAN_MAX;
39622 - ops->policy = macvlan_policy;
39623 - ops->changelink = macvlan_changelink;
39624 - ops->get_size = macvlan_get_size;
39625 - ops->fill_info = macvlan_fill_info;
39626 + pax_open_kernel();
39627 + *(size_t *)&ops->priv_size = sizeof(struct macvlan_dev);
39628 + *(void **)&ops->validate = macvlan_validate;
39629 + *(int *)&ops->maxtype = IFLA_MACVLAN_MAX;
39630 + *(const void **)&ops->policy = macvlan_policy;
39631 + *(void **)&ops->changelink = macvlan_changelink;
39632 + *(void **)&ops->get_size = macvlan_get_size;
39633 + *(void **)&ops->fill_info = macvlan_fill_info;
39634 + pax_close_kernel();
39635
39636 return rtnl_link_register(ops);
39637 };
39638 @@ -954,7 +956,7 @@ static int macvlan_device_event(struct notifier_block *unused,
39639 return NOTIFY_DONE;
39640 }
39641
39642 -static struct notifier_block macvlan_notifier_block __read_mostly = {
39643 +static struct notifier_block macvlan_notifier_block = {
39644 .notifier_call = macvlan_device_event,
39645 };
39646
39647 diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
39648 index a449439..1e468fe 100644
39649 --- a/drivers/net/macvtap.c
39650 +++ b/drivers/net/macvtap.c
39651 @@ -1090,7 +1090,7 @@ static int macvtap_device_event(struct notifier_block *unused,
39652 return NOTIFY_DONE;
39653 }
39654
39655 -static struct notifier_block macvtap_notifier_block __read_mostly = {
39656 +static struct notifier_block macvtap_notifier_block = {
39657 .notifier_call = macvtap_device_event,
39658 };
39659
39660 diff --git a/drivers/net/phy/mdio-bitbang.c b/drivers/net/phy/mdio-bitbang.c
39661 index daec9b0..6428fcb 100644
39662 --- a/drivers/net/phy/mdio-bitbang.c
39663 +++ b/drivers/net/phy/mdio-bitbang.c
39664 @@ -234,6 +234,7 @@ void free_mdio_bitbang(struct mii_bus *bus)
39665 struct mdiobb_ctrl *ctrl = bus->priv;
39666
39667 module_put(ctrl->ops->owner);
39668 + mdiobus_unregister(bus);
39669 mdiobus_free(bus);
39670 }
39671 EXPORT_SYMBOL(free_mdio_bitbang);
39672 diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
39673 index 72ff14b..11d442d 100644
39674 --- a/drivers/net/ppp/ppp_generic.c
39675 +++ b/drivers/net/ppp/ppp_generic.c
39676 @@ -999,7 +999,6 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
39677 void __user *addr = (void __user *) ifr->ifr_ifru.ifru_data;
39678 struct ppp_stats stats;
39679 struct ppp_comp_stats cstats;
39680 - char *vers;
39681
39682 switch (cmd) {
39683 case SIOCGPPPSTATS:
39684 @@ -1021,8 +1020,7 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
39685 break;
39686
39687 case SIOCGPPPVER:
39688 - vers = PPP_VERSION;
39689 - if (copy_to_user(addr, vers, strlen(vers) + 1))
39690 + if (copy_to_user(addr, PPP_VERSION, sizeof(PPP_VERSION)))
39691 break;
39692 err = 0;
39693 break;
39694 diff --git a/drivers/net/slip/slhc.c b/drivers/net/slip/slhc.c
39695 index 1252d9c..80e660b 100644
39696 --- a/drivers/net/slip/slhc.c
39697 +++ b/drivers/net/slip/slhc.c
39698 @@ -488,7 +488,7 @@ slhc_uncompress(struct slcompress *comp, unsigned char *icp, int isize)
39699 register struct tcphdr *thp;
39700 register struct iphdr *ip;
39701 register struct cstate *cs;
39702 - int len, hdrlen;
39703 + long len, hdrlen;
39704 unsigned char *cp = icp;
39705
39706 /* We've got a compressed packet; read the change byte */
39707 diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
39708 index bf34192..fba3500 100644
39709 --- a/drivers/net/team/team.c
39710 +++ b/drivers/net/team/team.c
39711 @@ -2668,7 +2668,7 @@ static int team_device_event(struct notifier_block *unused,
39712 return NOTIFY_DONE;
39713 }
39714
39715 -static struct notifier_block team_notifier_block __read_mostly = {
39716 +static struct notifier_block team_notifier_block = {
39717 .notifier_call = team_device_event,
39718 };
39719
39720 diff --git a/drivers/net/tun.c b/drivers/net/tun.c
39721 index 755fa9e..631fdce 100644
39722 --- a/drivers/net/tun.c
39723 +++ b/drivers/net/tun.c
39724 @@ -1841,7 +1841,7 @@ unlock:
39725 }
39726
39727 static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
39728 - unsigned long arg, int ifreq_len)
39729 + unsigned long arg, size_t ifreq_len)
39730 {
39731 struct tun_file *tfile = file->private_data;
39732 struct tun_struct *tun;
39733 @@ -1853,6 +1853,9 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
39734 int vnet_hdr_sz;
39735 int ret;
39736
39737 + if (ifreq_len > sizeof ifr)
39738 + return -EFAULT;
39739 +
39740 if (cmd == TUNSETIFF || cmd == TUNSETQUEUE || _IOC_TYPE(cmd) == 0x89) {
39741 if (copy_from_user(&ifr, argp, ifreq_len))
39742 return -EFAULT;
39743 diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
39744 index e2dd324..be92fcf 100644
39745 --- a/drivers/net/usb/hso.c
39746 +++ b/drivers/net/usb/hso.c
39747 @@ -71,7 +71,7 @@
39748 #include <asm/byteorder.h>
39749 #include <linux/serial_core.h>
39750 #include <linux/serial.h>
39751 -
39752 +#include <asm/local.h>
39753
39754 #define MOD_AUTHOR "Option Wireless"
39755 #define MOD_DESCRIPTION "USB High Speed Option driver"
39756 @@ -1180,7 +1180,7 @@ static void put_rxbuf_data_and_resubmit_ctrl_urb(struct hso_serial *serial)
39757 struct urb *urb;
39758
39759 urb = serial->rx_urb[0];
39760 - if (serial->port.count > 0) {
39761 + if (atomic_read(&serial->port.count) > 0) {
39762 count = put_rxbuf_data(urb, serial);
39763 if (count == -1)
39764 return;
39765 @@ -1216,7 +1216,7 @@ static void hso_std_serial_read_bulk_callback(struct urb *urb)
39766 DUMP1(urb->transfer_buffer, urb->actual_length);
39767
39768 /* Anyone listening? */
39769 - if (serial->port.count == 0)
39770 + if (atomic_read(&serial->port.count) == 0)
39771 return;
39772
39773 if (status == 0) {
39774 @@ -1298,8 +1298,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
39775 tty_port_tty_set(&serial->port, tty);
39776
39777 /* check for port already opened, if not set the termios */
39778 - serial->port.count++;
39779 - if (serial->port.count == 1) {
39780 + if (atomic_inc_return(&serial->port.count) == 1) {
39781 serial->rx_state = RX_IDLE;
39782 /* Force default termio settings */
39783 _hso_serial_set_termios(tty, NULL);
39784 @@ -1311,7 +1310,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
39785 result = hso_start_serial_device(serial->parent, GFP_KERNEL);
39786 if (result) {
39787 hso_stop_serial_device(serial->parent);
39788 - serial->port.count--;
39789 + atomic_dec(&serial->port.count);
39790 kref_put(&serial->parent->ref, hso_serial_ref_free);
39791 }
39792 } else {
39793 @@ -1348,10 +1347,10 @@ static void hso_serial_close(struct tty_struct *tty, struct file *filp)
39794
39795 /* reset the rts and dtr */
39796 /* do the actual close */
39797 - serial->port.count--;
39798 + atomic_dec(&serial->port.count);
39799
39800 - if (serial->port.count <= 0) {
39801 - serial->port.count = 0;
39802 + if (atomic_read(&serial->port.count) <= 0) {
39803 + atomic_set(&serial->port.count, 0);
39804 tty_port_tty_set(&serial->port, NULL);
39805 if (!usb_gone)
39806 hso_stop_serial_device(serial->parent);
39807 @@ -1427,7 +1426,7 @@ static void hso_serial_set_termios(struct tty_struct *tty, struct ktermios *old)
39808
39809 /* the actual setup */
39810 spin_lock_irqsave(&serial->serial_lock, flags);
39811 - if (serial->port.count)
39812 + if (atomic_read(&serial->port.count))
39813 _hso_serial_set_termios(tty, old);
39814 else
39815 tty->termios = *old;
39816 @@ -1886,7 +1885,7 @@ static void intr_callback(struct urb *urb)
39817 D1("Pending read interrupt on port %d\n", i);
39818 spin_lock(&serial->serial_lock);
39819 if (serial->rx_state == RX_IDLE &&
39820 - serial->port.count > 0) {
39821 + atomic_read(&serial->port.count) > 0) {
39822 /* Setup and send a ctrl req read on
39823 * port i */
39824 if (!serial->rx_urb_filled[0]) {
39825 @@ -3066,7 +3065,7 @@ static int hso_resume(struct usb_interface *iface)
39826 /* Start all serial ports */
39827 for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) {
39828 if (serial_table[i] && (serial_table[i]->interface == iface)) {
39829 - if (dev2ser(serial_table[i])->port.count) {
39830 + if (atomic_read(&dev2ser(serial_table[i])->port.count)) {
39831 result =
39832 hso_start_serial_device(serial_table[i], GFP_NOIO);
39833 hso_kick_transmit(dev2ser(serial_table[i]));
39834 diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
39835 index 7cee7a3..1eb9f3b 100644
39836 --- a/drivers/net/vxlan.c
39837 +++ b/drivers/net/vxlan.c
39838 @@ -1443,7 +1443,7 @@ nla_put_failure:
39839 return -EMSGSIZE;
39840 }
39841
39842 -static struct rtnl_link_ops vxlan_link_ops __read_mostly = {
39843 +static struct rtnl_link_ops vxlan_link_ops = {
39844 .kind = "vxlan",
39845 .maxtype = IFLA_VXLAN_MAX,
39846 .policy = vxlan_policy,
39847 diff --git a/drivers/net/wireless/at76c50x-usb.c b/drivers/net/wireless/at76c50x-usb.c
39848 index 5ac5f7a..5f82012 100644
39849 --- a/drivers/net/wireless/at76c50x-usb.c
39850 +++ b/drivers/net/wireless/at76c50x-usb.c
39851 @@ -353,7 +353,7 @@ static int at76_dfu_get_state(struct usb_device *udev, u8 *state)
39852 }
39853
39854 /* Convert timeout from the DFU status to jiffies */
39855 -static inline unsigned long at76_get_timeout(struct dfu_status *s)
39856 +static inline unsigned long __intentional_overflow(-1) at76_get_timeout(struct dfu_status *s)
39857 {
39858 return msecs_to_jiffies((s->poll_timeout[2] << 16)
39859 | (s->poll_timeout[1] << 8)
39860 diff --git a/drivers/net/wireless/ath/ath9k/ar9002_mac.c b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
39861 index 8d78253..bebbb68 100644
39862 --- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c
39863 +++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
39864 @@ -184,8 +184,8 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
39865 ads->ds_txstatus6 = ads->ds_txstatus7 = 0;
39866 ads->ds_txstatus8 = ads->ds_txstatus9 = 0;
39867
39868 - ACCESS_ONCE(ads->ds_link) = i->link;
39869 - ACCESS_ONCE(ads->ds_data) = i->buf_addr[0];
39870 + ACCESS_ONCE_RW(ads->ds_link) = i->link;
39871 + ACCESS_ONCE_RW(ads->ds_data) = i->buf_addr[0];
39872
39873 ctl1 = i->buf_len[0] | (i->is_last ? 0 : AR_TxMore);
39874 ctl6 = SM(i->keytype, AR_EncrType);
39875 @@ -199,26 +199,26 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
39876
39877 if ((i->is_first || i->is_last) &&
39878 i->aggr != AGGR_BUF_MIDDLE && i->aggr != AGGR_BUF_LAST) {
39879 - ACCESS_ONCE(ads->ds_ctl2) = set11nTries(i->rates, 0)
39880 + ACCESS_ONCE_RW(ads->ds_ctl2) = set11nTries(i->rates, 0)
39881 | set11nTries(i->rates, 1)
39882 | set11nTries(i->rates, 2)
39883 | set11nTries(i->rates, 3)
39884 | (i->dur_update ? AR_DurUpdateEna : 0)
39885 | SM(0, AR_BurstDur);
39886
39887 - ACCESS_ONCE(ads->ds_ctl3) = set11nRate(i->rates, 0)
39888 + ACCESS_ONCE_RW(ads->ds_ctl3) = set11nRate(i->rates, 0)
39889 | set11nRate(i->rates, 1)
39890 | set11nRate(i->rates, 2)
39891 | set11nRate(i->rates, 3);
39892 } else {
39893 - ACCESS_ONCE(ads->ds_ctl2) = 0;
39894 - ACCESS_ONCE(ads->ds_ctl3) = 0;
39895 + ACCESS_ONCE_RW(ads->ds_ctl2) = 0;
39896 + ACCESS_ONCE_RW(ads->ds_ctl3) = 0;
39897 }
39898
39899 if (!i->is_first) {
39900 - ACCESS_ONCE(ads->ds_ctl0) = 0;
39901 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
39902 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
39903 + ACCESS_ONCE_RW(ads->ds_ctl0) = 0;
39904 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
39905 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
39906 return;
39907 }
39908
39909 @@ -243,7 +243,7 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
39910 break;
39911 }
39912
39913 - ACCESS_ONCE(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
39914 + ACCESS_ONCE_RW(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
39915 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
39916 | SM(i->txpower, AR_XmitPower)
39917 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
39918 @@ -253,19 +253,19 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
39919 | (i->flags & ATH9K_TXDESC_RTSENA ? AR_RTSEnable :
39920 (i->flags & ATH9K_TXDESC_CTSENA ? AR_CTSEnable : 0));
39921
39922 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
39923 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
39924 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
39925 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
39926
39927 if (i->aggr == AGGR_BUF_MIDDLE || i->aggr == AGGR_BUF_LAST)
39928 return;
39929
39930 - ACCESS_ONCE(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
39931 + ACCESS_ONCE_RW(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
39932 | set11nPktDurRTSCTS(i->rates, 1);
39933
39934 - ACCESS_ONCE(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
39935 + ACCESS_ONCE_RW(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
39936 | set11nPktDurRTSCTS(i->rates, 3);
39937
39938 - ACCESS_ONCE(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
39939 + ACCESS_ONCE_RW(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
39940 | set11nRateFlags(i->rates, 1)
39941 | set11nRateFlags(i->rates, 2)
39942 | set11nRateFlags(i->rates, 3)
39943 diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
39944 index 301bf72..3f5654f 100644
39945 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
39946 +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
39947 @@ -39,47 +39,47 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
39948 (i->qcu << AR_TxQcuNum_S) | desc_len;
39949
39950 checksum += val;
39951 - ACCESS_ONCE(ads->info) = val;
39952 + ACCESS_ONCE_RW(ads->info) = val;
39953
39954 checksum += i->link;
39955 - ACCESS_ONCE(ads->link) = i->link;
39956 + ACCESS_ONCE_RW(ads->link) = i->link;
39957
39958 checksum += i->buf_addr[0];
39959 - ACCESS_ONCE(ads->data0) = i->buf_addr[0];
39960 + ACCESS_ONCE_RW(ads->data0) = i->buf_addr[0];
39961 checksum += i->buf_addr[1];
39962 - ACCESS_ONCE(ads->data1) = i->buf_addr[1];
39963 + ACCESS_ONCE_RW(ads->data1) = i->buf_addr[1];
39964 checksum += i->buf_addr[2];
39965 - ACCESS_ONCE(ads->data2) = i->buf_addr[2];
39966 + ACCESS_ONCE_RW(ads->data2) = i->buf_addr[2];
39967 checksum += i->buf_addr[3];
39968 - ACCESS_ONCE(ads->data3) = i->buf_addr[3];
39969 + ACCESS_ONCE_RW(ads->data3) = i->buf_addr[3];
39970
39971 checksum += (val = (i->buf_len[0] << AR_BufLen_S) & AR_BufLen);
39972 - ACCESS_ONCE(ads->ctl3) = val;
39973 + ACCESS_ONCE_RW(ads->ctl3) = val;
39974 checksum += (val = (i->buf_len[1] << AR_BufLen_S) & AR_BufLen);
39975 - ACCESS_ONCE(ads->ctl5) = val;
39976 + ACCESS_ONCE_RW(ads->ctl5) = val;
39977 checksum += (val = (i->buf_len[2] << AR_BufLen_S) & AR_BufLen);
39978 - ACCESS_ONCE(ads->ctl7) = val;
39979 + ACCESS_ONCE_RW(ads->ctl7) = val;
39980 checksum += (val = (i->buf_len[3] << AR_BufLen_S) & AR_BufLen);
39981 - ACCESS_ONCE(ads->ctl9) = val;
39982 + ACCESS_ONCE_RW(ads->ctl9) = val;
39983
39984 checksum = (u16) (((checksum & 0xffff) + (checksum >> 16)) & 0xffff);
39985 - ACCESS_ONCE(ads->ctl10) = checksum;
39986 + ACCESS_ONCE_RW(ads->ctl10) = checksum;
39987
39988 if (i->is_first || i->is_last) {
39989 - ACCESS_ONCE(ads->ctl13) = set11nTries(i->rates, 0)
39990 + ACCESS_ONCE_RW(ads->ctl13) = set11nTries(i->rates, 0)
39991 | set11nTries(i->rates, 1)
39992 | set11nTries(i->rates, 2)
39993 | set11nTries(i->rates, 3)
39994 | (i->dur_update ? AR_DurUpdateEna : 0)
39995 | SM(0, AR_BurstDur);
39996
39997 - ACCESS_ONCE(ads->ctl14) = set11nRate(i->rates, 0)
39998 + ACCESS_ONCE_RW(ads->ctl14) = set11nRate(i->rates, 0)
39999 | set11nRate(i->rates, 1)
40000 | set11nRate(i->rates, 2)
40001 | set11nRate(i->rates, 3);
40002 } else {
40003 - ACCESS_ONCE(ads->ctl13) = 0;
40004 - ACCESS_ONCE(ads->ctl14) = 0;
40005 + ACCESS_ONCE_RW(ads->ctl13) = 0;
40006 + ACCESS_ONCE_RW(ads->ctl14) = 0;
40007 }
40008
40009 ads->ctl20 = 0;
40010 @@ -89,17 +89,17 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40011
40012 ctl17 = SM(i->keytype, AR_EncrType);
40013 if (!i->is_first) {
40014 - ACCESS_ONCE(ads->ctl11) = 0;
40015 - ACCESS_ONCE(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
40016 - ACCESS_ONCE(ads->ctl15) = 0;
40017 - ACCESS_ONCE(ads->ctl16) = 0;
40018 - ACCESS_ONCE(ads->ctl17) = ctl17;
40019 - ACCESS_ONCE(ads->ctl18) = 0;
40020 - ACCESS_ONCE(ads->ctl19) = 0;
40021 + ACCESS_ONCE_RW(ads->ctl11) = 0;
40022 + ACCESS_ONCE_RW(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
40023 + ACCESS_ONCE_RW(ads->ctl15) = 0;
40024 + ACCESS_ONCE_RW(ads->ctl16) = 0;
40025 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
40026 + ACCESS_ONCE_RW(ads->ctl18) = 0;
40027 + ACCESS_ONCE_RW(ads->ctl19) = 0;
40028 return;
40029 }
40030
40031 - ACCESS_ONCE(ads->ctl11) = (i->pkt_len & AR_FrameLen)
40032 + ACCESS_ONCE_RW(ads->ctl11) = (i->pkt_len & AR_FrameLen)
40033 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
40034 | SM(i->txpower, AR_XmitPower)
40035 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
40036 @@ -135,22 +135,22 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40037 val = (i->flags & ATH9K_TXDESC_PAPRD) >> ATH9K_TXDESC_PAPRD_S;
40038 ctl12 |= SM(val, AR_PAPRDChainMask);
40039
40040 - ACCESS_ONCE(ads->ctl12) = ctl12;
40041 - ACCESS_ONCE(ads->ctl17) = ctl17;
40042 + ACCESS_ONCE_RW(ads->ctl12) = ctl12;
40043 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
40044
40045 - ACCESS_ONCE(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
40046 + ACCESS_ONCE_RW(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
40047 | set11nPktDurRTSCTS(i->rates, 1);
40048
40049 - ACCESS_ONCE(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
40050 + ACCESS_ONCE_RW(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
40051 | set11nPktDurRTSCTS(i->rates, 3);
40052
40053 - ACCESS_ONCE(ads->ctl18) = set11nRateFlags(i->rates, 0)
40054 + ACCESS_ONCE_RW(ads->ctl18) = set11nRateFlags(i->rates, 0)
40055 | set11nRateFlags(i->rates, 1)
40056 | set11nRateFlags(i->rates, 2)
40057 | set11nRateFlags(i->rates, 3)
40058 | SM(i->rtscts_rate, AR_RTSCTSRate);
40059
40060 - ACCESS_ONCE(ads->ctl19) = AR_Not_Sounding;
40061 + ACCESS_ONCE_RW(ads->ctl19) = AR_Not_Sounding;
40062 }
40063
40064 static u16 ar9003_calc_ptr_chksum(struct ar9003_txc *ads)
40065 diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
40066 index 784e81c..349e01e 100644
40067 --- a/drivers/net/wireless/ath/ath9k/hw.h
40068 +++ b/drivers/net/wireless/ath/ath9k/hw.h
40069 @@ -653,7 +653,7 @@ struct ath_hw_private_ops {
40070
40071 /* ANI */
40072 void (*ani_cache_ini_regs)(struct ath_hw *ah);
40073 -};
40074 +} __no_const;
40075
40076 /**
40077 * struct ath_spec_scan - parameters for Atheros spectral scan
40078 @@ -722,7 +722,7 @@ struct ath_hw_ops {
40079 struct ath_spec_scan *param);
40080 void (*spectral_scan_trigger)(struct ath_hw *ah);
40081 void (*spectral_scan_wait)(struct ath_hw *ah);
40082 -};
40083 +} __no_const;
40084
40085 struct ath_nf_limits {
40086 s16 max;
40087 diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c
40088 index c353b5f..62aaca2 100644
40089 --- a/drivers/net/wireless/iwlegacy/3945-mac.c
40090 +++ b/drivers/net/wireless/iwlegacy/3945-mac.c
40091 @@ -3639,7 +3639,9 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
40092 */
40093 if (il3945_mod_params.disable_hw_scan) {
40094 D_INFO("Disabling hw_scan\n");
40095 - il3945_mac_ops.hw_scan = NULL;
40096 + pax_open_kernel();
40097 + *(void **)&il3945_mac_ops.hw_scan = NULL;
40098 + pax_close_kernel();
40099 }
40100
40101 D_INFO("*** LOAD DRIVER ***\n");
40102 diff --git a/drivers/net/wireless/iwlwifi/dvm/debugfs.c b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
40103 index 81d4071..f2071ea 100644
40104 --- a/drivers/net/wireless/iwlwifi/dvm/debugfs.c
40105 +++ b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
40106 @@ -203,7 +203,7 @@ static ssize_t iwl_dbgfs_sram_write(struct file *file,
40107 {
40108 struct iwl_priv *priv = file->private_data;
40109 char buf[64];
40110 - int buf_size;
40111 + size_t buf_size;
40112 u32 offset, len;
40113
40114 memset(buf, 0, sizeof(buf));
40115 @@ -473,7 +473,7 @@ static ssize_t iwl_dbgfs_rx_handlers_write(struct file *file,
40116 struct iwl_priv *priv = file->private_data;
40117
40118 char buf[8];
40119 - int buf_size;
40120 + size_t buf_size;
40121 u32 reset_flag;
40122
40123 memset(buf, 0, sizeof(buf));
40124 @@ -554,7 +554,7 @@ static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file,
40125 {
40126 struct iwl_priv *priv = file->private_data;
40127 char buf[8];
40128 - int buf_size;
40129 + size_t buf_size;
40130 int ht40;
40131
40132 memset(buf, 0, sizeof(buf));
40133 @@ -606,7 +606,7 @@ static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
40134 {
40135 struct iwl_priv *priv = file->private_data;
40136 char buf[8];
40137 - int buf_size;
40138 + size_t buf_size;
40139 int value;
40140
40141 memset(buf, 0, sizeof(buf));
40142 @@ -1871,7 +1871,7 @@ static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
40143 {
40144 struct iwl_priv *priv = file->private_data;
40145 char buf[8];
40146 - int buf_size;
40147 + size_t buf_size;
40148 int clear;
40149
40150 memset(buf, 0, sizeof(buf));
40151 @@ -1916,7 +1916,7 @@ static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
40152 {
40153 struct iwl_priv *priv = file->private_data;
40154 char buf[8];
40155 - int buf_size;
40156 + size_t buf_size;
40157 int trace;
40158
40159 memset(buf, 0, sizeof(buf));
40160 @@ -1987,7 +1987,7 @@ static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file,
40161 {
40162 struct iwl_priv *priv = file->private_data;
40163 char buf[8];
40164 - int buf_size;
40165 + size_t buf_size;
40166 int missed;
40167
40168 memset(buf, 0, sizeof(buf));
40169 @@ -2028,7 +2028,7 @@ static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
40170
40171 struct iwl_priv *priv = file->private_data;
40172 char buf[8];
40173 - int buf_size;
40174 + size_t buf_size;
40175 int plcp;
40176
40177 memset(buf, 0, sizeof(buf));
40178 @@ -2088,7 +2088,7 @@ static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file,
40179
40180 struct iwl_priv *priv = file->private_data;
40181 char buf[8];
40182 - int buf_size;
40183 + size_t buf_size;
40184 int flush;
40185
40186 memset(buf, 0, sizeof(buf));
40187 @@ -2178,7 +2178,7 @@ static ssize_t iwl_dbgfs_protection_mode_write(struct file *file,
40188
40189 struct iwl_priv *priv = file->private_data;
40190 char buf[8];
40191 - int buf_size;
40192 + size_t buf_size;
40193 int rts;
40194
40195 if (!priv->cfg->ht_params)
40196 @@ -2220,7 +2220,7 @@ static ssize_t iwl_dbgfs_echo_test_write(struct file *file,
40197 {
40198 struct iwl_priv *priv = file->private_data;
40199 char buf[8];
40200 - int buf_size;
40201 + size_t buf_size;
40202
40203 memset(buf, 0, sizeof(buf));
40204 buf_size = min(count, sizeof(buf) - 1);
40205 @@ -2256,7 +2256,7 @@ static ssize_t iwl_dbgfs_log_event_write(struct file *file,
40206 struct iwl_priv *priv = file->private_data;
40207 u32 event_log_flag;
40208 char buf[8];
40209 - int buf_size;
40210 + size_t buf_size;
40211
40212 /* check that the interface is up */
40213 if (!iwl_is_ready(priv))
40214 @@ -2310,7 +2310,7 @@ static ssize_t iwl_dbgfs_calib_disabled_write(struct file *file,
40215 struct iwl_priv *priv = file->private_data;
40216 char buf[8];
40217 u32 calib_disabled;
40218 - int buf_size;
40219 + size_t buf_size;
40220
40221 memset(buf, 0, sizeof(buf));
40222 buf_size = min(count, sizeof(buf) - 1);
40223 diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
40224 index 12c4f31..484d948 100644
40225 --- a/drivers/net/wireless/iwlwifi/pcie/trans.c
40226 +++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
40227 @@ -1328,7 +1328,7 @@ static ssize_t iwl_dbgfs_interrupt_write(struct file *file,
40228 struct isr_statistics *isr_stats = &trans_pcie->isr_stats;
40229
40230 char buf[8];
40231 - int buf_size;
40232 + size_t buf_size;
40233 u32 reset_flag;
40234
40235 memset(buf, 0, sizeof(buf));
40236 @@ -1349,7 +1349,7 @@ static ssize_t iwl_dbgfs_csr_write(struct file *file,
40237 {
40238 struct iwl_trans *trans = file->private_data;
40239 char buf[8];
40240 - int buf_size;
40241 + size_t buf_size;
40242 int csr;
40243
40244 memset(buf, 0, sizeof(buf));
40245 diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
40246 index cffdf4f..7cefb69 100644
40247 --- a/drivers/net/wireless/mac80211_hwsim.c
40248 +++ b/drivers/net/wireless/mac80211_hwsim.c
40249 @@ -2144,25 +2144,19 @@ static int __init init_mac80211_hwsim(void)
40250
40251 if (channels > 1) {
40252 hwsim_if_comb.num_different_channels = channels;
40253 - mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
40254 - mac80211_hwsim_ops.cancel_hw_scan =
40255 - mac80211_hwsim_cancel_hw_scan;
40256 - mac80211_hwsim_ops.sw_scan_start = NULL;
40257 - mac80211_hwsim_ops.sw_scan_complete = NULL;
40258 - mac80211_hwsim_ops.remain_on_channel =
40259 - mac80211_hwsim_roc;
40260 - mac80211_hwsim_ops.cancel_remain_on_channel =
40261 - mac80211_hwsim_croc;
40262 - mac80211_hwsim_ops.add_chanctx =
40263 - mac80211_hwsim_add_chanctx;
40264 - mac80211_hwsim_ops.remove_chanctx =
40265 - mac80211_hwsim_remove_chanctx;
40266 - mac80211_hwsim_ops.change_chanctx =
40267 - mac80211_hwsim_change_chanctx;
40268 - mac80211_hwsim_ops.assign_vif_chanctx =
40269 - mac80211_hwsim_assign_vif_chanctx;
40270 - mac80211_hwsim_ops.unassign_vif_chanctx =
40271 - mac80211_hwsim_unassign_vif_chanctx;
40272 + pax_open_kernel();
40273 + *(void **)&mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
40274 + *(void **)&mac80211_hwsim_ops.cancel_hw_scan = mac80211_hwsim_cancel_hw_scan;
40275 + *(void **)&mac80211_hwsim_ops.sw_scan_start = NULL;
40276 + *(void **)&mac80211_hwsim_ops.sw_scan_complete = NULL;
40277 + *(void **)&mac80211_hwsim_ops.remain_on_channel = mac80211_hwsim_roc;
40278 + *(void **)&mac80211_hwsim_ops.cancel_remain_on_channel = mac80211_hwsim_croc;
40279 + *(void **)&mac80211_hwsim_ops.add_chanctx = mac80211_hwsim_add_chanctx;
40280 + *(void **)&mac80211_hwsim_ops.remove_chanctx = mac80211_hwsim_remove_chanctx;
40281 + *(void **)&mac80211_hwsim_ops.change_chanctx = mac80211_hwsim_change_chanctx;
40282 + *(void **)&mac80211_hwsim_ops.assign_vif_chanctx = mac80211_hwsim_assign_vif_chanctx;
40283 + *(void **)&mac80211_hwsim_ops.unassign_vif_chanctx = mac80211_hwsim_unassign_vif_chanctx;
40284 + pax_close_kernel();
40285 }
40286
40287 spin_lock_init(&hwsim_radio_lock);
40288 diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
40289 index 525fd75..6c9f791 100644
40290 --- a/drivers/net/wireless/rndis_wlan.c
40291 +++ b/drivers/net/wireless/rndis_wlan.c
40292 @@ -1238,7 +1238,7 @@ static int set_rts_threshold(struct usbnet *usbdev, u32 rts_threshold)
40293
40294 netdev_dbg(usbdev->net, "%s(): %i\n", __func__, rts_threshold);
40295
40296 - if (rts_threshold < 0 || rts_threshold > 2347)
40297 + if (rts_threshold > 2347)
40298 rts_threshold = 2347;
40299
40300 tmp = cpu_to_le32(rts_threshold);
40301 diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
40302 index 086abb4..8279c30 100644
40303 --- a/drivers/net/wireless/rt2x00/rt2x00.h
40304 +++ b/drivers/net/wireless/rt2x00/rt2x00.h
40305 @@ -396,7 +396,7 @@ struct rt2x00_intf {
40306 * for hardware which doesn't support hardware
40307 * sequence counting.
40308 */
40309 - atomic_t seqno;
40310 + atomic_unchecked_t seqno;
40311 };
40312
40313 static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif)
40314 diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
40315 index 4d91795..62fccff 100644
40316 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c
40317 +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
40318 @@ -251,9 +251,9 @@ static void rt2x00queue_create_tx_descriptor_seq(struct rt2x00_dev *rt2x00dev,
40319 * sequence counter given by mac80211.
40320 */
40321 if (test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags))
40322 - seqno = atomic_add_return(0x10, &intf->seqno);
40323 + seqno = atomic_add_return_unchecked(0x10, &intf->seqno);
40324 else
40325 - seqno = atomic_read(&intf->seqno);
40326 + seqno = atomic_read_unchecked(&intf->seqno);
40327
40328 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
40329 hdr->seq_ctrl |= cpu_to_le16(seqno);
40330 diff --git a/drivers/net/wireless/ti/wl1251/sdio.c b/drivers/net/wireless/ti/wl1251/sdio.c
40331 index e57ee48..541cf6c 100644
40332 --- a/drivers/net/wireless/ti/wl1251/sdio.c
40333 +++ b/drivers/net/wireless/ti/wl1251/sdio.c
40334 @@ -269,13 +269,17 @@ static int wl1251_sdio_probe(struct sdio_func *func,
40335
40336 irq_set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING);
40337
40338 - wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
40339 - wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
40340 + pax_open_kernel();
40341 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
40342 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
40343 + pax_close_kernel();
40344
40345 wl1251_info("using dedicated interrupt line");
40346 } else {
40347 - wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
40348 - wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
40349 + pax_open_kernel();
40350 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
40351 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
40352 + pax_close_kernel();
40353
40354 wl1251_info("using SDIO interrupt");
40355 }
40356 diff --git a/drivers/net/wireless/ti/wl12xx/main.c b/drivers/net/wireless/ti/wl12xx/main.c
40357 index 09694e3..24ccec7 100644
40358 --- a/drivers/net/wireless/ti/wl12xx/main.c
40359 +++ b/drivers/net/wireless/ti/wl12xx/main.c
40360 @@ -656,7 +656,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
40361 sizeof(wl->conf.mem));
40362
40363 /* read data preparation is only needed by wl127x */
40364 - wl->ops->prepare_read = wl127x_prepare_read;
40365 + pax_open_kernel();
40366 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
40367 + pax_close_kernel();
40368
40369 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
40370 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
40371 @@ -681,7 +683,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
40372 sizeof(wl->conf.mem));
40373
40374 /* read data preparation is only needed by wl127x */
40375 - wl->ops->prepare_read = wl127x_prepare_read;
40376 + pax_open_kernel();
40377 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
40378 + pax_close_kernel();
40379
40380 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
40381 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
40382 diff --git a/drivers/net/wireless/ti/wl18xx/main.c b/drivers/net/wireless/ti/wl18xx/main.c
40383 index da3ef1b..4790b95 100644
40384 --- a/drivers/net/wireless/ti/wl18xx/main.c
40385 +++ b/drivers/net/wireless/ti/wl18xx/main.c
40386 @@ -1664,8 +1664,10 @@ static int wl18xx_setup(struct wl1271 *wl)
40387 }
40388
40389 if (!checksum_param) {
40390 - wl18xx_ops.set_rx_csum = NULL;
40391 - wl18xx_ops.init_vif = NULL;
40392 + pax_open_kernel();
40393 + *(void **)&wl18xx_ops.set_rx_csum = NULL;
40394 + *(void **)&wl18xx_ops.init_vif = NULL;
40395 + pax_close_kernel();
40396 }
40397
40398 /* Enable 11a Band only if we have 5G antennas */
40399 diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
40400 index 7ef0b4a..ff65c28 100644
40401 --- a/drivers/net/wireless/zd1211rw/zd_usb.c
40402 +++ b/drivers/net/wireless/zd1211rw/zd_usb.c
40403 @@ -386,7 +386,7 @@ static inline void handle_regs_int(struct urb *urb)
40404 {
40405 struct zd_usb *usb = urb->context;
40406 struct zd_usb_interrupt *intr = &usb->intr;
40407 - int len;
40408 + unsigned int len;
40409 u16 int_num;
40410
40411 ZD_ASSERT(in_interrupt());
40412 diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
40413 index d93b2b6..ae50401 100644
40414 --- a/drivers/oprofile/buffer_sync.c
40415 +++ b/drivers/oprofile/buffer_sync.c
40416 @@ -332,7 +332,7 @@ static void add_data(struct op_entry *entry, struct mm_struct *mm)
40417 if (cookie == NO_COOKIE)
40418 offset = pc;
40419 if (cookie == INVALID_COOKIE) {
40420 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
40421 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
40422 offset = pc;
40423 }
40424 if (cookie != last_cookie) {
40425 @@ -376,14 +376,14 @@ add_sample(struct mm_struct *mm, struct op_sample *s, int in_kernel)
40426 /* add userspace sample */
40427
40428 if (!mm) {
40429 - atomic_inc(&oprofile_stats.sample_lost_no_mm);
40430 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mm);
40431 return 0;
40432 }
40433
40434 cookie = lookup_dcookie(mm, s->eip, &offset);
40435
40436 if (cookie == INVALID_COOKIE) {
40437 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
40438 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
40439 return 0;
40440 }
40441
40442 @@ -552,7 +552,7 @@ void sync_buffer(int cpu)
40443 /* ignore backtraces if failed to add a sample */
40444 if (state == sb_bt_start) {
40445 state = sb_bt_ignore;
40446 - atomic_inc(&oprofile_stats.bt_lost_no_mapping);
40447 + atomic_inc_unchecked(&oprofile_stats.bt_lost_no_mapping);
40448 }
40449 }
40450 release_mm(mm);
40451 diff --git a/drivers/oprofile/event_buffer.c b/drivers/oprofile/event_buffer.c
40452 index c0cc4e7..44d4e54 100644
40453 --- a/drivers/oprofile/event_buffer.c
40454 +++ b/drivers/oprofile/event_buffer.c
40455 @@ -53,7 +53,7 @@ void add_event_entry(unsigned long value)
40456 }
40457
40458 if (buffer_pos == buffer_size) {
40459 - atomic_inc(&oprofile_stats.event_lost_overflow);
40460 + atomic_inc_unchecked(&oprofile_stats.event_lost_overflow);
40461 return;
40462 }
40463
40464 diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c
40465 index ed2c3ec..deda85a 100644
40466 --- a/drivers/oprofile/oprof.c
40467 +++ b/drivers/oprofile/oprof.c
40468 @@ -110,7 +110,7 @@ static void switch_worker(struct work_struct *work)
40469 if (oprofile_ops.switch_events())
40470 return;
40471
40472 - atomic_inc(&oprofile_stats.multiplex_counter);
40473 + atomic_inc_unchecked(&oprofile_stats.multiplex_counter);
40474 start_switch_worker();
40475 }
40476
40477 diff --git a/drivers/oprofile/oprofile_files.c b/drivers/oprofile/oprofile_files.c
40478 index 84a208d..d61b0a1 100644
40479 --- a/drivers/oprofile/oprofile_files.c
40480 +++ b/drivers/oprofile/oprofile_files.c
40481 @@ -27,7 +27,7 @@ unsigned long oprofile_time_slice;
40482
40483 #ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
40484
40485 -static ssize_t timeout_read(struct file *file, char __user *buf,
40486 +static ssize_t __intentional_overflow(-1) timeout_read(struct file *file, char __user *buf,
40487 size_t count, loff_t *offset)
40488 {
40489 return oprofilefs_ulong_to_user(jiffies_to_msecs(oprofile_time_slice),
40490 diff --git a/drivers/oprofile/oprofile_stats.c b/drivers/oprofile/oprofile_stats.c
40491 index 917d28e..d62d981 100644
40492 --- a/drivers/oprofile/oprofile_stats.c
40493 +++ b/drivers/oprofile/oprofile_stats.c
40494 @@ -30,11 +30,11 @@ void oprofile_reset_stats(void)
40495 cpu_buf->sample_invalid_eip = 0;
40496 }
40497
40498 - atomic_set(&oprofile_stats.sample_lost_no_mm, 0);
40499 - atomic_set(&oprofile_stats.sample_lost_no_mapping, 0);
40500 - atomic_set(&oprofile_stats.event_lost_overflow, 0);
40501 - atomic_set(&oprofile_stats.bt_lost_no_mapping, 0);
40502 - atomic_set(&oprofile_stats.multiplex_counter, 0);
40503 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mm, 0);
40504 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mapping, 0);
40505 + atomic_set_unchecked(&oprofile_stats.event_lost_overflow, 0);
40506 + atomic_set_unchecked(&oprofile_stats.bt_lost_no_mapping, 0);
40507 + atomic_set_unchecked(&oprofile_stats.multiplex_counter, 0);
40508 }
40509
40510
40511 diff --git a/drivers/oprofile/oprofile_stats.h b/drivers/oprofile/oprofile_stats.h
40512 index 38b6fc0..b5cbfce 100644
40513 --- a/drivers/oprofile/oprofile_stats.h
40514 +++ b/drivers/oprofile/oprofile_stats.h
40515 @@ -13,11 +13,11 @@
40516 #include <linux/atomic.h>
40517
40518 struct oprofile_stat_struct {
40519 - atomic_t sample_lost_no_mm;
40520 - atomic_t sample_lost_no_mapping;
40521 - atomic_t bt_lost_no_mapping;
40522 - atomic_t event_lost_overflow;
40523 - atomic_t multiplex_counter;
40524 + atomic_unchecked_t sample_lost_no_mm;
40525 + atomic_unchecked_t sample_lost_no_mapping;
40526 + atomic_unchecked_t bt_lost_no_mapping;
40527 + atomic_unchecked_t event_lost_overflow;
40528 + atomic_unchecked_t multiplex_counter;
40529 };
40530
40531 extern struct oprofile_stat_struct oprofile_stats;
40532 diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c
40533 index 7c12d9c..558bf3bb 100644
40534 --- a/drivers/oprofile/oprofilefs.c
40535 +++ b/drivers/oprofile/oprofilefs.c
40536 @@ -190,7 +190,7 @@ static const struct file_operations atomic_ro_fops = {
40537
40538
40539 int oprofilefs_create_ro_atomic(struct super_block *sb, struct dentry *root,
40540 - char const *name, atomic_t *val)
40541 + char const *name, atomic_unchecked_t *val)
40542 {
40543 return __oprofilefs_create_file(sb, root, name,
40544 &atomic_ro_fops, 0444, val);
40545 diff --git a/drivers/oprofile/timer_int.c b/drivers/oprofile/timer_int.c
40546 index 93404f7..4a313d8 100644
40547 --- a/drivers/oprofile/timer_int.c
40548 +++ b/drivers/oprofile/timer_int.c
40549 @@ -93,7 +93,7 @@ static int __cpuinit oprofile_cpu_notify(struct notifier_block *self,
40550 return NOTIFY_OK;
40551 }
40552
40553 -static struct notifier_block __refdata oprofile_cpu_notifier = {
40554 +static struct notifier_block oprofile_cpu_notifier = {
40555 .notifier_call = oprofile_cpu_notify,
40556 };
40557
40558 diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
40559 index 3f56bc0..707d642 100644
40560 --- a/drivers/parport/procfs.c
40561 +++ b/drivers/parport/procfs.c
40562 @@ -64,7 +64,7 @@ static int do_active_device(ctl_table *table, int write,
40563
40564 *ppos += len;
40565
40566 - return copy_to_user(result, buffer, len) ? -EFAULT : 0;
40567 + return (len > sizeof buffer || copy_to_user(result, buffer, len)) ? -EFAULT : 0;
40568 }
40569
40570 #ifdef CONFIG_PARPORT_1284
40571 @@ -106,7 +106,7 @@ static int do_autoprobe(ctl_table *table, int write,
40572
40573 *ppos += len;
40574
40575 - return copy_to_user (result, buffer, len) ? -EFAULT : 0;
40576 + return (len > sizeof buffer || copy_to_user (result, buffer, len)) ? -EFAULT : 0;
40577 }
40578 #endif /* IEEE1284.3 support. */
40579
40580 diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
40581 index c35e8ad..fc33beb 100644
40582 --- a/drivers/pci/hotplug/acpiphp_ibm.c
40583 +++ b/drivers/pci/hotplug/acpiphp_ibm.c
40584 @@ -464,7 +464,9 @@ static int __init ibm_acpiphp_init(void)
40585 goto init_cleanup;
40586 }
40587
40588 - ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
40589 + pax_open_kernel();
40590 + *(size_t *)&ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
40591 + pax_close_kernel();
40592 retval = sysfs_create_bin_file(sysdir, &ibm_apci_table_attr);
40593
40594 return retval;
40595 diff --git a/drivers/pci/hotplug/cpcihp_generic.c b/drivers/pci/hotplug/cpcihp_generic.c
40596 index a6a71c4..c91097b 100644
40597 --- a/drivers/pci/hotplug/cpcihp_generic.c
40598 +++ b/drivers/pci/hotplug/cpcihp_generic.c
40599 @@ -73,7 +73,6 @@ static u16 port;
40600 static unsigned int enum_bit;
40601 static u8 enum_mask;
40602
40603 -static struct cpci_hp_controller_ops generic_hpc_ops;
40604 static struct cpci_hp_controller generic_hpc;
40605
40606 static int __init validate_parameters(void)
40607 @@ -139,6 +138,10 @@ static int query_enum(void)
40608 return ((value & enum_mask) == enum_mask);
40609 }
40610
40611 +static struct cpci_hp_controller_ops generic_hpc_ops = {
40612 + .query_enum = query_enum,
40613 +};
40614 +
40615 static int __init cpcihp_generic_init(void)
40616 {
40617 int status;
40618 @@ -165,7 +168,6 @@ static int __init cpcihp_generic_init(void)
40619 pci_dev_put(dev);
40620
40621 memset(&generic_hpc, 0, sizeof (struct cpci_hp_controller));
40622 - generic_hpc_ops.query_enum = query_enum;
40623 generic_hpc.ops = &generic_hpc_ops;
40624
40625 status = cpci_hp_register_controller(&generic_hpc);
40626 diff --git a/drivers/pci/hotplug/cpcihp_zt5550.c b/drivers/pci/hotplug/cpcihp_zt5550.c
40627 index 449b4bb..257e2e8 100644
40628 --- a/drivers/pci/hotplug/cpcihp_zt5550.c
40629 +++ b/drivers/pci/hotplug/cpcihp_zt5550.c
40630 @@ -59,7 +59,6 @@
40631 /* local variables */
40632 static bool debug;
40633 static bool poll;
40634 -static struct cpci_hp_controller_ops zt5550_hpc_ops;
40635 static struct cpci_hp_controller zt5550_hpc;
40636
40637 /* Primary cPCI bus bridge device */
40638 @@ -205,6 +204,10 @@ static int zt5550_hc_disable_irq(void)
40639 return 0;
40640 }
40641
40642 +static struct cpci_hp_controller_ops zt5550_hpc_ops = {
40643 + .query_enum = zt5550_hc_query_enum,
40644 +};
40645 +
40646 static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
40647 {
40648 int status;
40649 @@ -216,16 +219,17 @@ static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id
40650 dbg("returned from zt5550_hc_config");
40651
40652 memset(&zt5550_hpc, 0, sizeof (struct cpci_hp_controller));
40653 - zt5550_hpc_ops.query_enum = zt5550_hc_query_enum;
40654 zt5550_hpc.ops = &zt5550_hpc_ops;
40655 if(!poll) {
40656 zt5550_hpc.irq = hc_dev->irq;
40657 zt5550_hpc.irq_flags = IRQF_SHARED;
40658 zt5550_hpc.dev_id = hc_dev;
40659
40660 - zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
40661 - zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
40662 - zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
40663 + pax_open_kernel();
40664 + *(void **)&zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
40665 + *(void **)&zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
40666 + *(void **)&zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
40667 + pax_open_kernel();
40668 } else {
40669 info("using ENUM# polling mode");
40670 }
40671 diff --git a/drivers/pci/hotplug/cpqphp_nvram.c b/drivers/pci/hotplug/cpqphp_nvram.c
40672 index 76ba8a1..20ca857 100644
40673 --- a/drivers/pci/hotplug/cpqphp_nvram.c
40674 +++ b/drivers/pci/hotplug/cpqphp_nvram.c
40675 @@ -428,9 +428,13 @@ static u32 store_HRT (void __iomem *rom_start)
40676
40677 void compaq_nvram_init (void __iomem *rom_start)
40678 {
40679 +
40680 +#ifndef CONFIG_PAX_KERNEXEC
40681 if (rom_start) {
40682 compaq_int15_entry_point = (rom_start + ROM_INT15_PHY_ADDR - ROM_PHY_ADDR);
40683 }
40684 +#endif
40685 +
40686 dbg("int15 entry = %p\n", compaq_int15_entry_point);
40687
40688 /* initialize our int15 lock */
40689 diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
40690 index 202f4a9..8ee47d0 100644
40691 --- a/drivers/pci/hotplug/pci_hotplug_core.c
40692 +++ b/drivers/pci/hotplug/pci_hotplug_core.c
40693 @@ -448,8 +448,10 @@ int __pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus,
40694 return -EINVAL;
40695 }
40696
40697 - slot->ops->owner = owner;
40698 - slot->ops->mod_name = mod_name;
40699 + pax_open_kernel();
40700 + *(struct module **)&slot->ops->owner = owner;
40701 + *(const char **)&slot->ops->mod_name = mod_name;
40702 + pax_close_kernel();
40703
40704 mutex_lock(&pci_hp_mutex);
40705 /*
40706 diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
40707 index 7d72c5e..edce02c 100644
40708 --- a/drivers/pci/hotplug/pciehp_core.c
40709 +++ b/drivers/pci/hotplug/pciehp_core.c
40710 @@ -91,7 +91,7 @@ static int init_slot(struct controller *ctrl)
40711 struct slot *slot = ctrl->slot;
40712 struct hotplug_slot *hotplug = NULL;
40713 struct hotplug_slot_info *info = NULL;
40714 - struct hotplug_slot_ops *ops = NULL;
40715 + hotplug_slot_ops_no_const *ops = NULL;
40716 char name[SLOT_NAME_SIZE];
40717 int retval = -ENOMEM;
40718
40719 diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
40720 index 9c6e9bb..2916736 100644
40721 --- a/drivers/pci/pci-sysfs.c
40722 +++ b/drivers/pci/pci-sysfs.c
40723 @@ -1071,7 +1071,7 @@ static int pci_create_attr(struct pci_dev *pdev, int num, int write_combine)
40724 {
40725 /* allocate attribute structure, piggyback attribute name */
40726 int name_len = write_combine ? 13 : 10;
40727 - struct bin_attribute *res_attr;
40728 + bin_attribute_no_const *res_attr;
40729 int retval;
40730
40731 res_attr = kzalloc(sizeof(*res_attr) + name_len, GFP_ATOMIC);
40732 @@ -1256,7 +1256,7 @@ static struct device_attribute reset_attr = __ATTR(reset, 0200, NULL, reset_stor
40733 static int pci_create_capabilities_sysfs(struct pci_dev *dev)
40734 {
40735 int retval;
40736 - struct bin_attribute *attr;
40737 + bin_attribute_no_const *attr;
40738
40739 /* If the device has VPD, try to expose it in sysfs. */
40740 if (dev->vpd) {
40741 @@ -1303,7 +1303,7 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
40742 {
40743 int retval;
40744 int rom_size = 0;
40745 - struct bin_attribute *attr;
40746 + bin_attribute_no_const *attr;
40747
40748 if (!sysfs_initialized)
40749 return -EACCES;
40750 diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
40751 index 7346ee6..41520eb 100644
40752 --- a/drivers/pci/pci.h
40753 +++ b/drivers/pci/pci.h
40754 @@ -93,7 +93,7 @@ struct pci_vpd_ops {
40755 struct pci_vpd {
40756 unsigned int len;
40757 const struct pci_vpd_ops *ops;
40758 - struct bin_attribute *attr; /* descriptor for sysfs VPD entry */
40759 + bin_attribute_no_const *attr; /* descriptor for sysfs VPD entry */
40760 };
40761
40762 extern int pci_vpd_pci22_init(struct pci_dev *dev);
40763 diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
40764 index d320df6..ca9a8f6 100644
40765 --- a/drivers/pci/pcie/aspm.c
40766 +++ b/drivers/pci/pcie/aspm.c
40767 @@ -27,9 +27,9 @@
40768 #define MODULE_PARAM_PREFIX "pcie_aspm."
40769
40770 /* Note: those are not register definitions */
40771 -#define ASPM_STATE_L0S_UP (1) /* Upstream direction L0s state */
40772 -#define ASPM_STATE_L0S_DW (2) /* Downstream direction L0s state */
40773 -#define ASPM_STATE_L1 (4) /* L1 state */
40774 +#define ASPM_STATE_L0S_UP (1U) /* Upstream direction L0s state */
40775 +#define ASPM_STATE_L0S_DW (2U) /* Downstream direction L0s state */
40776 +#define ASPM_STATE_L1 (4U) /* L1 state */
40777 #define ASPM_STATE_L0S (ASPM_STATE_L0S_UP | ASPM_STATE_L0S_DW)
40778 #define ASPM_STATE_ALL (ASPM_STATE_L0S | ASPM_STATE_L1)
40779
40780 diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
40781 index 5427787..8df273b 100644
40782 --- a/drivers/pci/probe.c
40783 +++ b/drivers/pci/probe.c
40784 @@ -173,7 +173,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
40785 struct pci_bus_region region;
40786 bool bar_too_big = false, bar_disabled = false;
40787
40788 - mask = type ? PCI_ROM_ADDRESS_MASK : ~0;
40789 + mask = type ? (u32)PCI_ROM_ADDRESS_MASK : ~0;
40790
40791 /* No printks while decoding is disabled! */
40792 if (!dev->mmio_always_on) {
40793 diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
40794 index 0b00947..64f7c0a 100644
40795 --- a/drivers/pci/proc.c
40796 +++ b/drivers/pci/proc.c
40797 @@ -465,7 +465,16 @@ static const struct file_operations proc_bus_pci_dev_operations = {
40798 static int __init pci_proc_init(void)
40799 {
40800 struct pci_dev *dev = NULL;
40801 +
40802 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
40803 +#ifdef CONFIG_GRKERNSEC_PROC_USER
40804 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR, NULL);
40805 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
40806 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
40807 +#endif
40808 +#else
40809 proc_bus_pci_dir = proc_mkdir("bus/pci", NULL);
40810 +#endif
40811 proc_create("devices", 0, proc_bus_pci_dir,
40812 &proc_bus_pci_dev_operations);
40813 proc_initialized = 1;
40814 diff --git a/drivers/platform/x86/chromeos_laptop.c b/drivers/platform/x86/chromeos_laptop.c
40815 index 3e5b4497..dcdfb70 100644
40816 --- a/drivers/platform/x86/chromeos_laptop.c
40817 +++ b/drivers/platform/x86/chromeos_laptop.c
40818 @@ -301,7 +301,7 @@ static int __init setup_tsl2563_als(const struct dmi_system_id *id)
40819 return 0;
40820 }
40821
40822 -static struct dmi_system_id __initdata chromeos_laptop_dmi_table[] = {
40823 +static struct dmi_system_id __initconst chromeos_laptop_dmi_table[] = {
40824 {
40825 .ident = "Samsung Series 5 550 - Touchpad",
40826 .matches = {
40827 diff --git a/drivers/platform/x86/msi-laptop.c b/drivers/platform/x86/msi-laptop.c
40828 index 6b22938..bc9700e 100644
40829 --- a/drivers/platform/x86/msi-laptop.c
40830 +++ b/drivers/platform/x86/msi-laptop.c
40831 @@ -1000,12 +1000,14 @@ static int __init load_scm_model_init(struct platform_device *sdev)
40832
40833 if (!quirks->ec_read_only) {
40834 /* allow userland write sysfs file */
40835 - dev_attr_bluetooth.store = store_bluetooth;
40836 - dev_attr_wlan.store = store_wlan;
40837 - dev_attr_threeg.store = store_threeg;
40838 - dev_attr_bluetooth.attr.mode |= S_IWUSR;
40839 - dev_attr_wlan.attr.mode |= S_IWUSR;
40840 - dev_attr_threeg.attr.mode |= S_IWUSR;
40841 + pax_open_kernel();
40842 + *(void **)&dev_attr_bluetooth.store = store_bluetooth;
40843 + *(void **)&dev_attr_wlan.store = store_wlan;
40844 + *(void **)&dev_attr_threeg.store = store_threeg;
40845 + *(umode_t *)&dev_attr_bluetooth.attr.mode |= S_IWUSR;
40846 + *(umode_t *)&dev_attr_wlan.attr.mode |= S_IWUSR;
40847 + *(umode_t *)&dev_attr_threeg.attr.mode |= S_IWUSR;
40848 + pax_close_kernel();
40849 }
40850
40851 /* disable hardware control by fn key */
40852 diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
40853 index 14d4dce..b129917 100644
40854 --- a/drivers/platform/x86/sony-laptop.c
40855 +++ b/drivers/platform/x86/sony-laptop.c
40856 @@ -2465,7 +2465,7 @@ static void sony_nc_gfx_switch_cleanup(struct platform_device *pd)
40857 }
40858
40859 /* High speed charging function */
40860 -static struct device_attribute *hsc_handle;
40861 +static device_attribute_no_const *hsc_handle;
40862
40863 static ssize_t sony_nc_highspeed_charging_store(struct device *dev,
40864 struct device_attribute *attr,
40865 diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
40866 index edec135..59a24a3 100644
40867 --- a/drivers/platform/x86/thinkpad_acpi.c
40868 +++ b/drivers/platform/x86/thinkpad_acpi.c
40869 @@ -2093,7 +2093,7 @@ static int hotkey_mask_get(void)
40870 return 0;
40871 }
40872
40873 -void static hotkey_mask_warn_incomplete_mask(void)
40874 +static void hotkey_mask_warn_incomplete_mask(void)
40875 {
40876 /* log only what the user can fix... */
40877 const u32 wantedmask = hotkey_driver_mask &
40878 @@ -2324,11 +2324,6 @@ static void hotkey_read_nvram(struct tp_nvram_state *n, const u32 m)
40879 }
40880 }
40881
40882 -static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
40883 - struct tp_nvram_state *newn,
40884 - const u32 event_mask)
40885 -{
40886 -
40887 #define TPACPI_COMPARE_KEY(__scancode, __member) \
40888 do { \
40889 if ((event_mask & (1 << __scancode)) && \
40890 @@ -2342,36 +2337,42 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
40891 tpacpi_hotkey_send_key(__scancode); \
40892 } while (0)
40893
40894 - void issue_volchange(const unsigned int oldvol,
40895 - const unsigned int newvol)
40896 - {
40897 - unsigned int i = oldvol;
40898 +static void issue_volchange(const unsigned int oldvol,
40899 + const unsigned int newvol,
40900 + const u32 event_mask)
40901 +{
40902 + unsigned int i = oldvol;
40903
40904 - while (i > newvol) {
40905 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
40906 - i--;
40907 - }
40908 - while (i < newvol) {
40909 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
40910 - i++;
40911 - }
40912 + while (i > newvol) {
40913 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
40914 + i--;
40915 }
40916 + while (i < newvol) {
40917 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
40918 + i++;
40919 + }
40920 +}
40921
40922 - void issue_brightnesschange(const unsigned int oldbrt,
40923 - const unsigned int newbrt)
40924 - {
40925 - unsigned int i = oldbrt;
40926 +static void issue_brightnesschange(const unsigned int oldbrt,
40927 + const unsigned int newbrt,
40928 + const u32 event_mask)
40929 +{
40930 + unsigned int i = oldbrt;
40931
40932 - while (i > newbrt) {
40933 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
40934 - i--;
40935 - }
40936 - while (i < newbrt) {
40937 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
40938 - i++;
40939 - }
40940 + while (i > newbrt) {
40941 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
40942 + i--;
40943 + }
40944 + while (i < newbrt) {
40945 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
40946 + i++;
40947 }
40948 +}
40949
40950 +static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
40951 + struct tp_nvram_state *newn,
40952 + const u32 event_mask)
40953 +{
40954 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_THINKPAD, thinkpad_toggle);
40955 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNSPACE, zoom_toggle);
40956 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNF7, display_toggle);
40957 @@ -2405,7 +2406,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
40958 oldn->volume_level != newn->volume_level) {
40959 /* recently muted, or repeated mute keypress, or
40960 * multiple presses ending in mute */
40961 - issue_volchange(oldn->volume_level, newn->volume_level);
40962 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
40963 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_MUTE);
40964 }
40965 } else {
40966 @@ -2415,7 +2416,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
40967 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
40968 }
40969 if (oldn->volume_level != newn->volume_level) {
40970 - issue_volchange(oldn->volume_level, newn->volume_level);
40971 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
40972 } else if (oldn->volume_toggle != newn->volume_toggle) {
40973 /* repeated vol up/down keypress at end of scale ? */
40974 if (newn->volume_level == 0)
40975 @@ -2428,7 +2429,8 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
40976 /* handle brightness */
40977 if (oldn->brightness_level != newn->brightness_level) {
40978 issue_brightnesschange(oldn->brightness_level,
40979 - newn->brightness_level);
40980 + newn->brightness_level,
40981 + event_mask);
40982 } else if (oldn->brightness_toggle != newn->brightness_toggle) {
40983 /* repeated key presses that didn't change state */
40984 if (newn->brightness_level == 0)
40985 @@ -2437,10 +2439,10 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
40986 && !tp_features.bright_unkfw)
40987 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
40988 }
40989 +}
40990
40991 #undef TPACPI_COMPARE_KEY
40992 #undef TPACPI_MAY_SEND_KEY
40993 -}
40994
40995 /*
40996 * Polling driver
40997 diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c
40998 index 769d265..a3a05ca 100644
40999 --- a/drivers/pnp/pnpbios/bioscalls.c
41000 +++ b/drivers/pnp/pnpbios/bioscalls.c
41001 @@ -58,7 +58,7 @@ do { \
41002 set_desc_limit(&gdt[(selname) >> 3], (size) - 1); \
41003 } while(0)
41004
41005 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
41006 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
41007 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
41008
41009 /*
41010 @@ -95,7 +95,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
41011
41012 cpu = get_cpu();
41013 save_desc_40 = get_cpu_gdt_table(cpu)[0x40 / 8];
41014 +
41015 + pax_open_kernel();
41016 get_cpu_gdt_table(cpu)[0x40 / 8] = bad_bios_desc;
41017 + pax_close_kernel();
41018
41019 /* On some boxes IRQ's during PnP BIOS calls are deadly. */
41020 spin_lock_irqsave(&pnp_bios_lock, flags);
41021 @@ -133,7 +136,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
41022 :"memory");
41023 spin_unlock_irqrestore(&pnp_bios_lock, flags);
41024
41025 + pax_open_kernel();
41026 get_cpu_gdt_table(cpu)[0x40 / 8] = save_desc_40;
41027 + pax_close_kernel();
41028 +
41029 put_cpu();
41030
41031 /* If we get here and this is set then the PnP BIOS faulted on us. */
41032 @@ -467,7 +473,7 @@ int pnp_bios_read_escd(char *data, u32 nvram_base)
41033 return status;
41034 }
41035
41036 -void pnpbios_calls_init(union pnp_bios_install_struct *header)
41037 +void __init pnpbios_calls_init(union pnp_bios_install_struct *header)
41038 {
41039 int i;
41040
41041 @@ -475,6 +481,8 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
41042 pnp_bios_callpoint.offset = header->fields.pm16offset;
41043 pnp_bios_callpoint.segment = PNP_CS16;
41044
41045 + pax_open_kernel();
41046 +
41047 for_each_possible_cpu(i) {
41048 struct desc_struct *gdt = get_cpu_gdt_table(i);
41049 if (!gdt)
41050 @@ -486,4 +494,6 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
41051 set_desc_base(&gdt[GDT_ENTRY_PNPBIOS_DS],
41052 (unsigned long)__va(header->fields.pm16dseg));
41053 }
41054 +
41055 + pax_close_kernel();
41056 }
41057 diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
41058 index 3e6db1c..1fbbdae 100644
41059 --- a/drivers/pnp/resource.c
41060 +++ b/drivers/pnp/resource.c
41061 @@ -360,7 +360,7 @@ int pnp_check_irq(struct pnp_dev *dev, struct resource *res)
41062 return 1;
41063
41064 /* check if the resource is valid */
41065 - if (*irq < 0 || *irq > 15)
41066 + if (*irq > 15)
41067 return 0;
41068
41069 /* check if the resource is reserved */
41070 @@ -424,7 +424,7 @@ int pnp_check_dma(struct pnp_dev *dev, struct resource *res)
41071 return 1;
41072
41073 /* check if the resource is valid */
41074 - if (*dma < 0 || *dma == 4 || *dma > 7)
41075 + if (*dma == 4 || *dma > 7)
41076 return 0;
41077
41078 /* check if the resource is reserved */
41079 diff --git a/drivers/power/pda_power.c b/drivers/power/pda_power.c
41080 index 7df7c5f..bd48c47 100644
41081 --- a/drivers/power/pda_power.c
41082 +++ b/drivers/power/pda_power.c
41083 @@ -37,7 +37,11 @@ static int polling;
41084
41085 #ifdef CONFIG_USB_OTG_UTILS
41086 static struct usb_phy *transceiver;
41087 -static struct notifier_block otg_nb;
41088 +static int otg_handle_notification(struct notifier_block *nb,
41089 + unsigned long event, void *unused);
41090 +static struct notifier_block otg_nb = {
41091 + .notifier_call = otg_handle_notification
41092 +};
41093 #endif
41094
41095 static struct regulator *ac_draw;
41096 @@ -369,7 +373,6 @@ static int pda_power_probe(struct platform_device *pdev)
41097
41098 #ifdef CONFIG_USB_OTG_UTILS
41099 if (!IS_ERR_OR_NULL(transceiver) && pdata->use_otg_notifier) {
41100 - otg_nb.notifier_call = otg_handle_notification;
41101 ret = usb_register_notifier(transceiver, &otg_nb);
41102 if (ret) {
41103 dev_err(dev, "failure to register otg notifier\n");
41104 diff --git a/drivers/power/power_supply.h b/drivers/power/power_supply.h
41105 index cc439fd..8fa30df 100644
41106 --- a/drivers/power/power_supply.h
41107 +++ b/drivers/power/power_supply.h
41108 @@ -16,12 +16,12 @@ struct power_supply;
41109
41110 #ifdef CONFIG_SYSFS
41111
41112 -extern void power_supply_init_attrs(struct device_type *dev_type);
41113 +extern void power_supply_init_attrs(void);
41114 extern int power_supply_uevent(struct device *dev, struct kobj_uevent_env *env);
41115
41116 #else
41117
41118 -static inline void power_supply_init_attrs(struct device_type *dev_type) {}
41119 +static inline void power_supply_init_attrs(void) {}
41120 #define power_supply_uevent NULL
41121
41122 #endif /* CONFIG_SYSFS */
41123 diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
41124 index 5deac43..608c5ff 100644
41125 --- a/drivers/power/power_supply_core.c
41126 +++ b/drivers/power/power_supply_core.c
41127 @@ -24,7 +24,10 @@
41128 struct class *power_supply_class;
41129 EXPORT_SYMBOL_GPL(power_supply_class);
41130
41131 -static struct device_type power_supply_dev_type;
41132 +extern const struct attribute_group *power_supply_attr_groups[];
41133 +static struct device_type power_supply_dev_type = {
41134 + .groups = power_supply_attr_groups,
41135 +};
41136
41137 static int __power_supply_changed_work(struct device *dev, void *data)
41138 {
41139 @@ -393,7 +396,7 @@ static int __init power_supply_class_init(void)
41140 return PTR_ERR(power_supply_class);
41141
41142 power_supply_class->dev_uevent = power_supply_uevent;
41143 - power_supply_init_attrs(&power_supply_dev_type);
41144 + power_supply_init_attrs();
41145
41146 return 0;
41147 }
41148 diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
41149 index 29178f7..c65f324 100644
41150 --- a/drivers/power/power_supply_sysfs.c
41151 +++ b/drivers/power/power_supply_sysfs.c
41152 @@ -230,17 +230,15 @@ static struct attribute_group power_supply_attr_group = {
41153 .is_visible = power_supply_attr_is_visible,
41154 };
41155
41156 -static const struct attribute_group *power_supply_attr_groups[] = {
41157 +const struct attribute_group *power_supply_attr_groups[] = {
41158 &power_supply_attr_group,
41159 NULL,
41160 };
41161
41162 -void power_supply_init_attrs(struct device_type *dev_type)
41163 +void power_supply_init_attrs(void)
41164 {
41165 int i;
41166
41167 - dev_type->groups = power_supply_attr_groups;
41168 -
41169 for (i = 0; i < ARRAY_SIZE(power_supply_attrs); i++)
41170 __power_supply_attrs[i] = &power_supply_attrs[i].attr;
41171 }
41172 diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c
41173 index 4d7c635..9860196 100644
41174 --- a/drivers/regulator/max8660.c
41175 +++ b/drivers/regulator/max8660.c
41176 @@ -333,8 +333,10 @@ static int max8660_probe(struct i2c_client *client,
41177 max8660->shadow_regs[MAX8660_OVER1] = 5;
41178 } else {
41179 /* Otherwise devices can be toggled via software */
41180 - max8660_dcdc_ops.enable = max8660_dcdc_enable;
41181 - max8660_dcdc_ops.disable = max8660_dcdc_disable;
41182 + pax_open_kernel();
41183 + *(void **)&max8660_dcdc_ops.enable = max8660_dcdc_enable;
41184 + *(void **)&max8660_dcdc_ops.disable = max8660_dcdc_disable;
41185 + pax_close_kernel();
41186 }
41187
41188 /*
41189 diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c
41190 index 9a8ea91..c483dd9 100644
41191 --- a/drivers/regulator/max8973-regulator.c
41192 +++ b/drivers/regulator/max8973-regulator.c
41193 @@ -401,9 +401,11 @@ static int max8973_probe(struct i2c_client *client,
41194 if (!pdata->enable_ext_control) {
41195 max->desc.enable_reg = MAX8973_VOUT;
41196 max->desc.enable_mask = MAX8973_VOUT_ENABLE;
41197 - max8973_dcdc_ops.enable = regulator_enable_regmap;
41198 - max8973_dcdc_ops.disable = regulator_disable_regmap;
41199 - max8973_dcdc_ops.is_enabled = regulator_is_enabled_regmap;
41200 + pax_open_kernel();
41201 + *(void **)&max8973_dcdc_ops.enable = regulator_enable_regmap;
41202 + *(void **)&max8973_dcdc_ops.disable = regulator_disable_regmap;
41203 + *(void **)&max8973_dcdc_ops.is_enabled = regulator_is_enabled_regmap;
41204 + pax_close_kernel();
41205 }
41206
41207 max->enable_external_control = pdata->enable_ext_control;
41208 diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c
41209 index 9891aec..beb3083 100644
41210 --- a/drivers/regulator/mc13892-regulator.c
41211 +++ b/drivers/regulator/mc13892-regulator.c
41212 @@ -583,10 +583,12 @@ static int mc13892_regulator_probe(struct platform_device *pdev)
41213 }
41214 mc13xxx_unlock(mc13892);
41215
41216 - mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
41217 + pax_open_kernel();
41218 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
41219 = mc13892_vcam_set_mode;
41220 - mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
41221 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
41222 = mc13892_vcam_get_mode;
41223 + pax_close_kernel();
41224
41225 mc13xxx_data = mc13xxx_parse_regulators_dt(pdev, mc13892_regulators,
41226 ARRAY_SIZE(mc13892_regulators),
41227 diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
41228 index cc5bea9..689f7d9 100644
41229 --- a/drivers/rtc/rtc-cmos.c
41230 +++ b/drivers/rtc/rtc-cmos.c
41231 @@ -724,7 +724,9 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
41232 hpet_rtc_timer_init();
41233
41234 /* export at least the first block of NVRAM */
41235 - nvram.size = address_space - NVRAM_OFFSET;
41236 + pax_open_kernel();
41237 + *(size_t *)&nvram.size = address_space - NVRAM_OFFSET;
41238 + pax_close_kernel();
41239 retval = sysfs_create_bin_file(&dev->kobj, &nvram);
41240 if (retval < 0) {
41241 dev_dbg(dev, "can't create nvram file? %d\n", retval);
41242 diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
41243 index d049393..bb20be0 100644
41244 --- a/drivers/rtc/rtc-dev.c
41245 +++ b/drivers/rtc/rtc-dev.c
41246 @@ -16,6 +16,7 @@
41247 #include <linux/module.h>
41248 #include <linux/rtc.h>
41249 #include <linux/sched.h>
41250 +#include <linux/grsecurity.h>
41251 #include "rtc-core.h"
41252
41253 static dev_t rtc_devt;
41254 @@ -347,6 +348,8 @@ static long rtc_dev_ioctl(struct file *file,
41255 if (copy_from_user(&tm, uarg, sizeof(tm)))
41256 return -EFAULT;
41257
41258 + gr_log_timechange();
41259 +
41260 return rtc_set_time(rtc, &tm);
41261
41262 case RTC_PIE_ON:
41263 diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
41264 index 970a236..3613169 100644
41265 --- a/drivers/rtc/rtc-ds1307.c
41266 +++ b/drivers/rtc/rtc-ds1307.c
41267 @@ -106,7 +106,7 @@ struct ds1307 {
41268 u8 offset; /* register's offset */
41269 u8 regs[11];
41270 u16 nvram_offset;
41271 - struct bin_attribute *nvram;
41272 + bin_attribute_no_const *nvram;
41273 enum ds_type type;
41274 unsigned long flags;
41275 #define HAS_NVRAM 0 /* bit 0 == sysfs file active */
41276 diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c
41277 index 130f29a..6179d03 100644
41278 --- a/drivers/rtc/rtc-m48t59.c
41279 +++ b/drivers/rtc/rtc-m48t59.c
41280 @@ -482,7 +482,9 @@ static int m48t59_rtc_probe(struct platform_device *pdev)
41281 goto out;
41282 }
41283
41284 - m48t59_nvram_attr.size = pdata->offset;
41285 + pax_open_kernel();
41286 + *(size_t *)&m48t59_nvram_attr.size = pdata->offset;
41287 + pax_close_kernel();
41288
41289 ret = sysfs_create_bin_file(&pdev->dev.kobj, &m48t59_nvram_attr);
41290 if (ret) {
41291 diff --git a/drivers/scsi/bfa/bfa_fcpim.h b/drivers/scsi/bfa/bfa_fcpim.h
41292 index e693af6..2e525b6 100644
41293 --- a/drivers/scsi/bfa/bfa_fcpim.h
41294 +++ b/drivers/scsi/bfa/bfa_fcpim.h
41295 @@ -36,7 +36,7 @@ struct bfa_iotag_s {
41296
41297 struct bfa_itn_s {
41298 bfa_isr_func_t isr;
41299 -};
41300 +} __no_const;
41301
41302 void bfa_itn_create(struct bfa_s *bfa, struct bfa_rport_s *rport,
41303 void (*isr)(struct bfa_s *bfa, struct bfi_msg_s *m));
41304 diff --git a/drivers/scsi/bfa/bfa_ioc.h b/drivers/scsi/bfa/bfa_ioc.h
41305 index 23a90e7..9cf04ee 100644
41306 --- a/drivers/scsi/bfa/bfa_ioc.h
41307 +++ b/drivers/scsi/bfa/bfa_ioc.h
41308 @@ -258,7 +258,7 @@ struct bfa_ioc_cbfn_s {
41309 bfa_ioc_disable_cbfn_t disable_cbfn;
41310 bfa_ioc_hbfail_cbfn_t hbfail_cbfn;
41311 bfa_ioc_reset_cbfn_t reset_cbfn;
41312 -};
41313 +} __no_const;
41314
41315 /*
41316 * IOC event notification mechanism.
41317 @@ -346,7 +346,7 @@ struct bfa_ioc_hwif_s {
41318 void (*ioc_sync_ack) (struct bfa_ioc_s *ioc);
41319 bfa_boolean_t (*ioc_sync_complete) (struct bfa_ioc_s *ioc);
41320 bfa_boolean_t (*ioc_lpu_read_stat) (struct bfa_ioc_s *ioc);
41321 -};
41322 +} __no_const;
41323
41324 /*
41325 * Queue element to wait for room in request queue. FIFO order is
41326 diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
41327 index df0c3c7..b00e1d0 100644
41328 --- a/drivers/scsi/hosts.c
41329 +++ b/drivers/scsi/hosts.c
41330 @@ -42,7 +42,7 @@
41331 #include "scsi_logging.h"
41332
41333
41334 -static atomic_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
41335 +static atomic_unchecked_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
41336
41337
41338 static void scsi_host_cls_release(struct device *dev)
41339 @@ -361,7 +361,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
41340 * subtract one because we increment first then return, but we need to
41341 * know what the next host number was before increment
41342 */
41343 - shost->host_no = atomic_inc_return(&scsi_host_next_hn) - 1;
41344 + shost->host_no = atomic_inc_return_unchecked(&scsi_host_next_hn) - 1;
41345 shost->dma_channel = 0xff;
41346
41347 /* These three are default values which can be overridden */
41348 diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
41349 index 7f4f790..b75b92a 100644
41350 --- a/drivers/scsi/hpsa.c
41351 +++ b/drivers/scsi/hpsa.c
41352 @@ -554,7 +554,7 @@ static inline u32 next_command(struct ctlr_info *h, u8 q)
41353 unsigned long flags;
41354
41355 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
41356 - return h->access.command_completed(h, q);
41357 + return h->access->command_completed(h, q);
41358
41359 if ((rq->head[rq->current_entry] & 1) == rq->wraparound) {
41360 a = rq->head[rq->current_entry];
41361 @@ -3422,7 +3422,7 @@ static void start_io(struct ctlr_info *h)
41362 while (!list_empty(&h->reqQ)) {
41363 c = list_entry(h->reqQ.next, struct CommandList, list);
41364 /* can't do anything if fifo is full */
41365 - if ((h->access.fifo_full(h))) {
41366 + if ((h->access->fifo_full(h))) {
41367 dev_warn(&h->pdev->dev, "fifo full\n");
41368 break;
41369 }
41370 @@ -3444,7 +3444,7 @@ static void start_io(struct ctlr_info *h)
41371
41372 /* Tell the controller execute command */
41373 spin_unlock_irqrestore(&h->lock, flags);
41374 - h->access.submit_command(h, c);
41375 + h->access->submit_command(h, c);
41376 spin_lock_irqsave(&h->lock, flags);
41377 }
41378 spin_unlock_irqrestore(&h->lock, flags);
41379 @@ -3452,17 +3452,17 @@ static void start_io(struct ctlr_info *h)
41380
41381 static inline unsigned long get_next_completion(struct ctlr_info *h, u8 q)
41382 {
41383 - return h->access.command_completed(h, q);
41384 + return h->access->command_completed(h, q);
41385 }
41386
41387 static inline bool interrupt_pending(struct ctlr_info *h)
41388 {
41389 - return h->access.intr_pending(h);
41390 + return h->access->intr_pending(h);
41391 }
41392
41393 static inline long interrupt_not_for_us(struct ctlr_info *h)
41394 {
41395 - return (h->access.intr_pending(h) == 0) ||
41396 + return (h->access->intr_pending(h) == 0) ||
41397 (h->interrupts_enabled == 0);
41398 }
41399
41400 @@ -4364,7 +4364,7 @@ static int hpsa_pci_init(struct ctlr_info *h)
41401 if (prod_index < 0)
41402 return -ENODEV;
41403 h->product_name = products[prod_index].product_name;
41404 - h->access = *(products[prod_index].access);
41405 + h->access = products[prod_index].access;
41406
41407 pci_disable_link_state(h->pdev, PCIE_LINK_STATE_L0S |
41408 PCIE_LINK_STATE_L1 | PCIE_LINK_STATE_CLKPM);
41409 @@ -4646,7 +4646,7 @@ static void controller_lockup_detected(struct ctlr_info *h)
41410
41411 assert_spin_locked(&lockup_detector_lock);
41412 remove_ctlr_from_lockup_detector_list(h);
41413 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
41414 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
41415 spin_lock_irqsave(&h->lock, flags);
41416 h->lockup_detected = readl(h->vaddr + SA5_SCRATCHPAD_OFFSET);
41417 spin_unlock_irqrestore(&h->lock, flags);
41418 @@ -4823,7 +4823,7 @@ reinit_after_soft_reset:
41419 }
41420
41421 /* make sure the board interrupts are off */
41422 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
41423 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
41424
41425 if (hpsa_request_irq(h, do_hpsa_intr_msi, do_hpsa_intr_intx))
41426 goto clean2;
41427 @@ -4857,7 +4857,7 @@ reinit_after_soft_reset:
41428 * fake ones to scoop up any residual completions.
41429 */
41430 spin_lock_irqsave(&h->lock, flags);
41431 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
41432 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
41433 spin_unlock_irqrestore(&h->lock, flags);
41434 free_irqs(h);
41435 rc = hpsa_request_irq(h, hpsa_msix_discard_completions,
41436 @@ -4876,9 +4876,9 @@ reinit_after_soft_reset:
41437 dev_info(&h->pdev->dev, "Board READY.\n");
41438 dev_info(&h->pdev->dev,
41439 "Waiting for stale completions to drain.\n");
41440 - h->access.set_intr_mask(h, HPSA_INTR_ON);
41441 + h->access->set_intr_mask(h, HPSA_INTR_ON);
41442 msleep(10000);
41443 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
41444 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
41445
41446 rc = controller_reset_failed(h->cfgtable);
41447 if (rc)
41448 @@ -4899,7 +4899,7 @@ reinit_after_soft_reset:
41449 }
41450
41451 /* Turn the interrupts on so we can service requests */
41452 - h->access.set_intr_mask(h, HPSA_INTR_ON);
41453 + h->access->set_intr_mask(h, HPSA_INTR_ON);
41454
41455 hpsa_hba_inquiry(h);
41456 hpsa_register_scsi(h); /* hook ourselves into SCSI subsystem */
41457 @@ -4954,7 +4954,7 @@ static void hpsa_shutdown(struct pci_dev *pdev)
41458 * To write all data in the battery backed cache to disks
41459 */
41460 hpsa_flush_cache(h);
41461 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
41462 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
41463 hpsa_free_irqs_and_disable_msix(h);
41464 }
41465
41466 @@ -5122,7 +5122,7 @@ static void hpsa_enter_performant_mode(struct ctlr_info *h, u32 use_short_tags)
41467 return;
41468 }
41469 /* Change the access methods to the performant access methods */
41470 - h->access = SA5_performant_access;
41471 + h->access = &SA5_performant_access;
41472 h->transMethod = CFGTBL_Trans_Performant;
41473 }
41474
41475 diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
41476 index 9816479..c5d4e97 100644
41477 --- a/drivers/scsi/hpsa.h
41478 +++ b/drivers/scsi/hpsa.h
41479 @@ -79,7 +79,7 @@ struct ctlr_info {
41480 unsigned int msix_vector;
41481 unsigned int msi_vector;
41482 int intr_mode; /* either PERF_MODE_INT or SIMPLE_MODE_INT */
41483 - struct access_method access;
41484 + struct access_method *access;
41485
41486 /* queue and queue Info */
41487 struct list_head reqQ;
41488 diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
41489 index c772d8d..35c362c 100644
41490 --- a/drivers/scsi/libfc/fc_exch.c
41491 +++ b/drivers/scsi/libfc/fc_exch.c
41492 @@ -100,12 +100,12 @@ struct fc_exch_mgr {
41493 u16 pool_max_index;
41494
41495 struct {
41496 - atomic_t no_free_exch;
41497 - atomic_t no_free_exch_xid;
41498 - atomic_t xid_not_found;
41499 - atomic_t xid_busy;
41500 - atomic_t seq_not_found;
41501 - atomic_t non_bls_resp;
41502 + atomic_unchecked_t no_free_exch;
41503 + atomic_unchecked_t no_free_exch_xid;
41504 + atomic_unchecked_t xid_not_found;
41505 + atomic_unchecked_t xid_busy;
41506 + atomic_unchecked_t seq_not_found;
41507 + atomic_unchecked_t non_bls_resp;
41508 } stats;
41509 };
41510
41511 @@ -725,7 +725,7 @@ static struct fc_exch *fc_exch_em_alloc(struct fc_lport *lport,
41512 /* allocate memory for exchange */
41513 ep = mempool_alloc(mp->ep_pool, GFP_ATOMIC);
41514 if (!ep) {
41515 - atomic_inc(&mp->stats.no_free_exch);
41516 + atomic_inc_unchecked(&mp->stats.no_free_exch);
41517 goto out;
41518 }
41519 memset(ep, 0, sizeof(*ep));
41520 @@ -786,7 +786,7 @@ out:
41521 return ep;
41522 err:
41523 spin_unlock_bh(&pool->lock);
41524 - atomic_inc(&mp->stats.no_free_exch_xid);
41525 + atomic_inc_unchecked(&mp->stats.no_free_exch_xid);
41526 mempool_free(ep, mp->ep_pool);
41527 return NULL;
41528 }
41529 @@ -929,7 +929,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
41530 xid = ntohs(fh->fh_ox_id); /* we originated exch */
41531 ep = fc_exch_find(mp, xid);
41532 if (!ep) {
41533 - atomic_inc(&mp->stats.xid_not_found);
41534 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41535 reject = FC_RJT_OX_ID;
41536 goto out;
41537 }
41538 @@ -959,7 +959,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
41539 ep = fc_exch_find(mp, xid);
41540 if ((f_ctl & FC_FC_FIRST_SEQ) && fc_sof_is_init(fr_sof(fp))) {
41541 if (ep) {
41542 - atomic_inc(&mp->stats.xid_busy);
41543 + atomic_inc_unchecked(&mp->stats.xid_busy);
41544 reject = FC_RJT_RX_ID;
41545 goto rel;
41546 }
41547 @@ -970,7 +970,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
41548 }
41549 xid = ep->xid; /* get our XID */
41550 } else if (!ep) {
41551 - atomic_inc(&mp->stats.xid_not_found);
41552 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41553 reject = FC_RJT_RX_ID; /* XID not found */
41554 goto out;
41555 }
41556 @@ -987,7 +987,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
41557 } else {
41558 sp = &ep->seq;
41559 if (sp->id != fh->fh_seq_id) {
41560 - atomic_inc(&mp->stats.seq_not_found);
41561 + atomic_inc_unchecked(&mp->stats.seq_not_found);
41562 if (f_ctl & FC_FC_END_SEQ) {
41563 /*
41564 * Update sequence_id based on incoming last
41565 @@ -1437,22 +1437,22 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
41566
41567 ep = fc_exch_find(mp, ntohs(fh->fh_ox_id));
41568 if (!ep) {
41569 - atomic_inc(&mp->stats.xid_not_found);
41570 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41571 goto out;
41572 }
41573 if (ep->esb_stat & ESB_ST_COMPLETE) {
41574 - atomic_inc(&mp->stats.xid_not_found);
41575 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41576 goto rel;
41577 }
41578 if (ep->rxid == FC_XID_UNKNOWN)
41579 ep->rxid = ntohs(fh->fh_rx_id);
41580 if (ep->sid != 0 && ep->sid != ntoh24(fh->fh_d_id)) {
41581 - atomic_inc(&mp->stats.xid_not_found);
41582 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41583 goto rel;
41584 }
41585 if (ep->did != ntoh24(fh->fh_s_id) &&
41586 ep->did != FC_FID_FLOGI) {
41587 - atomic_inc(&mp->stats.xid_not_found);
41588 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41589 goto rel;
41590 }
41591 sof = fr_sof(fp);
41592 @@ -1461,7 +1461,7 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
41593 sp->ssb_stat |= SSB_ST_RESP;
41594 sp->id = fh->fh_seq_id;
41595 } else if (sp->id != fh->fh_seq_id) {
41596 - atomic_inc(&mp->stats.seq_not_found);
41597 + atomic_inc_unchecked(&mp->stats.seq_not_found);
41598 goto rel;
41599 }
41600
41601 @@ -1525,9 +1525,9 @@ static void fc_exch_recv_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
41602 sp = fc_seq_lookup_orig(mp, fp); /* doesn't hold sequence */
41603
41604 if (!sp)
41605 - atomic_inc(&mp->stats.xid_not_found);
41606 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41607 else
41608 - atomic_inc(&mp->stats.non_bls_resp);
41609 + atomic_inc_unchecked(&mp->stats.non_bls_resp);
41610
41611 fc_frame_free(fp);
41612 }
41613 @@ -2174,13 +2174,13 @@ void fc_exch_update_stats(struct fc_lport *lport)
41614
41615 list_for_each_entry(ema, &lport->ema_list, ema_list) {
41616 mp = ema->mp;
41617 - st->fc_no_free_exch += atomic_read(&mp->stats.no_free_exch);
41618 + st->fc_no_free_exch += atomic_read_unchecked(&mp->stats.no_free_exch);
41619 st->fc_no_free_exch_xid +=
41620 - atomic_read(&mp->stats.no_free_exch_xid);
41621 - st->fc_xid_not_found += atomic_read(&mp->stats.xid_not_found);
41622 - st->fc_xid_busy += atomic_read(&mp->stats.xid_busy);
41623 - st->fc_seq_not_found += atomic_read(&mp->stats.seq_not_found);
41624 - st->fc_non_bls_resp += atomic_read(&mp->stats.non_bls_resp);
41625 + atomic_read_unchecked(&mp->stats.no_free_exch_xid);
41626 + st->fc_xid_not_found += atomic_read_unchecked(&mp->stats.xid_not_found);
41627 + st->fc_xid_busy += atomic_read_unchecked(&mp->stats.xid_busy);
41628 + st->fc_seq_not_found += atomic_read_unchecked(&mp->stats.seq_not_found);
41629 + st->fc_non_bls_resp += atomic_read_unchecked(&mp->stats.non_bls_resp);
41630 }
41631 }
41632 EXPORT_SYMBOL(fc_exch_update_stats);
41633 diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
41634 index bdb81cd..d3c7c2c 100644
41635 --- a/drivers/scsi/libsas/sas_ata.c
41636 +++ b/drivers/scsi/libsas/sas_ata.c
41637 @@ -554,7 +554,7 @@ static struct ata_port_operations sas_sata_ops = {
41638 .postreset = ata_std_postreset,
41639 .error_handler = ata_std_error_handler,
41640 .post_internal_cmd = sas_ata_post_internal,
41641 - .qc_defer = ata_std_qc_defer,
41642 + .qc_defer = ata_std_qc_defer,
41643 .qc_prep = ata_noop_qc_prep,
41644 .qc_issue = sas_ata_qc_issue,
41645 .qc_fill_rtf = sas_ata_qc_fill_rtf,
41646 diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
41647 index 7706c99..3b4fc0c 100644
41648 --- a/drivers/scsi/lpfc/lpfc.h
41649 +++ b/drivers/scsi/lpfc/lpfc.h
41650 @@ -424,7 +424,7 @@ struct lpfc_vport {
41651 struct dentry *debug_nodelist;
41652 struct dentry *vport_debugfs_root;
41653 struct lpfc_debugfs_trc *disc_trc;
41654 - atomic_t disc_trc_cnt;
41655 + atomic_unchecked_t disc_trc_cnt;
41656 #endif
41657 uint8_t stat_data_enabled;
41658 uint8_t stat_data_blocked;
41659 @@ -853,8 +853,8 @@ struct lpfc_hba {
41660 struct timer_list fabric_block_timer;
41661 unsigned long bit_flags;
41662 #define FABRIC_COMANDS_BLOCKED 0
41663 - atomic_t num_rsrc_err;
41664 - atomic_t num_cmd_success;
41665 + atomic_unchecked_t num_rsrc_err;
41666 + atomic_unchecked_t num_cmd_success;
41667 unsigned long last_rsrc_error_time;
41668 unsigned long last_ramp_down_time;
41669 unsigned long last_ramp_up_time;
41670 @@ -890,7 +890,7 @@ struct lpfc_hba {
41671
41672 struct dentry *debug_slow_ring_trc;
41673 struct lpfc_debugfs_trc *slow_ring_trc;
41674 - atomic_t slow_ring_trc_cnt;
41675 + atomic_unchecked_t slow_ring_trc_cnt;
41676 /* iDiag debugfs sub-directory */
41677 struct dentry *idiag_root;
41678 struct dentry *idiag_pci_cfg;
41679 diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
41680 index f63f5ff..de29189 100644
41681 --- a/drivers/scsi/lpfc/lpfc_debugfs.c
41682 +++ b/drivers/scsi/lpfc/lpfc_debugfs.c
41683 @@ -106,7 +106,7 @@ MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc,
41684
41685 #include <linux/debugfs.h>
41686
41687 -static atomic_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
41688 +static atomic_unchecked_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
41689 static unsigned long lpfc_debugfs_start_time = 0L;
41690
41691 /* iDiag */
41692 @@ -147,7 +147,7 @@ lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size)
41693 lpfc_debugfs_enable = 0;
41694
41695 len = 0;
41696 - index = (atomic_read(&vport->disc_trc_cnt) + 1) &
41697 + index = (atomic_read_unchecked(&vport->disc_trc_cnt) + 1) &
41698 (lpfc_debugfs_max_disc_trc - 1);
41699 for (i = index; i < lpfc_debugfs_max_disc_trc; i++) {
41700 dtp = vport->disc_trc + i;
41701 @@ -213,7 +213,7 @@ lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba *phba, char *buf, int size)
41702 lpfc_debugfs_enable = 0;
41703
41704 len = 0;
41705 - index = (atomic_read(&phba->slow_ring_trc_cnt) + 1) &
41706 + index = (atomic_read_unchecked(&phba->slow_ring_trc_cnt) + 1) &
41707 (lpfc_debugfs_max_slow_ring_trc - 1);
41708 for (i = index; i < lpfc_debugfs_max_slow_ring_trc; i++) {
41709 dtp = phba->slow_ring_trc + i;
41710 @@ -646,14 +646,14 @@ lpfc_debugfs_disc_trc(struct lpfc_vport *vport, int mask, char *fmt,
41711 !vport || !vport->disc_trc)
41712 return;
41713
41714 - index = atomic_inc_return(&vport->disc_trc_cnt) &
41715 + index = atomic_inc_return_unchecked(&vport->disc_trc_cnt) &
41716 (lpfc_debugfs_max_disc_trc - 1);
41717 dtp = vport->disc_trc + index;
41718 dtp->fmt = fmt;
41719 dtp->data1 = data1;
41720 dtp->data2 = data2;
41721 dtp->data3 = data3;
41722 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
41723 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
41724 dtp->jif = jiffies;
41725 #endif
41726 return;
41727 @@ -684,14 +684,14 @@ lpfc_debugfs_slow_ring_trc(struct lpfc_hba *phba, char *fmt,
41728 !phba || !phba->slow_ring_trc)
41729 return;
41730
41731 - index = atomic_inc_return(&phba->slow_ring_trc_cnt) &
41732 + index = atomic_inc_return_unchecked(&phba->slow_ring_trc_cnt) &
41733 (lpfc_debugfs_max_slow_ring_trc - 1);
41734 dtp = phba->slow_ring_trc + index;
41735 dtp->fmt = fmt;
41736 dtp->data1 = data1;
41737 dtp->data2 = data2;
41738 dtp->data3 = data3;
41739 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
41740 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
41741 dtp->jif = jiffies;
41742 #endif
41743 return;
41744 @@ -4182,7 +4182,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
41745 "slow_ring buffer\n");
41746 goto debug_failed;
41747 }
41748 - atomic_set(&phba->slow_ring_trc_cnt, 0);
41749 + atomic_set_unchecked(&phba->slow_ring_trc_cnt, 0);
41750 memset(phba->slow_ring_trc, 0,
41751 (sizeof(struct lpfc_debugfs_trc) *
41752 lpfc_debugfs_max_slow_ring_trc));
41753 @@ -4228,7 +4228,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
41754 "buffer\n");
41755 goto debug_failed;
41756 }
41757 - atomic_set(&vport->disc_trc_cnt, 0);
41758 + atomic_set_unchecked(&vport->disc_trc_cnt, 0);
41759
41760 snprintf(name, sizeof(name), "discovery_trace");
41761 vport->debug_disc_trc =
41762 diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
41763 index 314b4f6..7005d10 100644
41764 --- a/drivers/scsi/lpfc/lpfc_init.c
41765 +++ b/drivers/scsi/lpfc/lpfc_init.c
41766 @@ -10551,8 +10551,10 @@ lpfc_init(void)
41767 "misc_register returned with status %d", error);
41768
41769 if (lpfc_enable_npiv) {
41770 - lpfc_transport_functions.vport_create = lpfc_vport_create;
41771 - lpfc_transport_functions.vport_delete = lpfc_vport_delete;
41772 + pax_open_kernel();
41773 + *(void **)&lpfc_transport_functions.vport_create = lpfc_vport_create;
41774 + *(void **)&lpfc_transport_functions.vport_delete = lpfc_vport_delete;
41775 + pax_close_kernel();
41776 }
41777 lpfc_transport_template =
41778 fc_attach_transport(&lpfc_transport_functions);
41779 diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
41780 index 98af07c..7625fb5 100644
41781 --- a/drivers/scsi/lpfc/lpfc_scsi.c
41782 +++ b/drivers/scsi/lpfc/lpfc_scsi.c
41783 @@ -325,7 +325,7 @@ lpfc_rampdown_queue_depth(struct lpfc_hba *phba)
41784 uint32_t evt_posted;
41785
41786 spin_lock_irqsave(&phba->hbalock, flags);
41787 - atomic_inc(&phba->num_rsrc_err);
41788 + atomic_inc_unchecked(&phba->num_rsrc_err);
41789 phba->last_rsrc_error_time = jiffies;
41790
41791 if ((phba->last_ramp_down_time + QUEUE_RAMP_DOWN_INTERVAL) > jiffies) {
41792 @@ -366,7 +366,7 @@ lpfc_rampup_queue_depth(struct lpfc_vport *vport,
41793 unsigned long flags;
41794 struct lpfc_hba *phba = vport->phba;
41795 uint32_t evt_posted;
41796 - atomic_inc(&phba->num_cmd_success);
41797 + atomic_inc_unchecked(&phba->num_cmd_success);
41798
41799 if (vport->cfg_lun_queue_depth <= queue_depth)
41800 return;
41801 @@ -410,8 +410,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
41802 unsigned long num_rsrc_err, num_cmd_success;
41803 int i;
41804
41805 - num_rsrc_err = atomic_read(&phba->num_rsrc_err);
41806 - num_cmd_success = atomic_read(&phba->num_cmd_success);
41807 + num_rsrc_err = atomic_read_unchecked(&phba->num_rsrc_err);
41808 + num_cmd_success = atomic_read_unchecked(&phba->num_cmd_success);
41809
41810 /*
41811 * The error and success command counters are global per
41812 @@ -439,8 +439,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
41813 }
41814 }
41815 lpfc_destroy_vport_work_array(phba, vports);
41816 - atomic_set(&phba->num_rsrc_err, 0);
41817 - atomic_set(&phba->num_cmd_success, 0);
41818 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
41819 + atomic_set_unchecked(&phba->num_cmd_success, 0);
41820 }
41821
41822 /**
41823 @@ -474,8 +474,8 @@ lpfc_ramp_up_queue_handler(struct lpfc_hba *phba)
41824 }
41825 }
41826 lpfc_destroy_vport_work_array(phba, vports);
41827 - atomic_set(&phba->num_rsrc_err, 0);
41828 - atomic_set(&phba->num_cmd_success, 0);
41829 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
41830 + atomic_set_unchecked(&phba->num_cmd_success, 0);
41831 }
41832
41833 /**
41834 diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
41835 index b46f5e9..c4c4ccb 100644
41836 --- a/drivers/scsi/pmcraid.c
41837 +++ b/drivers/scsi/pmcraid.c
41838 @@ -200,8 +200,8 @@ static int pmcraid_slave_alloc(struct scsi_device *scsi_dev)
41839 res->scsi_dev = scsi_dev;
41840 scsi_dev->hostdata = res;
41841 res->change_detected = 0;
41842 - atomic_set(&res->read_failures, 0);
41843 - atomic_set(&res->write_failures, 0);
41844 + atomic_set_unchecked(&res->read_failures, 0);
41845 + atomic_set_unchecked(&res->write_failures, 0);
41846 rc = 0;
41847 }
41848 spin_unlock_irqrestore(&pinstance->resource_lock, lock_flags);
41849 @@ -2676,9 +2676,9 @@ static int pmcraid_error_handler(struct pmcraid_cmd *cmd)
41850
41851 /* If this was a SCSI read/write command keep count of errors */
41852 if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_READ_CMD)
41853 - atomic_inc(&res->read_failures);
41854 + atomic_inc_unchecked(&res->read_failures);
41855 else if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_WRITE_CMD)
41856 - atomic_inc(&res->write_failures);
41857 + atomic_inc_unchecked(&res->write_failures);
41858
41859 if (!RES_IS_GSCSI(res->cfg_entry) &&
41860 masked_ioasc != PMCRAID_IOASC_HW_DEVICE_BUS_STATUS_ERROR) {
41861 @@ -3534,7 +3534,7 @@ static int pmcraid_queuecommand_lck(
41862 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
41863 * hrrq_id assigned here in queuecommand
41864 */
41865 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
41866 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
41867 pinstance->num_hrrq;
41868 cmd->cmd_done = pmcraid_io_done;
41869
41870 @@ -3859,7 +3859,7 @@ static long pmcraid_ioctl_passthrough(
41871 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
41872 * hrrq_id assigned here in queuecommand
41873 */
41874 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
41875 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
41876 pinstance->num_hrrq;
41877
41878 if (request_size) {
41879 @@ -4497,7 +4497,7 @@ static void pmcraid_worker_function(struct work_struct *workp)
41880
41881 pinstance = container_of(workp, struct pmcraid_instance, worker_q);
41882 /* add resources only after host is added into system */
41883 - if (!atomic_read(&pinstance->expose_resources))
41884 + if (!atomic_read_unchecked(&pinstance->expose_resources))
41885 return;
41886
41887 fw_version = be16_to_cpu(pinstance->inq_data->fw_version);
41888 @@ -5324,8 +5324,8 @@ static int pmcraid_init_instance(struct pci_dev *pdev, struct Scsi_Host *host,
41889 init_waitqueue_head(&pinstance->reset_wait_q);
41890
41891 atomic_set(&pinstance->outstanding_cmds, 0);
41892 - atomic_set(&pinstance->last_message_id, 0);
41893 - atomic_set(&pinstance->expose_resources, 0);
41894 + atomic_set_unchecked(&pinstance->last_message_id, 0);
41895 + atomic_set_unchecked(&pinstance->expose_resources, 0);
41896
41897 INIT_LIST_HEAD(&pinstance->free_res_q);
41898 INIT_LIST_HEAD(&pinstance->used_res_q);
41899 @@ -6038,7 +6038,7 @@ static int pmcraid_probe(struct pci_dev *pdev,
41900 /* Schedule worker thread to handle CCN and take care of adding and
41901 * removing devices to OS
41902 */
41903 - atomic_set(&pinstance->expose_resources, 1);
41904 + atomic_set_unchecked(&pinstance->expose_resources, 1);
41905 schedule_work(&pinstance->worker_q);
41906 return rc;
41907
41908 diff --git a/drivers/scsi/pmcraid.h b/drivers/scsi/pmcraid.h
41909 index e1d150f..6c6df44 100644
41910 --- a/drivers/scsi/pmcraid.h
41911 +++ b/drivers/scsi/pmcraid.h
41912 @@ -748,7 +748,7 @@ struct pmcraid_instance {
41913 struct pmcraid_isr_param hrrq_vector[PMCRAID_NUM_MSIX_VECTORS];
41914
41915 /* Message id as filled in last fired IOARCB, used to identify HRRQ */
41916 - atomic_t last_message_id;
41917 + atomic_unchecked_t last_message_id;
41918
41919 /* configuration table */
41920 struct pmcraid_config_table *cfg_table;
41921 @@ -777,7 +777,7 @@ struct pmcraid_instance {
41922 atomic_t outstanding_cmds;
41923
41924 /* should add/delete resources to mid-layer now ?*/
41925 - atomic_t expose_resources;
41926 + atomic_unchecked_t expose_resources;
41927
41928
41929
41930 @@ -813,8 +813,8 @@ struct pmcraid_resource_entry {
41931 struct pmcraid_config_table_entry_ext cfg_entry_ext;
41932 };
41933 struct scsi_device *scsi_dev; /* Link scsi_device structure */
41934 - atomic_t read_failures; /* count of failed READ commands */
41935 - atomic_t write_failures; /* count of failed WRITE commands */
41936 + atomic_unchecked_t read_failures; /* count of failed READ commands */
41937 + atomic_unchecked_t write_failures; /* count of failed WRITE commands */
41938
41939 /* To indicate add/delete/modify during CCN */
41940 u8 change_detected;
41941 diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
41942 index b3db9dc..c3b1756 100644
41943 --- a/drivers/scsi/qla2xxx/qla_attr.c
41944 +++ b/drivers/scsi/qla2xxx/qla_attr.c
41945 @@ -1971,7 +1971,7 @@ qla24xx_vport_disable(struct fc_vport *fc_vport, bool disable)
41946 return 0;
41947 }
41948
41949 -struct fc_function_template qla2xxx_transport_functions = {
41950 +fc_function_template_no_const qla2xxx_transport_functions = {
41951
41952 .show_host_node_name = 1,
41953 .show_host_port_name = 1,
41954 @@ -2018,7 +2018,7 @@ struct fc_function_template qla2xxx_transport_functions = {
41955 .bsg_timeout = qla24xx_bsg_timeout,
41956 };
41957
41958 -struct fc_function_template qla2xxx_transport_vport_functions = {
41959 +fc_function_template_no_const qla2xxx_transport_vport_functions = {
41960
41961 .show_host_node_name = 1,
41962 .show_host_port_name = 1,
41963 diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
41964 index b310fa9..b9b3944 100644
41965 --- a/drivers/scsi/qla2xxx/qla_gbl.h
41966 +++ b/drivers/scsi/qla2xxx/qla_gbl.h
41967 @@ -523,8 +523,8 @@ extern void qla2x00_get_sym_node_name(scsi_qla_host_t *, uint8_t *);
41968 struct device_attribute;
41969 extern struct device_attribute *qla2x00_host_attrs[];
41970 struct fc_function_template;
41971 -extern struct fc_function_template qla2xxx_transport_functions;
41972 -extern struct fc_function_template qla2xxx_transport_vport_functions;
41973 +extern fc_function_template_no_const qla2xxx_transport_functions;
41974 +extern fc_function_template_no_const qla2xxx_transport_vport_functions;
41975 extern void qla2x00_alloc_sysfs_attr(scsi_qla_host_t *);
41976 extern void qla2x00_free_sysfs_attr(scsi_qla_host_t *);
41977 extern void qla2x00_init_host_attr(scsi_qla_host_t *);
41978 diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
41979 index 2c6dd3d..e5ecd82 100644
41980 --- a/drivers/scsi/qla2xxx/qla_os.c
41981 +++ b/drivers/scsi/qla2xxx/qla_os.c
41982 @@ -1554,8 +1554,10 @@ qla2x00_config_dma_addressing(struct qla_hw_data *ha)
41983 !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) {
41984 /* Ok, a 64bit DMA mask is applicable. */
41985 ha->flags.enable_64bit_addressing = 1;
41986 - ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
41987 - ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
41988 + pax_open_kernel();
41989 + *(void **)&ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
41990 + *(void **)&ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
41991 + pax_close_kernel();
41992 return;
41993 }
41994 }
41995 diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
41996 index 129f5dd..ade53e8 100644
41997 --- a/drivers/scsi/qla4xxx/ql4_def.h
41998 +++ b/drivers/scsi/qla4xxx/ql4_def.h
41999 @@ -275,7 +275,7 @@ struct ddb_entry {
42000 * (4000 only) */
42001 atomic_t relogin_timer; /* Max Time to wait for
42002 * relogin to complete */
42003 - atomic_t relogin_retry_count; /* Num of times relogin has been
42004 + atomic_unchecked_t relogin_retry_count; /* Num of times relogin has been
42005 * retried */
42006 uint32_t default_time2wait; /* Default Min time between
42007 * relogins (+aens) */
42008 diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
42009 index 6142729..b6a85c9 100644
42010 --- a/drivers/scsi/qla4xxx/ql4_os.c
42011 +++ b/drivers/scsi/qla4xxx/ql4_os.c
42012 @@ -2622,12 +2622,12 @@ static void qla4xxx_check_relogin_flash_ddb(struct iscsi_cls_session *cls_sess)
42013 */
42014 if (!iscsi_is_session_online(cls_sess)) {
42015 /* Reset retry relogin timer */
42016 - atomic_inc(&ddb_entry->relogin_retry_count);
42017 + atomic_inc_unchecked(&ddb_entry->relogin_retry_count);
42018 DEBUG2(ql4_printk(KERN_INFO, ha,
42019 "%s: index[%d] relogin timed out-retrying"
42020 " relogin (%d), retry (%d)\n", __func__,
42021 ddb_entry->fw_ddb_index,
42022 - atomic_read(&ddb_entry->relogin_retry_count),
42023 + atomic_read_unchecked(&ddb_entry->relogin_retry_count),
42024 ddb_entry->default_time2wait + 4));
42025 set_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags);
42026 atomic_set(&ddb_entry->retry_relogin_timer,
42027 @@ -4742,7 +4742,7 @@ static void qla4xxx_setup_flash_ddb_entry(struct scsi_qla_host *ha,
42028
42029 atomic_set(&ddb_entry->retry_relogin_timer, INVALID_ENTRY);
42030 atomic_set(&ddb_entry->relogin_timer, 0);
42031 - atomic_set(&ddb_entry->relogin_retry_count, 0);
42032 + atomic_set_unchecked(&ddb_entry->relogin_retry_count, 0);
42033 def_timeout = le16_to_cpu(ddb_entry->fw_ddb_entry.def_timeout);
42034 ddb_entry->default_relogin_timeout =
42035 (def_timeout > LOGIN_TOV) && (def_timeout < LOGIN_TOV * 10) ?
42036 diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
42037 index 2c0d0ec..4e8681a 100644
42038 --- a/drivers/scsi/scsi.c
42039 +++ b/drivers/scsi/scsi.c
42040 @@ -661,7 +661,7 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
42041 unsigned long timeout;
42042 int rtn = 0;
42043
42044 - atomic_inc(&cmd->device->iorequest_cnt);
42045 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
42046
42047 /* check if the device is still usable */
42048 if (unlikely(cmd->device->sdev_state == SDEV_DEL)) {
42049 diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
42050 index c31187d..0ead8c3 100644
42051 --- a/drivers/scsi/scsi_lib.c
42052 +++ b/drivers/scsi/scsi_lib.c
42053 @@ -1459,7 +1459,7 @@ static void scsi_kill_request(struct request *req, struct request_queue *q)
42054 shost = sdev->host;
42055 scsi_init_cmd_errh(cmd);
42056 cmd->result = DID_NO_CONNECT << 16;
42057 - atomic_inc(&cmd->device->iorequest_cnt);
42058 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
42059
42060 /*
42061 * SCSI request completion path will do scsi_device_unbusy(),
42062 @@ -1485,9 +1485,9 @@ static void scsi_softirq_done(struct request *rq)
42063
42064 INIT_LIST_HEAD(&cmd->eh_entry);
42065
42066 - atomic_inc(&cmd->device->iodone_cnt);
42067 + atomic_inc_unchecked(&cmd->device->iodone_cnt);
42068 if (cmd->result)
42069 - atomic_inc(&cmd->device->ioerr_cnt);
42070 + atomic_inc_unchecked(&cmd->device->ioerr_cnt);
42071
42072 disposition = scsi_decide_disposition(cmd);
42073 if (disposition != SUCCESS &&
42074 diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
42075 index 931a7d9..0c2a754 100644
42076 --- a/drivers/scsi/scsi_sysfs.c
42077 +++ b/drivers/scsi/scsi_sysfs.c
42078 @@ -658,7 +658,7 @@ show_iostat_##field(struct device *dev, struct device_attribute *attr, \
42079 char *buf) \
42080 { \
42081 struct scsi_device *sdev = to_scsi_device(dev); \
42082 - unsigned long long count = atomic_read(&sdev->field); \
42083 + unsigned long long count = atomic_read_unchecked(&sdev->field); \
42084 return snprintf(buf, 20, "0x%llx\n", count); \
42085 } \
42086 static DEVICE_ATTR(field, S_IRUGO, show_iostat_##field, NULL)
42087 diff --git a/drivers/scsi/scsi_tgt_lib.c b/drivers/scsi/scsi_tgt_lib.c
42088 index 84a1fdf..693b0d6 100644
42089 --- a/drivers/scsi/scsi_tgt_lib.c
42090 +++ b/drivers/scsi/scsi_tgt_lib.c
42091 @@ -362,7 +362,7 @@ static int scsi_map_user_pages(struct scsi_tgt_cmd *tcmd, struct scsi_cmnd *cmd,
42092 int err;
42093
42094 dprintk("%lx %u\n", uaddr, len);
42095 - err = blk_rq_map_user(q, rq, NULL, (void *)uaddr, len, GFP_KERNEL);
42096 + err = blk_rq_map_user(q, rq, NULL, (void __user *)uaddr, len, GFP_KERNEL);
42097 if (err) {
42098 /*
42099 * TODO: need to fixup sg_tablesize, max_segment_size,
42100 diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
42101 index e894ca7..de9d7660 100644
42102 --- a/drivers/scsi/scsi_transport_fc.c
42103 +++ b/drivers/scsi/scsi_transport_fc.c
42104 @@ -498,7 +498,7 @@ static DECLARE_TRANSPORT_CLASS(fc_vport_class,
42105 * Netlink Infrastructure
42106 */
42107
42108 -static atomic_t fc_event_seq;
42109 +static atomic_unchecked_t fc_event_seq;
42110
42111 /**
42112 * fc_get_event_number - Obtain the next sequential FC event number
42113 @@ -511,7 +511,7 @@ static atomic_t fc_event_seq;
42114 u32
42115 fc_get_event_number(void)
42116 {
42117 - return atomic_add_return(1, &fc_event_seq);
42118 + return atomic_add_return_unchecked(1, &fc_event_seq);
42119 }
42120 EXPORT_SYMBOL(fc_get_event_number);
42121
42122 @@ -659,7 +659,7 @@ static __init int fc_transport_init(void)
42123 {
42124 int error;
42125
42126 - atomic_set(&fc_event_seq, 0);
42127 + atomic_set_unchecked(&fc_event_seq, 0);
42128
42129 error = transport_class_register(&fc_host_class);
42130 if (error)
42131 @@ -849,7 +849,7 @@ static int fc_str_to_dev_loss(const char *buf, unsigned long *val)
42132 char *cp;
42133
42134 *val = simple_strtoul(buf, &cp, 0);
42135 - if ((*cp && (*cp != '\n')) || (*val < 0))
42136 + if (*cp && (*cp != '\n'))
42137 return -EINVAL;
42138 /*
42139 * Check for overflow; dev_loss_tmo is u32
42140 diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
42141 index 0a74b97..fa8d648 100644
42142 --- a/drivers/scsi/scsi_transport_iscsi.c
42143 +++ b/drivers/scsi/scsi_transport_iscsi.c
42144 @@ -79,7 +79,7 @@ struct iscsi_internal {
42145 struct transport_container session_cont;
42146 };
42147
42148 -static atomic_t iscsi_session_nr; /* sysfs session id for next new session */
42149 +static atomic_unchecked_t iscsi_session_nr; /* sysfs session id for next new session */
42150 static struct workqueue_struct *iscsi_eh_timer_workq;
42151
42152 static DEFINE_IDA(iscsi_sess_ida);
42153 @@ -1064,7 +1064,7 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
42154 int err;
42155
42156 ihost = shost->shost_data;
42157 - session->sid = atomic_add_return(1, &iscsi_session_nr);
42158 + session->sid = atomic_add_return_unchecked(1, &iscsi_session_nr);
42159
42160 if (target_id == ISCSI_MAX_TARGET) {
42161 id = ida_simple_get(&iscsi_sess_ida, 0, 0, GFP_KERNEL);
42162 @@ -2955,7 +2955,7 @@ static __init int iscsi_transport_init(void)
42163 printk(KERN_INFO "Loading iSCSI transport class v%s.\n",
42164 ISCSI_TRANSPORT_VERSION);
42165
42166 - atomic_set(&iscsi_session_nr, 0);
42167 + atomic_set_unchecked(&iscsi_session_nr, 0);
42168
42169 err = class_register(&iscsi_transport_class);
42170 if (err)
42171 diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
42172 index f379c7f..e8fc69c 100644
42173 --- a/drivers/scsi/scsi_transport_srp.c
42174 +++ b/drivers/scsi/scsi_transport_srp.c
42175 @@ -33,7 +33,7 @@
42176 #include "scsi_transport_srp_internal.h"
42177
42178 struct srp_host_attrs {
42179 - atomic_t next_port_id;
42180 + atomic_unchecked_t next_port_id;
42181 };
42182 #define to_srp_host_attrs(host) ((struct srp_host_attrs *)(host)->shost_data)
42183
42184 @@ -61,7 +61,7 @@ static int srp_host_setup(struct transport_container *tc, struct device *dev,
42185 struct Scsi_Host *shost = dev_to_shost(dev);
42186 struct srp_host_attrs *srp_host = to_srp_host_attrs(shost);
42187
42188 - atomic_set(&srp_host->next_port_id, 0);
42189 + atomic_set_unchecked(&srp_host->next_port_id, 0);
42190 return 0;
42191 }
42192
42193 @@ -210,7 +210,7 @@ struct srp_rport *srp_rport_add(struct Scsi_Host *shost,
42194 memcpy(rport->port_id, ids->port_id, sizeof(rport->port_id));
42195 rport->roles = ids->roles;
42196
42197 - id = atomic_inc_return(&to_srp_host_attrs(shost)->next_port_id);
42198 + id = atomic_inc_return_unchecked(&to_srp_host_attrs(shost)->next_port_id);
42199 dev_set_name(&rport->dev, "port-%d:%d", shost->host_no, id);
42200
42201 transport_setup_device(&rport->dev);
42202 diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
42203 index 82910cc..7c350ad 100644
42204 --- a/drivers/scsi/sd.c
42205 +++ b/drivers/scsi/sd.c
42206 @@ -2929,7 +2929,7 @@ static int sd_probe(struct device *dev)
42207 sdkp->disk = gd;
42208 sdkp->index = index;
42209 atomic_set(&sdkp->openers, 0);
42210 - atomic_set(&sdkp->device->ioerr_cnt, 0);
42211 + atomic_set_unchecked(&sdkp->device->ioerr_cnt, 0);
42212
42213 if (!sdp->request_queue->rq_timeout) {
42214 if (sdp->type != TYPE_MOD)
42215 diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
42216 index 9f0c465..47194ee 100644
42217 --- a/drivers/scsi/sg.c
42218 +++ b/drivers/scsi/sg.c
42219 @@ -1101,7 +1101,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
42220 sdp->disk->disk_name,
42221 MKDEV(SCSI_GENERIC_MAJOR, sdp->index),
42222 NULL,
42223 - (char *)arg);
42224 + (char __user *)arg);
42225 case BLKTRACESTART:
42226 return blk_trace_startstop(sdp->device->request_queue, 1);
42227 case BLKTRACESTOP:
42228 diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
42229 index 004b10f..7c98d51 100644
42230 --- a/drivers/spi/spi.c
42231 +++ b/drivers/spi/spi.c
42232 @@ -1620,7 +1620,7 @@ int spi_bus_unlock(struct spi_master *master)
42233 EXPORT_SYMBOL_GPL(spi_bus_unlock);
42234
42235 /* portable code must never pass more than 32 bytes */
42236 -#define SPI_BUFSIZ max(32,SMP_CACHE_BYTES)
42237 +#define SPI_BUFSIZ max(32UL,SMP_CACHE_BYTES)
42238
42239 static u8 *buf;
42240
42241 diff --git a/drivers/staging/iio/iio_hwmon.c b/drivers/staging/iio/iio_hwmon.c
42242 index 93af756..a4bc5bf 100644
42243 --- a/drivers/staging/iio/iio_hwmon.c
42244 +++ b/drivers/staging/iio/iio_hwmon.c
42245 @@ -67,7 +67,7 @@ static int iio_hwmon_probe(struct platform_device *pdev)
42246 {
42247 struct device *dev = &pdev->dev;
42248 struct iio_hwmon_state *st;
42249 - struct sensor_device_attribute *a;
42250 + sensor_device_attribute_no_const *a;
42251 int ret, i;
42252 int in_i = 1, temp_i = 1, curr_i = 1;
42253 enum iio_chan_type type;
42254 diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c
42255 index 34afc16..ffe44dd 100644
42256 --- a/drivers/staging/octeon/ethernet-rx.c
42257 +++ b/drivers/staging/octeon/ethernet-rx.c
42258 @@ -421,11 +421,11 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
42259 /* Increment RX stats for virtual ports */
42260 if (work->ipprt >= CVMX_PIP_NUM_INPUT_PORTS) {
42261 #ifdef CONFIG_64BIT
42262 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_packets);
42263 - atomic64_add(skb->len, (atomic64_t *)&priv->stats.rx_bytes);
42264 + atomic64_add_unchecked(1, (atomic64_unchecked_t *)&priv->stats.rx_packets);
42265 + atomic64_add_unchecked(skb->len, (atomic64_unchecked_t *)&priv->stats.rx_bytes);
42266 #else
42267 - atomic_add(1, (atomic_t *)&priv->stats.rx_packets);
42268 - atomic_add(skb->len, (atomic_t *)&priv->stats.rx_bytes);
42269 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_packets);
42270 + atomic_add_unchecked(skb->len, (atomic_unchecked_t *)&priv->stats.rx_bytes);
42271 #endif
42272 }
42273 netif_receive_skb(skb);
42274 @@ -437,9 +437,9 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
42275 dev->name);
42276 */
42277 #ifdef CONFIG_64BIT
42278 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_dropped);
42279 + atomic64_unchecked_add(1, (atomic64_unchecked_t *)&priv->stats.rx_dropped);
42280 #else
42281 - atomic_add(1, (atomic_t *)&priv->stats.rx_dropped);
42282 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_dropped);
42283 #endif
42284 dev_kfree_skb_irq(skb);
42285 }
42286 diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
42287 index c3a90e7..023619a 100644
42288 --- a/drivers/staging/octeon/ethernet.c
42289 +++ b/drivers/staging/octeon/ethernet.c
42290 @@ -252,11 +252,11 @@ static struct net_device_stats *cvm_oct_common_get_stats(struct net_device *dev)
42291 * since the RX tasklet also increments it.
42292 */
42293 #ifdef CONFIG_64BIT
42294 - atomic64_add(rx_status.dropped_packets,
42295 - (atomic64_t *)&priv->stats.rx_dropped);
42296 + atomic64_add_unchecked(rx_status.dropped_packets,
42297 + (atomic64_unchecked_t *)&priv->stats.rx_dropped);
42298 #else
42299 - atomic_add(rx_status.dropped_packets,
42300 - (atomic_t *)&priv->stats.rx_dropped);
42301 + atomic_add_unchecked(rx_status.dropped_packets,
42302 + (atomic_unchecked_t *)&priv->stats.rx_dropped);
42303 #endif
42304 }
42305
42306 diff --git a/drivers/staging/rtl8712/rtl871x_io.h b/drivers/staging/rtl8712/rtl871x_io.h
42307 index dc23395..cf7e9b1 100644
42308 --- a/drivers/staging/rtl8712/rtl871x_io.h
42309 +++ b/drivers/staging/rtl8712/rtl871x_io.h
42310 @@ -108,7 +108,7 @@ struct _io_ops {
42311 u8 *pmem);
42312 u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
42313 u8 *pmem);
42314 -};
42315 +} __no_const;
42316
42317 struct io_req {
42318 struct list_head list;
42319 diff --git a/drivers/staging/sbe-2t3e3/netdev.c b/drivers/staging/sbe-2t3e3/netdev.c
42320 index 1f5088b..0e59820 100644
42321 --- a/drivers/staging/sbe-2t3e3/netdev.c
42322 +++ b/drivers/staging/sbe-2t3e3/netdev.c
42323 @@ -51,7 +51,7 @@ static int t3e3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
42324 t3e3_if_config(sc, cmd_2t3e3, (char *)&param, &resp, &rlen);
42325
42326 if (rlen)
42327 - if (copy_to_user(data, &resp, rlen))
42328 + if (rlen > sizeof resp || copy_to_user(data, &resp, rlen))
42329 return -EFAULT;
42330
42331 return 0;
42332 diff --git a/drivers/staging/usbip/vhci.h b/drivers/staging/usbip/vhci.h
42333 index 5dddc4d..34fcb2f 100644
42334 --- a/drivers/staging/usbip/vhci.h
42335 +++ b/drivers/staging/usbip/vhci.h
42336 @@ -83,7 +83,7 @@ struct vhci_hcd {
42337 unsigned resuming:1;
42338 unsigned long re_timeout;
42339
42340 - atomic_t seqnum;
42341 + atomic_unchecked_t seqnum;
42342
42343 /*
42344 * NOTE:
42345 diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c
42346 index f1ca084..7b5c0c3 100644
42347 --- a/drivers/staging/usbip/vhci_hcd.c
42348 +++ b/drivers/staging/usbip/vhci_hcd.c
42349 @@ -441,7 +441,7 @@ static void vhci_tx_urb(struct urb *urb)
42350
42351 spin_lock(&vdev->priv_lock);
42352
42353 - priv->seqnum = atomic_inc_return(&the_controller->seqnum);
42354 + priv->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
42355 if (priv->seqnum == 0xffff)
42356 dev_info(&urb->dev->dev, "seqnum max\n");
42357
42358 @@ -687,7 +687,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
42359 return -ENOMEM;
42360 }
42361
42362 - unlink->seqnum = atomic_inc_return(&the_controller->seqnum);
42363 + unlink->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
42364 if (unlink->seqnum == 0xffff)
42365 pr_info("seqnum max\n");
42366
42367 @@ -891,7 +891,7 @@ static int vhci_start(struct usb_hcd *hcd)
42368 vdev->rhport = rhport;
42369 }
42370
42371 - atomic_set(&vhci->seqnum, 0);
42372 + atomic_set_unchecked(&vhci->seqnum, 0);
42373 spin_lock_init(&vhci->lock);
42374
42375 hcd->power_budget = 0; /* no limit */
42376 diff --git a/drivers/staging/usbip/vhci_rx.c b/drivers/staging/usbip/vhci_rx.c
42377 index faf8e60..c46f8ab 100644
42378 --- a/drivers/staging/usbip/vhci_rx.c
42379 +++ b/drivers/staging/usbip/vhci_rx.c
42380 @@ -76,7 +76,7 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
42381 if (!urb) {
42382 pr_err("cannot find a urb of seqnum %u\n", pdu->base.seqnum);
42383 pr_info("max seqnum %d\n",
42384 - atomic_read(&the_controller->seqnum));
42385 + atomic_read_unchecked(&the_controller->seqnum));
42386 usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
42387 return;
42388 }
42389 diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c
42390 index 5f13890..36a044b 100644
42391 --- a/drivers/staging/vt6655/hostap.c
42392 +++ b/drivers/staging/vt6655/hostap.c
42393 @@ -73,14 +73,13 @@ static int msglevel =MSG_LEVEL_INFO;
42394 *
42395 */
42396
42397 +static net_device_ops_no_const apdev_netdev_ops;
42398 +
42399 static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
42400 {
42401 PSDevice apdev_priv;
42402 struct net_device *dev = pDevice->dev;
42403 int ret;
42404 - const struct net_device_ops apdev_netdev_ops = {
42405 - .ndo_start_xmit = pDevice->tx_80211,
42406 - };
42407
42408 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
42409
42410 @@ -92,6 +91,8 @@ static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
42411 *apdev_priv = *pDevice;
42412 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
42413
42414 + /* only half broken now */
42415 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
42416 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
42417
42418 pDevice->apdev->type = ARPHRD_IEEE80211;
42419 diff --git a/drivers/staging/vt6656/hostap.c b/drivers/staging/vt6656/hostap.c
42420 index bc5e9da..dacd556 100644
42421 --- a/drivers/staging/vt6656/hostap.c
42422 +++ b/drivers/staging/vt6656/hostap.c
42423 @@ -60,14 +60,13 @@ static int msglevel =MSG_LEVEL_INFO;
42424 *
42425 */
42426
42427 +static net_device_ops_no_const apdev_netdev_ops;
42428 +
42429 static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
42430 {
42431 struct vnt_private *apdev_priv;
42432 struct net_device *dev = pDevice->dev;
42433 int ret;
42434 - const struct net_device_ops apdev_netdev_ops = {
42435 - .ndo_start_xmit = pDevice->tx_80211,
42436 - };
42437
42438 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
42439
42440 @@ -79,6 +78,8 @@ static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
42441 *apdev_priv = *pDevice;
42442 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
42443
42444 + /* only half broken now */
42445 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
42446 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
42447
42448 pDevice->apdev->type = ARPHRD_IEEE80211;
42449 diff --git a/drivers/staging/zcache/tmem.c b/drivers/staging/zcache/tmem.c
42450 index a2b7e03..9ff4bbd 100644
42451 --- a/drivers/staging/zcache/tmem.c
42452 +++ b/drivers/staging/zcache/tmem.c
42453 @@ -50,7 +50,7 @@
42454 * A tmem host implementation must use this function to register callbacks
42455 * for memory allocation.
42456 */
42457 -static struct tmem_hostops tmem_hostops;
42458 +static tmem_hostops_no_const tmem_hostops;
42459
42460 static void tmem_objnode_tree_init(void);
42461
42462 @@ -64,7 +64,7 @@ void tmem_register_hostops(struct tmem_hostops *m)
42463 * A tmem host implementation must use this function to register
42464 * callbacks for a page-accessible memory (PAM) implementation.
42465 */
42466 -static struct tmem_pamops tmem_pamops;
42467 +static tmem_pamops_no_const tmem_pamops;
42468
42469 void tmem_register_pamops(struct tmem_pamops *m)
42470 {
42471 diff --git a/drivers/staging/zcache/tmem.h b/drivers/staging/zcache/tmem.h
42472 index adbe5a8..d387359 100644
42473 --- a/drivers/staging/zcache/tmem.h
42474 +++ b/drivers/staging/zcache/tmem.h
42475 @@ -226,6 +226,7 @@ struct tmem_pamops {
42476 int (*replace_in_obj)(void *, struct tmem_obj *);
42477 #endif
42478 };
42479 +typedef struct tmem_pamops __no_const tmem_pamops_no_const;
42480 extern void tmem_register_pamops(struct tmem_pamops *m);
42481
42482 /* memory allocation methods provided by the host implementation */
42483 @@ -235,6 +236,7 @@ struct tmem_hostops {
42484 struct tmem_objnode *(*objnode_alloc)(struct tmem_pool *);
42485 void (*objnode_free)(struct tmem_objnode *, struct tmem_pool *);
42486 };
42487 +typedef struct tmem_hostops __no_const tmem_hostops_no_const;
42488 extern void tmem_register_hostops(struct tmem_hostops *m);
42489
42490 /* core tmem accessor functions */
42491 diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
42492 index 2e4d655..fd72e68 100644
42493 --- a/drivers/target/target_core_device.c
42494 +++ b/drivers/target/target_core_device.c
42495 @@ -1414,7 +1414,7 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
42496 spin_lock_init(&dev->se_port_lock);
42497 spin_lock_init(&dev->se_tmr_lock);
42498 spin_lock_init(&dev->qf_cmd_lock);
42499 - atomic_set(&dev->dev_ordered_id, 0);
42500 + atomic_set_unchecked(&dev->dev_ordered_id, 0);
42501 INIT_LIST_HEAD(&dev->t10_wwn.t10_vpd_list);
42502 spin_lock_init(&dev->t10_wwn.t10_vpd_lock);
42503 INIT_LIST_HEAD(&dev->t10_pr.registration_list);
42504 diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
42505 index 0d46276..f327cab5 100644
42506 --- a/drivers/target/target_core_transport.c
42507 +++ b/drivers/target/target_core_transport.c
42508 @@ -1080,7 +1080,7 @@ transport_check_alloc_task_attr(struct se_cmd *cmd)
42509 * Used to determine when ORDERED commands should go from
42510 * Dormant to Active status.
42511 */
42512 - cmd->se_ordered_id = atomic_inc_return(&dev->dev_ordered_id);
42513 + cmd->se_ordered_id = atomic_inc_return_unchecked(&dev->dev_ordered_id);
42514 smp_mb__after_atomic_inc();
42515 pr_debug("Allocated se_ordered_id: %u for Task Attr: 0x%02x on %s\n",
42516 cmd->se_ordered_id, cmd->sam_task_attr,
42517 diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
42518 index 345bd0e..61d5375 100644
42519 --- a/drivers/tty/cyclades.c
42520 +++ b/drivers/tty/cyclades.c
42521 @@ -1576,10 +1576,10 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
42522 printk(KERN_DEBUG "cyc:cy_open ttyC%d, count = %d\n", info->line,
42523 info->port.count);
42524 #endif
42525 - info->port.count++;
42526 + atomic_inc(&info->port.count);
42527 #ifdef CY_DEBUG_COUNT
42528 printk(KERN_DEBUG "cyc:cy_open (%d): incrementing count to %d\n",
42529 - current->pid, info->port.count);
42530 + current->pid, atomic_read(&info->port.count));
42531 #endif
42532
42533 /*
42534 @@ -3978,7 +3978,7 @@ static int cyclades_proc_show(struct seq_file *m, void *v)
42535 for (j = 0; j < cy_card[i].nports; j++) {
42536 info = &cy_card[i].ports[j];
42537
42538 - if (info->port.count) {
42539 + if (atomic_read(&info->port.count)) {
42540 /* XXX is the ldisc num worth this? */
42541 struct tty_struct *tty;
42542 struct tty_ldisc *ld;
42543 diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
42544 index eb255e8..f637a57 100644
42545 --- a/drivers/tty/hvc/hvc_console.c
42546 +++ b/drivers/tty/hvc/hvc_console.c
42547 @@ -338,7 +338,7 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
42548
42549 spin_lock_irqsave(&hp->port.lock, flags);
42550 /* Check and then increment for fast path open. */
42551 - if (hp->port.count++ > 0) {
42552 + if (atomic_inc_return(&hp->port.count) > 1) {
42553 spin_unlock_irqrestore(&hp->port.lock, flags);
42554 hvc_kick();
42555 return 0;
42556 @@ -388,7 +388,7 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
42557
42558 spin_lock_irqsave(&hp->port.lock, flags);
42559
42560 - if (--hp->port.count == 0) {
42561 + if (atomic_dec_return(&hp->port.count) == 0) {
42562 spin_unlock_irqrestore(&hp->port.lock, flags);
42563 /* We are done with the tty pointer now. */
42564 tty_port_tty_set(&hp->port, NULL);
42565 @@ -406,9 +406,9 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
42566 */
42567 tty_wait_until_sent_from_close(tty, HVC_CLOSE_WAIT);
42568 } else {
42569 - if (hp->port.count < 0)
42570 + if (atomic_read(&hp->port.count) < 0)
42571 printk(KERN_ERR "hvc_close %X: oops, count is %d\n",
42572 - hp->vtermno, hp->port.count);
42573 + hp->vtermno, atomic_read(&hp->port.count));
42574 spin_unlock_irqrestore(&hp->port.lock, flags);
42575 }
42576 }
42577 @@ -438,12 +438,12 @@ static void hvc_hangup(struct tty_struct *tty)
42578 * open->hangup case this can be called after the final close so prevent
42579 * that from happening for now.
42580 */
42581 - if (hp->port.count <= 0) {
42582 + if (atomic_read(&hp->port.count) <= 0) {
42583 spin_unlock_irqrestore(&hp->port.lock, flags);
42584 return;
42585 }
42586
42587 - hp->port.count = 0;
42588 + atomic_set(&hp->port.count, 0);
42589 spin_unlock_irqrestore(&hp->port.lock, flags);
42590 tty_port_tty_set(&hp->port, NULL);
42591
42592 @@ -491,7 +491,7 @@ static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count
42593 return -EPIPE;
42594
42595 /* FIXME what's this (unprotected) check for? */
42596 - if (hp->port.count <= 0)
42597 + if (atomic_read(&hp->port.count) <= 0)
42598 return -EIO;
42599
42600 spin_lock_irqsave(&hp->lock, flags);
42601 diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
42602 index 81e939e..95ead10 100644
42603 --- a/drivers/tty/hvc/hvcs.c
42604 +++ b/drivers/tty/hvc/hvcs.c
42605 @@ -83,6 +83,7 @@
42606 #include <asm/hvcserver.h>
42607 #include <asm/uaccess.h>
42608 #include <asm/vio.h>
42609 +#include <asm/local.h>
42610
42611 /*
42612 * 1.3.0 -> 1.3.1 In hvcs_open memset(..,0x00,..) instead of memset(..,0x3F,00).
42613 @@ -416,7 +417,7 @@ static ssize_t hvcs_vterm_state_store(struct device *dev, struct device_attribut
42614
42615 spin_lock_irqsave(&hvcsd->lock, flags);
42616
42617 - if (hvcsd->port.count > 0) {
42618 + if (atomic_read(&hvcsd->port.count) > 0) {
42619 spin_unlock_irqrestore(&hvcsd->lock, flags);
42620 printk(KERN_INFO "HVCS: vterm state unchanged. "
42621 "The hvcs device node is still in use.\n");
42622 @@ -1127,7 +1128,7 @@ static int hvcs_install(struct tty_driver *driver, struct tty_struct *tty)
42623 }
42624 }
42625
42626 - hvcsd->port.count = 0;
42627 + atomic_set(&hvcsd->port.count, 0);
42628 hvcsd->port.tty = tty;
42629 tty->driver_data = hvcsd;
42630
42631 @@ -1180,7 +1181,7 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp)
42632 unsigned long flags;
42633
42634 spin_lock_irqsave(&hvcsd->lock, flags);
42635 - hvcsd->port.count++;
42636 + atomic_inc(&hvcsd->port.count);
42637 hvcsd->todo_mask |= HVCS_SCHED_READ;
42638 spin_unlock_irqrestore(&hvcsd->lock, flags);
42639
42640 @@ -1216,7 +1217,7 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
42641 hvcsd = tty->driver_data;
42642
42643 spin_lock_irqsave(&hvcsd->lock, flags);
42644 - if (--hvcsd->port.count == 0) {
42645 + if (atomic_dec_and_test(&hvcsd->port.count)) {
42646
42647 vio_disable_interrupts(hvcsd->vdev);
42648
42649 @@ -1241,10 +1242,10 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
42650
42651 free_irq(irq, hvcsd);
42652 return;
42653 - } else if (hvcsd->port.count < 0) {
42654 + } else if (atomic_read(&hvcsd->port.count) < 0) {
42655 printk(KERN_ERR "HVCS: vty-server@%X open_count: %d"
42656 " is missmanaged.\n",
42657 - hvcsd->vdev->unit_address, hvcsd->port.count);
42658 + hvcsd->vdev->unit_address, atomic_read(&hvcsd->port.count));
42659 }
42660
42661 spin_unlock_irqrestore(&hvcsd->lock, flags);
42662 @@ -1266,7 +1267,7 @@ static void hvcs_hangup(struct tty_struct * tty)
42663
42664 spin_lock_irqsave(&hvcsd->lock, flags);
42665 /* Preserve this so that we know how many kref refs to put */
42666 - temp_open_count = hvcsd->port.count;
42667 + temp_open_count = atomic_read(&hvcsd->port.count);
42668
42669 /*
42670 * Don't kref put inside the spinlock because the destruction
42671 @@ -1281,7 +1282,7 @@ static void hvcs_hangup(struct tty_struct * tty)
42672 tty->driver_data = NULL;
42673 hvcsd->port.tty = NULL;
42674
42675 - hvcsd->port.count = 0;
42676 + atomic_set(&hvcsd->port.count, 0);
42677
42678 /* This will drop any buffered data on the floor which is OK in a hangup
42679 * scenario. */
42680 @@ -1352,7 +1353,7 @@ static int hvcs_write(struct tty_struct *tty,
42681 * the middle of a write operation? This is a crummy place to do this
42682 * but we want to keep it all in the spinlock.
42683 */
42684 - if (hvcsd->port.count <= 0) {
42685 + if (atomic_read(&hvcsd->port.count) <= 0) {
42686 spin_unlock_irqrestore(&hvcsd->lock, flags);
42687 return -ENODEV;
42688 }
42689 @@ -1426,7 +1427,7 @@ static int hvcs_write_room(struct tty_struct *tty)
42690 {
42691 struct hvcs_struct *hvcsd = tty->driver_data;
42692
42693 - if (!hvcsd || hvcsd->port.count <= 0)
42694 + if (!hvcsd || atomic_read(&hvcsd->port.count) <= 0)
42695 return 0;
42696
42697 return HVCS_BUFF_LEN - hvcsd->chars_in_buffer;
42698 diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
42699 index 8fd72ff..34a0bed 100644
42700 --- a/drivers/tty/ipwireless/tty.c
42701 +++ b/drivers/tty/ipwireless/tty.c
42702 @@ -29,6 +29,7 @@
42703 #include <linux/tty_driver.h>
42704 #include <linux/tty_flip.h>
42705 #include <linux/uaccess.h>
42706 +#include <asm/local.h>
42707
42708 #include "tty.h"
42709 #include "network.h"
42710 @@ -99,10 +100,10 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
42711 mutex_unlock(&tty->ipw_tty_mutex);
42712 return -ENODEV;
42713 }
42714 - if (tty->port.count == 0)
42715 + if (atomic_read(&tty->port.count) == 0)
42716 tty->tx_bytes_queued = 0;
42717
42718 - tty->port.count++;
42719 + atomic_inc(&tty->port.count);
42720
42721 tty->port.tty = linux_tty;
42722 linux_tty->driver_data = tty;
42723 @@ -118,9 +119,7 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
42724
42725 static void do_ipw_close(struct ipw_tty *tty)
42726 {
42727 - tty->port.count--;
42728 -
42729 - if (tty->port.count == 0) {
42730 + if (atomic_dec_return(&tty->port.count) == 0) {
42731 struct tty_struct *linux_tty = tty->port.tty;
42732
42733 if (linux_tty != NULL) {
42734 @@ -141,7 +140,7 @@ static void ipw_hangup(struct tty_struct *linux_tty)
42735 return;
42736
42737 mutex_lock(&tty->ipw_tty_mutex);
42738 - if (tty->port.count == 0) {
42739 + if (atomic_read(&tty->port.count) == 0) {
42740 mutex_unlock(&tty->ipw_tty_mutex);
42741 return;
42742 }
42743 @@ -164,7 +163,7 @@ void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data,
42744
42745 mutex_lock(&tty->ipw_tty_mutex);
42746
42747 - if (!tty->port.count) {
42748 + if (!atomic_read(&tty->port.count)) {
42749 mutex_unlock(&tty->ipw_tty_mutex);
42750 return;
42751 }
42752 @@ -206,7 +205,7 @@ static int ipw_write(struct tty_struct *linux_tty,
42753 return -ENODEV;
42754
42755 mutex_lock(&tty->ipw_tty_mutex);
42756 - if (!tty->port.count) {
42757 + if (!atomic_read(&tty->port.count)) {
42758 mutex_unlock(&tty->ipw_tty_mutex);
42759 return -EINVAL;
42760 }
42761 @@ -246,7 +245,7 @@ static int ipw_write_room(struct tty_struct *linux_tty)
42762 if (!tty)
42763 return -ENODEV;
42764
42765 - if (!tty->port.count)
42766 + if (!atomic_read(&tty->port.count))
42767 return -EINVAL;
42768
42769 room = IPWIRELESS_TX_QUEUE_SIZE - tty->tx_bytes_queued;
42770 @@ -288,7 +287,7 @@ static int ipw_chars_in_buffer(struct tty_struct *linux_tty)
42771 if (!tty)
42772 return 0;
42773
42774 - if (!tty->port.count)
42775 + if (!atomic_read(&tty->port.count))
42776 return 0;
42777
42778 return tty->tx_bytes_queued;
42779 @@ -369,7 +368,7 @@ static int ipw_tiocmget(struct tty_struct *linux_tty)
42780 if (!tty)
42781 return -ENODEV;
42782
42783 - if (!tty->port.count)
42784 + if (!atomic_read(&tty->port.count))
42785 return -EINVAL;
42786
42787 return get_control_lines(tty);
42788 @@ -385,7 +384,7 @@ ipw_tiocmset(struct tty_struct *linux_tty,
42789 if (!tty)
42790 return -ENODEV;
42791
42792 - if (!tty->port.count)
42793 + if (!atomic_read(&tty->port.count))
42794 return -EINVAL;
42795
42796 return set_control_lines(tty, set, clear);
42797 @@ -399,7 +398,7 @@ static int ipw_ioctl(struct tty_struct *linux_tty,
42798 if (!tty)
42799 return -ENODEV;
42800
42801 - if (!tty->port.count)
42802 + if (!atomic_read(&tty->port.count))
42803 return -EINVAL;
42804
42805 /* FIXME: Exactly how is the tty object locked here .. */
42806 @@ -555,7 +554,7 @@ void ipwireless_tty_free(struct ipw_tty *tty)
42807 * are gone */
42808 mutex_lock(&ttyj->ipw_tty_mutex);
42809 }
42810 - while (ttyj->port.count)
42811 + while (atomic_read(&ttyj->port.count))
42812 do_ipw_close(ttyj);
42813 ipwireless_disassociate_network_ttys(network,
42814 ttyj->channel_idx);
42815 diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
42816 index adeac25..787a0a1 100644
42817 --- a/drivers/tty/moxa.c
42818 +++ b/drivers/tty/moxa.c
42819 @@ -1193,7 +1193,7 @@ static int moxa_open(struct tty_struct *tty, struct file *filp)
42820 }
42821
42822 ch = &brd->ports[port % MAX_PORTS_PER_BOARD];
42823 - ch->port.count++;
42824 + atomic_inc(&ch->port.count);
42825 tty->driver_data = ch;
42826 tty_port_tty_set(&ch->port, tty);
42827 mutex_lock(&ch->port.mutex);
42828 diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
42829 index 4a43ef5d7..aa71f27 100644
42830 --- a/drivers/tty/n_gsm.c
42831 +++ b/drivers/tty/n_gsm.c
42832 @@ -1636,7 +1636,7 @@ static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr)
42833 spin_lock_init(&dlci->lock);
42834 mutex_init(&dlci->mutex);
42835 dlci->fifo = &dlci->_fifo;
42836 - if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL) < 0) {
42837 + if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL)) {
42838 kfree(dlci);
42839 return NULL;
42840 }
42841 @@ -2936,7 +2936,7 @@ static int gsmtty_open(struct tty_struct *tty, struct file *filp)
42842 struct gsm_dlci *dlci = tty->driver_data;
42843 struct tty_port *port = &dlci->port;
42844
42845 - port->count++;
42846 + atomic_inc(&port->count);
42847 dlci_get(dlci);
42848 dlci_get(dlci->gsm->dlci[0]);
42849 mux_get(dlci->gsm);
42850 diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
42851 index 05e72be..67f6a0f 100644
42852 --- a/drivers/tty/n_tty.c
42853 +++ b/drivers/tty/n_tty.c
42854 @@ -2197,6 +2197,7 @@ void n_tty_inherit_ops(struct tty_ldisc_ops *ops)
42855 {
42856 *ops = tty_ldisc_N_TTY;
42857 ops->owner = NULL;
42858 - ops->refcount = ops->flags = 0;
42859 + atomic_set(&ops->refcount, 0);
42860 + ops->flags = 0;
42861 }
42862 EXPORT_SYMBOL_GPL(n_tty_inherit_ops);
42863 diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
42864 index 125e0fd..8c50690 100644
42865 --- a/drivers/tty/pty.c
42866 +++ b/drivers/tty/pty.c
42867 @@ -800,8 +800,10 @@ static void __init unix98_pty_init(void)
42868 panic("Couldn't register Unix98 pts driver");
42869
42870 /* Now create the /dev/ptmx special device */
42871 + pax_open_kernel();
42872 tty_default_fops(&ptmx_fops);
42873 - ptmx_fops.open = ptmx_open;
42874 + *(void **)&ptmx_fops.open = ptmx_open;
42875 + pax_close_kernel();
42876
42877 cdev_init(&ptmx_cdev, &ptmx_fops);
42878 if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
42879 diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c
42880 index 1d27003..959f452 100644
42881 --- a/drivers/tty/rocket.c
42882 +++ b/drivers/tty/rocket.c
42883 @@ -923,7 +923,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
42884 tty->driver_data = info;
42885 tty_port_tty_set(port, tty);
42886
42887 - if (port->count++ == 0) {
42888 + if (atomic_inc_return(&port->count) == 1) {
42889 atomic_inc(&rp_num_ports_open);
42890
42891 #ifdef ROCKET_DEBUG_OPEN
42892 @@ -932,7 +932,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
42893 #endif
42894 }
42895 #ifdef ROCKET_DEBUG_OPEN
42896 - printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, info->port.count);
42897 + printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, atomic-read(&info->port.count));
42898 #endif
42899
42900 /*
42901 @@ -1527,7 +1527,7 @@ static void rp_hangup(struct tty_struct *tty)
42902 spin_unlock_irqrestore(&info->port.lock, flags);
42903 return;
42904 }
42905 - if (info->port.count)
42906 + if (atomic_read(&info->port.count))
42907 atomic_dec(&rp_num_ports_open);
42908 clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]);
42909 spin_unlock_irqrestore(&info->port.lock, flags);
42910 diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c
42911 index 1002054..dd644a8 100644
42912 --- a/drivers/tty/serial/kgdboc.c
42913 +++ b/drivers/tty/serial/kgdboc.c
42914 @@ -24,8 +24,9 @@
42915 #define MAX_CONFIG_LEN 40
42916
42917 static struct kgdb_io kgdboc_io_ops;
42918 +static struct kgdb_io kgdboc_io_ops_console;
42919
42920 -/* -1 = init not run yet, 0 = unconfigured, 1 = configured. */
42921 +/* -1 = init not run yet, 0 = unconfigured, 1/2 = configured. */
42922 static int configured = -1;
42923
42924 static char config[MAX_CONFIG_LEN];
42925 @@ -151,6 +152,8 @@ static void cleanup_kgdboc(void)
42926 kgdboc_unregister_kbd();
42927 if (configured == 1)
42928 kgdb_unregister_io_module(&kgdboc_io_ops);
42929 + else if (configured == 2)
42930 + kgdb_unregister_io_module(&kgdboc_io_ops_console);
42931 }
42932
42933 static int configure_kgdboc(void)
42934 @@ -160,13 +163,13 @@ static int configure_kgdboc(void)
42935 int err;
42936 char *cptr = config;
42937 struct console *cons;
42938 + int is_console = 0;
42939
42940 err = kgdboc_option_setup(config);
42941 if (err || !strlen(config) || isspace(config[0]))
42942 goto noconfig;
42943
42944 err = -ENODEV;
42945 - kgdboc_io_ops.is_console = 0;
42946 kgdb_tty_driver = NULL;
42947
42948 kgdboc_use_kms = 0;
42949 @@ -187,7 +190,7 @@ static int configure_kgdboc(void)
42950 int idx;
42951 if (cons->device && cons->device(cons, &idx) == p &&
42952 idx == tty_line) {
42953 - kgdboc_io_ops.is_console = 1;
42954 + is_console = 1;
42955 break;
42956 }
42957 cons = cons->next;
42958 @@ -197,7 +200,13 @@ static int configure_kgdboc(void)
42959 kgdb_tty_line = tty_line;
42960
42961 do_register:
42962 - err = kgdb_register_io_module(&kgdboc_io_ops);
42963 + if (is_console) {
42964 + err = kgdb_register_io_module(&kgdboc_io_ops_console);
42965 + configured = 2;
42966 + } else {
42967 + err = kgdb_register_io_module(&kgdboc_io_ops);
42968 + configured = 1;
42969 + }
42970 if (err)
42971 goto noconfig;
42972
42973 @@ -205,8 +214,6 @@ do_register:
42974 if (err)
42975 goto nmi_con_failed;
42976
42977 - configured = 1;
42978 -
42979 return 0;
42980
42981 nmi_con_failed:
42982 @@ -223,7 +230,7 @@ noconfig:
42983 static int __init init_kgdboc(void)
42984 {
42985 /* Already configured? */
42986 - if (configured == 1)
42987 + if (configured >= 1)
42988 return 0;
42989
42990 return configure_kgdboc();
42991 @@ -272,7 +279,7 @@ static int param_set_kgdboc_var(const char *kmessage, struct kernel_param *kp)
42992 if (config[len - 1] == '\n')
42993 config[len - 1] = '\0';
42994
42995 - if (configured == 1)
42996 + if (configured >= 1)
42997 cleanup_kgdboc();
42998
42999 /* Go and configure with the new params. */
43000 @@ -312,6 +319,15 @@ static struct kgdb_io kgdboc_io_ops = {
43001 .post_exception = kgdboc_post_exp_handler,
43002 };
43003
43004 +static struct kgdb_io kgdboc_io_ops_console = {
43005 + .name = "kgdboc",
43006 + .read_char = kgdboc_get_char,
43007 + .write_char = kgdboc_put_char,
43008 + .pre_exception = kgdboc_pre_exp_handler,
43009 + .post_exception = kgdboc_post_exp_handler,
43010 + .is_console = 1
43011 +};
43012 +
43013 #ifdef CONFIG_KGDB_SERIAL_CONSOLE
43014 /* This is only available if kgdboc is a built in for early debugging */
43015 static int __init kgdboc_early_init(char *opt)
43016 diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
43017 index 2769a38..f3dbe48 100644
43018 --- a/drivers/tty/serial/samsung.c
43019 +++ b/drivers/tty/serial/samsung.c
43020 @@ -451,11 +451,16 @@ static void s3c24xx_serial_shutdown(struct uart_port *port)
43021 }
43022 }
43023
43024 +static int s3c64xx_serial_startup(struct uart_port *port);
43025 static int s3c24xx_serial_startup(struct uart_port *port)
43026 {
43027 struct s3c24xx_uart_port *ourport = to_ourport(port);
43028 int ret;
43029
43030 + /* Startup sequence is different for s3c64xx and higher SoC's */
43031 + if (s3c24xx_serial_has_interrupt_mask(port))
43032 + return s3c64xx_serial_startup(port);
43033 +
43034 dbg("s3c24xx_serial_startup: port=%p (%08lx,%p)\n",
43035 port->mapbase, port->membase);
43036
43037 @@ -1120,10 +1125,6 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
43038 /* setup info for port */
43039 port->dev = &platdev->dev;
43040
43041 - /* Startup sequence is different for s3c64xx and higher SoC's */
43042 - if (s3c24xx_serial_has_interrupt_mask(port))
43043 - s3c24xx_serial_ops.startup = s3c64xx_serial_startup;
43044 -
43045 port->uartclk = 1;
43046
43047 if (cfg->uart_flags & UPF_CONS_FLOW) {
43048 diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
43049 index 8fbb6d2..822a9e6 100644
43050 --- a/drivers/tty/serial/serial_core.c
43051 +++ b/drivers/tty/serial/serial_core.c
43052 @@ -1454,7 +1454,7 @@ static void uart_hangup(struct tty_struct *tty)
43053 uart_flush_buffer(tty);
43054 uart_shutdown(tty, state);
43055 spin_lock_irqsave(&port->lock, flags);
43056 - port->count = 0;
43057 + atomic_set(&port->count, 0);
43058 clear_bit(ASYNCB_NORMAL_ACTIVE, &port->flags);
43059 spin_unlock_irqrestore(&port->lock, flags);
43060 tty_port_tty_set(port, NULL);
43061 @@ -1550,7 +1550,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
43062 goto end;
43063 }
43064
43065 - port->count++;
43066 + atomic_inc(&port->count);
43067 if (!state->uart_port || state->uart_port->flags & UPF_DEAD) {
43068 retval = -ENXIO;
43069 goto err_dec_count;
43070 @@ -1578,7 +1578,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
43071 /*
43072 * Make sure the device is in D0 state.
43073 */
43074 - if (port->count == 1)
43075 + if (atomic_read(&port->count) == 1)
43076 uart_change_pm(state, UART_PM_STATE_ON);
43077
43078 /*
43079 @@ -1596,7 +1596,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
43080 end:
43081 return retval;
43082 err_dec_count:
43083 - port->count--;
43084 + atomic_inc(&port->count);
43085 mutex_unlock(&port->mutex);
43086 goto end;
43087 }
43088 diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c
43089 index 8983276..72a4090 100644
43090 --- a/drivers/tty/synclink.c
43091 +++ b/drivers/tty/synclink.c
43092 @@ -3093,7 +3093,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
43093
43094 if (debug_level >= DEBUG_LEVEL_INFO)
43095 printk("%s(%d):mgsl_close(%s) entry, count=%d\n",
43096 - __FILE__,__LINE__, info->device_name, info->port.count);
43097 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
43098
43099 if (tty_port_close_start(&info->port, tty, filp) == 0)
43100 goto cleanup;
43101 @@ -3111,7 +3111,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
43102 cleanup:
43103 if (debug_level >= DEBUG_LEVEL_INFO)
43104 printk("%s(%d):mgsl_close(%s) exit, count=%d\n", __FILE__,__LINE__,
43105 - tty->driver->name, info->port.count);
43106 + tty->driver->name, atomic_read(&info->port.count));
43107
43108 } /* end of mgsl_close() */
43109
43110 @@ -3210,8 +3210,8 @@ static void mgsl_hangup(struct tty_struct *tty)
43111
43112 mgsl_flush_buffer(tty);
43113 shutdown(info);
43114 -
43115 - info->port.count = 0;
43116 +
43117 + atomic_set(&info->port.count, 0);
43118 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
43119 info->port.tty = NULL;
43120
43121 @@ -3300,12 +3300,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
43122
43123 if (debug_level >= DEBUG_LEVEL_INFO)
43124 printk("%s(%d):block_til_ready before block on %s count=%d\n",
43125 - __FILE__,__LINE__, tty->driver->name, port->count );
43126 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43127
43128 spin_lock_irqsave(&info->irq_spinlock, flags);
43129 if (!tty_hung_up_p(filp)) {
43130 extra_count = true;
43131 - port->count--;
43132 + atomic_dec(&port->count);
43133 }
43134 spin_unlock_irqrestore(&info->irq_spinlock, flags);
43135 port->blocked_open++;
43136 @@ -3334,7 +3334,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
43137
43138 if (debug_level >= DEBUG_LEVEL_INFO)
43139 printk("%s(%d):block_til_ready blocking on %s count=%d\n",
43140 - __FILE__,__LINE__, tty->driver->name, port->count );
43141 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43142
43143 tty_unlock(tty);
43144 schedule();
43145 @@ -3346,12 +3346,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
43146
43147 /* FIXME: Racy on hangup during close wait */
43148 if (extra_count)
43149 - port->count++;
43150 + atomic_inc(&port->count);
43151 port->blocked_open--;
43152
43153 if (debug_level >= DEBUG_LEVEL_INFO)
43154 printk("%s(%d):block_til_ready after blocking on %s count=%d\n",
43155 - __FILE__,__LINE__, tty->driver->name, port->count );
43156 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43157
43158 if (!retval)
43159 port->flags |= ASYNC_NORMAL_ACTIVE;
43160 @@ -3403,7 +3403,7 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
43161
43162 if (debug_level >= DEBUG_LEVEL_INFO)
43163 printk("%s(%d):mgsl_open(%s), old ref count = %d\n",
43164 - __FILE__,__LINE__,tty->driver->name, info->port.count);
43165 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
43166
43167 /* If port is closing, signal caller to try again */
43168 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
43169 @@ -3422,10 +3422,10 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
43170 spin_unlock_irqrestore(&info->netlock, flags);
43171 goto cleanup;
43172 }
43173 - info->port.count++;
43174 + atomic_inc(&info->port.count);
43175 spin_unlock_irqrestore(&info->netlock, flags);
43176
43177 - if (info->port.count == 1) {
43178 + if (atomic_read(&info->port.count) == 1) {
43179 /* 1st open on this device, init hardware */
43180 retval = startup(info);
43181 if (retval < 0)
43182 @@ -3449,8 +3449,8 @@ cleanup:
43183 if (retval) {
43184 if (tty->count == 1)
43185 info->port.tty = NULL; /* tty layer will release tty struct */
43186 - if(info->port.count)
43187 - info->port.count--;
43188 + if (atomic_read(&info->port.count))
43189 + atomic_dec(&info->port.count);
43190 }
43191
43192 return retval;
43193 @@ -7668,7 +7668,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
43194 unsigned short new_crctype;
43195
43196 /* return error if TTY interface open */
43197 - if (info->port.count)
43198 + if (atomic_read(&info->port.count))
43199 return -EBUSY;
43200
43201 switch (encoding)
43202 @@ -7763,7 +7763,7 @@ static int hdlcdev_open(struct net_device *dev)
43203
43204 /* arbitrate between network and tty opens */
43205 spin_lock_irqsave(&info->netlock, flags);
43206 - if (info->port.count != 0 || info->netcount != 0) {
43207 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
43208 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
43209 spin_unlock_irqrestore(&info->netlock, flags);
43210 return -EBUSY;
43211 @@ -7849,7 +7849,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
43212 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
43213
43214 /* return error if TTY interface open */
43215 - if (info->port.count)
43216 + if (atomic_read(&info->port.count))
43217 return -EBUSY;
43218
43219 if (cmd != SIOCWANDEV)
43220 diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
43221 index aa9eece..d8baaec 100644
43222 --- a/drivers/tty/synclink_gt.c
43223 +++ b/drivers/tty/synclink_gt.c
43224 @@ -670,7 +670,7 @@ static int open(struct tty_struct *tty, struct file *filp)
43225 tty->driver_data = info;
43226 info->port.tty = tty;
43227
43228 - DBGINFO(("%s open, old ref count = %d\n", info->device_name, info->port.count));
43229 + DBGINFO(("%s open, old ref count = %d\n", info->device_name, atomic_read(&info->port.count)));
43230
43231 /* If port is closing, signal caller to try again */
43232 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
43233 @@ -691,10 +691,10 @@ static int open(struct tty_struct *tty, struct file *filp)
43234 mutex_unlock(&info->port.mutex);
43235 goto cleanup;
43236 }
43237 - info->port.count++;
43238 + atomic_inc(&info->port.count);
43239 spin_unlock_irqrestore(&info->netlock, flags);
43240
43241 - if (info->port.count == 1) {
43242 + if (atomic_read(&info->port.count) == 1) {
43243 /* 1st open on this device, init hardware */
43244 retval = startup(info);
43245 if (retval < 0) {
43246 @@ -715,8 +715,8 @@ cleanup:
43247 if (retval) {
43248 if (tty->count == 1)
43249 info->port.tty = NULL; /* tty layer will release tty struct */
43250 - if(info->port.count)
43251 - info->port.count--;
43252 + if(atomic_read(&info->port.count))
43253 + atomic_dec(&info->port.count);
43254 }
43255
43256 DBGINFO(("%s open rc=%d\n", info->device_name, retval));
43257 @@ -729,7 +729,7 @@ static void close(struct tty_struct *tty, struct file *filp)
43258
43259 if (sanity_check(info, tty->name, "close"))
43260 return;
43261 - DBGINFO(("%s close entry, count=%d\n", info->device_name, info->port.count));
43262 + DBGINFO(("%s close entry, count=%d\n", info->device_name, atomic_read(&info->port.count)));
43263
43264 if (tty_port_close_start(&info->port, tty, filp) == 0)
43265 goto cleanup;
43266 @@ -746,7 +746,7 @@ static void close(struct tty_struct *tty, struct file *filp)
43267 tty_port_close_end(&info->port, tty);
43268 info->port.tty = NULL;
43269 cleanup:
43270 - DBGINFO(("%s close exit, count=%d\n", tty->driver->name, info->port.count));
43271 + DBGINFO(("%s close exit, count=%d\n", tty->driver->name, atomic_read(&info->port.count)));
43272 }
43273
43274 static void hangup(struct tty_struct *tty)
43275 @@ -764,7 +764,7 @@ static void hangup(struct tty_struct *tty)
43276 shutdown(info);
43277
43278 spin_lock_irqsave(&info->port.lock, flags);
43279 - info->port.count = 0;
43280 + atomic_set(&info->port.count, 0);
43281 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
43282 info->port.tty = NULL;
43283 spin_unlock_irqrestore(&info->port.lock, flags);
43284 @@ -1449,7 +1449,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
43285 unsigned short new_crctype;
43286
43287 /* return error if TTY interface open */
43288 - if (info->port.count)
43289 + if (atomic_read(&info->port.count))
43290 return -EBUSY;
43291
43292 DBGINFO(("%s hdlcdev_attach\n", info->device_name));
43293 @@ -1544,7 +1544,7 @@ static int hdlcdev_open(struct net_device *dev)
43294
43295 /* arbitrate between network and tty opens */
43296 spin_lock_irqsave(&info->netlock, flags);
43297 - if (info->port.count != 0 || info->netcount != 0) {
43298 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
43299 DBGINFO(("%s hdlc_open busy\n", dev->name));
43300 spin_unlock_irqrestore(&info->netlock, flags);
43301 return -EBUSY;
43302 @@ -1629,7 +1629,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
43303 DBGINFO(("%s hdlcdev_ioctl\n", dev->name));
43304
43305 /* return error if TTY interface open */
43306 - if (info->port.count)
43307 + if (atomic_read(&info->port.count))
43308 return -EBUSY;
43309
43310 if (cmd != SIOCWANDEV)
43311 @@ -2413,7 +2413,7 @@ static irqreturn_t slgt_interrupt(int dummy, void *dev_id)
43312 if (port == NULL)
43313 continue;
43314 spin_lock(&port->lock);
43315 - if ((port->port.count || port->netcount) &&
43316 + if ((atomic_read(&port->port.count) || port->netcount) &&
43317 port->pending_bh && !port->bh_running &&
43318 !port->bh_requested) {
43319 DBGISR(("%s bh queued\n", port->device_name));
43320 @@ -3302,7 +3302,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
43321 spin_lock_irqsave(&info->lock, flags);
43322 if (!tty_hung_up_p(filp)) {
43323 extra_count = true;
43324 - port->count--;
43325 + atomic_dec(&port->count);
43326 }
43327 spin_unlock_irqrestore(&info->lock, flags);
43328 port->blocked_open++;
43329 @@ -3339,7 +3339,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
43330 remove_wait_queue(&port->open_wait, &wait);
43331
43332 if (extra_count)
43333 - port->count++;
43334 + atomic_inc(&port->count);
43335 port->blocked_open--;
43336
43337 if (!retval)
43338 diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c
43339 index 6d5780c..aa4d8cd 100644
43340 --- a/drivers/tty/synclinkmp.c
43341 +++ b/drivers/tty/synclinkmp.c
43342 @@ -750,7 +750,7 @@ static int open(struct tty_struct *tty, struct file *filp)
43343
43344 if (debug_level >= DEBUG_LEVEL_INFO)
43345 printk("%s(%d):%s open(), old ref count = %d\n",
43346 - __FILE__,__LINE__,tty->driver->name, info->port.count);
43347 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
43348
43349 /* If port is closing, signal caller to try again */
43350 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
43351 @@ -769,10 +769,10 @@ static int open(struct tty_struct *tty, struct file *filp)
43352 spin_unlock_irqrestore(&info->netlock, flags);
43353 goto cleanup;
43354 }
43355 - info->port.count++;
43356 + atomic_inc(&info->port.count);
43357 spin_unlock_irqrestore(&info->netlock, flags);
43358
43359 - if (info->port.count == 1) {
43360 + if (atomic_read(&info->port.count) == 1) {
43361 /* 1st open on this device, init hardware */
43362 retval = startup(info);
43363 if (retval < 0)
43364 @@ -796,8 +796,8 @@ cleanup:
43365 if (retval) {
43366 if (tty->count == 1)
43367 info->port.tty = NULL; /* tty layer will release tty struct */
43368 - if(info->port.count)
43369 - info->port.count--;
43370 + if(atomic_read(&info->port.count))
43371 + atomic_dec(&info->port.count);
43372 }
43373
43374 return retval;
43375 @@ -815,7 +815,7 @@ static void close(struct tty_struct *tty, struct file *filp)
43376
43377 if (debug_level >= DEBUG_LEVEL_INFO)
43378 printk("%s(%d):%s close() entry, count=%d\n",
43379 - __FILE__,__LINE__, info->device_name, info->port.count);
43380 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
43381
43382 if (tty_port_close_start(&info->port, tty, filp) == 0)
43383 goto cleanup;
43384 @@ -834,7 +834,7 @@ static void close(struct tty_struct *tty, struct file *filp)
43385 cleanup:
43386 if (debug_level >= DEBUG_LEVEL_INFO)
43387 printk("%s(%d):%s close() exit, count=%d\n", __FILE__,__LINE__,
43388 - tty->driver->name, info->port.count);
43389 + tty->driver->name, atomic_read(&info->port.count));
43390 }
43391
43392 /* Called by tty_hangup() when a hangup is signaled.
43393 @@ -857,7 +857,7 @@ static void hangup(struct tty_struct *tty)
43394 shutdown(info);
43395
43396 spin_lock_irqsave(&info->port.lock, flags);
43397 - info->port.count = 0;
43398 + atomic_set(&info->port.count, 0);
43399 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
43400 info->port.tty = NULL;
43401 spin_unlock_irqrestore(&info->port.lock, flags);
43402 @@ -1565,7 +1565,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
43403 unsigned short new_crctype;
43404
43405 /* return error if TTY interface open */
43406 - if (info->port.count)
43407 + if (atomic_read(&info->port.count))
43408 return -EBUSY;
43409
43410 switch (encoding)
43411 @@ -1660,7 +1660,7 @@ static int hdlcdev_open(struct net_device *dev)
43412
43413 /* arbitrate between network and tty opens */
43414 spin_lock_irqsave(&info->netlock, flags);
43415 - if (info->port.count != 0 || info->netcount != 0) {
43416 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
43417 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
43418 spin_unlock_irqrestore(&info->netlock, flags);
43419 return -EBUSY;
43420 @@ -1746,7 +1746,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
43421 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
43422
43423 /* return error if TTY interface open */
43424 - if (info->port.count)
43425 + if (atomic_read(&info->port.count))
43426 return -EBUSY;
43427
43428 if (cmd != SIOCWANDEV)
43429 @@ -2620,7 +2620,7 @@ static irqreturn_t synclinkmp_interrupt(int dummy, void *dev_id)
43430 * do not request bottom half processing if the
43431 * device is not open in a normal mode.
43432 */
43433 - if ( port && (port->port.count || port->netcount) &&
43434 + if ( port && (atomic_read(&port->port.count) || port->netcount) &&
43435 port->pending_bh && !port->bh_running &&
43436 !port->bh_requested ) {
43437 if ( debug_level >= DEBUG_LEVEL_ISR )
43438 @@ -3318,12 +3318,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
43439
43440 if (debug_level >= DEBUG_LEVEL_INFO)
43441 printk("%s(%d):%s block_til_ready() before block, count=%d\n",
43442 - __FILE__,__LINE__, tty->driver->name, port->count );
43443 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43444
43445 spin_lock_irqsave(&info->lock, flags);
43446 if (!tty_hung_up_p(filp)) {
43447 extra_count = true;
43448 - port->count--;
43449 + atomic_dec(&port->count);
43450 }
43451 spin_unlock_irqrestore(&info->lock, flags);
43452 port->blocked_open++;
43453 @@ -3352,7 +3352,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
43454
43455 if (debug_level >= DEBUG_LEVEL_INFO)
43456 printk("%s(%d):%s block_til_ready() count=%d\n",
43457 - __FILE__,__LINE__, tty->driver->name, port->count );
43458 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43459
43460 tty_unlock(tty);
43461 schedule();
43462 @@ -3363,12 +3363,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
43463 remove_wait_queue(&port->open_wait, &wait);
43464
43465 if (extra_count)
43466 - port->count++;
43467 + atomic_inc(&port->count);
43468 port->blocked_open--;
43469
43470 if (debug_level >= DEBUG_LEVEL_INFO)
43471 printk("%s(%d):%s block_til_ready() after, count=%d\n",
43472 - __FILE__,__LINE__, tty->driver->name, port->count );
43473 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43474
43475 if (!retval)
43476 port->flags |= ASYNC_NORMAL_ACTIVE;
43477 diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
43478 index 3687f0c..6b9b808 100644
43479 --- a/drivers/tty/sysrq.c
43480 +++ b/drivers/tty/sysrq.c
43481 @@ -995,7 +995,7 @@ EXPORT_SYMBOL(unregister_sysrq_key);
43482 static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf,
43483 size_t count, loff_t *ppos)
43484 {
43485 - if (count) {
43486 + if (count && capable(CAP_SYS_ADMIN)) {
43487 char c;
43488
43489 if (get_user(c, buf))
43490 diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
43491 index a9cd0b9..47b9336 100644
43492 --- a/drivers/tty/tty_io.c
43493 +++ b/drivers/tty/tty_io.c
43494 @@ -3398,7 +3398,7 @@ EXPORT_SYMBOL_GPL(get_current_tty);
43495
43496 void tty_default_fops(struct file_operations *fops)
43497 {
43498 - *fops = tty_fops;
43499 + memcpy((void *)fops, &tty_fops, sizeof(tty_fops));
43500 }
43501
43502 /*
43503 diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
43504 index d794087..e4f49e5 100644
43505 --- a/drivers/tty/tty_ldisc.c
43506 +++ b/drivers/tty/tty_ldisc.c
43507 @@ -56,7 +56,7 @@ static void put_ldisc(struct tty_ldisc *ld)
43508 if (atomic_dec_and_test(&ld->users)) {
43509 struct tty_ldisc_ops *ldo = ld->ops;
43510
43511 - ldo->refcount--;
43512 + atomic_dec(&ldo->refcount);
43513 module_put(ldo->owner);
43514 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
43515
43516 @@ -93,7 +93,7 @@ int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc)
43517 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
43518 tty_ldiscs[disc] = new_ldisc;
43519 new_ldisc->num = disc;
43520 - new_ldisc->refcount = 0;
43521 + atomic_set(&new_ldisc->refcount, 0);
43522 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
43523
43524 return ret;
43525 @@ -121,7 +121,7 @@ int tty_unregister_ldisc(int disc)
43526 return -EINVAL;
43527
43528 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
43529 - if (tty_ldiscs[disc]->refcount)
43530 + if (atomic_read(&tty_ldiscs[disc]->refcount))
43531 ret = -EBUSY;
43532 else
43533 tty_ldiscs[disc] = NULL;
43534 @@ -142,7 +142,7 @@ static struct tty_ldisc_ops *get_ldops(int disc)
43535 if (ldops) {
43536 ret = ERR_PTR(-EAGAIN);
43537 if (try_module_get(ldops->owner)) {
43538 - ldops->refcount++;
43539 + atomic_inc(&ldops->refcount);
43540 ret = ldops;
43541 }
43542 }
43543 @@ -155,7 +155,7 @@ static void put_ldops(struct tty_ldisc_ops *ldops)
43544 unsigned long flags;
43545
43546 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
43547 - ldops->refcount--;
43548 + atomic_dec(&ldops->refcount);
43549 module_put(ldops->owner);
43550 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
43551 }
43552 diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
43553 index b7ff59d..7c6105e 100644
43554 --- a/drivers/tty/tty_port.c
43555 +++ b/drivers/tty/tty_port.c
43556 @@ -218,7 +218,7 @@ void tty_port_hangup(struct tty_port *port)
43557 unsigned long flags;
43558
43559 spin_lock_irqsave(&port->lock, flags);
43560 - port->count = 0;
43561 + atomic_set(&port->count, 0);
43562 port->flags &= ~ASYNC_NORMAL_ACTIVE;
43563 if (port->tty) {
43564 set_bit(TTY_IO_ERROR, &port->tty->flags);
43565 @@ -344,7 +344,7 @@ int tty_port_block_til_ready(struct tty_port *port,
43566 /* The port lock protects the port counts */
43567 spin_lock_irqsave(&port->lock, flags);
43568 if (!tty_hung_up_p(filp))
43569 - port->count--;
43570 + atomic_dec(&port->count);
43571 port->blocked_open++;
43572 spin_unlock_irqrestore(&port->lock, flags);
43573
43574 @@ -386,7 +386,7 @@ int tty_port_block_til_ready(struct tty_port *port,
43575 we must not mess that up further */
43576 spin_lock_irqsave(&port->lock, flags);
43577 if (!tty_hung_up_p(filp))
43578 - port->count++;
43579 + atomic_inc(&port->count);
43580 port->blocked_open--;
43581 if (retval == 0)
43582 port->flags |= ASYNC_NORMAL_ACTIVE;
43583 @@ -406,19 +406,19 @@ int tty_port_close_start(struct tty_port *port,
43584 return 0;
43585 }
43586
43587 - if (tty->count == 1 && port->count != 1) {
43588 + if (tty->count == 1 && atomic_read(&port->count) != 1) {
43589 printk(KERN_WARNING
43590 "tty_port_close_start: tty->count = 1 port count = %d.\n",
43591 - port->count);
43592 - port->count = 1;
43593 + atomic_read(&port->count));
43594 + atomic_set(&port->count, 1);
43595 }
43596 - if (--port->count < 0) {
43597 + if (atomic_dec_return(&port->count) < 0) {
43598 printk(KERN_WARNING "tty_port_close_start: count = %d\n",
43599 - port->count);
43600 - port->count = 0;
43601 + atomic_read(&port->count));
43602 + atomic_set(&port->count, 0);
43603 }
43604
43605 - if (port->count) {
43606 + if (atomic_read(&port->count)) {
43607 spin_unlock_irqrestore(&port->lock, flags);
43608 if (port->ops->drop)
43609 port->ops->drop(port);
43610 @@ -516,7 +516,7 @@ int tty_port_open(struct tty_port *port, struct tty_struct *tty,
43611 {
43612 spin_lock_irq(&port->lock);
43613 if (!tty_hung_up_p(filp))
43614 - ++port->count;
43615 + atomic_inc(&port->count);
43616 spin_unlock_irq(&port->lock);
43617 tty_port_tty_set(port, tty);
43618
43619 diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
43620 index a9af1b9a..1e08e7f 100644
43621 --- a/drivers/tty/vt/keyboard.c
43622 +++ b/drivers/tty/vt/keyboard.c
43623 @@ -647,6 +647,16 @@ static void k_spec(struct vc_data *vc, unsigned char value, char up_flag)
43624 kbd->kbdmode == VC_OFF) &&
43625 value != KVAL(K_SAK))
43626 return; /* SAK is allowed even in raw mode */
43627 +
43628 +#if defined(CONFIG_GRKERNSEC_PROC) || defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
43629 + {
43630 + void *func = fn_handler[value];
43631 + if (func == fn_show_state || func == fn_show_ptregs ||
43632 + func == fn_show_mem)
43633 + return;
43634 + }
43635 +#endif
43636 +
43637 fn_handler[value](vc);
43638 }
43639
43640 @@ -1795,9 +1805,6 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
43641 if (copy_from_user(&tmp, user_kbe, sizeof(struct kbentry)))
43642 return -EFAULT;
43643
43644 - if (!capable(CAP_SYS_TTY_CONFIG))
43645 - perm = 0;
43646 -
43647 switch (cmd) {
43648 case KDGKBENT:
43649 /* Ensure another thread doesn't free it under us */
43650 @@ -1812,6 +1819,9 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
43651 spin_unlock_irqrestore(&kbd_event_lock, flags);
43652 return put_user(val, &user_kbe->kb_value);
43653 case KDSKBENT:
43654 + if (!capable(CAP_SYS_TTY_CONFIG))
43655 + perm = 0;
43656 +
43657 if (!perm)
43658 return -EPERM;
43659 if (!i && v == K_NOSUCHMAP) {
43660 @@ -1902,9 +1912,6 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
43661 int i, j, k;
43662 int ret;
43663
43664 - if (!capable(CAP_SYS_TTY_CONFIG))
43665 - perm = 0;
43666 -
43667 kbs = kmalloc(sizeof(*kbs), GFP_KERNEL);
43668 if (!kbs) {
43669 ret = -ENOMEM;
43670 @@ -1938,6 +1945,9 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
43671 kfree(kbs);
43672 return ((p && *p) ? -EOVERFLOW : 0);
43673 case KDSKBSENT:
43674 + if (!capable(CAP_SYS_TTY_CONFIG))
43675 + perm = 0;
43676 +
43677 if (!perm) {
43678 ret = -EPERM;
43679 goto reterr;
43680 diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
43681 index c8b9262..7e824e6 100644
43682 --- a/drivers/uio/uio.c
43683 +++ b/drivers/uio/uio.c
43684 @@ -25,6 +25,7 @@
43685 #include <linux/kobject.h>
43686 #include <linux/cdev.h>
43687 #include <linux/uio_driver.h>
43688 +#include <asm/local.h>
43689
43690 #define UIO_MAX_DEVICES (1U << MINORBITS)
43691
43692 @@ -32,10 +33,10 @@ struct uio_device {
43693 struct module *owner;
43694 struct device *dev;
43695 int minor;
43696 - atomic_t event;
43697 + atomic_unchecked_t event;
43698 struct fasync_struct *async_queue;
43699 wait_queue_head_t wait;
43700 - int vma_count;
43701 + local_t vma_count;
43702 struct uio_info *info;
43703 struct kobject *map_dir;
43704 struct kobject *portio_dir;
43705 @@ -242,7 +243,7 @@ static ssize_t show_event(struct device *dev,
43706 struct device_attribute *attr, char *buf)
43707 {
43708 struct uio_device *idev = dev_get_drvdata(dev);
43709 - return sprintf(buf, "%u\n", (unsigned int)atomic_read(&idev->event));
43710 + return sprintf(buf, "%u\n", (unsigned int)atomic_read_unchecked(&idev->event));
43711 }
43712
43713 static struct device_attribute uio_class_attributes[] = {
43714 @@ -397,7 +398,7 @@ void uio_event_notify(struct uio_info *info)
43715 {
43716 struct uio_device *idev = info->uio_dev;
43717
43718 - atomic_inc(&idev->event);
43719 + atomic_inc_unchecked(&idev->event);
43720 wake_up_interruptible(&idev->wait);
43721 kill_fasync(&idev->async_queue, SIGIO, POLL_IN);
43722 }
43723 @@ -450,7 +451,7 @@ static int uio_open(struct inode *inode, struct file *filep)
43724 }
43725
43726 listener->dev = idev;
43727 - listener->event_count = atomic_read(&idev->event);
43728 + listener->event_count = atomic_read_unchecked(&idev->event);
43729 filep->private_data = listener;
43730
43731 if (idev->info->open) {
43732 @@ -501,7 +502,7 @@ static unsigned int uio_poll(struct file *filep, poll_table *wait)
43733 return -EIO;
43734
43735 poll_wait(filep, &idev->wait, wait);
43736 - if (listener->event_count != atomic_read(&idev->event))
43737 + if (listener->event_count != atomic_read_unchecked(&idev->event))
43738 return POLLIN | POLLRDNORM;
43739 return 0;
43740 }
43741 @@ -526,7 +527,7 @@ static ssize_t uio_read(struct file *filep, char __user *buf,
43742 do {
43743 set_current_state(TASK_INTERRUPTIBLE);
43744
43745 - event_count = atomic_read(&idev->event);
43746 + event_count = atomic_read_unchecked(&idev->event);
43747 if (event_count != listener->event_count) {
43748 if (copy_to_user(buf, &event_count, count))
43749 retval = -EFAULT;
43750 @@ -595,13 +596,13 @@ static int uio_find_mem_index(struct vm_area_struct *vma)
43751 static void uio_vma_open(struct vm_area_struct *vma)
43752 {
43753 struct uio_device *idev = vma->vm_private_data;
43754 - idev->vma_count++;
43755 + local_inc(&idev->vma_count);
43756 }
43757
43758 static void uio_vma_close(struct vm_area_struct *vma)
43759 {
43760 struct uio_device *idev = vma->vm_private_data;
43761 - idev->vma_count--;
43762 + local_dec(&idev->vma_count);
43763 }
43764
43765 static int uio_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
43766 @@ -808,7 +809,7 @@ int __uio_register_device(struct module *owner,
43767 idev->owner = owner;
43768 idev->info = info;
43769 init_waitqueue_head(&idev->wait);
43770 - atomic_set(&idev->event, 0);
43771 + atomic_set_unchecked(&idev->event, 0);
43772
43773 ret = uio_get_minor(idev);
43774 if (ret)
43775 diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
43776 index b7eb86a..36d28af 100644
43777 --- a/drivers/usb/atm/cxacru.c
43778 +++ b/drivers/usb/atm/cxacru.c
43779 @@ -473,7 +473,7 @@ static ssize_t cxacru_sysfs_store_adsl_config(struct device *dev,
43780 ret = sscanf(buf + pos, "%x=%x%n", &index, &value, &tmp);
43781 if (ret < 2)
43782 return -EINVAL;
43783 - if (index < 0 || index > 0x7f)
43784 + if (index > 0x7f)
43785 return -EINVAL;
43786 pos += tmp;
43787
43788 diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
43789 index 35f10bf..6a38a0b 100644
43790 --- a/drivers/usb/atm/usbatm.c
43791 +++ b/drivers/usb/atm/usbatm.c
43792 @@ -333,7 +333,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
43793 if (printk_ratelimit())
43794 atm_warn(instance, "%s: OAM not supported (vpi %d, vci %d)!\n",
43795 __func__, vpi, vci);
43796 - atomic_inc(&vcc->stats->rx_err);
43797 + atomic_inc_unchecked(&vcc->stats->rx_err);
43798 return;
43799 }
43800
43801 @@ -361,7 +361,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
43802 if (length > ATM_MAX_AAL5_PDU) {
43803 atm_rldbg(instance, "%s: bogus length %u (vcc: 0x%p)!\n",
43804 __func__, length, vcc);
43805 - atomic_inc(&vcc->stats->rx_err);
43806 + atomic_inc_unchecked(&vcc->stats->rx_err);
43807 goto out;
43808 }
43809
43810 @@ -370,14 +370,14 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
43811 if (sarb->len < pdu_length) {
43812 atm_rldbg(instance, "%s: bogus pdu_length %u (sarb->len: %u, vcc: 0x%p)!\n",
43813 __func__, pdu_length, sarb->len, vcc);
43814 - atomic_inc(&vcc->stats->rx_err);
43815 + atomic_inc_unchecked(&vcc->stats->rx_err);
43816 goto out;
43817 }
43818
43819 if (crc32_be(~0, skb_tail_pointer(sarb) - pdu_length, pdu_length) != 0xc704dd7b) {
43820 atm_rldbg(instance, "%s: packet failed crc check (vcc: 0x%p)!\n",
43821 __func__, vcc);
43822 - atomic_inc(&vcc->stats->rx_err);
43823 + atomic_inc_unchecked(&vcc->stats->rx_err);
43824 goto out;
43825 }
43826
43827 @@ -389,7 +389,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
43828 if (printk_ratelimit())
43829 atm_err(instance, "%s: no memory for skb (length: %u)!\n",
43830 __func__, length);
43831 - atomic_inc(&vcc->stats->rx_drop);
43832 + atomic_inc_unchecked(&vcc->stats->rx_drop);
43833 goto out;
43834 }
43835
43836 @@ -417,7 +417,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
43837
43838 vcc->push(vcc, skb);
43839
43840 - atomic_inc(&vcc->stats->rx);
43841 + atomic_inc_unchecked(&vcc->stats->rx);
43842 out:
43843 skb_trim(sarb, 0);
43844 }
43845 @@ -623,7 +623,7 @@ static void usbatm_tx_process(unsigned long data)
43846 struct atm_vcc *vcc = UDSL_SKB(skb)->atm.vcc;
43847
43848 usbatm_pop(vcc, skb);
43849 - atomic_inc(&vcc->stats->tx);
43850 + atomic_inc_unchecked(&vcc->stats->tx);
43851
43852 skb = skb_dequeue(&instance->sndqueue);
43853 }
43854 @@ -779,11 +779,11 @@ static int usbatm_atm_proc_read(struct atm_dev *atm_dev, loff_t * pos, char *pag
43855 if (!left--)
43856 return sprintf(page,
43857 "AAL5: tx %d ( %d err ), rx %d ( %d err, %d drop )\n",
43858 - atomic_read(&atm_dev->stats.aal5.tx),
43859 - atomic_read(&atm_dev->stats.aal5.tx_err),
43860 - atomic_read(&atm_dev->stats.aal5.rx),
43861 - atomic_read(&atm_dev->stats.aal5.rx_err),
43862 - atomic_read(&atm_dev->stats.aal5.rx_drop));
43863 + atomic_read_unchecked(&atm_dev->stats.aal5.tx),
43864 + atomic_read_unchecked(&atm_dev->stats.aal5.tx_err),
43865 + atomic_read_unchecked(&atm_dev->stats.aal5.rx),
43866 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_err),
43867 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_drop));
43868
43869 if (!left--) {
43870 if (instance->disconnected)
43871 diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
43872 index 2a3bbdf..91d72cf 100644
43873 --- a/drivers/usb/core/devices.c
43874 +++ b/drivers/usb/core/devices.c
43875 @@ -126,7 +126,7 @@ static const char format_endpt[] =
43876 * time it gets called.
43877 */
43878 static struct device_connect_event {
43879 - atomic_t count;
43880 + atomic_unchecked_t count;
43881 wait_queue_head_t wait;
43882 } device_event = {
43883 .count = ATOMIC_INIT(1),
43884 @@ -164,7 +164,7 @@ static const struct class_info clas_info[] = {
43885
43886 void usbfs_conn_disc_event(void)
43887 {
43888 - atomic_add(2, &device_event.count);
43889 + atomic_add_unchecked(2, &device_event.count);
43890 wake_up(&device_event.wait);
43891 }
43892
43893 @@ -652,7 +652,7 @@ static unsigned int usb_device_poll(struct file *file,
43894
43895 poll_wait(file, &device_event.wait, wait);
43896
43897 - event_count = atomic_read(&device_event.count);
43898 + event_count = atomic_read_unchecked(&device_event.count);
43899 if (file->f_version != event_count) {
43900 file->f_version = event_count;
43901 return POLLIN | POLLRDNORM;
43902 diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
43903 index f9ec44c..eb5779f 100644
43904 --- a/drivers/usb/core/hcd.c
43905 +++ b/drivers/usb/core/hcd.c
43906 @@ -1526,7 +1526,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
43907 */
43908 usb_get_urb(urb);
43909 atomic_inc(&urb->use_count);
43910 - atomic_inc(&urb->dev->urbnum);
43911 + atomic_inc_unchecked(&urb->dev->urbnum);
43912 usbmon_urb_submit(&hcd->self, urb);
43913
43914 /* NOTE requirements on root-hub callers (usbfs and the hub
43915 @@ -1553,7 +1553,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
43916 urb->hcpriv = NULL;
43917 INIT_LIST_HEAD(&urb->urb_list);
43918 atomic_dec(&urb->use_count);
43919 - atomic_dec(&urb->dev->urbnum);
43920 + atomic_dec_unchecked(&urb->dev->urbnum);
43921 if (atomic_read(&urb->reject))
43922 wake_up(&usb_kill_urb_queue);
43923 usb_put_urb(urb);
43924 diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
43925 index 444d30e..f15c850 100644
43926 --- a/drivers/usb/core/message.c
43927 +++ b/drivers/usb/core/message.c
43928 @@ -129,7 +129,7 @@ static int usb_internal_control_msg(struct usb_device *usb_dev,
43929 * method can wait for it to complete. Since you don't have a handle on the
43930 * URB used, you can't cancel the request.
43931 */
43932 -int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
43933 +int __intentional_overflow(-1) usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
43934 __u8 requesttype, __u16 value, __u16 index, void *data,
43935 __u16 size, int timeout)
43936 {
43937 diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
43938 index 3f81a3d..a3aa993 100644
43939 --- a/drivers/usb/core/sysfs.c
43940 +++ b/drivers/usb/core/sysfs.c
43941 @@ -239,7 +239,7 @@ show_urbnum(struct device *dev, struct device_attribute *attr, char *buf)
43942 struct usb_device *udev;
43943
43944 udev = to_usb_device(dev);
43945 - return sprintf(buf, "%d\n", atomic_read(&udev->urbnum));
43946 + return sprintf(buf, "%d\n", atomic_read_unchecked(&udev->urbnum));
43947 }
43948 static DEVICE_ATTR(urbnum, S_IRUGO, show_urbnum, NULL);
43949
43950 diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
43951 index f81b925..78d22ec 100644
43952 --- a/drivers/usb/core/usb.c
43953 +++ b/drivers/usb/core/usb.c
43954 @@ -388,7 +388,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
43955 set_dev_node(&dev->dev, dev_to_node(bus->controller));
43956 dev->state = USB_STATE_ATTACHED;
43957 dev->lpm_disable_count = 1;
43958 - atomic_set(&dev->urbnum, 0);
43959 + atomic_set_unchecked(&dev->urbnum, 0);
43960
43961 INIT_LIST_HEAD(&dev->ep0.urb_list);
43962 dev->ep0.desc.bLength = USB_DT_ENDPOINT_SIZE;
43963 diff --git a/drivers/usb/early/ehci-dbgp.c b/drivers/usb/early/ehci-dbgp.c
43964 index 5e29dde..eca992f 100644
43965 --- a/drivers/usb/early/ehci-dbgp.c
43966 +++ b/drivers/usb/early/ehci-dbgp.c
43967 @@ -98,7 +98,8 @@ static inline u32 dbgp_len_update(u32 x, u32 len)
43968
43969 #ifdef CONFIG_KGDB
43970 static struct kgdb_io kgdbdbgp_io_ops;
43971 -#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops)
43972 +static struct kgdb_io kgdbdbgp_io_ops_console;
43973 +#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops || dbg_io_ops == &kgdbdbgp_io_ops_console)
43974 #else
43975 #define dbgp_kgdb_mode (0)
43976 #endif
43977 @@ -1047,6 +1048,13 @@ static struct kgdb_io kgdbdbgp_io_ops = {
43978 .write_char = kgdbdbgp_write_char,
43979 };
43980
43981 +static struct kgdb_io kgdbdbgp_io_ops_console = {
43982 + .name = "kgdbdbgp",
43983 + .read_char = kgdbdbgp_read_char,
43984 + .write_char = kgdbdbgp_write_char,
43985 + .is_console = 1
43986 +};
43987 +
43988 static int kgdbdbgp_wait_time;
43989
43990 static int __init kgdbdbgp_parse_config(char *str)
43991 @@ -1062,8 +1070,10 @@ static int __init kgdbdbgp_parse_config(char *str)
43992 ptr++;
43993 kgdbdbgp_wait_time = simple_strtoul(ptr, &ptr, 10);
43994 }
43995 - kgdb_register_io_module(&kgdbdbgp_io_ops);
43996 - kgdbdbgp_io_ops.is_console = early_dbgp_console.index != -1;
43997 + if (early_dbgp_console.index != -1)
43998 + kgdb_register_io_module(&kgdbdbgp_io_ops_console);
43999 + else
44000 + kgdb_register_io_module(&kgdbdbgp_io_ops);
44001
44002 return 0;
44003 }
44004 diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c
44005 index b369292..9f3ba40 100644
44006 --- a/drivers/usb/gadget/u_serial.c
44007 +++ b/drivers/usb/gadget/u_serial.c
44008 @@ -733,9 +733,9 @@ static int gs_open(struct tty_struct *tty, struct file *file)
44009 spin_lock_irq(&port->port_lock);
44010
44011 /* already open? Great. */
44012 - if (port->port.count) {
44013 + if (atomic_read(&port->port.count)) {
44014 status = 0;
44015 - port->port.count++;
44016 + atomic_inc(&port->port.count);
44017
44018 /* currently opening/closing? wait ... */
44019 } else if (port->openclose) {
44020 @@ -794,7 +794,7 @@ static int gs_open(struct tty_struct *tty, struct file *file)
44021 tty->driver_data = port;
44022 port->port.tty = tty;
44023
44024 - port->port.count = 1;
44025 + atomic_set(&port->port.count, 1);
44026 port->openclose = false;
44027
44028 /* if connected, start the I/O stream */
44029 @@ -836,11 +836,11 @@ static void gs_close(struct tty_struct *tty, struct file *file)
44030
44031 spin_lock_irq(&port->port_lock);
44032
44033 - if (port->port.count != 1) {
44034 - if (port->port.count == 0)
44035 + if (atomic_read(&port->port.count) != 1) {
44036 + if (atomic_read(&port->port.count) == 0)
44037 WARN_ON(1);
44038 else
44039 - --port->port.count;
44040 + atomic_dec(&port->port.count);
44041 goto exit;
44042 }
44043
44044 @@ -850,7 +850,7 @@ static void gs_close(struct tty_struct *tty, struct file *file)
44045 * and sleep if necessary
44046 */
44047 port->openclose = true;
44048 - port->port.count = 0;
44049 + atomic_set(&port->port.count, 0);
44050
44051 gser = port->port_usb;
44052 if (gser && gser->disconnect)
44053 @@ -1066,7 +1066,7 @@ static int gs_closed(struct gs_port *port)
44054 int cond;
44055
44056 spin_lock_irq(&port->port_lock);
44057 - cond = (port->port.count == 0) && !port->openclose;
44058 + cond = (atomic_read(&port->port.count) == 0) && !port->openclose;
44059 spin_unlock_irq(&port->port_lock);
44060 return cond;
44061 }
44062 @@ -1209,7 +1209,7 @@ int gserial_connect(struct gserial *gser, u8 port_num)
44063 /* if it's already open, start I/O ... and notify the serial
44064 * protocol about open/close status (connect/disconnect).
44065 */
44066 - if (port->port.count) {
44067 + if (atomic_read(&port->port.count)) {
44068 pr_debug("gserial_connect: start ttyGS%d\n", port->port_num);
44069 gs_start_io(port);
44070 if (gser->connect)
44071 @@ -1256,7 +1256,7 @@ void gserial_disconnect(struct gserial *gser)
44072
44073 port->port_usb = NULL;
44074 gser->ioport = NULL;
44075 - if (port->port.count > 0 || port->openclose) {
44076 + if (atomic_read(&port->port.count) > 0 || port->openclose) {
44077 wake_up_interruptible(&port->drain_wait);
44078 if (port->port.tty)
44079 tty_hangup(port->port.tty);
44080 @@ -1272,7 +1272,7 @@ void gserial_disconnect(struct gserial *gser)
44081
44082 /* finally, free any unused/unusable I/O buffers */
44083 spin_lock_irqsave(&port->port_lock, flags);
44084 - if (port->port.count == 0 && !port->openclose)
44085 + if (atomic_read(&port->port.count) == 0 && !port->openclose)
44086 gs_buf_free(&port->port_write_buf);
44087 gs_free_requests(gser->out, &port->read_pool, NULL);
44088 gs_free_requests(gser->out, &port->read_queue, NULL);
44089 diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
44090 index 5f3bcd3..bfca43f 100644
44091 --- a/drivers/usb/serial/console.c
44092 +++ b/drivers/usb/serial/console.c
44093 @@ -124,7 +124,7 @@ static int usb_console_setup(struct console *co, char *options)
44094
44095 info->port = port;
44096
44097 - ++port->port.count;
44098 + atomic_inc(&port->port.count);
44099 if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) {
44100 if (serial->type->set_termios) {
44101 /*
44102 @@ -174,7 +174,7 @@ static int usb_console_setup(struct console *co, char *options)
44103 }
44104 /* Now that any required fake tty operations are completed restore
44105 * the tty port count */
44106 - --port->port.count;
44107 + atomic_dec(&port->port.count);
44108 /* The console is special in terms of closing the device so
44109 * indicate this port is now acting as a system console. */
44110 port->port.console = 1;
44111 @@ -187,7 +187,7 @@ static int usb_console_setup(struct console *co, char *options)
44112 free_tty:
44113 kfree(tty);
44114 reset_open_count:
44115 - port->port.count = 0;
44116 + atomic_set(&port->port.count, 0);
44117 usb_autopm_put_interface(serial->interface);
44118 error_get_interface:
44119 usb_serial_put(serial);
44120 diff --git a/drivers/usb/storage/realtek_cr.c b/drivers/usb/storage/realtek_cr.c
44121 index 6c3586a..a94e621 100644
44122 --- a/drivers/usb/storage/realtek_cr.c
44123 +++ b/drivers/usb/storage/realtek_cr.c
44124 @@ -429,7 +429,7 @@ static int rts51x_read_status(struct us_data *us,
44125
44126 buf = kmalloc(len, GFP_NOIO);
44127 if (buf == NULL)
44128 - return USB_STOR_TRANSPORT_ERROR;
44129 + return -ENOMEM;
44130
44131 US_DEBUGP("%s, lun = %d\n", __func__, lun);
44132
44133 diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
44134 index 75f70f0..d467e1a 100644
44135 --- a/drivers/usb/storage/usb.h
44136 +++ b/drivers/usb/storage/usb.h
44137 @@ -63,7 +63,7 @@ struct us_unusual_dev {
44138 __u8 useProtocol;
44139 __u8 useTransport;
44140 int (*initFunction)(struct us_data *);
44141 -};
44142 +} __do_const;
44143
44144
44145 /* Dynamic bitflag definitions (us->dflags): used in set_bit() etc. */
44146 diff --git a/drivers/usb/wusbcore/wa-hc.h b/drivers/usb/wusbcore/wa-hc.h
44147 index d6bea3e..60b250e 100644
44148 --- a/drivers/usb/wusbcore/wa-hc.h
44149 +++ b/drivers/usb/wusbcore/wa-hc.h
44150 @@ -192,7 +192,7 @@ struct wahc {
44151 struct list_head xfer_delayed_list;
44152 spinlock_t xfer_list_lock;
44153 struct work_struct xfer_work;
44154 - atomic_t xfer_id_count;
44155 + atomic_unchecked_t xfer_id_count;
44156 };
44157
44158
44159 @@ -246,7 +246,7 @@ static inline void wa_init(struct wahc *wa)
44160 INIT_LIST_HEAD(&wa->xfer_delayed_list);
44161 spin_lock_init(&wa->xfer_list_lock);
44162 INIT_WORK(&wa->xfer_work, wa_urb_enqueue_run);
44163 - atomic_set(&wa->xfer_id_count, 1);
44164 + atomic_set_unchecked(&wa->xfer_id_count, 1);
44165 }
44166
44167 /**
44168 diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c
44169 index 6ef94bc..1b41265 100644
44170 --- a/drivers/usb/wusbcore/wa-xfer.c
44171 +++ b/drivers/usb/wusbcore/wa-xfer.c
44172 @@ -296,7 +296,7 @@ out:
44173 */
44174 static void wa_xfer_id_init(struct wa_xfer *xfer)
44175 {
44176 - xfer->id = atomic_add_return(1, &xfer->wa->xfer_id_count);
44177 + xfer->id = atomic_add_return_unchecked(1, &xfer->wa->xfer_id_count);
44178 }
44179
44180 /*
44181 diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c
44182 index 8c55011..eed4ae1a 100644
44183 --- a/drivers/video/aty/aty128fb.c
44184 +++ b/drivers/video/aty/aty128fb.c
44185 @@ -149,7 +149,7 @@ enum {
44186 };
44187
44188 /* Must match above enum */
44189 -static char * const r128_family[] = {
44190 +static const char * const r128_family[] = {
44191 "AGP",
44192 "PCI",
44193 "PRO AGP",
44194 diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
44195 index 4f27fdc..d3537e6 100644
44196 --- a/drivers/video/aty/atyfb_base.c
44197 +++ b/drivers/video/aty/atyfb_base.c
44198 @@ -1325,10 +1325,14 @@ static int atyfb_set_par(struct fb_info *info)
44199 par->accel_flags = var->accel_flags; /* hack */
44200
44201 if (var->accel_flags) {
44202 - info->fbops->fb_sync = atyfb_sync;
44203 + pax_open_kernel();
44204 + *(void **)&info->fbops->fb_sync = atyfb_sync;
44205 + pax_close_kernel();
44206 info->flags &= ~FBINFO_HWACCEL_DISABLED;
44207 } else {
44208 - info->fbops->fb_sync = NULL;
44209 + pax_open_kernel();
44210 + *(void **)&info->fbops->fb_sync = NULL;
44211 + pax_close_kernel();
44212 info->flags |= FBINFO_HWACCEL_DISABLED;
44213 }
44214
44215 diff --git a/drivers/video/aty/mach64_cursor.c b/drivers/video/aty/mach64_cursor.c
44216 index 95ec042..e6affdd 100644
44217 --- a/drivers/video/aty/mach64_cursor.c
44218 +++ b/drivers/video/aty/mach64_cursor.c
44219 @@ -7,6 +7,7 @@
44220 #include <linux/string.h>
44221
44222 #include <asm/io.h>
44223 +#include <asm/pgtable.h>
44224
44225 #ifdef __sparc__
44226 #include <asm/fbio.h>
44227 @@ -208,7 +209,9 @@ int aty_init_cursor(struct fb_info *info)
44228 info->sprite.buf_align = 16; /* and 64 lines tall. */
44229 info->sprite.flags = FB_PIXMAP_IO;
44230
44231 - info->fbops->fb_cursor = atyfb_cursor;
44232 + pax_open_kernel();
44233 + *(void **)&info->fbops->fb_cursor = atyfb_cursor;
44234 + pax_close_kernel();
44235
44236 return 0;
44237 }
44238 diff --git a/drivers/video/backlight/kb3886_bl.c b/drivers/video/backlight/kb3886_bl.c
44239 index 6c5ed6b..b727c88 100644
44240 --- a/drivers/video/backlight/kb3886_bl.c
44241 +++ b/drivers/video/backlight/kb3886_bl.c
44242 @@ -78,7 +78,7 @@ static struct kb3886bl_machinfo *bl_machinfo;
44243 static unsigned long kb3886bl_flags;
44244 #define KB3886BL_SUSPENDED 0x01
44245
44246 -static struct dmi_system_id __initdata kb3886bl_device_table[] = {
44247 +static const struct dmi_system_id __initconst kb3886bl_device_table[] = {
44248 {
44249 .ident = "Sahara Touch-iT",
44250 .matches = {
44251 diff --git a/drivers/video/fb_defio.c b/drivers/video/fb_defio.c
44252 index 900aa4e..6d49418 100644
44253 --- a/drivers/video/fb_defio.c
44254 +++ b/drivers/video/fb_defio.c
44255 @@ -206,7 +206,9 @@ void fb_deferred_io_init(struct fb_info *info)
44256
44257 BUG_ON(!fbdefio);
44258 mutex_init(&fbdefio->lock);
44259 - info->fbops->fb_mmap = fb_deferred_io_mmap;
44260 + pax_open_kernel();
44261 + *(void **)&info->fbops->fb_mmap = fb_deferred_io_mmap;
44262 + pax_close_kernel();
44263 INIT_DELAYED_WORK(&info->deferred_work, fb_deferred_io_work);
44264 INIT_LIST_HEAD(&fbdefio->pagelist);
44265 if (fbdefio->delay == 0) /* set a default of 1 s */
44266 @@ -237,7 +239,7 @@ void fb_deferred_io_cleanup(struct fb_info *info)
44267 page->mapping = NULL;
44268 }
44269
44270 - info->fbops->fb_mmap = NULL;
44271 + *(void **)&info->fbops->fb_mmap = NULL;
44272 mutex_destroy(&fbdefio->lock);
44273 }
44274 EXPORT_SYMBOL_GPL(fb_deferred_io_cleanup);
44275 diff --git a/drivers/video/fbcmap.c b/drivers/video/fbcmap.c
44276 index 5c3960d..15cf8fc 100644
44277 --- a/drivers/video/fbcmap.c
44278 +++ b/drivers/video/fbcmap.c
44279 @@ -285,8 +285,7 @@ int fb_set_user_cmap(struct fb_cmap_user *cmap, struct fb_info *info)
44280 rc = -ENODEV;
44281 goto out;
44282 }
44283 - if (cmap->start < 0 || (!info->fbops->fb_setcolreg &&
44284 - !info->fbops->fb_setcmap)) {
44285 + if (!info->fbops->fb_setcolreg && !info->fbops->fb_setcmap) {
44286 rc = -EINVAL;
44287 goto out1;
44288 }
44289 diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
44290 index 86291dc..7cc5962 100644
44291 --- a/drivers/video/fbmem.c
44292 +++ b/drivers/video/fbmem.c
44293 @@ -428,7 +428,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
44294 image->dx += image->width + 8;
44295 }
44296 } else if (rotate == FB_ROTATE_UD) {
44297 - for (x = 0; x < num && image->dx >= 0; x++) {
44298 + for (x = 0; x < num && (__s32)image->dx >= 0; x++) {
44299 info->fbops->fb_imageblit(info, image);
44300 image->dx -= image->width + 8;
44301 }
44302 @@ -440,7 +440,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
44303 image->dy += image->height + 8;
44304 }
44305 } else if (rotate == FB_ROTATE_CCW) {
44306 - for (x = 0; x < num && image->dy >= 0; x++) {
44307 + for (x = 0; x < num && (__s32)image->dy >= 0; x++) {
44308 info->fbops->fb_imageblit(info, image);
44309 image->dy -= image->height + 8;
44310 }
44311 @@ -1166,7 +1166,7 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
44312 return -EFAULT;
44313 if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES)
44314 return -EINVAL;
44315 - if (con2fb.framebuffer < 0 || con2fb.framebuffer >= FB_MAX)
44316 + if (con2fb.framebuffer >= FB_MAX)
44317 return -EINVAL;
44318 if (!registered_fb[con2fb.framebuffer])
44319 request_module("fb%d", con2fb.framebuffer);
44320 diff --git a/drivers/video/i810/i810_accel.c b/drivers/video/i810/i810_accel.c
44321 index 7672d2e..b56437f 100644
44322 --- a/drivers/video/i810/i810_accel.c
44323 +++ b/drivers/video/i810/i810_accel.c
44324 @@ -73,6 +73,7 @@ static inline int wait_for_space(struct fb_info *info, u32 space)
44325 }
44326 }
44327 printk("ringbuffer lockup!!!\n");
44328 + printk("head:%u tail:%u iring.size:%u space:%u\n", head, tail, par->iring.size, space);
44329 i810_report_error(mmio);
44330 par->dev_flags |= LOCKUP;
44331 info->pixmap.scan_align = 1;
44332 diff --git a/drivers/video/logo/logo_linux_clut224.ppm b/drivers/video/logo/logo_linux_clut224.ppm
44333 index 3c14e43..eafa544 100644
44334 --- a/drivers/video/logo/logo_linux_clut224.ppm
44335 +++ b/drivers/video/logo/logo_linux_clut224.ppm
44336 @@ -1,1604 +1,1123 @@
44337 P3
44338 -# Standard 224-color Linux logo
44339 80 80
44340 255
44341 - 0 0 0 0 0 0 0 0 0 0 0 0
44342 - 0 0 0 0 0 0 0 0 0 0 0 0
44343 - 0 0 0 0 0 0 0 0 0 0 0 0
44344 - 0 0 0 0 0 0 0 0 0 0 0 0
44345 - 0 0 0 0 0 0 0 0 0 0 0 0
44346 - 0 0 0 0 0 0 0 0 0 0 0 0
44347 - 0 0 0 0 0 0 0 0 0 0 0 0
44348 - 0 0 0 0 0 0 0 0 0 0 0 0
44349 - 0 0 0 0 0 0 0 0 0 0 0 0
44350 - 6 6 6 6 6 6 10 10 10 10 10 10
44351 - 10 10 10 6 6 6 6 6 6 6 6 6
44352 - 0 0 0 0 0 0 0 0 0 0 0 0
44353 - 0 0 0 0 0 0 0 0 0 0 0 0
44354 - 0 0 0 0 0 0 0 0 0 0 0 0
44355 - 0 0 0 0 0 0 0 0 0 0 0 0
44356 - 0 0 0 0 0 0 0 0 0 0 0 0
44357 - 0 0 0 0 0 0 0 0 0 0 0 0
44358 - 0 0 0 0 0 0 0 0 0 0 0 0
44359 - 0 0 0 0 0 0 0 0 0 0 0 0
44360 - 0 0 0 0 0 0 0 0 0 0 0 0
44361 - 0 0 0 0 0 0 0 0 0 0 0 0
44362 - 0 0 0 0 0 0 0 0 0 0 0 0
44363 - 0 0 0 0 0 0 0 0 0 0 0 0
44364 - 0 0 0 0 0 0 0 0 0 0 0 0
44365 - 0 0 0 0 0 0 0 0 0 0 0 0
44366 - 0 0 0 0 0 0 0 0 0 0 0 0
44367 - 0 0 0 0 0 0 0 0 0 0 0 0
44368 - 0 0 0 0 0 0 0 0 0 0 0 0
44369 - 0 0 0 6 6 6 10 10 10 14 14 14
44370 - 22 22 22 26 26 26 30 30 30 34 34 34
44371 - 30 30 30 30 30 30 26 26 26 18 18 18
44372 - 14 14 14 10 10 10 6 6 6 0 0 0
44373 - 0 0 0 0 0 0 0 0 0 0 0 0
44374 - 0 0 0 0 0 0 0 0 0 0 0 0
44375 - 0 0 0 0 0 0 0 0 0 0 0 0
44376 - 0 0 0 0 0 0 0 0 0 0 0 0
44377 - 0 0 0 0 0 0 0 0 0 0 0 0
44378 - 0 0 0 0 0 0 0 0 0 0 0 0
44379 - 0 0 0 0 0 0 0 0 0 0 0 0
44380 - 0 0 0 0 0 0 0 0 0 0 0 0
44381 - 0 0 0 0 0 0 0 0 0 0 0 0
44382 - 0 0 0 0 0 1 0 0 1 0 0 0
44383 - 0 0 0 0 0 0 0 0 0 0 0 0
44384 - 0 0 0 0 0 0 0 0 0 0 0 0
44385 - 0 0 0 0 0 0 0 0 0 0 0 0
44386 - 0 0 0 0 0 0 0 0 0 0 0 0
44387 - 0 0 0 0 0 0 0 0 0 0 0 0
44388 - 0 0 0 0 0 0 0 0 0 0 0 0
44389 - 6 6 6 14 14 14 26 26 26 42 42 42
44390 - 54 54 54 66 66 66 78 78 78 78 78 78
44391 - 78 78 78 74 74 74 66 66 66 54 54 54
44392 - 42 42 42 26 26 26 18 18 18 10 10 10
44393 - 6 6 6 0 0 0 0 0 0 0 0 0
44394 - 0 0 0 0 0 0 0 0 0 0 0 0
44395 - 0 0 0 0 0 0 0 0 0 0 0 0
44396 - 0 0 0 0 0 0 0 0 0 0 0 0
44397 - 0 0 0 0 0 0 0 0 0 0 0 0
44398 - 0 0 0 0 0 0 0 0 0 0 0 0
44399 - 0 0 0 0 0 0 0 0 0 0 0 0
44400 - 0 0 0 0 0 0 0 0 0 0 0 0
44401 - 0 0 0 0 0 0 0 0 0 0 0 0
44402 - 0 0 1 0 0 0 0 0 0 0 0 0
44403 - 0 0 0 0 0 0 0 0 0 0 0 0
44404 - 0 0 0 0 0 0 0 0 0 0 0 0
44405 - 0 0 0 0 0 0 0 0 0 0 0 0
44406 - 0 0 0 0 0 0 0 0 0 0 0 0
44407 - 0 0 0 0 0 0 0 0 0 0 0 0
44408 - 0 0 0 0 0 0 0 0 0 10 10 10
44409 - 22 22 22 42 42 42 66 66 66 86 86 86
44410 - 66 66 66 38 38 38 38 38 38 22 22 22
44411 - 26 26 26 34 34 34 54 54 54 66 66 66
44412 - 86 86 86 70 70 70 46 46 46 26 26 26
44413 - 14 14 14 6 6 6 0 0 0 0 0 0
44414 - 0 0 0 0 0 0 0 0 0 0 0 0
44415 - 0 0 0 0 0 0 0 0 0 0 0 0
44416 - 0 0 0 0 0 0 0 0 0 0 0 0
44417 - 0 0 0 0 0 0 0 0 0 0 0 0
44418 - 0 0 0 0 0 0 0 0 0 0 0 0
44419 - 0 0 0 0 0 0 0 0 0 0 0 0
44420 - 0 0 0 0 0 0 0 0 0 0 0 0
44421 - 0 0 0 0 0 0 0 0 0 0 0 0
44422 - 0 0 1 0 0 1 0 0 1 0 0 0
44423 - 0 0 0 0 0 0 0 0 0 0 0 0
44424 - 0 0 0 0 0 0 0 0 0 0 0 0
44425 - 0 0 0 0 0 0 0 0 0 0 0 0
44426 - 0 0 0 0 0 0 0 0 0 0 0 0
44427 - 0 0 0 0 0 0 0 0 0 0 0 0
44428 - 0 0 0 0 0 0 10 10 10 26 26 26
44429 - 50 50 50 82 82 82 58 58 58 6 6 6
44430 - 2 2 6 2 2 6 2 2 6 2 2 6
44431 - 2 2 6 2 2 6 2 2 6 2 2 6
44432 - 6 6 6 54 54 54 86 86 86 66 66 66
44433 - 38 38 38 18 18 18 6 6 6 0 0 0
44434 - 0 0 0 0 0 0 0 0 0 0 0 0
44435 - 0 0 0 0 0 0 0 0 0 0 0 0
44436 - 0 0 0 0 0 0 0 0 0 0 0 0
44437 - 0 0 0 0 0 0 0 0 0 0 0 0
44438 - 0 0 0 0 0 0 0 0 0 0 0 0
44439 - 0 0 0 0 0 0 0 0 0 0 0 0
44440 - 0 0 0 0 0 0 0 0 0 0 0 0
44441 - 0 0 0 0 0 0 0 0 0 0 0 0
44442 - 0 0 0 0 0 0 0 0 0 0 0 0
44443 - 0 0 0 0 0 0 0 0 0 0 0 0
44444 - 0 0 0 0 0 0 0 0 0 0 0 0
44445 - 0 0 0 0 0 0 0 0 0 0 0 0
44446 - 0 0 0 0 0 0 0 0 0 0 0 0
44447 - 0 0 0 0 0 0 0 0 0 0 0 0
44448 - 0 0 0 6 6 6 22 22 22 50 50 50
44449 - 78 78 78 34 34 34 2 2 6 2 2 6
44450 - 2 2 6 2 2 6 2 2 6 2 2 6
44451 - 2 2 6 2 2 6 2 2 6 2 2 6
44452 - 2 2 6 2 2 6 6 6 6 70 70 70
44453 - 78 78 78 46 46 46 22 22 22 6 6 6
44454 - 0 0 0 0 0 0 0 0 0 0 0 0
44455 - 0 0 0 0 0 0 0 0 0 0 0 0
44456 - 0 0 0 0 0 0 0 0 0 0 0 0
44457 - 0 0 0 0 0 0 0 0 0 0 0 0
44458 - 0 0 0 0 0 0 0 0 0 0 0 0
44459 - 0 0 0 0 0 0 0 0 0 0 0 0
44460 - 0 0 0 0 0 0 0 0 0 0 0 0
44461 - 0 0 0 0 0 0 0 0 0 0 0 0
44462 - 0 0 1 0 0 1 0 0 1 0 0 0
44463 - 0 0 0 0 0 0 0 0 0 0 0 0
44464 - 0 0 0 0 0 0 0 0 0 0 0 0
44465 - 0 0 0 0 0 0 0 0 0 0 0 0
44466 - 0 0 0 0 0 0 0 0 0 0 0 0
44467 - 0 0 0 0 0 0 0 0 0 0 0 0
44468 - 6 6 6 18 18 18 42 42 42 82 82 82
44469 - 26 26 26 2 2 6 2 2 6 2 2 6
44470 - 2 2 6 2 2 6 2 2 6 2 2 6
44471 - 2 2 6 2 2 6 2 2 6 14 14 14
44472 - 46 46 46 34 34 34 6 6 6 2 2 6
44473 - 42 42 42 78 78 78 42 42 42 18 18 18
44474 - 6 6 6 0 0 0 0 0 0 0 0 0
44475 - 0 0 0 0 0 0 0 0 0 0 0 0
44476 - 0 0 0 0 0 0 0 0 0 0 0 0
44477 - 0 0 0 0 0 0 0 0 0 0 0 0
44478 - 0 0 0 0 0 0 0 0 0 0 0 0
44479 - 0 0 0 0 0 0 0 0 0 0 0 0
44480 - 0 0 0 0 0 0 0 0 0 0 0 0
44481 - 0 0 0 0 0 0 0 0 0 0 0 0
44482 - 0 0 1 0 0 0 0 0 1 0 0 0
44483 - 0 0 0 0 0 0 0 0 0 0 0 0
44484 - 0 0 0 0 0 0 0 0 0 0 0 0
44485 - 0 0 0 0 0 0 0 0 0 0 0 0
44486 - 0 0 0 0 0 0 0 0 0 0 0 0
44487 - 0 0 0 0 0 0 0 0 0 0 0 0
44488 - 10 10 10 30 30 30 66 66 66 58 58 58
44489 - 2 2 6 2 2 6 2 2 6 2 2 6
44490 - 2 2 6 2 2 6 2 2 6 2 2 6
44491 - 2 2 6 2 2 6 2 2 6 26 26 26
44492 - 86 86 86 101 101 101 46 46 46 10 10 10
44493 - 2 2 6 58 58 58 70 70 70 34 34 34
44494 - 10 10 10 0 0 0 0 0 0 0 0 0
44495 - 0 0 0 0 0 0 0 0 0 0 0 0
44496 - 0 0 0 0 0 0 0 0 0 0 0 0
44497 - 0 0 0 0 0 0 0 0 0 0 0 0
44498 - 0 0 0 0 0 0 0 0 0 0 0 0
44499 - 0 0 0 0 0 0 0 0 0 0 0 0
44500 - 0 0 0 0 0 0 0 0 0 0 0 0
44501 - 0 0 0 0 0 0 0 0 0 0 0 0
44502 - 0 0 1 0 0 1 0 0 1 0 0 0
44503 - 0 0 0 0 0 0 0 0 0 0 0 0
44504 - 0 0 0 0 0 0 0 0 0 0 0 0
44505 - 0 0 0 0 0 0 0 0 0 0 0 0
44506 - 0 0 0 0 0 0 0 0 0 0 0 0
44507 - 0 0 0 0 0 0 0 0 0 0 0 0
44508 - 14 14 14 42 42 42 86 86 86 10 10 10
44509 - 2 2 6 2 2 6 2 2 6 2 2 6
44510 - 2 2 6 2 2 6 2 2 6 2 2 6
44511 - 2 2 6 2 2 6 2 2 6 30 30 30
44512 - 94 94 94 94 94 94 58 58 58 26 26 26
44513 - 2 2 6 6 6 6 78 78 78 54 54 54
44514 - 22 22 22 6 6 6 0 0 0 0 0 0
44515 - 0 0 0 0 0 0 0 0 0 0 0 0
44516 - 0 0 0 0 0 0 0 0 0 0 0 0
44517 - 0 0 0 0 0 0 0 0 0 0 0 0
44518 - 0 0 0 0 0 0 0 0 0 0 0 0
44519 - 0 0 0 0 0 0 0 0 0 0 0 0
44520 - 0 0 0 0 0 0 0 0 0 0 0 0
44521 - 0 0 0 0 0 0 0 0 0 0 0 0
44522 - 0 0 0 0 0 0 0 0 0 0 0 0
44523 - 0 0 0 0 0 0 0 0 0 0 0 0
44524 - 0 0 0 0 0 0 0 0 0 0 0 0
44525 - 0 0 0 0 0 0 0 0 0 0 0 0
44526 - 0 0 0 0 0 0 0 0 0 0 0 0
44527 - 0 0 0 0 0 0 0 0 0 6 6 6
44528 - 22 22 22 62 62 62 62 62 62 2 2 6
44529 - 2 2 6 2 2 6 2 2 6 2 2 6
44530 - 2 2 6 2 2 6 2 2 6 2 2 6
44531 - 2 2 6 2 2 6 2 2 6 26 26 26
44532 - 54 54 54 38 38 38 18 18 18 10 10 10
44533 - 2 2 6 2 2 6 34 34 34 82 82 82
44534 - 38 38 38 14 14 14 0 0 0 0 0 0
44535 - 0 0 0 0 0 0 0 0 0 0 0 0
44536 - 0 0 0 0 0 0 0 0 0 0 0 0
44537 - 0 0 0 0 0 0 0 0 0 0 0 0
44538 - 0 0 0 0 0 0 0 0 0 0 0 0
44539 - 0 0 0 0 0 0 0 0 0 0 0 0
44540 - 0 0 0 0 0 0 0 0 0 0 0 0
44541 - 0 0 0 0 0 0 0 0 0 0 0 0
44542 - 0 0 0 0 0 1 0 0 1 0 0 0
44543 - 0 0 0 0 0 0 0 0 0 0 0 0
44544 - 0 0 0 0 0 0 0 0 0 0 0 0
44545 - 0 0 0 0 0 0 0 0 0 0 0 0
44546 - 0 0 0 0 0 0 0 0 0 0 0 0
44547 - 0 0 0 0 0 0 0 0 0 6 6 6
44548 - 30 30 30 78 78 78 30 30 30 2 2 6
44549 - 2 2 6 2 2 6 2 2 6 2 2 6
44550 - 2 2 6 2 2 6 2 2 6 2 2 6
44551 - 2 2 6 2 2 6 2 2 6 10 10 10
44552 - 10 10 10 2 2 6 2 2 6 2 2 6
44553 - 2 2 6 2 2 6 2 2 6 78 78 78
44554 - 50 50 50 18 18 18 6 6 6 0 0 0
44555 - 0 0 0 0 0 0 0 0 0 0 0 0
44556 - 0 0 0 0 0 0 0 0 0 0 0 0
44557 - 0 0 0 0 0 0 0 0 0 0 0 0
44558 - 0 0 0 0 0 0 0 0 0 0 0 0
44559 - 0 0 0 0 0 0 0 0 0 0 0 0
44560 - 0 0 0 0 0 0 0 0 0 0 0 0
44561 - 0 0 0 0 0 0 0 0 0 0 0 0
44562 - 0 0 1 0 0 0 0 0 0 0 0 0
44563 - 0 0 0 0 0 0 0 0 0 0 0 0
44564 - 0 0 0 0 0 0 0 0 0 0 0 0
44565 - 0 0 0 0 0 0 0 0 0 0 0 0
44566 - 0 0 0 0 0 0 0 0 0 0 0 0
44567 - 0 0 0 0 0 0 0 0 0 10 10 10
44568 - 38 38 38 86 86 86 14 14 14 2 2 6
44569 - 2 2 6 2 2 6 2 2 6 2 2 6
44570 - 2 2 6 2 2 6 2 2 6 2 2 6
44571 - 2 2 6 2 2 6 2 2 6 2 2 6
44572 - 2 2 6 2 2 6 2 2 6 2 2 6
44573 - 2 2 6 2 2 6 2 2 6 54 54 54
44574 - 66 66 66 26 26 26 6 6 6 0 0 0
44575 - 0 0 0 0 0 0 0 0 0 0 0 0
44576 - 0 0 0 0 0 0 0 0 0 0 0 0
44577 - 0 0 0 0 0 0 0 0 0 0 0 0
44578 - 0 0 0 0 0 0 0 0 0 0 0 0
44579 - 0 0 0 0 0 0 0 0 0 0 0 0
44580 - 0 0 0 0 0 0 0 0 0 0 0 0
44581 - 0 0 0 0 0 0 0 0 0 0 0 0
44582 - 0 0 0 0 0 1 0 0 1 0 0 0
44583 - 0 0 0 0 0 0 0 0 0 0 0 0
44584 - 0 0 0 0 0 0 0 0 0 0 0 0
44585 - 0 0 0 0 0 0 0 0 0 0 0 0
44586 - 0 0 0 0 0 0 0 0 0 0 0 0
44587 - 0 0 0 0 0 0 0 0 0 14 14 14
44588 - 42 42 42 82 82 82 2 2 6 2 2 6
44589 - 2 2 6 6 6 6 10 10 10 2 2 6
44590 - 2 2 6 2 2 6 2 2 6 2 2 6
44591 - 2 2 6 2 2 6 2 2 6 6 6 6
44592 - 14 14 14 10 10 10 2 2 6 2 2 6
44593 - 2 2 6 2 2 6 2 2 6 18 18 18
44594 - 82 82 82 34 34 34 10 10 10 0 0 0
44595 - 0 0 0 0 0 0 0 0 0 0 0 0
44596 - 0 0 0 0 0 0 0 0 0 0 0 0
44597 - 0 0 0 0 0 0 0 0 0 0 0 0
44598 - 0 0 0 0 0 0 0 0 0 0 0 0
44599 - 0 0 0 0 0 0 0 0 0 0 0 0
44600 - 0 0 0 0 0 0 0 0 0 0 0 0
44601 - 0 0 0 0 0 0 0 0 0 0 0 0
44602 - 0 0 1 0 0 0 0 0 0 0 0 0
44603 - 0 0 0 0 0 0 0 0 0 0 0 0
44604 - 0 0 0 0 0 0 0 0 0 0 0 0
44605 - 0 0 0 0 0 0 0 0 0 0 0 0
44606 - 0 0 0 0 0 0 0 0 0 0 0 0
44607 - 0 0 0 0 0 0 0 0 0 14 14 14
44608 - 46 46 46 86 86 86 2 2 6 2 2 6
44609 - 6 6 6 6 6 6 22 22 22 34 34 34
44610 - 6 6 6 2 2 6 2 2 6 2 2 6
44611 - 2 2 6 2 2 6 18 18 18 34 34 34
44612 - 10 10 10 50 50 50 22 22 22 2 2 6
44613 - 2 2 6 2 2 6 2 2 6 10 10 10
44614 - 86 86 86 42 42 42 14 14 14 0 0 0
44615 - 0 0 0 0 0 0 0 0 0 0 0 0
44616 - 0 0 0 0 0 0 0 0 0 0 0 0
44617 - 0 0 0 0 0 0 0 0 0 0 0 0
44618 - 0 0 0 0 0 0 0 0 0 0 0 0
44619 - 0 0 0 0 0 0 0 0 0 0 0 0
44620 - 0 0 0 0 0 0 0 0 0 0 0 0
44621 - 0 0 0 0 0 0 0 0 0 0 0 0
44622 - 0 0 1 0 0 1 0 0 1 0 0 0
44623 - 0 0 0 0 0 0 0 0 0 0 0 0
44624 - 0 0 0 0 0 0 0 0 0 0 0 0
44625 - 0 0 0 0 0 0 0 0 0 0 0 0
44626 - 0 0 0 0 0 0 0 0 0 0 0 0
44627 - 0 0 0 0 0 0 0 0 0 14 14 14
44628 - 46 46 46 86 86 86 2 2 6 2 2 6
44629 - 38 38 38 116 116 116 94 94 94 22 22 22
44630 - 22 22 22 2 2 6 2 2 6 2 2 6
44631 - 14 14 14 86 86 86 138 138 138 162 162 162
44632 -154 154 154 38 38 38 26 26 26 6 6 6
44633 - 2 2 6 2 2 6 2 2 6 2 2 6
44634 - 86 86 86 46 46 46 14 14 14 0 0 0
44635 - 0 0 0 0 0 0 0 0 0 0 0 0
44636 - 0 0 0 0 0 0 0 0 0 0 0 0
44637 - 0 0 0 0 0 0 0 0 0 0 0 0
44638 - 0 0 0 0 0 0 0 0 0 0 0 0
44639 - 0 0 0 0 0 0 0 0 0 0 0 0
44640 - 0 0 0 0 0 0 0 0 0 0 0 0
44641 - 0 0 0 0 0 0 0 0 0 0 0 0
44642 - 0 0 0 0 0 0 0 0 0 0 0 0
44643 - 0 0 0 0 0 0 0 0 0 0 0 0
44644 - 0 0 0 0 0 0 0 0 0 0 0 0
44645 - 0 0 0 0 0 0 0 0 0 0 0 0
44646 - 0 0 0 0 0 0 0 0 0 0 0 0
44647 - 0 0 0 0 0 0 0 0 0 14 14 14
44648 - 46 46 46 86 86 86 2 2 6 14 14 14
44649 -134 134 134 198 198 198 195 195 195 116 116 116
44650 - 10 10 10 2 2 6 2 2 6 6 6 6
44651 -101 98 89 187 187 187 210 210 210 218 218 218
44652 -214 214 214 134 134 134 14 14 14 6 6 6
44653 - 2 2 6 2 2 6 2 2 6 2 2 6
44654 - 86 86 86 50 50 50 18 18 18 6 6 6
44655 - 0 0 0 0 0 0 0 0 0 0 0 0
44656 - 0 0 0 0 0 0 0 0 0 0 0 0
44657 - 0 0 0 0 0 0 0 0 0 0 0 0
44658 - 0 0 0 0 0 0 0 0 0 0 0 0
44659 - 0 0 0 0 0 0 0 0 0 0 0 0
44660 - 0 0 0 0 0 0 0 0 0 0 0 0
44661 - 0 0 0 0 0 0 0 0 1 0 0 0
44662 - 0 0 1 0 0 1 0 0 1 0 0 0
44663 - 0 0 0 0 0 0 0 0 0 0 0 0
44664 - 0 0 0 0 0 0 0 0 0 0 0 0
44665 - 0 0 0 0 0 0 0 0 0 0 0 0
44666 - 0 0 0 0 0 0 0 0 0 0 0 0
44667 - 0 0 0 0 0 0 0 0 0 14 14 14
44668 - 46 46 46 86 86 86 2 2 6 54 54 54
44669 -218 218 218 195 195 195 226 226 226 246 246 246
44670 - 58 58 58 2 2 6 2 2 6 30 30 30
44671 -210 210 210 253 253 253 174 174 174 123 123 123
44672 -221 221 221 234 234 234 74 74 74 2 2 6
44673 - 2 2 6 2 2 6 2 2 6 2 2 6
44674 - 70 70 70 58 58 58 22 22 22 6 6 6
44675 - 0 0 0 0 0 0 0 0 0 0 0 0
44676 - 0 0 0 0 0 0 0 0 0 0 0 0
44677 - 0 0 0 0 0 0 0 0 0 0 0 0
44678 - 0 0 0 0 0 0 0 0 0 0 0 0
44679 - 0 0 0 0 0 0 0 0 0 0 0 0
44680 - 0 0 0 0 0 0 0 0 0 0 0 0
44681 - 0 0 0 0 0 0 0 0 0 0 0 0
44682 - 0 0 0 0 0 0 0 0 0 0 0 0
44683 - 0 0 0 0 0 0 0 0 0 0 0 0
44684 - 0 0 0 0 0 0 0 0 0 0 0 0
44685 - 0 0 0 0 0 0 0 0 0 0 0 0
44686 - 0 0 0 0 0 0 0 0 0 0 0 0
44687 - 0 0 0 0 0 0 0 0 0 14 14 14
44688 - 46 46 46 82 82 82 2 2 6 106 106 106
44689 -170 170 170 26 26 26 86 86 86 226 226 226
44690 -123 123 123 10 10 10 14 14 14 46 46 46
44691 -231 231 231 190 190 190 6 6 6 70 70 70
44692 - 90 90 90 238 238 238 158 158 158 2 2 6
44693 - 2 2 6 2 2 6 2 2 6 2 2 6
44694 - 70 70 70 58 58 58 22 22 22 6 6 6
44695 - 0 0 0 0 0 0 0 0 0 0 0 0
44696 - 0 0 0 0 0 0 0 0 0 0 0 0
44697 - 0 0 0 0 0 0 0 0 0 0 0 0
44698 - 0 0 0 0 0 0 0 0 0 0 0 0
44699 - 0 0 0 0 0 0 0 0 0 0 0 0
44700 - 0 0 0 0 0 0 0 0 0 0 0 0
44701 - 0 0 0 0 0 0 0 0 1 0 0 0
44702 - 0 0 1 0 0 1 0 0 1 0 0 0
44703 - 0 0 0 0 0 0 0 0 0 0 0 0
44704 - 0 0 0 0 0 0 0 0 0 0 0 0
44705 - 0 0 0 0 0 0 0 0 0 0 0 0
44706 - 0 0 0 0 0 0 0 0 0 0 0 0
44707 - 0 0 0 0 0 0 0 0 0 14 14 14
44708 - 42 42 42 86 86 86 6 6 6 116 116 116
44709 -106 106 106 6 6 6 70 70 70 149 149 149
44710 -128 128 128 18 18 18 38 38 38 54 54 54
44711 -221 221 221 106 106 106 2 2 6 14 14 14
44712 - 46 46 46 190 190 190 198 198 198 2 2 6
44713 - 2 2 6 2 2 6 2 2 6 2 2 6
44714 - 74 74 74 62 62 62 22 22 22 6 6 6
44715 - 0 0 0 0 0 0 0 0 0 0 0 0
44716 - 0 0 0 0 0 0 0 0 0 0 0 0
44717 - 0 0 0 0 0 0 0 0 0 0 0 0
44718 - 0 0 0 0 0 0 0 0 0 0 0 0
44719 - 0 0 0 0 0 0 0 0 0 0 0 0
44720 - 0 0 0 0 0 0 0 0 0 0 0 0
44721 - 0 0 0 0 0 0 0 0 1 0 0 0
44722 - 0 0 1 0 0 0 0 0 1 0 0 0
44723 - 0 0 0 0 0 0 0 0 0 0 0 0
44724 - 0 0 0 0 0 0 0 0 0 0 0 0
44725 - 0 0 0 0 0 0 0 0 0 0 0 0
44726 - 0 0 0 0 0 0 0 0 0 0 0 0
44727 - 0 0 0 0 0 0 0 0 0 14 14 14
44728 - 42 42 42 94 94 94 14 14 14 101 101 101
44729 -128 128 128 2 2 6 18 18 18 116 116 116
44730 -118 98 46 121 92 8 121 92 8 98 78 10
44731 -162 162 162 106 106 106 2 2 6 2 2 6
44732 - 2 2 6 195 195 195 195 195 195 6 6 6
44733 - 2 2 6 2 2 6 2 2 6 2 2 6
44734 - 74 74 74 62 62 62 22 22 22 6 6 6
44735 - 0 0 0 0 0 0 0 0 0 0 0 0
44736 - 0 0 0 0 0 0 0 0 0 0 0 0
44737 - 0 0 0 0 0 0 0 0 0 0 0 0
44738 - 0 0 0 0 0 0 0 0 0 0 0 0
44739 - 0 0 0 0 0 0 0 0 0 0 0 0
44740 - 0 0 0 0 0 0 0 0 0 0 0 0
44741 - 0 0 0 0 0 0 0 0 1 0 0 1
44742 - 0 0 1 0 0 0 0 0 1 0 0 0
44743 - 0 0 0 0 0 0 0 0 0 0 0 0
44744 - 0 0 0 0 0 0 0 0 0 0 0 0
44745 - 0 0 0 0 0 0 0 0 0 0 0 0
44746 - 0 0 0 0 0 0 0 0 0 0 0 0
44747 - 0 0 0 0 0 0 0 0 0 10 10 10
44748 - 38 38 38 90 90 90 14 14 14 58 58 58
44749 -210 210 210 26 26 26 54 38 6 154 114 10
44750 -226 170 11 236 186 11 225 175 15 184 144 12
44751 -215 174 15 175 146 61 37 26 9 2 2 6
44752 - 70 70 70 246 246 246 138 138 138 2 2 6
44753 - 2 2 6 2 2 6 2 2 6 2 2 6
44754 - 70 70 70 66 66 66 26 26 26 6 6 6
44755 - 0 0 0 0 0 0 0 0 0 0 0 0
44756 - 0 0 0 0 0 0 0 0 0 0 0 0
44757 - 0 0 0 0 0 0 0 0 0 0 0 0
44758 - 0 0 0 0 0 0 0 0 0 0 0 0
44759 - 0 0 0 0 0 0 0 0 0 0 0 0
44760 - 0 0 0 0 0 0 0 0 0 0 0 0
44761 - 0 0 0 0 0 0 0 0 0 0 0 0
44762 - 0 0 0 0 0 0 0 0 0 0 0 0
44763 - 0 0 0 0 0 0 0 0 0 0 0 0
44764 - 0 0 0 0 0 0 0 0 0 0 0 0
44765 - 0 0 0 0 0 0 0 0 0 0 0 0
44766 - 0 0 0 0 0 0 0 0 0 0 0 0
44767 - 0 0 0 0 0 0 0 0 0 10 10 10
44768 - 38 38 38 86 86 86 14 14 14 10 10 10
44769 -195 195 195 188 164 115 192 133 9 225 175 15
44770 -239 182 13 234 190 10 232 195 16 232 200 30
44771 -245 207 45 241 208 19 232 195 16 184 144 12
44772 -218 194 134 211 206 186 42 42 42 2 2 6
44773 - 2 2 6 2 2 6 2 2 6 2 2 6
44774 - 50 50 50 74 74 74 30 30 30 6 6 6
44775 - 0 0 0 0 0 0 0 0 0 0 0 0
44776 - 0 0 0 0 0 0 0 0 0 0 0 0
44777 - 0 0 0 0 0 0 0 0 0 0 0 0
44778 - 0 0 0 0 0 0 0 0 0 0 0 0
44779 - 0 0 0 0 0 0 0 0 0 0 0 0
44780 - 0 0 0 0 0 0 0 0 0 0 0 0
44781 - 0 0 0 0 0 0 0 0 0 0 0 0
44782 - 0 0 0 0 0 0 0 0 0 0 0 0
44783 - 0 0 0 0 0 0 0 0 0 0 0 0
44784 - 0 0 0 0 0 0 0 0 0 0 0 0
44785 - 0 0 0 0 0 0 0 0 0 0 0 0
44786 - 0 0 0 0 0 0 0 0 0 0 0 0
44787 - 0 0 0 0 0 0 0 0 0 10 10 10
44788 - 34 34 34 86 86 86 14 14 14 2 2 6
44789 -121 87 25 192 133 9 219 162 10 239 182 13
44790 -236 186 11 232 195 16 241 208 19 244 214 54
44791 -246 218 60 246 218 38 246 215 20 241 208 19
44792 -241 208 19 226 184 13 121 87 25 2 2 6
44793 - 2 2 6 2 2 6 2 2 6 2 2 6
44794 - 50 50 50 82 82 82 34 34 34 10 10 10
44795 - 0 0 0 0 0 0 0 0 0 0 0 0
44796 - 0 0 0 0 0 0 0 0 0 0 0 0
44797 - 0 0 0 0 0 0 0 0 0 0 0 0
44798 - 0 0 0 0 0 0 0 0 0 0 0 0
44799 - 0 0 0 0 0 0 0 0 0 0 0 0
44800 - 0 0 0 0 0 0 0 0 0 0 0 0
44801 - 0 0 0 0 0 0 0 0 0 0 0 0
44802 - 0 0 0 0 0 0 0 0 0 0 0 0
44803 - 0 0 0 0 0 0 0 0 0 0 0 0
44804 - 0 0 0 0 0 0 0 0 0 0 0 0
44805 - 0 0 0 0 0 0 0 0 0 0 0 0
44806 - 0 0 0 0 0 0 0 0 0 0 0 0
44807 - 0 0 0 0 0 0 0 0 0 10 10 10
44808 - 34 34 34 82 82 82 30 30 30 61 42 6
44809 -180 123 7 206 145 10 230 174 11 239 182 13
44810 -234 190 10 238 202 15 241 208 19 246 218 74
44811 -246 218 38 246 215 20 246 215 20 246 215 20
44812 -226 184 13 215 174 15 184 144 12 6 6 6
44813 - 2 2 6 2 2 6 2 2 6 2 2 6
44814 - 26 26 26 94 94 94 42 42 42 14 14 14
44815 - 0 0 0 0 0 0 0 0 0 0 0 0
44816 - 0 0 0 0 0 0 0 0 0 0 0 0
44817 - 0 0 0 0 0 0 0 0 0 0 0 0
44818 - 0 0 0 0 0 0 0 0 0 0 0 0
44819 - 0 0 0 0 0 0 0 0 0 0 0 0
44820 - 0 0 0 0 0 0 0 0 0 0 0 0
44821 - 0 0 0 0 0 0 0 0 0 0 0 0
44822 - 0 0 0 0 0 0 0 0 0 0 0 0
44823 - 0 0 0 0 0 0 0 0 0 0 0 0
44824 - 0 0 0 0 0 0 0 0 0 0 0 0
44825 - 0 0 0 0 0 0 0 0 0 0 0 0
44826 - 0 0 0 0 0 0 0 0 0 0 0 0
44827 - 0 0 0 0 0 0 0 0 0 10 10 10
44828 - 30 30 30 78 78 78 50 50 50 104 69 6
44829 -192 133 9 216 158 10 236 178 12 236 186 11
44830 -232 195 16 241 208 19 244 214 54 245 215 43
44831 -246 215 20 246 215 20 241 208 19 198 155 10
44832 -200 144 11 216 158 10 156 118 10 2 2 6
44833 - 2 2 6 2 2 6 2 2 6 2 2 6
44834 - 6 6 6 90 90 90 54 54 54 18 18 18
44835 - 6 6 6 0 0 0 0 0 0 0 0 0
44836 - 0 0 0 0 0 0 0 0 0 0 0 0
44837 - 0 0 0 0 0 0 0 0 0 0 0 0
44838 - 0 0 0 0 0 0 0 0 0 0 0 0
44839 - 0 0 0 0 0 0 0 0 0 0 0 0
44840 - 0 0 0 0 0 0 0 0 0 0 0 0
44841 - 0 0 0 0 0 0 0 0 0 0 0 0
44842 - 0 0 0 0 0 0 0 0 0 0 0 0
44843 - 0 0 0 0 0 0 0 0 0 0 0 0
44844 - 0 0 0 0 0 0 0 0 0 0 0 0
44845 - 0 0 0 0 0 0 0 0 0 0 0 0
44846 - 0 0 0 0 0 0 0 0 0 0 0 0
44847 - 0 0 0 0 0 0 0 0 0 10 10 10
44848 - 30 30 30 78 78 78 46 46 46 22 22 22
44849 -137 92 6 210 162 10 239 182 13 238 190 10
44850 -238 202 15 241 208 19 246 215 20 246 215 20
44851 -241 208 19 203 166 17 185 133 11 210 150 10
44852 -216 158 10 210 150 10 102 78 10 2 2 6
44853 - 6 6 6 54 54 54 14 14 14 2 2 6
44854 - 2 2 6 62 62 62 74 74 74 30 30 30
44855 - 10 10 10 0 0 0 0 0 0 0 0 0
44856 - 0 0 0 0 0 0 0 0 0 0 0 0
44857 - 0 0 0 0 0 0 0 0 0 0 0 0
44858 - 0 0 0 0 0 0 0 0 0 0 0 0
44859 - 0 0 0 0 0 0 0 0 0 0 0 0
44860 - 0 0 0 0 0 0 0 0 0 0 0 0
44861 - 0 0 0 0 0 0 0 0 0 0 0 0
44862 - 0 0 0 0 0 0 0 0 0 0 0 0
44863 - 0 0 0 0 0 0 0 0 0 0 0 0
44864 - 0 0 0 0 0 0 0 0 0 0 0 0
44865 - 0 0 0 0 0 0 0 0 0 0 0 0
44866 - 0 0 0 0 0 0 0 0 0 0 0 0
44867 - 0 0 0 0 0 0 0 0 0 10 10 10
44868 - 34 34 34 78 78 78 50 50 50 6 6 6
44869 - 94 70 30 139 102 15 190 146 13 226 184 13
44870 -232 200 30 232 195 16 215 174 15 190 146 13
44871 -168 122 10 192 133 9 210 150 10 213 154 11
44872 -202 150 34 182 157 106 101 98 89 2 2 6
44873 - 2 2 6 78 78 78 116 116 116 58 58 58
44874 - 2 2 6 22 22 22 90 90 90 46 46 46
44875 - 18 18 18 6 6 6 0 0 0 0 0 0
44876 - 0 0 0 0 0 0 0 0 0 0 0 0
44877 - 0 0 0 0 0 0 0 0 0 0 0 0
44878 - 0 0 0 0 0 0 0 0 0 0 0 0
44879 - 0 0 0 0 0 0 0 0 0 0 0 0
44880 - 0 0 0 0 0 0 0 0 0 0 0 0
44881 - 0 0 0 0 0 0 0 0 0 0 0 0
44882 - 0 0 0 0 0 0 0 0 0 0 0 0
44883 - 0 0 0 0 0 0 0 0 0 0 0 0
44884 - 0 0 0 0 0 0 0 0 0 0 0 0
44885 - 0 0 0 0 0 0 0 0 0 0 0 0
44886 - 0 0 0 0 0 0 0 0 0 0 0 0
44887 - 0 0 0 0 0 0 0 0 0 10 10 10
44888 - 38 38 38 86 86 86 50 50 50 6 6 6
44889 -128 128 128 174 154 114 156 107 11 168 122 10
44890 -198 155 10 184 144 12 197 138 11 200 144 11
44891 -206 145 10 206 145 10 197 138 11 188 164 115
44892 -195 195 195 198 198 198 174 174 174 14 14 14
44893 - 2 2 6 22 22 22 116 116 116 116 116 116
44894 - 22 22 22 2 2 6 74 74 74 70 70 70
44895 - 30 30 30 10 10 10 0 0 0 0 0 0
44896 - 0 0 0 0 0 0 0 0 0 0 0 0
44897 - 0 0 0 0 0 0 0 0 0 0 0 0
44898 - 0 0 0 0 0 0 0 0 0 0 0 0
44899 - 0 0 0 0 0 0 0 0 0 0 0 0
44900 - 0 0 0 0 0 0 0 0 0 0 0 0
44901 - 0 0 0 0 0 0 0 0 0 0 0 0
44902 - 0 0 0 0 0 0 0 0 0 0 0 0
44903 - 0 0 0 0 0 0 0 0 0 0 0 0
44904 - 0 0 0 0 0 0 0 0 0 0 0 0
44905 - 0 0 0 0 0 0 0 0 0 0 0 0
44906 - 0 0 0 0 0 0 0 0 0 0 0 0
44907 - 0 0 0 0 0 0 6 6 6 18 18 18
44908 - 50 50 50 101 101 101 26 26 26 10 10 10
44909 -138 138 138 190 190 190 174 154 114 156 107 11
44910 -197 138 11 200 144 11 197 138 11 192 133 9
44911 -180 123 7 190 142 34 190 178 144 187 187 187
44912 -202 202 202 221 221 221 214 214 214 66 66 66
44913 - 2 2 6 2 2 6 50 50 50 62 62 62
44914 - 6 6 6 2 2 6 10 10 10 90 90 90
44915 - 50 50 50 18 18 18 6 6 6 0 0 0
44916 - 0 0 0 0 0 0 0 0 0 0 0 0
44917 - 0 0 0 0 0 0 0 0 0 0 0 0
44918 - 0 0 0 0 0 0 0 0 0 0 0 0
44919 - 0 0 0 0 0 0 0 0 0 0 0 0
44920 - 0 0 0 0 0 0 0 0 0 0 0 0
44921 - 0 0 0 0 0 0 0 0 0 0 0 0
44922 - 0 0 0 0 0 0 0 0 0 0 0 0
44923 - 0 0 0 0 0 0 0 0 0 0 0 0
44924 - 0 0 0 0 0 0 0 0 0 0 0 0
44925 - 0 0 0 0 0 0 0 0 0 0 0 0
44926 - 0 0 0 0 0 0 0 0 0 0 0 0
44927 - 0 0 0 0 0 0 10 10 10 34 34 34
44928 - 74 74 74 74 74 74 2 2 6 6 6 6
44929 -144 144 144 198 198 198 190 190 190 178 166 146
44930 -154 121 60 156 107 11 156 107 11 168 124 44
44931 -174 154 114 187 187 187 190 190 190 210 210 210
44932 -246 246 246 253 253 253 253 253 253 182 182 182
44933 - 6 6 6 2 2 6 2 2 6 2 2 6
44934 - 2 2 6 2 2 6 2 2 6 62 62 62
44935 - 74 74 74 34 34 34 14 14 14 0 0 0
44936 - 0 0 0 0 0 0 0 0 0 0 0 0
44937 - 0 0 0 0 0 0 0 0 0 0 0 0
44938 - 0 0 0 0 0 0 0 0 0 0 0 0
44939 - 0 0 0 0 0 0 0 0 0 0 0 0
44940 - 0 0 0 0 0 0 0 0 0 0 0 0
44941 - 0 0 0 0 0 0 0 0 0 0 0 0
44942 - 0 0 0 0 0 0 0 0 0 0 0 0
44943 - 0 0 0 0 0 0 0 0 0 0 0 0
44944 - 0 0 0 0 0 0 0 0 0 0 0 0
44945 - 0 0 0 0 0 0 0 0 0 0 0 0
44946 - 0 0 0 0 0 0 0 0 0 0 0 0
44947 - 0 0 0 10 10 10 22 22 22 54 54 54
44948 - 94 94 94 18 18 18 2 2 6 46 46 46
44949 -234 234 234 221 221 221 190 190 190 190 190 190
44950 -190 190 190 187 187 187 187 187 187 190 190 190
44951 -190 190 190 195 195 195 214 214 214 242 242 242
44952 -253 253 253 253 253 253 253 253 253 253 253 253
44953 - 82 82 82 2 2 6 2 2 6 2 2 6
44954 - 2 2 6 2 2 6 2 2 6 14 14 14
44955 - 86 86 86 54 54 54 22 22 22 6 6 6
44956 - 0 0 0 0 0 0 0 0 0 0 0 0
44957 - 0 0 0 0 0 0 0 0 0 0 0 0
44958 - 0 0 0 0 0 0 0 0 0 0 0 0
44959 - 0 0 0 0 0 0 0 0 0 0 0 0
44960 - 0 0 0 0 0 0 0 0 0 0 0 0
44961 - 0 0 0 0 0 0 0 0 0 0 0 0
44962 - 0 0 0 0 0 0 0 0 0 0 0 0
44963 - 0 0 0 0 0 0 0 0 0 0 0 0
44964 - 0 0 0 0 0 0 0 0 0 0 0 0
44965 - 0 0 0 0 0 0 0 0 0 0 0 0
44966 - 0 0 0 0 0 0 0 0 0 0 0 0
44967 - 6 6 6 18 18 18 46 46 46 90 90 90
44968 - 46 46 46 18 18 18 6 6 6 182 182 182
44969 -253 253 253 246 246 246 206 206 206 190 190 190
44970 -190 190 190 190 190 190 190 190 190 190 190 190
44971 -206 206 206 231 231 231 250 250 250 253 253 253
44972 -253 253 253 253 253 253 253 253 253 253 253 253
44973 -202 202 202 14 14 14 2 2 6 2 2 6
44974 - 2 2 6 2 2 6 2 2 6 2 2 6
44975 - 42 42 42 86 86 86 42 42 42 18 18 18
44976 - 6 6 6 0 0 0 0 0 0 0 0 0
44977 - 0 0 0 0 0 0 0 0 0 0 0 0
44978 - 0 0 0 0 0 0 0 0 0 0 0 0
44979 - 0 0 0 0 0 0 0 0 0 0 0 0
44980 - 0 0 0 0 0 0 0 0 0 0 0 0
44981 - 0 0 0 0 0 0 0 0 0 0 0 0
44982 - 0 0 0 0 0 0 0 0 0 0 0 0
44983 - 0 0 0 0 0 0 0 0 0 0 0 0
44984 - 0 0 0 0 0 0 0 0 0 0 0 0
44985 - 0 0 0 0 0 0 0 0 0 0 0 0
44986 - 0 0 0 0 0 0 0 0 0 6 6 6
44987 - 14 14 14 38 38 38 74 74 74 66 66 66
44988 - 2 2 6 6 6 6 90 90 90 250 250 250
44989 -253 253 253 253 253 253 238 238 238 198 198 198
44990 -190 190 190 190 190 190 195 195 195 221 221 221
44991 -246 246 246 253 253 253 253 253 253 253 253 253
44992 -253 253 253 253 253 253 253 253 253 253 253 253
44993 -253 253 253 82 82 82 2 2 6 2 2 6
44994 - 2 2 6 2 2 6 2 2 6 2 2 6
44995 - 2 2 6 78 78 78 70 70 70 34 34 34
44996 - 14 14 14 6 6 6 0 0 0 0 0 0
44997 - 0 0 0 0 0 0 0 0 0 0 0 0
44998 - 0 0 0 0 0 0 0 0 0 0 0 0
44999 - 0 0 0 0 0 0 0 0 0 0 0 0
45000 - 0 0 0 0 0 0 0 0 0 0 0 0
45001 - 0 0 0 0 0 0 0 0 0 0 0 0
45002 - 0 0 0 0 0 0 0 0 0 0 0 0
45003 - 0 0 0 0 0 0 0 0 0 0 0 0
45004 - 0 0 0 0 0 0 0 0 0 0 0 0
45005 - 0 0 0 0 0 0 0 0 0 0 0 0
45006 - 0 0 0 0 0 0 0 0 0 14 14 14
45007 - 34 34 34 66 66 66 78 78 78 6 6 6
45008 - 2 2 6 18 18 18 218 218 218 253 253 253
45009 -253 253 253 253 253 253 253 253 253 246 246 246
45010 -226 226 226 231 231 231 246 246 246 253 253 253
45011 -253 253 253 253 253 253 253 253 253 253 253 253
45012 -253 253 253 253 253 253 253 253 253 253 253 253
45013 -253 253 253 178 178 178 2 2 6 2 2 6
45014 - 2 2 6 2 2 6 2 2 6 2 2 6
45015 - 2 2 6 18 18 18 90 90 90 62 62 62
45016 - 30 30 30 10 10 10 0 0 0 0 0 0
45017 - 0 0 0 0 0 0 0 0 0 0 0 0
45018 - 0 0 0 0 0 0 0 0 0 0 0 0
45019 - 0 0 0 0 0 0 0 0 0 0 0 0
45020 - 0 0 0 0 0 0 0 0 0 0 0 0
45021 - 0 0 0 0 0 0 0 0 0 0 0 0
45022 - 0 0 0 0 0 0 0 0 0 0 0 0
45023 - 0 0 0 0 0 0 0 0 0 0 0 0
45024 - 0 0 0 0 0 0 0 0 0 0 0 0
45025 - 0 0 0 0 0 0 0 0 0 0 0 0
45026 - 0 0 0 0 0 0 10 10 10 26 26 26
45027 - 58 58 58 90 90 90 18 18 18 2 2 6
45028 - 2 2 6 110 110 110 253 253 253 253 253 253
45029 -253 253 253 253 253 253 253 253 253 253 253 253
45030 -250 250 250 253 253 253 253 253 253 253 253 253
45031 -253 253 253 253 253 253 253 253 253 253 253 253
45032 -253 253 253 253 253 253 253 253 253 253 253 253
45033 -253 253 253 231 231 231 18 18 18 2 2 6
45034 - 2 2 6 2 2 6 2 2 6 2 2 6
45035 - 2 2 6 2 2 6 18 18 18 94 94 94
45036 - 54 54 54 26 26 26 10 10 10 0 0 0
45037 - 0 0 0 0 0 0 0 0 0 0 0 0
45038 - 0 0 0 0 0 0 0 0 0 0 0 0
45039 - 0 0 0 0 0 0 0 0 0 0 0 0
45040 - 0 0 0 0 0 0 0 0 0 0 0 0
45041 - 0 0 0 0 0 0 0 0 0 0 0 0
45042 - 0 0 0 0 0 0 0 0 0 0 0 0
45043 - 0 0 0 0 0 0 0 0 0 0 0 0
45044 - 0 0 0 0 0 0 0 0 0 0 0 0
45045 - 0 0 0 0 0 0 0 0 0 0 0 0
45046 - 0 0 0 6 6 6 22 22 22 50 50 50
45047 - 90 90 90 26 26 26 2 2 6 2 2 6
45048 - 14 14 14 195 195 195 250 250 250 253 253 253
45049 -253 253 253 253 253 253 253 253 253 253 253 253
45050 -253 253 253 253 253 253 253 253 253 253 253 253
45051 -253 253 253 253 253 253 253 253 253 253 253 253
45052 -253 253 253 253 253 253 253 253 253 253 253 253
45053 -250 250 250 242 242 242 54 54 54 2 2 6
45054 - 2 2 6 2 2 6 2 2 6 2 2 6
45055 - 2 2 6 2 2 6 2 2 6 38 38 38
45056 - 86 86 86 50 50 50 22 22 22 6 6 6
45057 - 0 0 0 0 0 0 0 0 0 0 0 0
45058 - 0 0 0 0 0 0 0 0 0 0 0 0
45059 - 0 0 0 0 0 0 0 0 0 0 0 0
45060 - 0 0 0 0 0 0 0 0 0 0 0 0
45061 - 0 0 0 0 0 0 0 0 0 0 0 0
45062 - 0 0 0 0 0 0 0 0 0 0 0 0
45063 - 0 0 0 0 0 0 0 0 0 0 0 0
45064 - 0 0 0 0 0 0 0 0 0 0 0 0
45065 - 0 0 0 0 0 0 0 0 0 0 0 0
45066 - 6 6 6 14 14 14 38 38 38 82 82 82
45067 - 34 34 34 2 2 6 2 2 6 2 2 6
45068 - 42 42 42 195 195 195 246 246 246 253 253 253
45069 -253 253 253 253 253 253 253 253 253 250 250 250
45070 -242 242 242 242 242 242 250 250 250 253 253 253
45071 -253 253 253 253 253 253 253 253 253 253 253 253
45072 -253 253 253 250 250 250 246 246 246 238 238 238
45073 -226 226 226 231 231 231 101 101 101 6 6 6
45074 - 2 2 6 2 2 6 2 2 6 2 2 6
45075 - 2 2 6 2 2 6 2 2 6 2 2 6
45076 - 38 38 38 82 82 82 42 42 42 14 14 14
45077 - 6 6 6 0 0 0 0 0 0 0 0 0
45078 - 0 0 0 0 0 0 0 0 0 0 0 0
45079 - 0 0 0 0 0 0 0 0 0 0 0 0
45080 - 0 0 0 0 0 0 0 0 0 0 0 0
45081 - 0 0 0 0 0 0 0 0 0 0 0 0
45082 - 0 0 0 0 0 0 0 0 0 0 0 0
45083 - 0 0 0 0 0 0 0 0 0 0 0 0
45084 - 0 0 0 0 0 0 0 0 0 0 0 0
45085 - 0 0 0 0 0 0 0 0 0 0 0 0
45086 - 10 10 10 26 26 26 62 62 62 66 66 66
45087 - 2 2 6 2 2 6 2 2 6 6 6 6
45088 - 70 70 70 170 170 170 206 206 206 234 234 234
45089 -246 246 246 250 250 250 250 250 250 238 238 238
45090 -226 226 226 231 231 231 238 238 238 250 250 250
45091 -250 250 250 250 250 250 246 246 246 231 231 231
45092 -214 214 214 206 206 206 202 202 202 202 202 202
45093 -198 198 198 202 202 202 182 182 182 18 18 18
45094 - 2 2 6 2 2 6 2 2 6 2 2 6
45095 - 2 2 6 2 2 6 2 2 6 2 2 6
45096 - 2 2 6 62 62 62 66 66 66 30 30 30
45097 - 10 10 10 0 0 0 0 0 0 0 0 0
45098 - 0 0 0 0 0 0 0 0 0 0 0 0
45099 - 0 0 0 0 0 0 0 0 0 0 0 0
45100 - 0 0 0 0 0 0 0 0 0 0 0 0
45101 - 0 0 0 0 0 0 0 0 0 0 0 0
45102 - 0 0 0 0 0 0 0 0 0 0 0 0
45103 - 0 0 0 0 0 0 0 0 0 0 0 0
45104 - 0 0 0 0 0 0 0 0 0 0 0 0
45105 - 0 0 0 0 0 0 0 0 0 0 0 0
45106 - 14 14 14 42 42 42 82 82 82 18 18 18
45107 - 2 2 6 2 2 6 2 2 6 10 10 10
45108 - 94 94 94 182 182 182 218 218 218 242 242 242
45109 -250 250 250 253 253 253 253 253 253 250 250 250
45110 -234 234 234 253 253 253 253 253 253 253 253 253
45111 -253 253 253 253 253 253 253 253 253 246 246 246
45112 -238 238 238 226 226 226 210 210 210 202 202 202
45113 -195 195 195 195 195 195 210 210 210 158 158 158
45114 - 6 6 6 14 14 14 50 50 50 14 14 14
45115 - 2 2 6 2 2 6 2 2 6 2 2 6
45116 - 2 2 6 6 6 6 86 86 86 46 46 46
45117 - 18 18 18 6 6 6 0 0 0 0 0 0
45118 - 0 0 0 0 0 0 0 0 0 0 0 0
45119 - 0 0 0 0 0 0 0 0 0 0 0 0
45120 - 0 0 0 0 0 0 0 0 0 0 0 0
45121 - 0 0 0 0 0 0 0 0 0 0 0 0
45122 - 0 0 0 0 0 0 0 0 0 0 0 0
45123 - 0 0 0 0 0 0 0 0 0 0 0 0
45124 - 0 0 0 0 0 0 0 0 0 0 0 0
45125 - 0 0 0 0 0 0 0 0 0 6 6 6
45126 - 22 22 22 54 54 54 70 70 70 2 2 6
45127 - 2 2 6 10 10 10 2 2 6 22 22 22
45128 -166 166 166 231 231 231 250 250 250 253 253 253
45129 -253 253 253 253 253 253 253 253 253 250 250 250
45130 -242 242 242 253 253 253 253 253 253 253 253 253
45131 -253 253 253 253 253 253 253 253 253 253 253 253
45132 -253 253 253 253 253 253 253 253 253 246 246 246
45133 -231 231 231 206 206 206 198 198 198 226 226 226
45134 - 94 94 94 2 2 6 6 6 6 38 38 38
45135 - 30 30 30 2 2 6 2 2 6 2 2 6
45136 - 2 2 6 2 2 6 62 62 62 66 66 66
45137 - 26 26 26 10 10 10 0 0 0 0 0 0
45138 - 0 0 0 0 0 0 0 0 0 0 0 0
45139 - 0 0 0 0 0 0 0 0 0 0 0 0
45140 - 0 0 0 0 0 0 0 0 0 0 0 0
45141 - 0 0 0 0 0 0 0 0 0 0 0 0
45142 - 0 0 0 0 0 0 0 0 0 0 0 0
45143 - 0 0 0 0 0 0 0 0 0 0 0 0
45144 - 0 0 0 0 0 0 0 0 0 0 0 0
45145 - 0 0 0 0 0 0 0 0 0 10 10 10
45146 - 30 30 30 74 74 74 50 50 50 2 2 6
45147 - 26 26 26 26 26 26 2 2 6 106 106 106
45148 -238 238 238 253 253 253 253 253 253 253 253 253
45149 -253 253 253 253 253 253 253 253 253 253 253 253
45150 -253 253 253 253 253 253 253 253 253 253 253 253
45151 -253 253 253 253 253 253 253 253 253 253 253 253
45152 -253 253 253 253 253 253 253 253 253 253 253 253
45153 -253 253 253 246 246 246 218 218 218 202 202 202
45154 -210 210 210 14 14 14 2 2 6 2 2 6
45155 - 30 30 30 22 22 22 2 2 6 2 2 6
45156 - 2 2 6 2 2 6 18 18 18 86 86 86
45157 - 42 42 42 14 14 14 0 0 0 0 0 0
45158 - 0 0 0 0 0 0 0 0 0 0 0 0
45159 - 0 0 0 0 0 0 0 0 0 0 0 0
45160 - 0 0 0 0 0 0 0 0 0 0 0 0
45161 - 0 0 0 0 0 0 0 0 0 0 0 0
45162 - 0 0 0 0 0 0 0 0 0 0 0 0
45163 - 0 0 0 0 0 0 0 0 0 0 0 0
45164 - 0 0 0 0 0 0 0 0 0 0 0 0
45165 - 0 0 0 0 0 0 0 0 0 14 14 14
45166 - 42 42 42 90 90 90 22 22 22 2 2 6
45167 - 42 42 42 2 2 6 18 18 18 218 218 218
45168 -253 253 253 253 253 253 253 253 253 253 253 253
45169 -253 253 253 253 253 253 253 253 253 253 253 253
45170 -253 253 253 253 253 253 253 253 253 253 253 253
45171 -253 253 253 253 253 253 253 253 253 253 253 253
45172 -253 253 253 253 253 253 253 253 253 253 253 253
45173 -253 253 253 253 253 253 250 250 250 221 221 221
45174 -218 218 218 101 101 101 2 2 6 14 14 14
45175 - 18 18 18 38 38 38 10 10 10 2 2 6
45176 - 2 2 6 2 2 6 2 2 6 78 78 78
45177 - 58 58 58 22 22 22 6 6 6 0 0 0
45178 - 0 0 0 0 0 0 0 0 0 0 0 0
45179 - 0 0 0 0 0 0 0 0 0 0 0 0
45180 - 0 0 0 0 0 0 0 0 0 0 0 0
45181 - 0 0 0 0 0 0 0 0 0 0 0 0
45182 - 0 0 0 0 0 0 0 0 0 0 0 0
45183 - 0 0 0 0 0 0 0 0 0 0 0 0
45184 - 0 0 0 0 0 0 0 0 0 0 0 0
45185 - 0 0 0 0 0 0 6 6 6 18 18 18
45186 - 54 54 54 82 82 82 2 2 6 26 26 26
45187 - 22 22 22 2 2 6 123 123 123 253 253 253
45188 -253 253 253 253 253 253 253 253 253 253 253 253
45189 -253 253 253 253 253 253 253 253 253 253 253 253
45190 -253 253 253 253 253 253 253 253 253 253 253 253
45191 -253 253 253 253 253 253 253 253 253 253 253 253
45192 -253 253 253 253 253 253 253 253 253 253 253 253
45193 -253 253 253 253 253 253 253 253 253 250 250 250
45194 -238 238 238 198 198 198 6 6 6 38 38 38
45195 - 58 58 58 26 26 26 38 38 38 2 2 6
45196 - 2 2 6 2 2 6 2 2 6 46 46 46
45197 - 78 78 78 30 30 30 10 10 10 0 0 0
45198 - 0 0 0 0 0 0 0 0 0 0 0 0
45199 - 0 0 0 0 0 0 0 0 0 0 0 0
45200 - 0 0 0 0 0 0 0 0 0 0 0 0
45201 - 0 0 0 0 0 0 0 0 0 0 0 0
45202 - 0 0 0 0 0 0 0 0 0 0 0 0
45203 - 0 0 0 0 0 0 0 0 0 0 0 0
45204 - 0 0 0 0 0 0 0 0 0 0 0 0
45205 - 0 0 0 0 0 0 10 10 10 30 30 30
45206 - 74 74 74 58 58 58 2 2 6 42 42 42
45207 - 2 2 6 22 22 22 231 231 231 253 253 253
45208 -253 253 253 253 253 253 253 253 253 253 253 253
45209 -253 253 253 253 253 253 253 253 253 250 250 250
45210 -253 253 253 253 253 253 253 253 253 253 253 253
45211 -253 253 253 253 253 253 253 253 253 253 253 253
45212 -253 253 253 253 253 253 253 253 253 253 253 253
45213 -253 253 253 253 253 253 253 253 253 253 253 253
45214 -253 253 253 246 246 246 46 46 46 38 38 38
45215 - 42 42 42 14 14 14 38 38 38 14 14 14
45216 - 2 2 6 2 2 6 2 2 6 6 6 6
45217 - 86 86 86 46 46 46 14 14 14 0 0 0
45218 - 0 0 0 0 0 0 0 0 0 0 0 0
45219 - 0 0 0 0 0 0 0 0 0 0 0 0
45220 - 0 0 0 0 0 0 0 0 0 0 0 0
45221 - 0 0 0 0 0 0 0 0 0 0 0 0
45222 - 0 0 0 0 0 0 0 0 0 0 0 0
45223 - 0 0 0 0 0 0 0 0 0 0 0 0
45224 - 0 0 0 0 0 0 0 0 0 0 0 0
45225 - 0 0 0 6 6 6 14 14 14 42 42 42
45226 - 90 90 90 18 18 18 18 18 18 26 26 26
45227 - 2 2 6 116 116 116 253 253 253 253 253 253
45228 -253 253 253 253 253 253 253 253 253 253 253 253
45229 -253 253 253 253 253 253 250 250 250 238 238 238
45230 -253 253 253 253 253 253 253 253 253 253 253 253
45231 -253 253 253 253 253 253 253 253 253 253 253 253
45232 -253 253 253 253 253 253 253 253 253 253 253 253
45233 -253 253 253 253 253 253 253 253 253 253 253 253
45234 -253 253 253 253 253 253 94 94 94 6 6 6
45235 - 2 2 6 2 2 6 10 10 10 34 34 34
45236 - 2 2 6 2 2 6 2 2 6 2 2 6
45237 - 74 74 74 58 58 58 22 22 22 6 6 6
45238 - 0 0 0 0 0 0 0 0 0 0 0 0
45239 - 0 0 0 0 0 0 0 0 0 0 0 0
45240 - 0 0 0 0 0 0 0 0 0 0 0 0
45241 - 0 0 0 0 0 0 0 0 0 0 0 0
45242 - 0 0 0 0 0 0 0 0 0 0 0 0
45243 - 0 0 0 0 0 0 0 0 0 0 0 0
45244 - 0 0 0 0 0 0 0 0 0 0 0 0
45245 - 0 0 0 10 10 10 26 26 26 66 66 66
45246 - 82 82 82 2 2 6 38 38 38 6 6 6
45247 - 14 14 14 210 210 210 253 253 253 253 253 253
45248 -253 253 253 253 253 253 253 253 253 253 253 253
45249 -253 253 253 253 253 253 246 246 246 242 242 242
45250 -253 253 253 253 253 253 253 253 253 253 253 253
45251 -253 253 253 253 253 253 253 253 253 253 253 253
45252 -253 253 253 253 253 253 253 253 253 253 253 253
45253 -253 253 253 253 253 253 253 253 253 253 253 253
45254 -253 253 253 253 253 253 144 144 144 2 2 6
45255 - 2 2 6 2 2 6 2 2 6 46 46 46
45256 - 2 2 6 2 2 6 2 2 6 2 2 6
45257 - 42 42 42 74 74 74 30 30 30 10 10 10
45258 - 0 0 0 0 0 0 0 0 0 0 0 0
45259 - 0 0 0 0 0 0 0 0 0 0 0 0
45260 - 0 0 0 0 0 0 0 0 0 0 0 0
45261 - 0 0 0 0 0 0 0 0 0 0 0 0
45262 - 0 0 0 0 0 0 0 0 0 0 0 0
45263 - 0 0 0 0 0 0 0 0 0 0 0 0
45264 - 0 0 0 0 0 0 0 0 0 0 0 0
45265 - 6 6 6 14 14 14 42 42 42 90 90 90
45266 - 26 26 26 6 6 6 42 42 42 2 2 6
45267 - 74 74 74 250 250 250 253 253 253 253 253 253
45268 -253 253 253 253 253 253 253 253 253 253 253 253
45269 -253 253 253 253 253 253 242 242 242 242 242 242
45270 -253 253 253 253 253 253 253 253 253 253 253 253
45271 -253 253 253 253 253 253 253 253 253 253 253 253
45272 -253 253 253 253 253 253 253 253 253 253 253 253
45273 -253 253 253 253 253 253 253 253 253 253 253 253
45274 -253 253 253 253 253 253 182 182 182 2 2 6
45275 - 2 2 6 2 2 6 2 2 6 46 46 46
45276 - 2 2 6 2 2 6 2 2 6 2 2 6
45277 - 10 10 10 86 86 86 38 38 38 10 10 10
45278 - 0 0 0 0 0 0 0 0 0 0 0 0
45279 - 0 0 0 0 0 0 0 0 0 0 0 0
45280 - 0 0 0 0 0 0 0 0 0 0 0 0
45281 - 0 0 0 0 0 0 0 0 0 0 0 0
45282 - 0 0 0 0 0 0 0 0 0 0 0 0
45283 - 0 0 0 0 0 0 0 0 0 0 0 0
45284 - 0 0 0 0 0 0 0 0 0 0 0 0
45285 - 10 10 10 26 26 26 66 66 66 82 82 82
45286 - 2 2 6 22 22 22 18 18 18 2 2 6
45287 -149 149 149 253 253 253 253 253 253 253 253 253
45288 -253 253 253 253 253 253 253 253 253 253 253 253
45289 -253 253 253 253 253 253 234 234 234 242 242 242
45290 -253 253 253 253 253 253 253 253 253 253 253 253
45291 -253 253 253 253 253 253 253 253 253 253 253 253
45292 -253 253 253 253 253 253 253 253 253 253 253 253
45293 -253 253 253 253 253 253 253 253 253 253 253 253
45294 -253 253 253 253 253 253 206 206 206 2 2 6
45295 - 2 2 6 2 2 6 2 2 6 38 38 38
45296 - 2 2 6 2 2 6 2 2 6 2 2 6
45297 - 6 6 6 86 86 86 46 46 46 14 14 14
45298 - 0 0 0 0 0 0 0 0 0 0 0 0
45299 - 0 0 0 0 0 0 0 0 0 0 0 0
45300 - 0 0 0 0 0 0 0 0 0 0 0 0
45301 - 0 0 0 0 0 0 0 0 0 0 0 0
45302 - 0 0 0 0 0 0 0 0 0 0 0 0
45303 - 0 0 0 0 0 0 0 0 0 0 0 0
45304 - 0 0 0 0 0 0 0 0 0 6 6 6
45305 - 18 18 18 46 46 46 86 86 86 18 18 18
45306 - 2 2 6 34 34 34 10 10 10 6 6 6
45307 -210 210 210 253 253 253 253 253 253 253 253 253
45308 -253 253 253 253 253 253 253 253 253 253 253 253
45309 -253 253 253 253 253 253 234 234 234 242 242 242
45310 -253 253 253 253 253 253 253 253 253 253 253 253
45311 -253 253 253 253 253 253 253 253 253 253 253 253
45312 -253 253 253 253 253 253 253 253 253 253 253 253
45313 -253 253 253 253 253 253 253 253 253 253 253 253
45314 -253 253 253 253 253 253 221 221 221 6 6 6
45315 - 2 2 6 2 2 6 6 6 6 30 30 30
45316 - 2 2 6 2 2 6 2 2 6 2 2 6
45317 - 2 2 6 82 82 82 54 54 54 18 18 18
45318 - 6 6 6 0 0 0 0 0 0 0 0 0
45319 - 0 0 0 0 0 0 0 0 0 0 0 0
45320 - 0 0 0 0 0 0 0 0 0 0 0 0
45321 - 0 0 0 0 0 0 0 0 0 0 0 0
45322 - 0 0 0 0 0 0 0 0 0 0 0 0
45323 - 0 0 0 0 0 0 0 0 0 0 0 0
45324 - 0 0 0 0 0 0 0 0 0 10 10 10
45325 - 26 26 26 66 66 66 62 62 62 2 2 6
45326 - 2 2 6 38 38 38 10 10 10 26 26 26
45327 -238 238 238 253 253 253 253 253 253 253 253 253
45328 -253 253 253 253 253 253 253 253 253 253 253 253
45329 -253 253 253 253 253 253 231 231 231 238 238 238
45330 -253 253 253 253 253 253 253 253 253 253 253 253
45331 -253 253 253 253 253 253 253 253 253 253 253 253
45332 -253 253 253 253 253 253 253 253 253 253 253 253
45333 -253 253 253 253 253 253 253 253 253 253 253 253
45334 -253 253 253 253 253 253 231 231 231 6 6 6
45335 - 2 2 6 2 2 6 10 10 10 30 30 30
45336 - 2 2 6 2 2 6 2 2 6 2 2 6
45337 - 2 2 6 66 66 66 58 58 58 22 22 22
45338 - 6 6 6 0 0 0 0 0 0 0 0 0
45339 - 0 0 0 0 0 0 0 0 0 0 0 0
45340 - 0 0 0 0 0 0 0 0 0 0 0 0
45341 - 0 0 0 0 0 0 0 0 0 0 0 0
45342 - 0 0 0 0 0 0 0 0 0 0 0 0
45343 - 0 0 0 0 0 0 0 0 0 0 0 0
45344 - 0 0 0 0 0 0 0 0 0 10 10 10
45345 - 38 38 38 78 78 78 6 6 6 2 2 6
45346 - 2 2 6 46 46 46 14 14 14 42 42 42
45347 -246 246 246 253 253 253 253 253 253 253 253 253
45348 -253 253 253 253 253 253 253 253 253 253 253 253
45349 -253 253 253 253 253 253 231 231 231 242 242 242
45350 -253 253 253 253 253 253 253 253 253 253 253 253
45351 -253 253 253 253 253 253 253 253 253 253 253 253
45352 -253 253 253 253 253 253 253 253 253 253 253 253
45353 -253 253 253 253 253 253 253 253 253 253 253 253
45354 -253 253 253 253 253 253 234 234 234 10 10 10
45355 - 2 2 6 2 2 6 22 22 22 14 14 14
45356 - 2 2 6 2 2 6 2 2 6 2 2 6
45357 - 2 2 6 66 66 66 62 62 62 22 22 22
45358 - 6 6 6 0 0 0 0 0 0 0 0 0
45359 - 0 0 0 0 0 0 0 0 0 0 0 0
45360 - 0 0 0 0 0 0 0 0 0 0 0 0
45361 - 0 0 0 0 0 0 0 0 0 0 0 0
45362 - 0 0 0 0 0 0 0 0 0 0 0 0
45363 - 0 0 0 0 0 0 0 0 0 0 0 0
45364 - 0 0 0 0 0 0 6 6 6 18 18 18
45365 - 50 50 50 74 74 74 2 2 6 2 2 6
45366 - 14 14 14 70 70 70 34 34 34 62 62 62
45367 -250 250 250 253 253 253 253 253 253 253 253 253
45368 -253 253 253 253 253 253 253 253 253 253 253 253
45369 -253 253 253 253 253 253 231 231 231 246 246 246
45370 -253 253 253 253 253 253 253 253 253 253 253 253
45371 -253 253 253 253 253 253 253 253 253 253 253 253
45372 -253 253 253 253 253 253 253 253 253 253 253 253
45373 -253 253 253 253 253 253 253 253 253 253 253 253
45374 -253 253 253 253 253 253 234 234 234 14 14 14
45375 - 2 2 6 2 2 6 30 30 30 2 2 6
45376 - 2 2 6 2 2 6 2 2 6 2 2 6
45377 - 2 2 6 66 66 66 62 62 62 22 22 22
45378 - 6 6 6 0 0 0 0 0 0 0 0 0
45379 - 0 0 0 0 0 0 0 0 0 0 0 0
45380 - 0 0 0 0 0 0 0 0 0 0 0 0
45381 - 0 0 0 0 0 0 0 0 0 0 0 0
45382 - 0 0 0 0 0 0 0 0 0 0 0 0
45383 - 0 0 0 0 0 0 0 0 0 0 0 0
45384 - 0 0 0 0 0 0 6 6 6 18 18 18
45385 - 54 54 54 62 62 62 2 2 6 2 2 6
45386 - 2 2 6 30 30 30 46 46 46 70 70 70
45387 -250 250 250 253 253 253 253 253 253 253 253 253
45388 -253 253 253 253 253 253 253 253 253 253 253 253
45389 -253 253 253 253 253 253 231 231 231 246 246 246
45390 -253 253 253 253 253 253 253 253 253 253 253 253
45391 -253 253 253 253 253 253 253 253 253 253 253 253
45392 -253 253 253 253 253 253 253 253 253 253 253 253
45393 -253 253 253 253 253 253 253 253 253 253 253 253
45394 -253 253 253 253 253 253 226 226 226 10 10 10
45395 - 2 2 6 6 6 6 30 30 30 2 2 6
45396 - 2 2 6 2 2 6 2 2 6 2 2 6
45397 - 2 2 6 66 66 66 58 58 58 22 22 22
45398 - 6 6 6 0 0 0 0 0 0 0 0 0
45399 - 0 0 0 0 0 0 0 0 0 0 0 0
45400 - 0 0 0 0 0 0 0 0 0 0 0 0
45401 - 0 0 0 0 0 0 0 0 0 0 0 0
45402 - 0 0 0 0 0 0 0 0 0 0 0 0
45403 - 0 0 0 0 0 0 0 0 0 0 0 0
45404 - 0 0 0 0 0 0 6 6 6 22 22 22
45405 - 58 58 58 62 62 62 2 2 6 2 2 6
45406 - 2 2 6 2 2 6 30 30 30 78 78 78
45407 -250 250 250 253 253 253 253 253 253 253 253 253
45408 -253 253 253 253 253 253 253 253 253 253 253 253
45409 -253 253 253 253 253 253 231 231 231 246 246 246
45410 -253 253 253 253 253 253 253 253 253 253 253 253
45411 -253 253 253 253 253 253 253 253 253 253 253 253
45412 -253 253 253 253 253 253 253 253 253 253 253 253
45413 -253 253 253 253 253 253 253 253 253 253 253 253
45414 -253 253 253 253 253 253 206 206 206 2 2 6
45415 - 22 22 22 34 34 34 18 14 6 22 22 22
45416 - 26 26 26 18 18 18 6 6 6 2 2 6
45417 - 2 2 6 82 82 82 54 54 54 18 18 18
45418 - 6 6 6 0 0 0 0 0 0 0 0 0
45419 - 0 0 0 0 0 0 0 0 0 0 0 0
45420 - 0 0 0 0 0 0 0 0 0 0 0 0
45421 - 0 0 0 0 0 0 0 0 0 0 0 0
45422 - 0 0 0 0 0 0 0 0 0 0 0 0
45423 - 0 0 0 0 0 0 0 0 0 0 0 0
45424 - 0 0 0 0 0 0 6 6 6 26 26 26
45425 - 62 62 62 106 106 106 74 54 14 185 133 11
45426 -210 162 10 121 92 8 6 6 6 62 62 62
45427 -238 238 238 253 253 253 253 253 253 253 253 253
45428 -253 253 253 253 253 253 253 253 253 253 253 253
45429 -253 253 253 253 253 253 231 231 231 246 246 246
45430 -253 253 253 253 253 253 253 253 253 253 253 253
45431 -253 253 253 253 253 253 253 253 253 253 253 253
45432 -253 253 253 253 253 253 253 253 253 253 253 253
45433 -253 253 253 253 253 253 253 253 253 253 253 253
45434 -253 253 253 253 253 253 158 158 158 18 18 18
45435 - 14 14 14 2 2 6 2 2 6 2 2 6
45436 - 6 6 6 18 18 18 66 66 66 38 38 38
45437 - 6 6 6 94 94 94 50 50 50 18 18 18
45438 - 6 6 6 0 0 0 0 0 0 0 0 0
45439 - 0 0 0 0 0 0 0 0 0 0 0 0
45440 - 0 0 0 0 0 0 0 0 0 0 0 0
45441 - 0 0 0 0 0 0 0 0 0 0 0 0
45442 - 0 0 0 0 0 0 0 0 0 0 0 0
45443 - 0 0 0 0 0 0 0 0 0 6 6 6
45444 - 10 10 10 10 10 10 18 18 18 38 38 38
45445 - 78 78 78 142 134 106 216 158 10 242 186 14
45446 -246 190 14 246 190 14 156 118 10 10 10 10
45447 - 90 90 90 238 238 238 253 253 253 253 253 253
45448 -253 253 253 253 253 253 253 253 253 253 253 253
45449 -253 253 253 253 253 253 231 231 231 250 250 250
45450 -253 253 253 253 253 253 253 253 253 253 253 253
45451 -253 253 253 253 253 253 253 253 253 253 253 253
45452 -253 253 253 253 253 253 253 253 253 253 253 253
45453 -253 253 253 253 253 253 253 253 253 246 230 190
45454 -238 204 91 238 204 91 181 142 44 37 26 9
45455 - 2 2 6 2 2 6 2 2 6 2 2 6
45456 - 2 2 6 2 2 6 38 38 38 46 46 46
45457 - 26 26 26 106 106 106 54 54 54 18 18 18
45458 - 6 6 6 0 0 0 0 0 0 0 0 0
45459 - 0 0 0 0 0 0 0 0 0 0 0 0
45460 - 0 0 0 0 0 0 0 0 0 0 0 0
45461 - 0 0 0 0 0 0 0 0 0 0 0 0
45462 - 0 0 0 0 0 0 0 0 0 0 0 0
45463 - 0 0 0 6 6 6 14 14 14 22 22 22
45464 - 30 30 30 38 38 38 50 50 50 70 70 70
45465 -106 106 106 190 142 34 226 170 11 242 186 14
45466 -246 190 14 246 190 14 246 190 14 154 114 10
45467 - 6 6 6 74 74 74 226 226 226 253 253 253
45468 -253 253 253 253 253 253 253 253 253 253 253 253
45469 -253 253 253 253 253 253 231 231 231 250 250 250
45470 -253 253 253 253 253 253 253 253 253 253 253 253
45471 -253 253 253 253 253 253 253 253 253 253 253 253
45472 -253 253 253 253 253 253 253 253 253 253 253 253
45473 -253 253 253 253 253 253 253 253 253 228 184 62
45474 -241 196 14 241 208 19 232 195 16 38 30 10
45475 - 2 2 6 2 2 6 2 2 6 2 2 6
45476 - 2 2 6 6 6 6 30 30 30 26 26 26
45477 -203 166 17 154 142 90 66 66 66 26 26 26
45478 - 6 6 6 0 0 0 0 0 0 0 0 0
45479 - 0 0 0 0 0 0 0 0 0 0 0 0
45480 - 0 0 0 0 0 0 0 0 0 0 0 0
45481 - 0 0 0 0 0 0 0 0 0 0 0 0
45482 - 0 0 0 0 0 0 0 0 0 0 0 0
45483 - 6 6 6 18 18 18 38 38 38 58 58 58
45484 - 78 78 78 86 86 86 101 101 101 123 123 123
45485 -175 146 61 210 150 10 234 174 13 246 186 14
45486 -246 190 14 246 190 14 246 190 14 238 190 10
45487 -102 78 10 2 2 6 46 46 46 198 198 198
45488 -253 253 253 253 253 253 253 253 253 253 253 253
45489 -253 253 253 253 253 253 234 234 234 242 242 242
45490 -253 253 253 253 253 253 253 253 253 253 253 253
45491 -253 253 253 253 253 253 253 253 253 253 253 253
45492 -253 253 253 253 253 253 253 253 253 253 253 253
45493 -253 253 253 253 253 253 253 253 253 224 178 62
45494 -242 186 14 241 196 14 210 166 10 22 18 6
45495 - 2 2 6 2 2 6 2 2 6 2 2 6
45496 - 2 2 6 2 2 6 6 6 6 121 92 8
45497 -238 202 15 232 195 16 82 82 82 34 34 34
45498 - 10 10 10 0 0 0 0 0 0 0 0 0
45499 - 0 0 0 0 0 0 0 0 0 0 0 0
45500 - 0 0 0 0 0 0 0 0 0 0 0 0
45501 - 0 0 0 0 0 0 0 0 0 0 0 0
45502 - 0 0 0 0 0 0 0 0 0 0 0 0
45503 - 14 14 14 38 38 38 70 70 70 154 122 46
45504 -190 142 34 200 144 11 197 138 11 197 138 11
45505 -213 154 11 226 170 11 242 186 14 246 190 14
45506 -246 190 14 246 190 14 246 190 14 246 190 14
45507 -225 175 15 46 32 6 2 2 6 22 22 22
45508 -158 158 158 250 250 250 253 253 253 253 253 253
45509 -253 253 253 253 253 253 253 253 253 253 253 253
45510 -253 253 253 253 253 253 253 253 253 253 253 253
45511 -253 253 253 253 253 253 253 253 253 253 253 253
45512 -253 253 253 253 253 253 253 253 253 253 253 253
45513 -253 253 253 250 250 250 242 242 242 224 178 62
45514 -239 182 13 236 186 11 213 154 11 46 32 6
45515 - 2 2 6 2 2 6 2 2 6 2 2 6
45516 - 2 2 6 2 2 6 61 42 6 225 175 15
45517 -238 190 10 236 186 11 112 100 78 42 42 42
45518 - 14 14 14 0 0 0 0 0 0 0 0 0
45519 - 0 0 0 0 0 0 0 0 0 0 0 0
45520 - 0 0 0 0 0 0 0 0 0 0 0 0
45521 - 0 0 0 0 0 0 0 0 0 0 0 0
45522 - 0 0 0 0 0 0 0 0 0 6 6 6
45523 - 22 22 22 54 54 54 154 122 46 213 154 11
45524 -226 170 11 230 174 11 226 170 11 226 170 11
45525 -236 178 12 242 186 14 246 190 14 246 190 14
45526 -246 190 14 246 190 14 246 190 14 246 190 14
45527 -241 196 14 184 144 12 10 10 10 2 2 6
45528 - 6 6 6 116 116 116 242 242 242 253 253 253
45529 -253 253 253 253 253 253 253 253 253 253 253 253
45530 -253 253 253 253 253 253 253 253 253 253 253 253
45531 -253 253 253 253 253 253 253 253 253 253 253 253
45532 -253 253 253 253 253 253 253 253 253 253 253 253
45533 -253 253 253 231 231 231 198 198 198 214 170 54
45534 -236 178 12 236 178 12 210 150 10 137 92 6
45535 - 18 14 6 2 2 6 2 2 6 2 2 6
45536 - 6 6 6 70 47 6 200 144 11 236 178 12
45537 -239 182 13 239 182 13 124 112 88 58 58 58
45538 - 22 22 22 6 6 6 0 0 0 0 0 0
45539 - 0 0 0 0 0 0 0 0 0 0 0 0
45540 - 0 0 0 0 0 0 0 0 0 0 0 0
45541 - 0 0 0 0 0 0 0 0 0 0 0 0
45542 - 0 0 0 0 0 0 0 0 0 10 10 10
45543 - 30 30 30 70 70 70 180 133 36 226 170 11
45544 -239 182 13 242 186 14 242 186 14 246 186 14
45545 -246 190 14 246 190 14 246 190 14 246 190 14
45546 -246 190 14 246 190 14 246 190 14 246 190 14
45547 -246 190 14 232 195 16 98 70 6 2 2 6
45548 - 2 2 6 2 2 6 66 66 66 221 221 221
45549 -253 253 253 253 253 253 253 253 253 253 253 253
45550 -253 253 253 253 253 253 253 253 253 253 253 253
45551 -253 253 253 253 253 253 253 253 253 253 253 253
45552 -253 253 253 253 253 253 253 253 253 253 253 253
45553 -253 253 253 206 206 206 198 198 198 214 166 58
45554 -230 174 11 230 174 11 216 158 10 192 133 9
45555 -163 110 8 116 81 8 102 78 10 116 81 8
45556 -167 114 7 197 138 11 226 170 11 239 182 13
45557 -242 186 14 242 186 14 162 146 94 78 78 78
45558 - 34 34 34 14 14 14 6 6 6 0 0 0
45559 - 0 0 0 0 0 0 0 0 0 0 0 0
45560 - 0 0 0 0 0 0 0 0 0 0 0 0
45561 - 0 0 0 0 0 0 0 0 0 0 0 0
45562 - 0 0 0 0 0 0 0 0 0 6 6 6
45563 - 30 30 30 78 78 78 190 142 34 226 170 11
45564 -239 182 13 246 190 14 246 190 14 246 190 14
45565 -246 190 14 246 190 14 246 190 14 246 190 14
45566 -246 190 14 246 190 14 246 190 14 246 190 14
45567 -246 190 14 241 196 14 203 166 17 22 18 6
45568 - 2 2 6 2 2 6 2 2 6 38 38 38
45569 -218 218 218 253 253 253 253 253 253 253 253 253
45570 -253 253 253 253 253 253 253 253 253 253 253 253
45571 -253 253 253 253 253 253 253 253 253 253 253 253
45572 -253 253 253 253 253 253 253 253 253 253 253 253
45573 -250 250 250 206 206 206 198 198 198 202 162 69
45574 -226 170 11 236 178 12 224 166 10 210 150 10
45575 -200 144 11 197 138 11 192 133 9 197 138 11
45576 -210 150 10 226 170 11 242 186 14 246 190 14
45577 -246 190 14 246 186 14 225 175 15 124 112 88
45578 - 62 62 62 30 30 30 14 14 14 6 6 6
45579 - 0 0 0 0 0 0 0 0 0 0 0 0
45580 - 0 0 0 0 0 0 0 0 0 0 0 0
45581 - 0 0 0 0 0 0 0 0 0 0 0 0
45582 - 0 0 0 0 0 0 0 0 0 10 10 10
45583 - 30 30 30 78 78 78 174 135 50 224 166 10
45584 -239 182 13 246 190 14 246 190 14 246 190 14
45585 -246 190 14 246 190 14 246 190 14 246 190 14
45586 -246 190 14 246 190 14 246 190 14 246 190 14
45587 -246 190 14 246 190 14 241 196 14 139 102 15
45588 - 2 2 6 2 2 6 2 2 6 2 2 6
45589 - 78 78 78 250 250 250 253 253 253 253 253 253
45590 -253 253 253 253 253 253 253 253 253 253 253 253
45591 -253 253 253 253 253 253 253 253 253 253 253 253
45592 -253 253 253 253 253 253 253 253 253 253 253 253
45593 -250 250 250 214 214 214 198 198 198 190 150 46
45594 -219 162 10 236 178 12 234 174 13 224 166 10
45595 -216 158 10 213 154 11 213 154 11 216 158 10
45596 -226 170 11 239 182 13 246 190 14 246 190 14
45597 -246 190 14 246 190 14 242 186 14 206 162 42
45598 -101 101 101 58 58 58 30 30 30 14 14 14
45599 - 6 6 6 0 0 0 0 0 0 0 0 0
45600 - 0 0 0 0 0 0 0 0 0 0 0 0
45601 - 0 0 0 0 0 0 0 0 0 0 0 0
45602 - 0 0 0 0 0 0 0 0 0 10 10 10
45603 - 30 30 30 74 74 74 174 135 50 216 158 10
45604 -236 178 12 246 190 14 246 190 14 246 190 14
45605 -246 190 14 246 190 14 246 190 14 246 190 14
45606 -246 190 14 246 190 14 246 190 14 246 190 14
45607 -246 190 14 246 190 14 241 196 14 226 184 13
45608 - 61 42 6 2 2 6 2 2 6 2 2 6
45609 - 22 22 22 238 238 238 253 253 253 253 253 253
45610 -253 253 253 253 253 253 253 253 253 253 253 253
45611 -253 253 253 253 253 253 253 253 253 253 253 253
45612 -253 253 253 253 253 253 253 253 253 253 253 253
45613 -253 253 253 226 226 226 187 187 187 180 133 36
45614 -216 158 10 236 178 12 239 182 13 236 178 12
45615 -230 174 11 226 170 11 226 170 11 230 174 11
45616 -236 178 12 242 186 14 246 190 14 246 190 14
45617 -246 190 14 246 190 14 246 186 14 239 182 13
45618 -206 162 42 106 106 106 66 66 66 34 34 34
45619 - 14 14 14 6 6 6 0 0 0 0 0 0
45620 - 0 0 0 0 0 0 0 0 0 0 0 0
45621 - 0 0 0 0 0 0 0 0 0 0 0 0
45622 - 0 0 0 0 0 0 0 0 0 6 6 6
45623 - 26 26 26 70 70 70 163 133 67 213 154 11
45624 -236 178 12 246 190 14 246 190 14 246 190 14
45625 -246 190 14 246 190 14 246 190 14 246 190 14
45626 -246 190 14 246 190 14 246 190 14 246 190 14
45627 -246 190 14 246 190 14 246 190 14 241 196 14
45628 -190 146 13 18 14 6 2 2 6 2 2 6
45629 - 46 46 46 246 246 246 253 253 253 253 253 253
45630 -253 253 253 253 253 253 253 253 253 253 253 253
45631 -253 253 253 253 253 253 253 253 253 253 253 253
45632 -253 253 253 253 253 253 253 253 253 253 253 253
45633 -253 253 253 221 221 221 86 86 86 156 107 11
45634 -216 158 10 236 178 12 242 186 14 246 186 14
45635 -242 186 14 239 182 13 239 182 13 242 186 14
45636 -242 186 14 246 186 14 246 190 14 246 190 14
45637 -246 190 14 246 190 14 246 190 14 246 190 14
45638 -242 186 14 225 175 15 142 122 72 66 66 66
45639 - 30 30 30 10 10 10 0 0 0 0 0 0
45640 - 0 0 0 0 0 0 0 0 0 0 0 0
45641 - 0 0 0 0 0 0 0 0 0 0 0 0
45642 - 0 0 0 0 0 0 0 0 0 6 6 6
45643 - 26 26 26 70 70 70 163 133 67 210 150 10
45644 -236 178 12 246 190 14 246 190 14 246 190 14
45645 -246 190 14 246 190 14 246 190 14 246 190 14
45646 -246 190 14 246 190 14 246 190 14 246 190 14
45647 -246 190 14 246 190 14 246 190 14 246 190 14
45648 -232 195 16 121 92 8 34 34 34 106 106 106
45649 -221 221 221 253 253 253 253 253 253 253 253 253
45650 -253 253 253 253 253 253 253 253 253 253 253 253
45651 -253 253 253 253 253 253 253 253 253 253 253 253
45652 -253 253 253 253 253 253 253 253 253 253 253 253
45653 -242 242 242 82 82 82 18 14 6 163 110 8
45654 -216 158 10 236 178 12 242 186 14 246 190 14
45655 -246 190 14 246 190 14 246 190 14 246 190 14
45656 -246 190 14 246 190 14 246 190 14 246 190 14
45657 -246 190 14 246 190 14 246 190 14 246 190 14
45658 -246 190 14 246 190 14 242 186 14 163 133 67
45659 - 46 46 46 18 18 18 6 6 6 0 0 0
45660 - 0 0 0 0 0 0 0 0 0 0 0 0
45661 - 0 0 0 0 0 0 0 0 0 0 0 0
45662 - 0 0 0 0 0 0 0 0 0 10 10 10
45663 - 30 30 30 78 78 78 163 133 67 210 150 10
45664 -236 178 12 246 186 14 246 190 14 246 190 14
45665 -246 190 14 246 190 14 246 190 14 246 190 14
45666 -246 190 14 246 190 14 246 190 14 246 190 14
45667 -246 190 14 246 190 14 246 190 14 246 190 14
45668 -241 196 14 215 174 15 190 178 144 253 253 253
45669 -253 253 253 253 253 253 253 253 253 253 253 253
45670 -253 253 253 253 253 253 253 253 253 253 253 253
45671 -253 253 253 253 253 253 253 253 253 253 253 253
45672 -253 253 253 253 253 253 253 253 253 218 218 218
45673 - 58 58 58 2 2 6 22 18 6 167 114 7
45674 -216 158 10 236 178 12 246 186 14 246 190 14
45675 -246 190 14 246 190 14 246 190 14 246 190 14
45676 -246 190 14 246 190 14 246 190 14 246 190 14
45677 -246 190 14 246 190 14 246 190 14 246 190 14
45678 -246 190 14 246 186 14 242 186 14 190 150 46
45679 - 54 54 54 22 22 22 6 6 6 0 0 0
45680 - 0 0 0 0 0 0 0 0 0 0 0 0
45681 - 0 0 0 0 0 0 0 0 0 0 0 0
45682 - 0 0 0 0 0 0 0 0 0 14 14 14
45683 - 38 38 38 86 86 86 180 133 36 213 154 11
45684 -236 178 12 246 186 14 246 190 14 246 190 14
45685 -246 190 14 246 190 14 246 190 14 246 190 14
45686 -246 190 14 246 190 14 246 190 14 246 190 14
45687 -246 190 14 246 190 14 246 190 14 246 190 14
45688 -246 190 14 232 195 16 190 146 13 214 214 214
45689 -253 253 253 253 253 253 253 253 253 253 253 253
45690 -253 253 253 253 253 253 253 253 253 253 253 253
45691 -253 253 253 253 253 253 253 253 253 253 253 253
45692 -253 253 253 250 250 250 170 170 170 26 26 26
45693 - 2 2 6 2 2 6 37 26 9 163 110 8
45694 -219 162 10 239 182 13 246 186 14 246 190 14
45695 -246 190 14 246 190 14 246 190 14 246 190 14
45696 -246 190 14 246 190 14 246 190 14 246 190 14
45697 -246 190 14 246 190 14 246 190 14 246 190 14
45698 -246 186 14 236 178 12 224 166 10 142 122 72
45699 - 46 46 46 18 18 18 6 6 6 0 0 0
45700 - 0 0 0 0 0 0 0 0 0 0 0 0
45701 - 0 0 0 0 0 0 0 0 0 0 0 0
45702 - 0 0 0 0 0 0 6 6 6 18 18 18
45703 - 50 50 50 109 106 95 192 133 9 224 166 10
45704 -242 186 14 246 190 14 246 190 14 246 190 14
45705 -246 190 14 246 190 14 246 190 14 246 190 14
45706 -246 190 14 246 190 14 246 190 14 246 190 14
45707 -246 190 14 246 190 14 246 190 14 246 190 14
45708 -242 186 14 226 184 13 210 162 10 142 110 46
45709 -226 226 226 253 253 253 253 253 253 253 253 253
45710 -253 253 253 253 253 253 253 253 253 253 253 253
45711 -253 253 253 253 253 253 253 253 253 253 253 253
45712 -198 198 198 66 66 66 2 2 6 2 2 6
45713 - 2 2 6 2 2 6 50 34 6 156 107 11
45714 -219 162 10 239 182 13 246 186 14 246 190 14
45715 -246 190 14 246 190 14 246 190 14 246 190 14
45716 -246 190 14 246 190 14 246 190 14 246 190 14
45717 -246 190 14 246 190 14 246 190 14 242 186 14
45718 -234 174 13 213 154 11 154 122 46 66 66 66
45719 - 30 30 30 10 10 10 0 0 0 0 0 0
45720 - 0 0 0 0 0 0 0 0 0 0 0 0
45721 - 0 0 0 0 0 0 0 0 0 0 0 0
45722 - 0 0 0 0 0 0 6 6 6 22 22 22
45723 - 58 58 58 154 121 60 206 145 10 234 174 13
45724 -242 186 14 246 186 14 246 190 14 246 190 14
45725 -246 190 14 246 190 14 246 190 14 246 190 14
45726 -246 190 14 246 190 14 246 190 14 246 190 14
45727 -246 190 14 246 190 14 246 190 14 246 190 14
45728 -246 186 14 236 178 12 210 162 10 163 110 8
45729 - 61 42 6 138 138 138 218 218 218 250 250 250
45730 -253 253 253 253 253 253 253 253 253 250 250 250
45731 -242 242 242 210 210 210 144 144 144 66 66 66
45732 - 6 6 6 2 2 6 2 2 6 2 2 6
45733 - 2 2 6 2 2 6 61 42 6 163 110 8
45734 -216 158 10 236 178 12 246 190 14 246 190 14
45735 -246 190 14 246 190 14 246 190 14 246 190 14
45736 -246 190 14 246 190 14 246 190 14 246 190 14
45737 -246 190 14 239 182 13 230 174 11 216 158 10
45738 -190 142 34 124 112 88 70 70 70 38 38 38
45739 - 18 18 18 6 6 6 0 0 0 0 0 0
45740 - 0 0 0 0 0 0 0 0 0 0 0 0
45741 - 0 0 0 0 0 0 0 0 0 0 0 0
45742 - 0 0 0 0 0 0 6 6 6 22 22 22
45743 - 62 62 62 168 124 44 206 145 10 224 166 10
45744 -236 178 12 239 182 13 242 186 14 242 186 14
45745 -246 186 14 246 190 14 246 190 14 246 190 14
45746 -246 190 14 246 190 14 246 190 14 246 190 14
45747 -246 190 14 246 190 14 246 190 14 246 190 14
45748 -246 190 14 236 178 12 216 158 10 175 118 6
45749 - 80 54 7 2 2 6 6 6 6 30 30 30
45750 - 54 54 54 62 62 62 50 50 50 38 38 38
45751 - 14 14 14 2 2 6 2 2 6 2 2 6
45752 - 2 2 6 2 2 6 2 2 6 2 2 6
45753 - 2 2 6 6 6 6 80 54 7 167 114 7
45754 -213 154 11 236 178 12 246 190 14 246 190 14
45755 -246 190 14 246 190 14 246 190 14 246 190 14
45756 -246 190 14 242 186 14 239 182 13 239 182 13
45757 -230 174 11 210 150 10 174 135 50 124 112 88
45758 - 82 82 82 54 54 54 34 34 34 18 18 18
45759 - 6 6 6 0 0 0 0 0 0 0 0 0
45760 - 0 0 0 0 0 0 0 0 0 0 0 0
45761 - 0 0 0 0 0 0 0 0 0 0 0 0
45762 - 0 0 0 0 0 0 6 6 6 18 18 18
45763 - 50 50 50 158 118 36 192 133 9 200 144 11
45764 -216 158 10 219 162 10 224 166 10 226 170 11
45765 -230 174 11 236 178 12 239 182 13 239 182 13
45766 -242 186 14 246 186 14 246 190 14 246 190 14
45767 -246 190 14 246 190 14 246 190 14 246 190 14
45768 -246 186 14 230 174 11 210 150 10 163 110 8
45769 -104 69 6 10 10 10 2 2 6 2 2 6
45770 - 2 2 6 2 2 6 2 2 6 2 2 6
45771 - 2 2 6 2 2 6 2 2 6 2 2 6
45772 - 2 2 6 2 2 6 2 2 6 2 2 6
45773 - 2 2 6 6 6 6 91 60 6 167 114 7
45774 -206 145 10 230 174 11 242 186 14 246 190 14
45775 -246 190 14 246 190 14 246 186 14 242 186 14
45776 -239 182 13 230 174 11 224 166 10 213 154 11
45777 -180 133 36 124 112 88 86 86 86 58 58 58
45778 - 38 38 38 22 22 22 10 10 10 6 6 6
45779 - 0 0 0 0 0 0 0 0 0 0 0 0
45780 - 0 0 0 0 0 0 0 0 0 0 0 0
45781 - 0 0 0 0 0 0 0 0 0 0 0 0
45782 - 0 0 0 0 0 0 0 0 0 14 14 14
45783 - 34 34 34 70 70 70 138 110 50 158 118 36
45784 -167 114 7 180 123 7 192 133 9 197 138 11
45785 -200 144 11 206 145 10 213 154 11 219 162 10
45786 -224 166 10 230 174 11 239 182 13 242 186 14
45787 -246 186 14 246 186 14 246 186 14 246 186 14
45788 -239 182 13 216 158 10 185 133 11 152 99 6
45789 -104 69 6 18 14 6 2 2 6 2 2 6
45790 - 2 2 6 2 2 6 2 2 6 2 2 6
45791 - 2 2 6 2 2 6 2 2 6 2 2 6
45792 - 2 2 6 2 2 6 2 2 6 2 2 6
45793 - 2 2 6 6 6 6 80 54 7 152 99 6
45794 -192 133 9 219 162 10 236 178 12 239 182 13
45795 -246 186 14 242 186 14 239 182 13 236 178 12
45796 -224 166 10 206 145 10 192 133 9 154 121 60
45797 - 94 94 94 62 62 62 42 42 42 22 22 22
45798 - 14 14 14 6 6 6 0 0 0 0 0 0
45799 - 0 0 0 0 0 0 0 0 0 0 0 0
45800 - 0 0 0 0 0 0 0 0 0 0 0 0
45801 - 0 0 0 0 0 0 0 0 0 0 0 0
45802 - 0 0 0 0 0 0 0 0 0 6 6 6
45803 - 18 18 18 34 34 34 58 58 58 78 78 78
45804 -101 98 89 124 112 88 142 110 46 156 107 11
45805 -163 110 8 167 114 7 175 118 6 180 123 7
45806 -185 133 11 197 138 11 210 150 10 219 162 10
45807 -226 170 11 236 178 12 236 178 12 234 174 13
45808 -219 162 10 197 138 11 163 110 8 130 83 6
45809 - 91 60 6 10 10 10 2 2 6 2 2 6
45810 - 18 18 18 38 38 38 38 38 38 38 38 38
45811 - 38 38 38 38 38 38 38 38 38 38 38 38
45812 - 38 38 38 38 38 38 26 26 26 2 2 6
45813 - 2 2 6 6 6 6 70 47 6 137 92 6
45814 -175 118 6 200 144 11 219 162 10 230 174 11
45815 -234 174 13 230 174 11 219 162 10 210 150 10
45816 -192 133 9 163 110 8 124 112 88 82 82 82
45817 - 50 50 50 30 30 30 14 14 14 6 6 6
45818 - 0 0 0 0 0 0 0 0 0 0 0 0
45819 - 0 0 0 0 0 0 0 0 0 0 0 0
45820 - 0 0 0 0 0 0 0 0 0 0 0 0
45821 - 0 0 0 0 0 0 0 0 0 0 0 0
45822 - 0 0 0 0 0 0 0 0 0 0 0 0
45823 - 6 6 6 14 14 14 22 22 22 34 34 34
45824 - 42 42 42 58 58 58 74 74 74 86 86 86
45825 -101 98 89 122 102 70 130 98 46 121 87 25
45826 -137 92 6 152 99 6 163 110 8 180 123 7
45827 -185 133 11 197 138 11 206 145 10 200 144 11
45828 -180 123 7 156 107 11 130 83 6 104 69 6
45829 - 50 34 6 54 54 54 110 110 110 101 98 89
45830 - 86 86 86 82 82 82 78 78 78 78 78 78
45831 - 78 78 78 78 78 78 78 78 78 78 78 78
45832 - 78 78 78 82 82 82 86 86 86 94 94 94
45833 -106 106 106 101 101 101 86 66 34 124 80 6
45834 -156 107 11 180 123 7 192 133 9 200 144 11
45835 -206 145 10 200 144 11 192 133 9 175 118 6
45836 -139 102 15 109 106 95 70 70 70 42 42 42
45837 - 22 22 22 10 10 10 0 0 0 0 0 0
45838 - 0 0 0 0 0 0 0 0 0 0 0 0
45839 - 0 0 0 0 0 0 0 0 0 0 0 0
45840 - 0 0 0 0 0 0 0 0 0 0 0 0
45841 - 0 0 0 0 0 0 0 0 0 0 0 0
45842 - 0 0 0 0 0 0 0 0 0 0 0 0
45843 - 0 0 0 0 0 0 6 6 6 10 10 10
45844 - 14 14 14 22 22 22 30 30 30 38 38 38
45845 - 50 50 50 62 62 62 74 74 74 90 90 90
45846 -101 98 89 112 100 78 121 87 25 124 80 6
45847 -137 92 6 152 99 6 152 99 6 152 99 6
45848 -138 86 6 124 80 6 98 70 6 86 66 30
45849 -101 98 89 82 82 82 58 58 58 46 46 46
45850 - 38 38 38 34 34 34 34 34 34 34 34 34
45851 - 34 34 34 34 34 34 34 34 34 34 34 34
45852 - 34 34 34 34 34 34 38 38 38 42 42 42
45853 - 54 54 54 82 82 82 94 86 76 91 60 6
45854 -134 86 6 156 107 11 167 114 7 175 118 6
45855 -175 118 6 167 114 7 152 99 6 121 87 25
45856 -101 98 89 62 62 62 34 34 34 18 18 18
45857 - 6 6 6 0 0 0 0 0 0 0 0 0
45858 - 0 0 0 0 0 0 0 0 0 0 0 0
45859 - 0 0 0 0 0 0 0 0 0 0 0 0
45860 - 0 0 0 0 0 0 0 0 0 0 0 0
45861 - 0 0 0 0 0 0 0 0 0 0 0 0
45862 - 0 0 0 0 0 0 0 0 0 0 0 0
45863 - 0 0 0 0 0 0 0 0 0 0 0 0
45864 - 0 0 0 6 6 6 6 6 6 10 10 10
45865 - 18 18 18 22 22 22 30 30 30 42 42 42
45866 - 50 50 50 66 66 66 86 86 86 101 98 89
45867 -106 86 58 98 70 6 104 69 6 104 69 6
45868 -104 69 6 91 60 6 82 62 34 90 90 90
45869 - 62 62 62 38 38 38 22 22 22 14 14 14
45870 - 10 10 10 10 10 10 10 10 10 10 10 10
45871 - 10 10 10 10 10 10 6 6 6 10 10 10
45872 - 10 10 10 10 10 10 10 10 10 14 14 14
45873 - 22 22 22 42 42 42 70 70 70 89 81 66
45874 - 80 54 7 104 69 6 124 80 6 137 92 6
45875 -134 86 6 116 81 8 100 82 52 86 86 86
45876 - 58 58 58 30 30 30 14 14 14 6 6 6
45877 - 0 0 0 0 0 0 0 0 0 0 0 0
45878 - 0 0 0 0 0 0 0 0 0 0 0 0
45879 - 0 0 0 0 0 0 0 0 0 0 0 0
45880 - 0 0 0 0 0 0 0 0 0 0 0 0
45881 - 0 0 0 0 0 0 0 0 0 0 0 0
45882 - 0 0 0 0 0 0 0 0 0 0 0 0
45883 - 0 0 0 0 0 0 0 0 0 0 0 0
45884 - 0 0 0 0 0 0 0 0 0 0 0 0
45885 - 0 0 0 6 6 6 10 10 10 14 14 14
45886 - 18 18 18 26 26 26 38 38 38 54 54 54
45887 - 70 70 70 86 86 86 94 86 76 89 81 66
45888 - 89 81 66 86 86 86 74 74 74 50 50 50
45889 - 30 30 30 14 14 14 6 6 6 0 0 0
45890 - 0 0 0 0 0 0 0 0 0 0 0 0
45891 - 0 0 0 0 0 0 0 0 0 0 0 0
45892 - 0 0 0 0 0 0 0 0 0 0 0 0
45893 - 6 6 6 18 18 18 34 34 34 58 58 58
45894 - 82 82 82 89 81 66 89 81 66 89 81 66
45895 - 94 86 66 94 86 76 74 74 74 50 50 50
45896 - 26 26 26 14 14 14 6 6 6 0 0 0
45897 - 0 0 0 0 0 0 0 0 0 0 0 0
45898 - 0 0 0 0 0 0 0 0 0 0 0 0
45899 - 0 0 0 0 0 0 0 0 0 0 0 0
45900 - 0 0 0 0 0 0 0 0 0 0 0 0
45901 - 0 0 0 0 0 0 0 0 0 0 0 0
45902 - 0 0 0 0 0 0 0 0 0 0 0 0
45903 - 0 0 0 0 0 0 0 0 0 0 0 0
45904 - 0 0 0 0 0 0 0 0 0 0 0 0
45905 - 0 0 0 0 0 0 0 0 0 0 0 0
45906 - 6 6 6 6 6 6 14 14 14 18 18 18
45907 - 30 30 30 38 38 38 46 46 46 54 54 54
45908 - 50 50 50 42 42 42 30 30 30 18 18 18
45909 - 10 10 10 0 0 0 0 0 0 0 0 0
45910 - 0 0 0 0 0 0 0 0 0 0 0 0
45911 - 0 0 0 0 0 0 0 0 0 0 0 0
45912 - 0 0 0 0 0 0 0 0 0 0 0 0
45913 - 0 0 0 6 6 6 14 14 14 26 26 26
45914 - 38 38 38 50 50 50 58 58 58 58 58 58
45915 - 54 54 54 42 42 42 30 30 30 18 18 18
45916 - 10 10 10 0 0 0 0 0 0 0 0 0
45917 - 0 0 0 0 0 0 0 0 0 0 0 0
45918 - 0 0 0 0 0 0 0 0 0 0 0 0
45919 - 0 0 0 0 0 0 0 0 0 0 0 0
45920 - 0 0 0 0 0 0 0 0 0 0 0 0
45921 - 0 0 0 0 0 0 0 0 0 0 0 0
45922 - 0 0 0 0 0 0 0 0 0 0 0 0
45923 - 0 0 0 0 0 0 0 0 0 0 0 0
45924 - 0 0 0 0 0 0 0 0 0 0 0 0
45925 - 0 0 0 0 0 0 0 0 0 0 0 0
45926 - 0 0 0 0 0 0 0 0 0 6 6 6
45927 - 6 6 6 10 10 10 14 14 14 18 18 18
45928 - 18 18 18 14 14 14 10 10 10 6 6 6
45929 - 0 0 0 0 0 0 0 0 0 0 0 0
45930 - 0 0 0 0 0 0 0 0 0 0 0 0
45931 - 0 0 0 0 0 0 0 0 0 0 0 0
45932 - 0 0 0 0 0 0 0 0 0 0 0 0
45933 - 0 0 0 0 0 0 0 0 0 6 6 6
45934 - 14 14 14 18 18 18 22 22 22 22 22 22
45935 - 18 18 18 14 14 14 10 10 10 6 6 6
45936 - 0 0 0 0 0 0 0 0 0 0 0 0
45937 - 0 0 0 0 0 0 0 0 0 0 0 0
45938 - 0 0 0 0 0 0 0 0 0 0 0 0
45939 - 0 0 0 0 0 0 0 0 0 0 0 0
45940 - 0 0 0 0 0 0 0 0 0 0 0 0
45941 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45942 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45943 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45944 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45945 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45946 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45947 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45948 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45949 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45950 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45951 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45952 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45953 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45954 +4 4 4 4 4 4
45955 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45956 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45957 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45958 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45959 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45960 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45961 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45962 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45963 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45964 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45965 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45966 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45967 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45968 +4 4 4 4 4 4
45969 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45970 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45971 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45972 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45973 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45974 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45975 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45976 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45977 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45978 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45979 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45980 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45981 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45982 +4 4 4 4 4 4
45983 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45984 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45985 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45986 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45987 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45988 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45989 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45990 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45991 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45992 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45993 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45994 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45995 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45996 +4 4 4 4 4 4
45997 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45998 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45999 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46000 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46001 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46002 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46003 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46004 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46005 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46006 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46007 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46008 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46009 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46010 +4 4 4 4 4 4
46011 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46012 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46013 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46014 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46015 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46016 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46017 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46018 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46019 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46020 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46021 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46022 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46023 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46024 +4 4 4 4 4 4
46025 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46026 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46027 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46028 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46029 +4 4 4 4 4 4 4 4 4 3 3 3 0 0 0 0 0 0
46030 +0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 4 4 4
46031 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46032 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46033 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46034 +4 4 4 4 4 4 4 4 4 4 4 4 1 1 1 0 0 0
46035 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
46036 +4 4 4 4 4 4 4 4 4 2 1 0 2 1 0 3 2 2
46037 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46038 +4 4 4 4 4 4
46039 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46040 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46041 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46042 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46043 +4 4 4 4 4 4 2 2 2 0 0 0 3 4 3 26 28 28
46044 +37 38 37 37 38 37 14 17 19 2 2 2 0 0 0 2 2 2
46045 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46046 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46047 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46048 +4 4 4 4 4 4 3 3 3 0 0 0 1 1 1 6 6 6
46049 +2 2 2 0 0 0 3 3 3 4 4 4 4 4 4 4 4 4
46050 +4 4 5 3 3 3 1 0 0 0 0 0 1 0 0 0 0 0
46051 +1 1 1 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46052 +4 4 4 4 4 4
46053 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46054 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46055 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46056 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46057 +2 2 2 0 0 0 0 0 0 14 17 19 60 74 84 137 136 137
46058 +153 152 153 137 136 137 125 124 125 60 73 81 6 6 6 3 1 0
46059 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
46060 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46061 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46062 +4 4 4 4 4 4 0 0 0 4 4 4 41 54 63 125 124 125
46063 +60 73 81 6 6 6 4 0 0 3 3 3 4 4 4 4 4 4
46064 +4 4 4 0 0 0 6 9 11 41 54 63 41 65 82 22 30 35
46065 +2 2 2 2 1 0 4 4 4 4 4 4 4 4 4 4 4 4
46066 +4 4 4 4 4 4
46067 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46068 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46069 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46070 +4 4 4 4 4 4 5 5 5 5 5 5 2 2 2 0 0 0
46071 +4 0 0 6 6 6 41 54 63 137 136 137 174 174 174 167 166 167
46072 +165 164 165 165 164 165 163 162 163 163 162 163 125 124 125 41 54 63
46073 +1 1 1 0 0 0 0 0 0 3 3 3 5 5 5 4 4 4
46074 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46075 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
46076 +3 3 3 2 0 0 4 0 0 60 73 81 156 155 156 167 166 167
46077 +163 162 163 85 115 134 5 7 8 0 0 0 4 4 4 5 5 5
46078 +0 0 0 2 5 5 55 98 126 90 154 193 90 154 193 72 125 159
46079 +37 51 59 2 0 0 1 1 1 4 5 5 4 4 4 4 4 4
46080 +4 4 4 4 4 4
46081 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46082 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46083 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46084 +4 4 4 5 5 5 4 4 4 1 1 1 0 0 0 3 3 3
46085 +37 38 37 125 124 125 163 162 163 174 174 174 158 157 158 158 157 158
46086 +156 155 156 156 155 156 158 157 158 165 164 165 174 174 174 166 165 166
46087 +125 124 125 16 19 21 1 0 0 0 0 0 0 0 0 4 4 4
46088 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
46089 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 1 1 1
46090 +0 0 0 0 0 0 37 38 37 153 152 153 174 174 174 158 157 158
46091 +174 174 174 163 162 163 37 38 37 4 3 3 4 0 0 1 1 1
46092 +0 0 0 22 40 52 101 161 196 101 161 196 90 154 193 101 161 196
46093 +64 123 161 14 17 19 0 0 0 4 4 4 4 4 4 4 4 4
46094 +4 4 4 4 4 4
46095 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46096 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46097 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
46098 +5 5 5 2 2 2 0 0 0 4 0 0 24 26 27 85 115 134
46099 +156 155 156 174 174 174 167 166 167 156 155 156 154 153 154 157 156 157
46100 +156 155 156 156 155 156 155 154 155 153 152 153 158 157 158 167 166 167
46101 +174 174 174 156 155 156 60 74 84 16 19 21 0 0 0 0 0 0
46102 +1 1 1 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
46103 +4 4 4 5 5 5 6 6 6 3 3 3 0 0 0 4 0 0
46104 +13 16 17 60 73 81 137 136 137 165 164 165 156 155 156 153 152 153
46105 +174 174 174 177 184 187 60 73 81 3 1 0 0 0 0 1 1 2
46106 +22 30 35 64 123 161 136 185 209 90 154 193 90 154 193 90 154 193
46107 +90 154 193 21 29 34 0 0 0 3 2 2 4 4 5 4 4 4
46108 +4 4 4 4 4 4
46109 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46110 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46111 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 3 3 3
46112 +0 0 0 0 0 0 10 13 16 60 74 84 157 156 157 174 174 174
46113 +174 174 174 158 157 158 153 152 153 154 153 154 156 155 156 155 154 155
46114 +156 155 156 155 154 155 154 153 154 157 156 157 154 153 154 153 152 153
46115 +163 162 163 174 174 174 177 184 187 137 136 137 60 73 81 13 16 17
46116 +4 0 0 0 0 0 3 3 3 5 5 5 4 4 4 4 4 4
46117 +5 5 5 4 4 4 1 1 1 0 0 0 3 3 3 41 54 63
46118 +131 129 131 174 174 174 174 174 174 174 174 174 167 166 167 174 174 174
46119 +190 197 201 137 136 137 24 26 27 4 0 0 16 21 25 50 82 103
46120 +90 154 193 136 185 209 90 154 193 101 161 196 101 161 196 101 161 196
46121 +31 91 132 3 6 7 0 0 0 4 4 4 4 4 4 4 4 4
46122 +4 4 4 4 4 4
46123 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46124 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46125 +4 4 4 4 4 4 4 4 4 2 2 2 0 0 0 4 0 0
46126 +4 0 0 43 57 68 137 136 137 177 184 187 174 174 174 163 162 163
46127 +155 154 155 155 154 155 156 155 156 155 154 155 158 157 158 165 164 165
46128 +167 166 167 166 165 166 163 162 163 157 156 157 155 154 155 155 154 155
46129 +153 152 153 156 155 156 167 166 167 174 174 174 174 174 174 131 129 131
46130 +41 54 63 5 5 5 0 0 0 0 0 0 3 3 3 4 4 4
46131 +1 1 1 0 0 0 1 0 0 26 28 28 125 124 125 174 174 174
46132 +177 184 187 174 174 174 174 174 174 156 155 156 131 129 131 137 136 137
46133 +125 124 125 24 26 27 4 0 0 41 65 82 90 154 193 136 185 209
46134 +136 185 209 101 161 196 53 118 160 37 112 160 90 154 193 34 86 122
46135 +7 12 15 0 0 0 4 4 4 4 4 4 4 4 4 4 4 4
46136 +4 4 4 4 4 4
46137 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46138 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46139 +4 4 4 3 3 3 0 0 0 0 0 0 5 5 5 37 38 37
46140 +125 124 125 167 166 167 174 174 174 167 166 167 158 157 158 155 154 155
46141 +156 155 156 156 155 156 156 155 156 163 162 163 167 166 167 155 154 155
46142 +137 136 137 153 152 153 156 155 156 165 164 165 163 162 163 156 155 156
46143 +156 155 156 156 155 156 155 154 155 158 157 158 166 165 166 174 174 174
46144 +167 166 167 125 124 125 37 38 37 1 0 0 0 0 0 0 0 0
46145 +0 0 0 24 26 27 60 74 84 158 157 158 174 174 174 174 174 174
46146 +166 165 166 158 157 158 125 124 125 41 54 63 13 16 17 6 6 6
46147 +6 6 6 37 38 37 80 127 157 136 185 209 101 161 196 101 161 196
46148 +90 154 193 28 67 93 6 10 14 13 20 25 13 20 25 6 10 14
46149 +1 1 2 4 3 3 4 4 4 4 4 4 4 4 4 4 4 4
46150 +4 4 4 4 4 4
46151 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46152 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46153 +1 1 1 1 0 0 4 3 3 37 38 37 60 74 84 153 152 153
46154 +167 166 167 167 166 167 158 157 158 154 153 154 155 154 155 156 155 156
46155 +157 156 157 158 157 158 167 166 167 167 166 167 131 129 131 43 57 68
46156 +26 28 28 37 38 37 60 73 81 131 129 131 165 164 165 166 165 166
46157 +158 157 158 155 154 155 156 155 156 156 155 156 156 155 156 158 157 158
46158 +165 164 165 174 174 174 163 162 163 60 74 84 16 19 21 13 16 17
46159 +60 73 81 131 129 131 174 174 174 174 174 174 167 166 167 165 164 165
46160 +137 136 137 60 73 81 24 26 27 4 0 0 4 0 0 16 19 21
46161 +52 104 138 101 161 196 136 185 209 136 185 209 90 154 193 27 99 146
46162 +13 20 25 4 5 7 2 5 5 4 5 7 1 1 2 0 0 0
46163 +4 4 4 4 4 4 3 3 3 2 2 2 2 2 2 4 4 4
46164 +4 4 4 4 4 4
46165 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46166 +4 4 4 4 4 4 4 4 4 4 4 4 3 3 3 0 0 0
46167 +0 0 0 13 16 17 60 73 81 137 136 137 174 174 174 166 165 166
46168 +158 157 158 156 155 156 157 156 157 156 155 156 155 154 155 158 157 158
46169 +167 166 167 174 174 174 153 152 153 60 73 81 16 19 21 4 0 0
46170 +4 0 0 4 0 0 6 6 6 26 28 28 60 74 84 158 157 158
46171 +174 174 174 166 165 166 157 156 157 155 154 155 156 155 156 156 155 156
46172 +155 154 155 158 157 158 167 166 167 167 166 167 131 129 131 125 124 125
46173 +137 136 137 167 166 167 167 166 167 174 174 174 158 157 158 125 124 125
46174 +16 19 21 4 0 0 4 0 0 10 13 16 49 76 92 107 159 188
46175 +136 185 209 136 185 209 90 154 193 26 108 161 22 40 52 6 10 14
46176 +2 3 3 1 1 2 1 1 2 4 4 5 4 4 5 4 4 5
46177 +4 4 5 2 2 1 0 0 0 0 0 0 0 0 0 2 2 2
46178 +4 4 4 4 4 4
46179 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46180 +4 4 4 5 5 5 3 3 3 0 0 0 1 0 0 4 0 0
46181 +37 51 59 131 129 131 167 166 167 167 166 167 163 162 163 157 156 157
46182 +157 156 157 155 154 155 153 152 153 157 156 157 167 166 167 174 174 174
46183 +153 152 153 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
46184 +4 3 3 4 3 3 4 0 0 6 6 6 4 0 0 37 38 37
46185 +125 124 125 174 174 174 174 174 174 165 164 165 156 155 156 154 153 154
46186 +156 155 156 156 155 156 155 154 155 163 162 163 158 157 158 163 162 163
46187 +174 174 174 174 174 174 174 174 174 125 124 125 37 38 37 0 0 0
46188 +4 0 0 6 9 11 41 54 63 90 154 193 136 185 209 146 190 211
46189 +136 185 209 37 112 160 22 40 52 6 10 14 3 6 7 1 1 2
46190 +1 1 2 3 3 3 1 1 2 3 3 3 4 4 4 4 4 4
46191 +2 2 2 2 0 0 16 19 21 37 38 37 24 26 27 0 0 0
46192 +0 0 0 4 4 4
46193 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
46194 +4 4 4 0 0 0 0 0 0 0 0 0 26 28 28 120 125 127
46195 +158 157 158 174 174 174 165 164 165 157 156 157 155 154 155 156 155 156
46196 +153 152 153 153 152 153 167 166 167 174 174 174 174 174 174 125 124 125
46197 +37 38 37 4 0 0 0 0 0 4 0 0 4 3 3 4 4 4
46198 +4 4 4 4 4 4 5 5 5 4 0 0 4 0 0 4 0 0
46199 +4 3 3 43 57 68 137 136 137 174 174 174 174 174 174 165 164 165
46200 +154 153 154 153 152 153 153 152 153 153 152 153 163 162 163 174 174 174
46201 +174 174 174 153 152 153 60 73 81 6 6 6 4 0 0 4 3 3
46202 +32 43 50 80 127 157 136 185 209 146 190 211 146 190 211 90 154 193
46203 +28 67 93 28 67 93 40 71 93 3 6 7 1 1 2 2 5 5
46204 +50 82 103 79 117 143 26 37 45 0 0 0 3 3 3 1 1 1
46205 +0 0 0 41 54 63 137 136 137 174 174 174 153 152 153 60 73 81
46206 +2 0 0 0 0 0
46207 +4 4 4 4 4 4 4 4 4 4 4 4 6 6 6 2 2 2
46208 +0 0 0 2 0 0 24 26 27 60 74 84 153 152 153 174 174 174
46209 +174 174 174 157 156 157 154 153 154 156 155 156 154 153 154 153 152 153
46210 +165 164 165 174 174 174 177 184 187 137 136 137 43 57 68 6 6 6
46211 +4 0 0 2 0 0 3 3 3 5 5 5 5 5 5 4 4 4
46212 +4 4 4 4 4 4 4 4 4 5 5 5 6 6 6 4 3 3
46213 +4 0 0 4 0 0 24 26 27 60 73 81 153 152 153 174 174 174
46214 +174 174 174 158 157 158 158 157 158 174 174 174 174 174 174 158 157 158
46215 +60 74 84 24 26 27 4 0 0 4 0 0 17 23 27 59 113 148
46216 +136 185 209 191 222 234 146 190 211 136 185 209 31 91 132 7 11 13
46217 +22 40 52 101 161 196 90 154 193 6 9 11 3 4 4 43 95 132
46218 +136 185 209 172 205 220 55 98 126 0 0 0 0 0 0 2 0 0
46219 +26 28 28 153 152 153 177 184 187 167 166 167 177 184 187 165 164 165
46220 +37 38 37 0 0 0
46221 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
46222 +13 16 17 60 73 81 137 136 137 174 174 174 174 174 174 165 164 165
46223 +153 152 153 153 152 153 155 154 155 154 153 154 158 157 158 174 174 174
46224 +177 184 187 163 162 163 60 73 81 16 19 21 4 0 0 4 0 0
46225 +4 3 3 4 4 4 5 5 5 5 5 5 4 4 4 5 5 5
46226 +5 5 5 5 5 5 5 5 5 4 4 4 4 4 4 5 5 5
46227 +6 6 6 4 0 0 4 0 0 4 0 0 24 26 27 60 74 84
46228 +166 165 166 174 174 174 177 184 187 165 164 165 125 124 125 24 26 27
46229 +4 0 0 4 0 0 5 5 5 50 82 103 136 185 209 172 205 220
46230 +146 190 211 136 185 209 26 108 161 22 40 52 7 12 15 44 81 103
46231 +71 116 144 28 67 93 37 51 59 41 65 82 100 139 164 101 161 196
46232 +90 154 193 90 154 193 28 67 93 0 0 0 0 0 0 26 28 28
46233 +125 124 125 167 166 167 163 162 163 153 152 153 163 162 163 174 174 174
46234 +85 115 134 4 0 0
46235 +4 4 4 5 5 5 4 4 4 1 0 0 4 0 0 34 47 55
46236 +125 124 125 174 174 174 174 174 174 167 166 167 157 156 157 153 152 153
46237 +155 154 155 155 154 155 158 157 158 166 165 166 167 166 167 154 153 154
46238 +125 124 125 26 28 28 4 0 0 4 0 0 4 0 0 5 5 5
46239 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 1 1 1
46240 +0 0 0 0 0 0 1 1 1 4 4 4 4 4 4 4 4 4
46241 +5 5 5 5 5 5 4 3 3 4 0 0 4 0 0 6 6 6
46242 +37 38 37 131 129 131 137 136 137 37 38 37 0 0 0 4 0 0
46243 +4 5 5 43 61 72 90 154 193 172 205 220 146 190 211 136 185 209
46244 +90 154 193 28 67 93 13 20 25 43 61 72 71 116 144 44 81 103
46245 +2 5 5 7 11 13 59 113 148 101 161 196 90 154 193 28 67 93
46246 +13 20 25 6 10 14 0 0 0 13 16 17 60 73 81 137 136 137
46247 +166 165 166 158 157 158 156 155 156 154 153 154 167 166 167 174 174 174
46248 +60 73 81 4 0 0
46249 +4 4 4 4 4 4 0 0 0 3 3 3 60 74 84 174 174 174
46250 +174 174 174 167 166 167 163 162 163 155 154 155 157 156 157 155 154 155
46251 +156 155 156 163 162 163 167 166 167 158 157 158 125 124 125 37 38 37
46252 +4 3 3 4 0 0 4 0 0 6 6 6 6 6 6 5 5 5
46253 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 2 3 3
46254 +10 13 16 7 11 13 1 0 0 0 0 0 2 2 1 4 4 4
46255 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 4 0 0
46256 +4 0 0 7 11 13 13 16 17 4 0 0 3 3 3 34 47 55
46257 +80 127 157 146 190 211 172 205 220 136 185 209 136 185 209 136 185 209
46258 +28 67 93 22 40 52 55 98 126 55 98 126 21 29 34 7 11 13
46259 +50 82 103 101 161 196 101 161 196 35 83 115 13 20 25 2 2 1
46260 +1 1 2 1 1 2 37 51 59 131 129 131 174 174 174 174 174 174
46261 +167 166 167 163 162 163 163 162 163 167 166 167 174 174 174 125 124 125
46262 +16 19 21 4 0 0
46263 +4 4 4 4 0 0 4 0 0 60 74 84 174 174 174 174 174 174
46264 +158 157 158 155 154 155 155 154 155 156 155 156 155 154 155 158 157 158
46265 +167 166 167 165 164 165 131 129 131 60 73 81 13 16 17 4 0 0
46266 +4 0 0 4 3 3 6 6 6 4 3 3 5 5 5 4 4 4
46267 +4 4 4 3 2 2 0 0 0 0 0 0 7 11 13 45 69 86
46268 +80 127 157 71 116 144 43 61 72 7 11 13 0 0 0 1 1 1
46269 +4 3 3 4 4 4 4 4 4 4 4 4 6 6 6 5 5 5
46270 +3 2 2 4 0 0 1 0 0 21 29 34 59 113 148 136 185 209
46271 +146 190 211 136 185 209 136 185 209 136 185 209 136 185 209 136 185 209
46272 +68 124 159 44 81 103 22 40 52 13 16 17 43 61 72 90 154 193
46273 +136 185 209 59 113 148 21 29 34 3 4 3 1 1 1 0 0 0
46274 +24 26 27 125 124 125 163 162 163 174 174 174 166 165 166 165 164 165
46275 +163 162 163 125 124 125 125 124 125 125 124 125 125 124 125 26 28 28
46276 +4 0 0 4 3 3
46277 +3 3 3 0 0 0 24 26 27 153 152 153 177 184 187 158 157 158
46278 +156 155 156 156 155 156 155 154 155 155 154 155 165 164 165 174 174 174
46279 +155 154 155 60 74 84 26 28 28 4 0 0 4 0 0 3 1 0
46280 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3
46281 +2 0 0 0 0 0 0 0 0 32 43 50 72 125 159 101 161 196
46282 +136 185 209 101 161 196 101 161 196 79 117 143 32 43 50 0 0 0
46283 +0 0 0 2 2 2 4 4 4 4 4 4 3 3 3 1 0 0
46284 +0 0 0 4 5 5 49 76 92 101 161 196 146 190 211 146 190 211
46285 +136 185 209 136 185 209 136 185 209 136 185 209 136 185 209 90 154 193
46286 +28 67 93 13 16 17 37 51 59 80 127 157 136 185 209 90 154 193
46287 +22 40 52 6 9 11 3 4 3 2 2 1 16 19 21 60 73 81
46288 +137 136 137 163 162 163 158 157 158 166 165 166 167 166 167 153 152 153
46289 +60 74 84 37 38 37 6 6 6 13 16 17 4 0 0 1 0 0
46290 +3 2 2 4 4 4
46291 +3 2 2 4 0 0 37 38 37 137 136 137 167 166 167 158 157 158
46292 +157 156 157 154 153 154 157 156 157 167 166 167 174 174 174 125 124 125
46293 +37 38 37 4 0 0 4 0 0 4 0 0 4 3 3 4 4 4
46294 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
46295 +0 0 0 16 21 25 55 98 126 90 154 193 136 185 209 101 161 196
46296 +101 161 196 101 161 196 136 185 209 136 185 209 101 161 196 55 98 126
46297 +14 17 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
46298 +22 40 52 90 154 193 146 190 211 146 190 211 136 185 209 136 185 209
46299 +136 185 209 136 185 209 136 185 209 101 161 196 35 83 115 7 11 13
46300 +17 23 27 59 113 148 136 185 209 101 161 196 34 86 122 7 12 15
46301 +2 5 5 3 4 3 6 6 6 60 73 81 131 129 131 163 162 163
46302 +166 165 166 174 174 174 174 174 174 163 162 163 125 124 125 41 54 63
46303 +13 16 17 4 0 0 4 0 0 4 0 0 1 0 0 2 2 2
46304 +4 4 4 4 4 4
46305 +1 1 1 2 1 0 43 57 68 137 136 137 153 152 153 153 152 153
46306 +163 162 163 156 155 156 165 164 165 167 166 167 60 74 84 6 6 6
46307 +4 0 0 4 0 0 5 5 5 4 4 4 4 4 4 4 4 4
46308 +4 5 5 6 6 6 4 3 3 0 0 0 0 0 0 11 15 18
46309 +40 71 93 100 139 164 101 161 196 101 161 196 101 161 196 101 161 196
46310 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 136 185 209
46311 +101 161 196 45 69 86 6 6 6 0 0 0 17 23 27 55 98 126
46312 +136 185 209 146 190 211 136 185 209 136 185 209 136 185 209 136 185 209
46313 +136 185 209 136 185 209 90 154 193 22 40 52 7 11 13 50 82 103
46314 +136 185 209 136 185 209 53 118 160 22 40 52 7 11 13 2 5 5
46315 +3 4 3 37 38 37 125 124 125 157 156 157 166 165 166 167 166 167
46316 +174 174 174 174 174 174 137 136 137 60 73 81 4 0 0 4 0 0
46317 +4 0 0 4 0 0 5 5 5 3 3 3 3 3 3 4 4 4
46318 +4 4 4 4 4 4
46319 +4 0 0 4 0 0 41 54 63 137 136 137 125 124 125 131 129 131
46320 +155 154 155 167 166 167 174 174 174 60 74 84 6 6 6 4 0 0
46321 +4 3 3 6 6 6 4 4 4 4 4 4 4 4 4 5 5 5
46322 +4 4 4 1 1 1 0 0 0 3 6 7 41 65 82 72 125 159
46323 +101 161 196 101 161 196 101 161 196 90 154 193 90 154 193 101 161 196
46324 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
46325 +136 185 209 136 185 209 80 127 157 55 98 126 101 161 196 146 190 211
46326 +136 185 209 136 185 209 136 185 209 101 161 196 136 185 209 101 161 196
46327 +136 185 209 101 161 196 35 83 115 22 30 35 101 161 196 172 205 220
46328 +90 154 193 28 67 93 7 11 13 2 5 5 3 4 3 13 16 17
46329 +85 115 134 167 166 167 174 174 174 174 174 174 174 174 174 174 174 174
46330 +167 166 167 60 74 84 13 16 17 4 0 0 4 0 0 4 3 3
46331 +6 6 6 5 5 5 4 4 4 5 5 5 4 4 4 5 5 5
46332 +5 5 5 5 5 5
46333 +1 1 1 4 0 0 41 54 63 137 136 137 137 136 137 125 124 125
46334 +131 129 131 167 166 167 157 156 157 37 38 37 6 6 6 4 0 0
46335 +6 6 6 5 5 5 4 4 4 4 4 4 4 5 5 2 2 1
46336 +0 0 0 0 0 0 26 37 45 58 111 146 101 161 196 101 161 196
46337 +101 161 196 90 154 193 90 154 193 90 154 193 101 161 196 101 161 196
46338 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
46339 +101 161 196 136 185 209 136 185 209 136 185 209 146 190 211 136 185 209
46340 +136 185 209 101 161 196 136 185 209 136 185 209 101 161 196 136 185 209
46341 +101 161 196 136 185 209 136 185 209 136 185 209 136 185 209 16 89 141
46342 +7 11 13 2 5 5 2 5 5 13 16 17 60 73 81 154 154 154
46343 +174 174 174 174 174 174 174 174 174 174 174 174 163 162 163 125 124 125
46344 +24 26 27 4 0 0 4 0 0 4 0 0 5 5 5 5 5 5
46345 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
46346 +5 5 5 4 4 4
46347 +4 0 0 6 6 6 37 38 37 137 136 137 137 136 137 131 129 131
46348 +131 129 131 153 152 153 131 129 131 26 28 28 4 0 0 4 3 3
46349 +6 6 6 4 4 4 4 4 4 4 4 4 0 0 0 0 0 0
46350 +13 20 25 51 88 114 90 154 193 101 161 196 101 161 196 90 154 193
46351 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
46352 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 101 161 196
46353 +101 161 196 136 185 209 101 161 196 136 185 209 136 185 209 101 161 196
46354 +136 185 209 101 161 196 136 185 209 101 161 196 101 161 196 101 161 196
46355 +136 185 209 136 185 209 136 185 209 37 112 160 21 29 34 5 7 8
46356 +2 5 5 13 16 17 43 57 68 131 129 131 174 174 174 174 174 174
46357 +174 174 174 167 166 167 157 156 157 125 124 125 37 38 37 4 0 0
46358 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
46359 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46360 +4 4 4 4 4 4
46361 +1 1 1 4 0 0 41 54 63 153 152 153 137 136 137 137 136 137
46362 +137 136 137 153 152 153 125 124 125 24 26 27 4 0 0 3 2 2
46363 +4 4 4 4 4 4 4 3 3 4 0 0 3 6 7 43 61 72
46364 +64 123 161 101 161 196 90 154 193 90 154 193 90 154 193 90 154 193
46365 +90 154 193 90 154 193 90 154 193 90 154 193 101 161 196 90 154 193
46366 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
46367 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
46368 +136 185 209 101 161 196 101 161 196 136 185 209 136 185 209 101 161 196
46369 +101 161 196 90 154 193 28 67 93 13 16 17 7 11 13 3 6 7
46370 +37 51 59 125 124 125 163 162 163 174 174 174 167 166 167 166 165 166
46371 +167 166 167 131 129 131 60 73 81 4 0 0 4 0 0 4 0 0
46372 +3 3 3 5 5 5 6 6 6 4 4 4 4 4 4 4 4 4
46373 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46374 +4 4 4 4 4 4
46375 +4 0 0 4 0 0 41 54 63 137 136 137 153 152 153 137 136 137
46376 +153 152 153 157 156 157 125 124 125 24 26 27 0 0 0 2 2 2
46377 +4 4 4 4 4 4 2 0 0 0 0 0 28 67 93 90 154 193
46378 +90 154 193 90 154 193 90 154 193 90 154 193 64 123 161 90 154 193
46379 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
46380 +90 154 193 101 161 196 101 161 196 101 161 196 90 154 193 136 185 209
46381 +101 161 196 101 161 196 136 185 209 101 161 196 136 185 209 101 161 196
46382 +101 161 196 101 161 196 136 185 209 101 161 196 101 161 196 90 154 193
46383 +35 83 115 13 16 17 3 6 7 2 5 5 13 16 17 60 74 84
46384 +154 154 154 166 165 166 165 164 165 158 157 158 163 162 163 157 156 157
46385 +60 74 84 13 16 17 4 0 0 4 0 0 3 2 2 4 4 4
46386 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46387 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46388 +4 4 4 4 4 4
46389 +1 1 1 4 0 0 41 54 63 157 156 157 155 154 155 137 136 137
46390 +153 152 153 158 157 158 137 136 137 26 28 28 2 0 0 2 2 2
46391 +4 4 4 4 4 4 1 0 0 6 10 14 34 86 122 90 154 193
46392 +64 123 161 90 154 193 64 123 161 90 154 193 90 154 193 90 154 193
46393 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
46394 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
46395 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
46396 +136 185 209 101 161 196 136 185 209 90 154 193 26 108 161 22 40 52
46397 +13 16 17 5 7 8 2 5 5 2 5 5 37 38 37 165 164 165
46398 +174 174 174 163 162 163 154 154 154 165 164 165 167 166 167 60 73 81
46399 +6 6 6 4 0 0 4 0 0 4 4 4 4 4 4 4 4 4
46400 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46401 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46402 +4 4 4 4 4 4
46403 +4 0 0 6 6 6 41 54 63 156 155 156 158 157 158 153 152 153
46404 +156 155 156 165 164 165 137 136 137 26 28 28 0 0 0 2 2 2
46405 +4 4 5 4 4 4 2 0 0 7 12 15 31 96 139 64 123 161
46406 +90 154 193 64 123 161 90 154 193 90 154 193 64 123 161 90 154 193
46407 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
46408 +90 154 193 90 154 193 90 154 193 101 161 196 101 161 196 101 161 196
46409 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
46410 +101 161 196 136 185 209 26 108 161 22 40 52 7 11 13 5 7 8
46411 +2 5 5 2 5 5 2 5 5 2 2 1 37 38 37 158 157 158
46412 +174 174 174 154 154 154 156 155 156 167 166 167 165 164 165 37 38 37
46413 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46414 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46415 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46416 +4 4 4 4 4 4
46417 +3 1 0 4 0 0 60 73 81 157 156 157 163 162 163 153 152 153
46418 +158 157 158 167 166 167 137 136 137 26 28 28 2 0 0 2 2 2
46419 +4 5 5 4 4 4 4 0 0 7 12 15 24 86 132 26 108 161
46420 +37 112 160 64 123 161 90 154 193 64 123 161 90 154 193 90 154 193
46421 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
46422 +90 154 193 101 161 196 90 154 193 101 161 196 101 161 196 101 161 196
46423 +101 161 196 101 161 196 101 161 196 136 185 209 101 161 196 136 185 209
46424 +90 154 193 35 83 115 13 16 17 13 16 17 7 11 13 3 6 7
46425 +5 7 8 6 6 6 3 4 3 2 2 1 30 32 34 154 154 154
46426 +167 166 167 154 154 154 154 154 154 174 174 174 165 164 165 37 38 37
46427 +6 6 6 4 0 0 6 6 6 4 4 4 4 4 4 4 4 4
46428 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46429 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46430 +4 4 4 4 4 4
46431 +4 0 0 4 0 0 41 54 63 163 162 163 166 165 166 154 154 154
46432 +163 162 163 174 174 174 137 136 137 26 28 28 0 0 0 2 2 2
46433 +4 5 5 4 4 5 1 1 2 6 10 14 28 67 93 18 97 151
46434 +18 97 151 18 97 151 26 108 161 37 112 160 37 112 160 90 154 193
46435 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
46436 +90 154 193 101 161 196 101 161 196 90 154 193 101 161 196 101 161 196
46437 +101 161 196 101 161 196 101 161 196 136 185 209 90 154 193 16 89 141
46438 +13 20 25 7 11 13 5 7 8 5 7 8 2 5 5 4 5 5
46439 +3 4 3 4 5 5 3 4 3 0 0 0 37 38 37 158 157 158
46440 +174 174 174 158 157 158 158 157 158 167 166 167 174 174 174 41 54 63
46441 +4 0 0 3 2 2 5 5 5 4 4 4 4 4 4 4 4 4
46442 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46443 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46444 +4 4 4 4 4 4
46445 +1 1 1 4 0 0 60 73 81 165 164 165 174 174 174 158 157 158
46446 +167 166 167 174 174 174 153 152 153 26 28 28 2 0 0 2 2 2
46447 +4 5 5 4 4 4 4 0 0 7 12 15 10 87 144 10 87 144
46448 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
46449 +26 108 161 37 112 160 53 118 160 90 154 193 90 154 193 90 154 193
46450 +90 154 193 90 154 193 101 161 196 101 161 196 101 161 196 101 161 196
46451 +101 161 196 136 185 209 90 154 193 26 108 161 22 40 52 13 16 17
46452 +7 11 13 3 6 7 5 7 8 5 7 8 2 5 5 4 5 5
46453 +4 5 5 6 6 6 3 4 3 0 0 0 30 32 34 158 157 158
46454 +174 174 174 156 155 156 155 154 155 165 164 165 154 153 154 37 38 37
46455 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46456 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46457 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46458 +4 4 4 4 4 4
46459 +4 0 0 4 0 0 60 73 81 167 166 167 174 174 174 163 162 163
46460 +174 174 174 174 174 174 153 152 153 26 28 28 0 0 0 3 3 3
46461 +5 5 5 4 4 4 1 1 2 7 12 15 28 67 93 18 97 151
46462 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
46463 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
46464 +90 154 193 26 108 161 90 154 193 90 154 193 90 154 193 101 161 196
46465 +101 161 196 26 108 161 22 40 52 13 16 17 7 11 13 2 5 5
46466 +2 5 5 6 6 6 2 5 5 4 5 5 4 5 5 4 5 5
46467 +3 4 3 5 5 5 3 4 3 2 0 0 30 32 34 137 136 137
46468 +153 152 153 137 136 137 131 129 131 137 136 137 131 129 131 37 38 37
46469 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46470 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46471 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46472 +4 4 4 4 4 4
46473 +1 1 1 4 0 0 60 73 81 167 166 167 174 174 174 166 165 166
46474 +174 174 174 177 184 187 153 152 153 30 32 34 1 0 0 3 3 3
46475 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
46476 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
46477 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
46478 +26 108 161 26 108 161 26 108 161 90 154 193 90 154 193 26 108 161
46479 +35 83 115 13 16 17 7 11 13 5 7 8 3 6 7 5 7 8
46480 +2 5 5 6 6 6 4 5 5 4 5 5 3 4 3 4 5 5
46481 +3 4 3 6 6 6 3 4 3 0 0 0 26 28 28 125 124 125
46482 +131 129 131 125 124 125 125 124 125 131 129 131 131 129 131 37 38 37
46483 +4 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46484 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46485 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46486 +4 4 4 4 4 4
46487 +3 1 0 4 0 0 60 73 81 174 174 174 177 184 187 167 166 167
46488 +174 174 174 177 184 187 153 152 153 30 32 34 0 0 0 3 3 3
46489 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
46490 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
46491 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
46492 +26 108 161 90 154 193 26 108 161 26 108 161 24 86 132 13 20 25
46493 +7 11 13 13 20 25 22 40 52 5 7 8 3 4 3 3 4 3
46494 +4 5 5 3 4 3 4 5 5 3 4 3 4 5 5 3 4 3
46495 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
46496 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46497 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46498 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46499 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46500 +4 4 4 4 4 4
46501 +1 1 1 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
46502 +174 174 174 190 197 201 157 156 157 30 32 34 1 0 0 3 3 3
46503 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
46504 +18 97 151 19 95 150 19 95 150 18 97 151 18 97 151 26 108 161
46505 +18 97 151 26 108 161 26 108 161 26 108 161 26 108 161 90 154 193
46506 +26 108 161 26 108 161 26 108 161 22 40 52 2 5 5 3 4 3
46507 +28 67 93 37 112 160 34 86 122 2 5 5 3 4 3 3 4 3
46508 +3 4 3 3 4 3 3 4 3 2 2 1 3 4 3 4 4 4
46509 +4 5 5 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
46510 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46511 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46512 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46513 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46514 +4 4 4 4 4 4
46515 +4 0 0 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
46516 +174 174 174 190 197 201 158 157 158 30 32 34 0 0 0 2 2 2
46517 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
46518 +10 87 144 19 95 150 19 95 150 18 97 151 18 97 151 18 97 151
46519 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
46520 +18 97 151 22 40 52 2 5 5 2 2 1 22 40 52 26 108 161
46521 +90 154 193 37 112 160 22 40 52 3 4 3 13 20 25 22 30 35
46522 +3 6 7 1 1 1 2 2 2 6 9 11 5 5 5 4 3 3
46523 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
46524 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46525 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46526 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46527 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46528 +4 4 4 4 4 4
46529 +1 1 1 4 0 0 60 73 81 177 184 187 193 200 203 174 174 174
46530 +177 184 187 193 200 203 163 162 163 30 32 34 4 0 0 2 2 2
46531 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
46532 +10 87 144 10 87 144 19 95 150 19 95 150 19 95 150 18 97 151
46533 +26 108 161 26 108 161 26 108 161 90 154 193 26 108 161 28 67 93
46534 +6 10 14 2 5 5 13 20 25 24 86 132 37 112 160 90 154 193
46535 +10 87 144 7 12 15 2 5 5 28 67 93 37 112 160 28 67 93
46536 +2 2 1 7 12 15 35 83 115 28 67 93 3 6 7 1 0 0
46537 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
46538 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46539 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46540 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46541 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46542 +4 4 4 4 4 4
46543 +4 0 0 4 0 0 60 73 81 174 174 174 190 197 201 174 174 174
46544 +177 184 187 193 200 203 163 162 163 30 32 34 0 0 0 2 2 2
46545 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
46546 +10 87 144 16 89 141 19 95 150 10 87 144 26 108 161 26 108 161
46547 +26 108 161 26 108 161 26 108 161 28 67 93 6 10 14 1 1 2
46548 +7 12 15 28 67 93 26 108 161 16 89 141 24 86 132 21 29 34
46549 +3 4 3 21 29 34 37 112 160 37 112 160 27 99 146 21 29 34
46550 +21 29 34 26 108 161 90 154 193 35 83 115 1 1 2 2 0 0
46551 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
46552 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46553 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46554 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46555 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46556 +4 4 4 4 4 4
46557 +3 1 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
46558 +190 197 201 193 200 203 165 164 165 37 38 37 4 0 0 2 2 2
46559 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
46560 +10 87 144 10 87 144 16 89 141 18 97 151 18 97 151 10 87 144
46561 +24 86 132 24 86 132 13 20 25 4 5 7 4 5 7 22 40 52
46562 +18 97 151 37 112 160 26 108 161 7 12 15 1 1 1 0 0 0
46563 +28 67 93 37 112 160 26 108 161 28 67 93 22 40 52 28 67 93
46564 +26 108 161 90 154 193 26 108 161 10 87 144 0 0 0 2 0 0
46565 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
46566 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46567 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46568 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46569 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46570 +4 4 4 4 4 4
46571 +4 0 0 6 6 6 60 73 81 174 174 174 193 200 203 174 174 174
46572 +190 197 201 193 200 203 165 164 165 30 32 34 0 0 0 2 2 2
46573 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
46574 +10 87 144 10 87 144 10 87 144 18 97 151 28 67 93 6 10 14
46575 +0 0 0 1 1 2 4 5 7 13 20 25 16 89 141 26 108 161
46576 +26 108 161 26 108 161 24 86 132 6 9 11 2 3 3 22 40 52
46577 +37 112 160 16 89 141 22 40 52 28 67 93 26 108 161 26 108 161
46578 +90 154 193 26 108 161 26 108 161 28 67 93 1 1 1 4 0 0
46579 +4 4 4 5 5 5 3 3 3 4 0 0 26 28 28 124 126 130
46580 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46581 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46582 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46583 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46584 +4 4 4 4 4 4
46585 +4 0 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
46586 +193 200 203 193 200 203 167 166 167 37 38 37 4 0 0 2 2 2
46587 +5 5 5 4 4 4 4 0 0 6 10 14 28 67 93 10 87 144
46588 +10 87 144 10 87 144 18 97 151 10 87 144 13 20 25 4 5 7
46589 +1 1 2 1 1 1 22 40 52 26 108 161 26 108 161 26 108 161
46590 +26 108 161 26 108 161 26 108 161 24 86 132 22 40 52 22 40 52
46591 +22 40 52 22 40 52 10 87 144 26 108 161 26 108 161 26 108 161
46592 +26 108 161 26 108 161 90 154 193 10 87 144 0 0 0 4 0 0
46593 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
46594 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46595 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46596 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46597 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46598 +4 4 4 4 4 4
46599 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
46600 +190 197 201 205 212 215 167 166 167 30 32 34 0 0 0 2 2 2
46601 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
46602 +10 87 144 10 87 144 10 87 144 10 87 144 22 40 52 1 1 2
46603 +2 0 0 1 1 2 24 86 132 26 108 161 26 108 161 26 108 161
46604 +26 108 161 19 95 150 16 89 141 10 87 144 22 40 52 22 40 52
46605 +10 87 144 26 108 161 37 112 160 26 108 161 26 108 161 26 108 161
46606 +26 108 161 26 108 161 26 108 161 28 67 93 2 0 0 3 1 0
46607 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
46608 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46609 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46610 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46611 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46612 +4 4 4 4 4 4
46613 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
46614 +193 200 203 193 200 203 174 174 174 37 38 37 4 0 0 2 2 2
46615 +5 5 5 4 4 4 3 2 2 1 1 2 13 20 25 10 87 144
46616 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 13 20 25
46617 +13 20 25 22 40 52 10 87 144 18 97 151 18 97 151 26 108 161
46618 +10 87 144 13 20 25 6 10 14 21 29 34 24 86 132 18 97 151
46619 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
46620 +26 108 161 90 154 193 18 97 151 13 20 25 0 0 0 4 3 3
46621 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
46622 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46623 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46624 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46625 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46626 +4 4 4 4 4 4
46627 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
46628 +190 197 201 220 221 221 167 166 167 30 32 34 1 0 0 2 2 2
46629 +5 5 5 4 4 4 4 4 5 2 5 5 4 5 7 13 20 25
46630 +28 67 93 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
46631 +10 87 144 10 87 144 18 97 151 10 87 144 18 97 151 18 97 151
46632 +28 67 93 2 3 3 0 0 0 28 67 93 26 108 161 26 108 161
46633 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
46634 +26 108 161 10 87 144 13 20 25 1 1 2 3 2 2 4 4 4
46635 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
46636 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46637 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46638 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46639 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46640 +4 4 4 4 4 4
46641 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
46642 +193 200 203 193 200 203 174 174 174 26 28 28 4 0 0 4 3 3
46643 +5 5 5 4 4 4 4 4 4 4 4 5 1 1 2 2 5 5
46644 +4 5 7 22 40 52 10 87 144 10 87 144 18 97 151 10 87 144
46645 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 18 97 151
46646 +10 87 144 28 67 93 22 40 52 10 87 144 26 108 161 18 97 151
46647 +18 97 151 18 97 151 26 108 161 26 108 161 26 108 161 26 108 161
46648 +22 40 52 1 1 2 0 0 0 2 3 3 4 4 4 4 4 4
46649 +4 4 4 5 5 5 4 4 4 0 0 0 26 28 28 131 129 131
46650 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46651 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46652 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46653 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46654 +4 4 4 4 4 4
46655 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
46656 +190 197 201 220 221 221 190 197 201 41 54 63 4 0 0 2 2 2
46657 +6 6 6 4 4 4 4 4 4 4 4 5 4 4 5 3 3 3
46658 +1 1 2 1 1 2 6 10 14 22 40 52 10 87 144 18 97 151
46659 +18 97 151 10 87 144 10 87 144 10 87 144 18 97 151 10 87 144
46660 +10 87 144 18 97 151 26 108 161 18 97 151 18 97 151 10 87 144
46661 +26 108 161 26 108 161 26 108 161 10 87 144 28 67 93 6 10 14
46662 +1 1 2 1 1 2 4 3 3 4 4 5 4 4 4 4 4 4
46663 +5 5 5 5 5 5 1 1 1 4 0 0 37 51 59 137 136 137
46664 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46665 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46666 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46667 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46668 +4 4 4 4 4 4
46669 +4 0 0 4 0 0 60 73 81 220 221 221 193 200 203 174 174 174
46670 +193 200 203 193 200 203 220 221 221 137 136 137 13 16 17 4 0 0
46671 +2 2 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5
46672 +4 4 5 4 3 3 1 1 2 4 5 7 13 20 25 28 67 93
46673 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
46674 +10 87 144 18 97 151 18 97 151 10 87 144 18 97 151 26 108 161
46675 +26 108 161 18 97 151 28 67 93 6 10 14 0 0 0 0 0 0
46676 +2 3 3 4 5 5 4 4 5 4 4 4 4 4 4 5 5 5
46677 +3 3 3 1 1 1 0 0 0 16 19 21 125 124 125 137 136 137
46678 +131 129 131 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46679 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46680 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46681 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46682 +4 4 4 4 4 4
46683 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
46684 +193 200 203 190 197 201 220 221 221 220 221 221 153 152 153 30 32 34
46685 +0 0 0 0 0 0 2 2 2 4 4 4 4 4 4 4 4 4
46686 +4 4 4 4 5 5 4 5 7 1 1 2 1 1 2 4 5 7
46687 +13 20 25 28 67 93 10 87 144 18 97 151 10 87 144 10 87 144
46688 +10 87 144 10 87 144 10 87 144 18 97 151 26 108 161 18 97 151
46689 +28 67 93 7 12 15 0 0 0 0 0 0 2 2 1 4 4 4
46690 +4 5 5 4 5 5 4 4 4 4 4 4 3 3 3 0 0 0
46691 +0 0 0 0 0 0 37 38 37 125 124 125 158 157 158 131 129 131
46692 +125 124 125 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46693 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46694 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46695 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46696 +4 4 4 4 4 4
46697 +4 3 3 4 0 0 41 54 63 193 200 203 220 221 221 174 174 174
46698 +193 200 203 193 200 203 193 200 203 220 221 221 244 246 246 193 200 203
46699 +120 125 127 5 5 5 1 0 0 0 0 0 1 1 1 4 4 4
46700 +4 4 4 4 4 4 4 5 5 4 5 5 4 4 5 1 1 2
46701 +4 5 7 4 5 7 22 40 52 10 87 144 10 87 144 10 87 144
46702 +10 87 144 10 87 144 18 97 151 10 87 144 10 87 144 13 20 25
46703 +4 5 7 2 3 3 1 1 2 4 4 4 4 5 5 4 4 4
46704 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 1 2
46705 +24 26 27 60 74 84 153 152 153 163 162 163 137 136 137 125 124 125
46706 +125 124 125 125 124 125 125 124 125 137 136 137 125 124 125 26 28 28
46707 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46708 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46709 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46710 +4 4 4 4 4 4
46711 +4 0 0 6 6 6 26 28 28 156 155 156 220 221 221 220 221 221
46712 +174 174 174 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
46713 +220 221 221 167 166 167 60 73 81 7 11 13 0 0 0 0 0 0
46714 +3 3 3 4 4 4 4 4 4 4 4 4 4 4 5 4 4 5
46715 +4 4 5 1 1 2 1 1 2 4 5 7 22 40 52 10 87 144
46716 +10 87 144 10 87 144 10 87 144 22 40 52 4 5 7 1 1 2
46717 +1 1 2 4 4 5 4 4 4 4 4 4 4 4 4 4 4 4
46718 +5 5 5 2 2 2 0 0 0 4 0 0 16 19 21 60 73 81
46719 +137 136 137 167 166 167 158 157 158 137 136 137 131 129 131 131 129 131
46720 +125 124 125 125 124 125 131 129 131 155 154 155 60 74 84 5 7 8
46721 +0 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46722 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46723 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46724 +4 4 4 4 4 4
46725 +5 5 5 4 0 0 4 0 0 60 73 81 193 200 203 220 221 221
46726 +193 200 203 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
46727 +220 221 221 220 221 221 220 221 221 137 136 137 43 57 68 6 6 6
46728 +4 0 0 1 1 1 4 4 4 4 4 4 4 4 4 4 4 4
46729 +4 4 5 4 4 5 3 2 2 1 1 2 2 5 5 13 20 25
46730 +22 40 52 22 40 52 13 20 25 2 3 3 1 1 2 3 3 3
46731 +4 5 7 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46732 +1 1 1 0 0 0 2 3 3 41 54 63 131 129 131 166 165 166
46733 +166 165 166 155 154 155 153 152 153 137 136 137 137 136 137 125 124 125
46734 +125 124 125 137 136 137 137 136 137 125 124 125 37 38 37 4 3 3
46735 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
46736 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46737 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46738 +4 4 4 4 4 4
46739 +4 3 3 6 6 6 6 6 6 13 16 17 60 73 81 167 166 167
46740 +220 221 221 220 221 221 220 221 221 193 200 203 193 200 203 193 200 203
46741 +205 212 215 220 221 221 220 221 221 244 246 246 205 212 215 125 124 125
46742 +24 26 27 0 0 0 0 0 0 2 2 2 5 5 5 5 5 5
46743 +4 4 4 4 4 4 4 4 4 4 4 5 1 1 2 4 5 7
46744 +4 5 7 4 5 7 1 1 2 3 2 2 4 4 5 4 4 4
46745 +4 4 4 4 4 4 5 5 5 4 4 4 0 0 0 0 0 0
46746 +2 0 0 26 28 28 125 124 125 174 174 174 174 174 174 166 165 166
46747 +156 155 156 153 152 153 137 136 137 137 136 137 131 129 131 137 136 137
46748 +137 136 137 137 136 137 60 74 84 30 32 34 4 0 0 4 0 0
46749 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46750 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46751 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46752 +4 4 4 4 4 4
46753 +5 5 5 6 6 6 4 0 0 4 0 0 6 6 6 26 28 28
46754 +125 124 125 174 174 174 220 221 221 220 221 221 220 221 221 193 200 203
46755 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
46756 +193 200 203 60 74 84 13 16 17 4 0 0 0 0 0 3 3 3
46757 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 5 3 3 3
46758 +1 1 2 3 3 3 4 4 5 4 4 5 4 4 4 4 4 4
46759 +5 5 5 5 5 5 2 2 2 0 0 0 0 0 0 13 16 17
46760 +60 74 84 174 174 174 193 200 203 174 174 174 167 166 167 163 162 163
46761 +153 152 153 153 152 153 137 136 137 137 136 137 153 152 153 137 136 137
46762 +125 124 125 41 54 63 24 26 27 4 0 0 4 0 0 5 5 5
46763 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46764 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46765 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46766 +4 4 4 4 4 4
46767 +4 3 3 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
46768 +6 6 6 37 38 37 131 129 131 220 221 221 220 221 221 220 221 221
46769 +193 200 203 193 200 203 220 221 221 205 212 215 220 221 221 244 246 246
46770 +244 246 246 244 246 246 174 174 174 41 54 63 0 0 0 0 0 0
46771 +0 0 0 4 4 4 5 5 5 5 5 5 4 4 4 4 4 5
46772 +4 4 5 4 4 5 4 4 4 4 4 4 6 6 6 6 6 6
46773 +3 3 3 0 0 0 2 0 0 13 16 17 60 73 81 156 155 156
46774 +220 221 221 193 200 203 174 174 174 165 164 165 163 162 163 154 153 154
46775 +153 152 153 153 152 153 158 157 158 163 162 163 137 136 137 60 73 81
46776 +13 16 17 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
46777 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46778 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46779 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46780 +4 4 4 4 4 4
46781 +5 5 5 4 3 3 4 3 3 6 6 6 6 6 6 6 6 6
46782 +6 6 6 6 6 6 6 6 6 37 38 37 167 166 167 244 246 246
46783 +244 246 246 220 221 221 205 212 215 205 212 215 220 221 221 193 200 203
46784 +220 221 221 244 246 246 244 246 246 244 246 246 137 136 137 37 38 37
46785 +3 2 2 0 0 0 1 1 1 5 5 5 5 5 5 4 4 4
46786 +4 4 4 4 4 4 4 4 4 5 5 5 4 4 4 1 1 1
46787 +0 0 0 5 5 5 43 57 68 153 152 153 193 200 203 220 221 221
46788 +177 184 187 174 174 174 167 166 167 166 165 166 158 157 158 157 156 157
46789 +158 157 158 166 165 166 156 155 156 85 115 134 13 16 17 4 0 0
46790 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
46791 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46792 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46793 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46794 +4 4 4 4 4 4
46795 +5 5 5 4 3 3 6 6 6 6 6 6 4 0 0 6 6 6
46796 +6 6 6 6 6 6 6 6 6 6 6 6 13 16 17 60 73 81
46797 +177 184 187 220 221 221 220 221 221 220 221 221 205 212 215 220 221 221
46798 +220 221 221 205 212 215 220 221 221 244 246 246 244 246 246 205 212 215
46799 +125 124 125 30 32 34 0 0 0 0 0 0 2 2 2 5 5 5
46800 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 0 0
46801 +37 38 37 131 129 131 205 212 215 220 221 221 193 200 203 174 174 174
46802 +174 174 174 174 174 174 167 166 167 165 164 165 166 165 166 167 166 167
46803 +158 157 158 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
46804 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
46805 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46806 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46807 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46808 +4 4 4 4 4 4
46809 +4 4 4 5 5 5 4 3 3 4 3 3 6 6 6 6 6 6
46810 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
46811 +26 28 28 125 124 125 205 212 215 220 221 221 220 221 221 220 221 221
46812 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
46813 +244 246 246 190 197 201 60 74 84 16 19 21 4 0 0 0 0 0
46814 +0 0 0 0 0 0 0 0 0 0 0 0 16 19 21 120 125 127
46815 +177 184 187 220 221 221 205 212 215 177 184 187 174 174 174 177 184 187
46816 +174 174 174 174 174 174 167 166 167 174 174 174 166 165 166 137 136 137
46817 +60 73 81 13 16 17 4 0 0 4 0 0 4 3 3 6 6 6
46818 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46819 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46820 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46821 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46822 +4 4 4 4 4 4
46823 +5 5 5 4 3 3 5 5 5 4 3 3 6 6 6 4 0 0
46824 +6 6 6 6 6 6 4 0 0 6 6 6 4 0 0 6 6 6
46825 +6 6 6 6 6 6 37 38 37 137 136 137 193 200 203 220 221 221
46826 +220 221 221 205 212 215 220 221 221 205 212 215 205 212 215 220 221 221
46827 +220 221 221 220 221 221 244 246 246 166 165 166 43 57 68 2 2 2
46828 +0 0 0 4 0 0 16 19 21 60 73 81 157 156 157 202 210 214
46829 +220 221 221 193 200 203 177 184 187 177 184 187 177 184 187 174 174 174
46830 +174 174 174 174 174 174 174 174 174 157 156 157 60 74 84 24 26 27
46831 +4 0 0 4 0 0 4 0 0 6 6 6 4 4 4 4 4 4
46832 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46833 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46834 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46835 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46836 +4 4 4 4 4 4
46837 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
46838 +6 6 6 4 0 0 6 6 6 6 6 6 6 6 6 4 0 0
46839 +4 0 0 4 0 0 6 6 6 24 26 27 60 73 81 167 166 167
46840 +220 221 221 220 221 221 220 221 221 205 212 215 205 212 215 205 212 215
46841 +205 212 215 220 221 221 220 221 221 220 221 221 205 212 215 137 136 137
46842 +60 74 84 125 124 125 137 136 137 190 197 201 220 221 221 193 200 203
46843 +177 184 187 177 184 187 177 184 187 174 174 174 174 174 174 177 184 187
46844 +190 197 201 174 174 174 125 124 125 37 38 37 6 6 6 4 0 0
46845 +4 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46846 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46847 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46848 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46849 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46850 +4 4 4 4 4 4
46851 +4 4 4 4 4 4 5 5 5 5 5 5 4 3 3 6 6 6
46852 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 6 6 6
46853 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
46854 +125 124 125 193 200 203 244 246 246 220 221 221 205 212 215 205 212 215
46855 +205 212 215 193 200 203 205 212 215 205 212 215 220 221 221 220 221 221
46856 +193 200 203 193 200 203 205 212 215 193 200 203 193 200 203 177 184 187
46857 +190 197 201 190 197 201 174 174 174 190 197 201 193 200 203 190 197 201
46858 +153 152 153 60 73 81 4 0 0 4 0 0 4 0 0 3 2 2
46859 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46860 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46861 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46862 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46863 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46864 +4 4 4 4 4 4
46865 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
46866 +6 6 6 4 3 3 4 3 3 4 3 3 6 6 6 6 6 6
46867 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 4 0 0
46868 +4 0 0 26 28 28 131 129 131 220 221 221 244 246 246 220 221 221
46869 +205 212 215 193 200 203 205 212 215 193 200 203 193 200 203 205 212 215
46870 +220 221 221 193 200 203 193 200 203 193 200 203 190 197 201 174 174 174
46871 +174 174 174 190 197 201 193 200 203 193 200 203 167 166 167 125 124 125
46872 +6 6 6 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
46873 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46874 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46875 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46876 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46877 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46878 +4 4 4 4 4 4
46879 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
46880 +5 5 5 4 3 3 5 5 5 6 6 6 4 3 3 5 5 5
46881 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
46882 +4 0 0 4 0 0 6 6 6 41 54 63 158 157 158 220 221 221
46883 +220 221 221 220 221 221 193 200 203 193 200 203 193 200 203 190 197 201
46884 +190 197 201 190 197 201 190 197 201 190 197 201 174 174 174 193 200 203
46885 +193 200 203 220 221 221 174 174 174 125 124 125 37 38 37 4 0 0
46886 +4 0 0 4 3 3 6 6 6 4 4 4 4 4 4 4 4 4
46887 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46888 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46889 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46890 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46891 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46892 +4 4 4 4 4 4
46893 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46894 +4 4 4 5 5 5 4 3 3 4 3 3 4 3 3 5 5 5
46895 +4 3 3 6 6 6 5 5 5 4 3 3 6 6 6 6 6 6
46896 +6 6 6 6 6 6 4 0 0 4 0 0 13 16 17 60 73 81
46897 +174 174 174 220 221 221 220 221 221 205 212 215 190 197 201 174 174 174
46898 +193 200 203 174 174 174 190 197 201 174 174 174 193 200 203 220 221 221
46899 +193 200 203 131 129 131 37 38 37 6 6 6 4 0 0 4 0 0
46900 +6 6 6 6 6 6 4 3 3 5 5 5 4 4 4 4 4 4
46901 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46902 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46903 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46904 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46905 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46906 +4 4 4 4 4 4
46907 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46908 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
46909 +5 5 5 4 3 3 4 3 3 5 5 5 4 3 3 4 3 3
46910 +5 5 5 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
46911 +6 6 6 125 124 125 174 174 174 220 221 221 220 221 221 193 200 203
46912 +193 200 203 193 200 203 193 200 203 193 200 203 220 221 221 158 157 158
46913 +60 73 81 6 6 6 4 0 0 4 0 0 5 5 5 6 6 6
46914 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
46915 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46916 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46917 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46918 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46919 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46920 +4 4 4 4 4 4
46921 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46922 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46923 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
46924 +5 5 5 5 5 5 6 6 6 6 6 6 4 0 0 4 0 0
46925 +4 0 0 4 0 0 26 28 28 125 124 125 174 174 174 193 200 203
46926 +193 200 203 174 174 174 193 200 203 167 166 167 125 124 125 6 6 6
46927 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 5 5 5
46928 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
46929 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46930 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46931 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46932 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46933 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46934 +4 4 4 4 4 4
46935 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46936 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46937 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
46938 +4 3 3 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
46939 +6 6 6 4 0 0 4 0 0 6 6 6 37 38 37 125 124 125
46940 +153 152 153 131 129 131 125 124 125 37 38 37 6 6 6 6 6 6
46941 +6 6 6 4 0 0 6 6 6 6 6 6 4 3 3 5 5 5
46942 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46943 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46944 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46945 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46946 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46947 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46948 +4 4 4 4 4 4
46949 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46950 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46951 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46952 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
46953 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
46954 +24 26 27 24 26 27 6 6 6 6 6 6 6 6 6 4 0 0
46955 +6 6 6 6 6 6 4 0 0 6 6 6 5 5 5 4 3 3
46956 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46957 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46958 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46959 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46960 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46961 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46962 +4 4 4 4 4 4
46963 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46964 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46965 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46966 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
46967 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
46968 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
46969 +4 0 0 6 6 6 6 6 6 4 3 3 5 5 5 4 4 4
46970 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46971 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46972 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46973 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46974 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46975 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46976 +4 4 4 4 4 4
46977 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46978 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46979 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46980 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 5 5 5
46981 +5 5 5 5 5 5 4 0 0 6 6 6 4 0 0 6 6 6
46982 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 4 0 0
46983 +6 6 6 4 3 3 5 5 5 4 3 3 5 5 5 4 4 4
46984 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46985 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46986 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46987 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46988 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46989 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46990 +4 4 4 4 4 4
46991 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46992 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46993 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46994 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
46995 +4 3 3 6 6 6 4 3 3 6 6 6 6 6 6 6 6 6
46996 +4 0 0 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
46997 +6 6 6 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46998 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46999 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47000 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47001 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47002 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47003 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47004 +4 4 4 4 4 4
47005 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47006 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47007 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47008 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47009 +4 4 4 5 5 5 4 3 3 5 5 5 4 0 0 6 6 6
47010 +6 6 6 4 0 0 6 6 6 6 6 6 4 0 0 6 6 6
47011 +4 3 3 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
47012 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47013 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47014 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47015 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47016 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47017 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47018 +4 4 4 4 4 4
47019 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47020 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47021 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47022 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47023 +4 4 4 5 5 5 4 3 3 5 5 5 6 6 6 4 3 3
47024 +4 3 3 6 6 6 6 6 6 4 3 3 6 6 6 4 3 3
47025 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47026 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47027 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47028 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47029 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47030 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47031 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47032 +4 4 4 4 4 4
47033 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47034 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47035 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47036 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47037 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 6 6 6
47038 +5 5 5 4 3 3 4 3 3 4 3 3 5 5 5 5 5 5
47039 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47040 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47041 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47042 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47043 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47044 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47045 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47046 +4 4 4 4 4 4
47047 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47048 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47049 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47050 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47051 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
47052 +5 5 5 4 3 3 5 5 5 5 5 5 4 4 4 4 4 4
47053 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47054 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47055 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47056 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47057 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47058 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47059 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47060 +4 4 4 4 4 4
47061 diff --git a/drivers/video/mb862xx/mb862xxfb_accel.c b/drivers/video/mb862xx/mb862xxfb_accel.c
47062 index fe92eed..106e085 100644
47063 --- a/drivers/video/mb862xx/mb862xxfb_accel.c
47064 +++ b/drivers/video/mb862xx/mb862xxfb_accel.c
47065 @@ -312,14 +312,18 @@ void mb862xxfb_init_accel(struct fb_info *info, int xres)
47066 struct mb862xxfb_par *par = info->par;
47067
47068 if (info->var.bits_per_pixel == 32) {
47069 - info->fbops->fb_fillrect = cfb_fillrect;
47070 - info->fbops->fb_copyarea = cfb_copyarea;
47071 - info->fbops->fb_imageblit = cfb_imageblit;
47072 + pax_open_kernel();
47073 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
47074 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
47075 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
47076 + pax_close_kernel();
47077 } else {
47078 outreg(disp, GC_L0EM, 3);
47079 - info->fbops->fb_fillrect = mb86290fb_fillrect;
47080 - info->fbops->fb_copyarea = mb86290fb_copyarea;
47081 - info->fbops->fb_imageblit = mb86290fb_imageblit;
47082 + pax_open_kernel();
47083 + *(void **)&info->fbops->fb_fillrect = mb86290fb_fillrect;
47084 + *(void **)&info->fbops->fb_copyarea = mb86290fb_copyarea;
47085 + *(void **)&info->fbops->fb_imageblit = mb86290fb_imageblit;
47086 + pax_close_kernel();
47087 }
47088 outreg(draw, GDC_REG_DRAW_BASE, 0);
47089 outreg(draw, GDC_REG_MODE_MISC, 0x8000);
47090 diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c
47091 index ff22871..b129bed 100644
47092 --- a/drivers/video/nvidia/nvidia.c
47093 +++ b/drivers/video/nvidia/nvidia.c
47094 @@ -669,19 +669,23 @@ static int nvidiafb_set_par(struct fb_info *info)
47095 info->fix.line_length = (info->var.xres_virtual *
47096 info->var.bits_per_pixel) >> 3;
47097 if (info->var.accel_flags) {
47098 - info->fbops->fb_imageblit = nvidiafb_imageblit;
47099 - info->fbops->fb_fillrect = nvidiafb_fillrect;
47100 - info->fbops->fb_copyarea = nvidiafb_copyarea;
47101 - info->fbops->fb_sync = nvidiafb_sync;
47102 + pax_open_kernel();
47103 + *(void **)&info->fbops->fb_imageblit = nvidiafb_imageblit;
47104 + *(void **)&info->fbops->fb_fillrect = nvidiafb_fillrect;
47105 + *(void **)&info->fbops->fb_copyarea = nvidiafb_copyarea;
47106 + *(void **)&info->fbops->fb_sync = nvidiafb_sync;
47107 + pax_close_kernel();
47108 info->pixmap.scan_align = 4;
47109 info->flags &= ~FBINFO_HWACCEL_DISABLED;
47110 info->flags |= FBINFO_READS_FAST;
47111 NVResetGraphics(info);
47112 } else {
47113 - info->fbops->fb_imageblit = cfb_imageblit;
47114 - info->fbops->fb_fillrect = cfb_fillrect;
47115 - info->fbops->fb_copyarea = cfb_copyarea;
47116 - info->fbops->fb_sync = NULL;
47117 + pax_open_kernel();
47118 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
47119 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
47120 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
47121 + *(void **)&info->fbops->fb_sync = NULL;
47122 + pax_close_kernel();
47123 info->pixmap.scan_align = 1;
47124 info->flags |= FBINFO_HWACCEL_DISABLED;
47125 info->flags &= ~FBINFO_READS_FAST;
47126 @@ -1173,8 +1177,11 @@ static int nvidia_set_fbinfo(struct fb_info *info)
47127 info->pixmap.size = 8 * 1024;
47128 info->pixmap.flags = FB_PIXMAP_SYSTEM;
47129
47130 - if (!hwcur)
47131 - info->fbops->fb_cursor = NULL;
47132 + if (!hwcur) {
47133 + pax_open_kernel();
47134 + *(void **)&info->fbops->fb_cursor = NULL;
47135 + pax_close_kernel();
47136 + }
47137
47138 info->var.accel_flags = (!noaccel);
47139
47140 diff --git a/drivers/video/s1d13xxxfb.c b/drivers/video/s1d13xxxfb.c
47141 index 76d9053..dec2bfd 100644
47142 --- a/drivers/video/s1d13xxxfb.c
47143 +++ b/drivers/video/s1d13xxxfb.c
47144 @@ -881,8 +881,10 @@ static int s1d13xxxfb_probe(struct platform_device *pdev)
47145
47146 switch(prod_id) {
47147 case S1D13506_PROD_ID: /* activate acceleration */
47148 - s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
47149 - s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
47150 + pax_open_kernel();
47151 + *(void **)&s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
47152 + *(void **)&s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
47153 + pax_close_kernel();
47154 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN |
47155 FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_COPYAREA;
47156 break;
47157 diff --git a/drivers/video/smscufx.c b/drivers/video/smscufx.c
47158 index 97bd662..39fab85 100644
47159 --- a/drivers/video/smscufx.c
47160 +++ b/drivers/video/smscufx.c
47161 @@ -1171,7 +1171,9 @@ static int ufx_ops_release(struct fb_info *info, int user)
47162 fb_deferred_io_cleanup(info);
47163 kfree(info->fbdefio);
47164 info->fbdefio = NULL;
47165 - info->fbops->fb_mmap = ufx_ops_mmap;
47166 + pax_open_kernel();
47167 + *(void **)&info->fbops->fb_mmap = ufx_ops_mmap;
47168 + pax_close_kernel();
47169 }
47170
47171 pr_debug("released /dev/fb%d user=%d count=%d",
47172 diff --git a/drivers/video/udlfb.c b/drivers/video/udlfb.c
47173 index 86d449e..8e04dc5 100644
47174 --- a/drivers/video/udlfb.c
47175 +++ b/drivers/video/udlfb.c
47176 @@ -619,11 +619,11 @@ int dlfb_handle_damage(struct dlfb_data *dev, int x, int y,
47177 dlfb_urb_completion(urb);
47178
47179 error:
47180 - atomic_add(bytes_sent, &dev->bytes_sent);
47181 - atomic_add(bytes_identical, &dev->bytes_identical);
47182 - atomic_add(width*height*2, &dev->bytes_rendered);
47183 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
47184 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
47185 + atomic_add_unchecked(width*height*2, &dev->bytes_rendered);
47186 end_cycles = get_cycles();
47187 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
47188 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
47189 >> 10)), /* Kcycles */
47190 &dev->cpu_kcycles_used);
47191
47192 @@ -744,11 +744,11 @@ static void dlfb_dpy_deferred_io(struct fb_info *info,
47193 dlfb_urb_completion(urb);
47194
47195 error:
47196 - atomic_add(bytes_sent, &dev->bytes_sent);
47197 - atomic_add(bytes_identical, &dev->bytes_identical);
47198 - atomic_add(bytes_rendered, &dev->bytes_rendered);
47199 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
47200 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
47201 + atomic_add_unchecked(bytes_rendered, &dev->bytes_rendered);
47202 end_cycles = get_cycles();
47203 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
47204 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
47205 >> 10)), /* Kcycles */
47206 &dev->cpu_kcycles_used);
47207 }
47208 @@ -989,7 +989,9 @@ static int dlfb_ops_release(struct fb_info *info, int user)
47209 fb_deferred_io_cleanup(info);
47210 kfree(info->fbdefio);
47211 info->fbdefio = NULL;
47212 - info->fbops->fb_mmap = dlfb_ops_mmap;
47213 + pax_open_kernel();
47214 + *(void **)&info->fbops->fb_mmap = dlfb_ops_mmap;
47215 + pax_close_kernel();
47216 }
47217
47218 pr_warn("released /dev/fb%d user=%d count=%d\n",
47219 @@ -1372,7 +1374,7 @@ static ssize_t metrics_bytes_rendered_show(struct device *fbdev,
47220 struct fb_info *fb_info = dev_get_drvdata(fbdev);
47221 struct dlfb_data *dev = fb_info->par;
47222 return snprintf(buf, PAGE_SIZE, "%u\n",
47223 - atomic_read(&dev->bytes_rendered));
47224 + atomic_read_unchecked(&dev->bytes_rendered));
47225 }
47226
47227 static ssize_t metrics_bytes_identical_show(struct device *fbdev,
47228 @@ -1380,7 +1382,7 @@ static ssize_t metrics_bytes_identical_show(struct device *fbdev,
47229 struct fb_info *fb_info = dev_get_drvdata(fbdev);
47230 struct dlfb_data *dev = fb_info->par;
47231 return snprintf(buf, PAGE_SIZE, "%u\n",
47232 - atomic_read(&dev->bytes_identical));
47233 + atomic_read_unchecked(&dev->bytes_identical));
47234 }
47235
47236 static ssize_t metrics_bytes_sent_show(struct device *fbdev,
47237 @@ -1388,7 +1390,7 @@ static ssize_t metrics_bytes_sent_show(struct device *fbdev,
47238 struct fb_info *fb_info = dev_get_drvdata(fbdev);
47239 struct dlfb_data *dev = fb_info->par;
47240 return snprintf(buf, PAGE_SIZE, "%u\n",
47241 - atomic_read(&dev->bytes_sent));
47242 + atomic_read_unchecked(&dev->bytes_sent));
47243 }
47244
47245 static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
47246 @@ -1396,7 +1398,7 @@ static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
47247 struct fb_info *fb_info = dev_get_drvdata(fbdev);
47248 struct dlfb_data *dev = fb_info->par;
47249 return snprintf(buf, PAGE_SIZE, "%u\n",
47250 - atomic_read(&dev->cpu_kcycles_used));
47251 + atomic_read_unchecked(&dev->cpu_kcycles_used));
47252 }
47253
47254 static ssize_t edid_show(
47255 @@ -1456,10 +1458,10 @@ static ssize_t metrics_reset_store(struct device *fbdev,
47256 struct fb_info *fb_info = dev_get_drvdata(fbdev);
47257 struct dlfb_data *dev = fb_info->par;
47258
47259 - atomic_set(&dev->bytes_rendered, 0);
47260 - atomic_set(&dev->bytes_identical, 0);
47261 - atomic_set(&dev->bytes_sent, 0);
47262 - atomic_set(&dev->cpu_kcycles_used, 0);
47263 + atomic_set_unchecked(&dev->bytes_rendered, 0);
47264 + atomic_set_unchecked(&dev->bytes_identical, 0);
47265 + atomic_set_unchecked(&dev->bytes_sent, 0);
47266 + atomic_set_unchecked(&dev->cpu_kcycles_used, 0);
47267
47268 return count;
47269 }
47270 diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c
47271 index d428445..79a78df 100644
47272 --- a/drivers/video/uvesafb.c
47273 +++ b/drivers/video/uvesafb.c
47274 @@ -19,6 +19,7 @@
47275 #include <linux/io.h>
47276 #include <linux/mutex.h>
47277 #include <linux/slab.h>
47278 +#include <linux/moduleloader.h>
47279 #include <video/edid.h>
47280 #include <video/uvesafb.h>
47281 #ifdef CONFIG_X86
47282 @@ -569,10 +570,32 @@ static int uvesafb_vbe_getpmi(struct uvesafb_ktask *task,
47283 if ((task->t.regs.eax & 0xffff) != 0x4f || task->t.regs.es < 0xc000) {
47284 par->pmi_setpal = par->ypan = 0;
47285 } else {
47286 +
47287 +#ifdef CONFIG_PAX_KERNEXEC
47288 +#ifdef CONFIG_MODULES
47289 + par->pmi_code = module_alloc_exec((u16)task->t.regs.ecx);
47290 +#endif
47291 + if (!par->pmi_code) {
47292 + par->pmi_setpal = par->ypan = 0;
47293 + return 0;
47294 + }
47295 +#endif
47296 +
47297 par->pmi_base = (u16 *)phys_to_virt(((u32)task->t.regs.es << 4)
47298 + task->t.regs.edi);
47299 +
47300 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47301 + pax_open_kernel();
47302 + memcpy(par->pmi_code, par->pmi_base, (u16)task->t.regs.ecx);
47303 + pax_close_kernel();
47304 +
47305 + par->pmi_start = ktva_ktla(par->pmi_code + par->pmi_base[1]);
47306 + par->pmi_pal = ktva_ktla(par->pmi_code + par->pmi_base[2]);
47307 +#else
47308 par->pmi_start = (u8 *)par->pmi_base + par->pmi_base[1];
47309 par->pmi_pal = (u8 *)par->pmi_base + par->pmi_base[2];
47310 +#endif
47311 +
47312 printk(KERN_INFO "uvesafb: protected mode interface info at "
47313 "%04x:%04x\n",
47314 (u16)task->t.regs.es, (u16)task->t.regs.edi);
47315 @@ -817,13 +840,14 @@ static int uvesafb_vbe_init(struct fb_info *info)
47316 par->ypan = ypan;
47317
47318 if (par->pmi_setpal || par->ypan) {
47319 +#if !defined(CONFIG_MODULES) || !defined(CONFIG_PAX_KERNEXEC)
47320 if (__supported_pte_mask & _PAGE_NX) {
47321 par->pmi_setpal = par->ypan = 0;
47322 printk(KERN_WARNING "uvesafb: NX protection is actively."
47323 "We have better not to use the PMI.\n");
47324 - } else {
47325 + } else
47326 +#endif
47327 uvesafb_vbe_getpmi(task, par);
47328 - }
47329 }
47330 #else
47331 /* The protected mode interface is not available on non-x86. */
47332 @@ -1457,8 +1481,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
47333 info->fix.ywrapstep = (par->ypan > 1) ? 1 : 0;
47334
47335 /* Disable blanking if the user requested so. */
47336 - if (!blank)
47337 - info->fbops->fb_blank = NULL;
47338 + if (!blank) {
47339 + pax_open_kernel();
47340 + *(void **)&info->fbops->fb_blank = NULL;
47341 + pax_close_kernel();
47342 + }
47343
47344 /*
47345 * Find out how much IO memory is required for the mode with
47346 @@ -1534,8 +1561,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
47347 info->flags = FBINFO_FLAG_DEFAULT |
47348 (par->ypan ? FBINFO_HWACCEL_YPAN : 0);
47349
47350 - if (!par->ypan)
47351 - info->fbops->fb_pan_display = NULL;
47352 + if (!par->ypan) {
47353 + pax_open_kernel();
47354 + *(void **)&info->fbops->fb_pan_display = NULL;
47355 + pax_close_kernel();
47356 + }
47357 }
47358
47359 static void uvesafb_init_mtrr(struct fb_info *info)
47360 @@ -1836,6 +1866,11 @@ out:
47361 if (par->vbe_modes)
47362 kfree(par->vbe_modes);
47363
47364 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47365 + if (par->pmi_code)
47366 + module_free_exec(NULL, par->pmi_code);
47367 +#endif
47368 +
47369 framebuffer_release(info);
47370 return err;
47371 }
47372 @@ -1862,6 +1897,12 @@ static int uvesafb_remove(struct platform_device *dev)
47373 kfree(par->vbe_state_orig);
47374 if (par->vbe_state_saved)
47375 kfree(par->vbe_state_saved);
47376 +
47377 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47378 + if (par->pmi_code)
47379 + module_free_exec(NULL, par->pmi_code);
47380 +#endif
47381 +
47382 }
47383
47384 framebuffer_release(info);
47385 diff --git a/drivers/video/vesafb.c b/drivers/video/vesafb.c
47386 index 501b340..d80aa17 100644
47387 --- a/drivers/video/vesafb.c
47388 +++ b/drivers/video/vesafb.c
47389 @@ -9,6 +9,7 @@
47390 */
47391
47392 #include <linux/module.h>
47393 +#include <linux/moduleloader.h>
47394 #include <linux/kernel.h>
47395 #include <linux/errno.h>
47396 #include <linux/string.h>
47397 @@ -52,8 +53,8 @@ static int vram_remap __initdata; /* Set amount of memory to be used */
47398 static int vram_total __initdata; /* Set total amount of memory */
47399 static int pmi_setpal __read_mostly = 1; /* pmi for palette changes ??? */
47400 static int ypan __read_mostly; /* 0..nothing, 1..ypan, 2..ywrap */
47401 -static void (*pmi_start)(void) __read_mostly;
47402 -static void (*pmi_pal) (void) __read_mostly;
47403 +static void (*pmi_start)(void) __read_only;
47404 +static void (*pmi_pal) (void) __read_only;
47405 static int depth __read_mostly;
47406 static int vga_compat __read_mostly;
47407 /* --------------------------------------------------------------------- */
47408 @@ -233,6 +234,7 @@ static int __init vesafb_probe(struct platform_device *dev)
47409 unsigned int size_vmode;
47410 unsigned int size_remap;
47411 unsigned int size_total;
47412 + void *pmi_code = NULL;
47413
47414 if (screen_info.orig_video_isVGA != VIDEO_TYPE_VLFB)
47415 return -ENODEV;
47416 @@ -275,10 +277,6 @@ static int __init vesafb_probe(struct platform_device *dev)
47417 size_remap = size_total;
47418 vesafb_fix.smem_len = size_remap;
47419
47420 -#ifndef __i386__
47421 - screen_info.vesapm_seg = 0;
47422 -#endif
47423 -
47424 if (!request_mem_region(vesafb_fix.smem_start, size_total, "vesafb")) {
47425 printk(KERN_WARNING
47426 "vesafb: cannot reserve video memory at 0x%lx\n",
47427 @@ -307,9 +305,21 @@ static int __init vesafb_probe(struct platform_device *dev)
47428 printk(KERN_INFO "vesafb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
47429 vesafb_defined.xres, vesafb_defined.yres, vesafb_defined.bits_per_pixel, vesafb_fix.line_length, screen_info.pages);
47430
47431 +#ifdef __i386__
47432 +
47433 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47434 + pmi_code = module_alloc_exec(screen_info.vesapm_size);
47435 + if (!pmi_code)
47436 +#elif !defined(CONFIG_PAX_KERNEXEC)
47437 + if (0)
47438 +#endif
47439 +
47440 +#endif
47441 + screen_info.vesapm_seg = 0;
47442 +
47443 if (screen_info.vesapm_seg) {
47444 - printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x\n",
47445 - screen_info.vesapm_seg,screen_info.vesapm_off);
47446 + printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x %04x bytes\n",
47447 + screen_info.vesapm_seg,screen_info.vesapm_off,screen_info.vesapm_size);
47448 }
47449
47450 if (screen_info.vesapm_seg < 0xc000)
47451 @@ -317,9 +327,25 @@ static int __init vesafb_probe(struct platform_device *dev)
47452
47453 if (ypan || pmi_setpal) {
47454 unsigned short *pmi_base;
47455 +
47456 pmi_base = (unsigned short*)phys_to_virt(((unsigned long)screen_info.vesapm_seg << 4) + screen_info.vesapm_off);
47457 - pmi_start = (void*)((char*)pmi_base + pmi_base[1]);
47458 - pmi_pal = (void*)((char*)pmi_base + pmi_base[2]);
47459 +
47460 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47461 + pax_open_kernel();
47462 + memcpy(pmi_code, pmi_base, screen_info.vesapm_size);
47463 +#else
47464 + pmi_code = pmi_base;
47465 +#endif
47466 +
47467 + pmi_start = (void*)((char*)pmi_code + pmi_base[1]);
47468 + pmi_pal = (void*)((char*)pmi_code + pmi_base[2]);
47469 +
47470 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47471 + pmi_start = ktva_ktla(pmi_start);
47472 + pmi_pal = ktva_ktla(pmi_pal);
47473 + pax_close_kernel();
47474 +#endif
47475 +
47476 printk(KERN_INFO "vesafb: pmi: set display start = %p, set palette = %p\n",pmi_start,pmi_pal);
47477 if (pmi_base[3]) {
47478 printk(KERN_INFO "vesafb: pmi: ports = ");
47479 @@ -472,8 +498,11 @@ static int __init vesafb_probe(struct platform_device *dev)
47480 info->flags = FBINFO_FLAG_DEFAULT | FBINFO_MISC_FIRMWARE |
47481 (ypan ? FBINFO_HWACCEL_YPAN : 0);
47482
47483 - if (!ypan)
47484 - info->fbops->fb_pan_display = NULL;
47485 + if (!ypan) {
47486 + pax_open_kernel();
47487 + *(void **)&info->fbops->fb_pan_display = NULL;
47488 + pax_close_kernel();
47489 + }
47490
47491 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
47492 err = -ENOMEM;
47493 @@ -488,6 +517,11 @@ static int __init vesafb_probe(struct platform_device *dev)
47494 info->node, info->fix.id);
47495 return 0;
47496 err:
47497 +
47498 +#if defined(__i386__) && defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47499 + module_free_exec(NULL, pmi_code);
47500 +#endif
47501 +
47502 if (info->screen_base)
47503 iounmap(info->screen_base);
47504 framebuffer_release(info);
47505 diff --git a/drivers/video/via/via_clock.h b/drivers/video/via/via_clock.h
47506 index 88714ae..16c2e11 100644
47507 --- a/drivers/video/via/via_clock.h
47508 +++ b/drivers/video/via/via_clock.h
47509 @@ -56,7 +56,7 @@ struct via_clock {
47510
47511 void (*set_engine_pll_state)(u8 state);
47512 void (*set_engine_pll)(struct via_pll_config config);
47513 -};
47514 +} __no_const;
47515
47516
47517 static inline u32 get_pll_internal_frequency(u32 ref_freq,
47518 diff --git a/drivers/xen/xenfs/xenstored.c b/drivers/xen/xenfs/xenstored.c
47519 index fef20db..d28b1ab 100644
47520 --- a/drivers/xen/xenfs/xenstored.c
47521 +++ b/drivers/xen/xenfs/xenstored.c
47522 @@ -24,7 +24,12 @@ static int xsd_release(struct inode *inode, struct file *file)
47523 static int xsd_kva_open(struct inode *inode, struct file *file)
47524 {
47525 file->private_data = (void *)kasprintf(GFP_KERNEL, "0x%p",
47526 +#ifdef CONFIG_GRKERNSEC_HIDESYM
47527 + NULL);
47528 +#else
47529 xen_store_interface);
47530 +#endif
47531 +
47532 if (!file->private_data)
47533 return -ENOMEM;
47534 return 0;
47535 diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
47536 index d86edc8..40ff2fb 100644
47537 --- a/fs/9p/vfs_inode.c
47538 +++ b/fs/9p/vfs_inode.c
47539 @@ -1314,7 +1314,7 @@ static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd)
47540 void
47541 v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
47542 {
47543 - char *s = nd_get_link(nd);
47544 + const char *s = nd_get_link(nd);
47545
47546 p9_debug(P9_DEBUG_VFS, " %s %s\n",
47547 dentry->d_name.name, IS_ERR(s) ? "<error>" : s);
47548 diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
47549 index 0efd152..b5802ad 100644
47550 --- a/fs/Kconfig.binfmt
47551 +++ b/fs/Kconfig.binfmt
47552 @@ -89,7 +89,7 @@ config HAVE_AOUT
47553
47554 config BINFMT_AOUT
47555 tristate "Kernel support for a.out and ECOFF binaries"
47556 - depends on HAVE_AOUT
47557 + depends on HAVE_AOUT && BROKEN
47558 ---help---
47559 A.out (Assembler.OUTput) is a set of formats for libraries and
47560 executables used in the earliest versions of UNIX. Linux used
47561 diff --git a/fs/aio.c b/fs/aio.c
47562 index 1dc8786..d3b29e8 100644
47563 --- a/fs/aio.c
47564 +++ b/fs/aio.c
47565 @@ -111,7 +111,7 @@ static int aio_setup_ring(struct kioctx *ctx)
47566 size += sizeof(struct io_event) * nr_events;
47567 nr_pages = (size + PAGE_SIZE-1) >> PAGE_SHIFT;
47568
47569 - if (nr_pages < 0)
47570 + if (nr_pages <= 0)
47571 return -EINVAL;
47572
47573 nr_events = (PAGE_SIZE * nr_pages - sizeof(struct aio_ring)) / sizeof(struct io_event);
47574 @@ -1375,18 +1375,19 @@ static ssize_t aio_fsync(struct kiocb *iocb)
47575 static ssize_t aio_setup_vectored_rw(int type, struct kiocb *kiocb, bool compat)
47576 {
47577 ssize_t ret;
47578 + struct iovec iovstack;
47579
47580 #ifdef CONFIG_COMPAT
47581 if (compat)
47582 ret = compat_rw_copy_check_uvector(type,
47583 (struct compat_iovec __user *)kiocb->ki_buf,
47584 - kiocb->ki_nbytes, 1, &kiocb->ki_inline_vec,
47585 + kiocb->ki_nbytes, 1, &iovstack,
47586 &kiocb->ki_iovec);
47587 else
47588 #endif
47589 ret = rw_copy_check_uvector(type,
47590 (struct iovec __user *)kiocb->ki_buf,
47591 - kiocb->ki_nbytes, 1, &kiocb->ki_inline_vec,
47592 + kiocb->ki_nbytes, 1, &iovstack,
47593 &kiocb->ki_iovec);
47594 if (ret < 0)
47595 goto out;
47596 @@ -1395,6 +1396,10 @@ static ssize_t aio_setup_vectored_rw(int type, struct kiocb *kiocb, bool compat)
47597 if (ret < 0)
47598 goto out;
47599
47600 + if (kiocb->ki_iovec == &iovstack) {
47601 + kiocb->ki_inline_vec = iovstack;
47602 + kiocb->ki_iovec = &kiocb->ki_inline_vec;
47603 + }
47604 kiocb->ki_nr_segs = kiocb->ki_nbytes;
47605 kiocb->ki_cur_seg = 0;
47606 /* ki_nbytes/left now reflect bytes instead of segs */
47607 diff --git a/fs/attr.c b/fs/attr.c
47608 index 1449adb..a2038c2 100644
47609 --- a/fs/attr.c
47610 +++ b/fs/attr.c
47611 @@ -102,6 +102,7 @@ int inode_newsize_ok(const struct inode *inode, loff_t offset)
47612 unsigned long limit;
47613
47614 limit = rlimit(RLIMIT_FSIZE);
47615 + gr_learn_resource(current, RLIMIT_FSIZE, (unsigned long)offset, 1);
47616 if (limit != RLIM_INFINITY && offset > limit)
47617 goto out_sig;
47618 if (offset > inode->i_sb->s_maxbytes)
47619 diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
47620 index 3db70da..7aeec5b 100644
47621 --- a/fs/autofs4/waitq.c
47622 +++ b/fs/autofs4/waitq.c
47623 @@ -59,7 +59,7 @@ static int autofs4_write(struct autofs_sb_info *sbi,
47624 {
47625 unsigned long sigpipe, flags;
47626 mm_segment_t fs;
47627 - const char *data = (const char *)addr;
47628 + const char __user *data = (const char __force_user *)addr;
47629 ssize_t wr = 0;
47630
47631 sigpipe = sigismember(&current->pending.signal, SIGPIPE);
47632 @@ -346,6 +346,10 @@ static int validate_request(struct autofs_wait_queue **wait,
47633 return 1;
47634 }
47635
47636 +#ifdef CONFIG_GRKERNSEC_HIDESYM
47637 +static atomic_unchecked_t autofs_dummy_name_id = ATOMIC_INIT(0);
47638 +#endif
47639 +
47640 int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
47641 enum autofs_notify notify)
47642 {
47643 @@ -379,7 +383,12 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
47644
47645 /* If this is a direct mount request create a dummy name */
47646 if (IS_ROOT(dentry) && autofs_type_trigger(sbi->type))
47647 +#ifdef CONFIG_GRKERNSEC_HIDESYM
47648 + /* this name does get written to userland via autofs4_write() */
47649 + qstr.len = sprintf(name, "%08x", atomic_inc_return_unchecked(&autofs_dummy_name_id));
47650 +#else
47651 qstr.len = sprintf(name, "%p", dentry);
47652 +#endif
47653 else {
47654 qstr.len = autofs4_getpath(sbi, dentry, &name);
47655 if (!qstr.len) {
47656 diff --git a/fs/befs/endian.h b/fs/befs/endian.h
47657 index 2722387..c8dd2a7 100644
47658 --- a/fs/befs/endian.h
47659 +++ b/fs/befs/endian.h
47660 @@ -11,7 +11,7 @@
47661
47662 #include <asm/byteorder.h>
47663
47664 -static inline u64
47665 +static inline u64 __intentional_overflow(-1)
47666 fs64_to_cpu(const struct super_block *sb, fs64 n)
47667 {
47668 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
47669 @@ -29,7 +29,7 @@ cpu_to_fs64(const struct super_block *sb, u64 n)
47670 return (__force fs64)cpu_to_be64(n);
47671 }
47672
47673 -static inline u32
47674 +static inline u32 __intentional_overflow(-1)
47675 fs32_to_cpu(const struct super_block *sb, fs32 n)
47676 {
47677 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
47678 diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
47679 index 8615ee8..388ed68 100644
47680 --- a/fs/befs/linuxvfs.c
47681 +++ b/fs/befs/linuxvfs.c
47682 @@ -510,7 +510,7 @@ static void befs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
47683 {
47684 befs_inode_info *befs_ino = BEFS_I(dentry->d_inode);
47685 if (befs_ino->i_flags & BEFS_LONG_SYMLINK) {
47686 - char *link = nd_get_link(nd);
47687 + const char *link = nd_get_link(nd);
47688 if (!IS_ERR(link))
47689 kfree(link);
47690 }
47691 diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
47692 index bbc8f88..7c7ac97 100644
47693 --- a/fs/binfmt_aout.c
47694 +++ b/fs/binfmt_aout.c
47695 @@ -16,6 +16,7 @@
47696 #include <linux/string.h>
47697 #include <linux/fs.h>
47698 #include <linux/file.h>
47699 +#include <linux/security.h>
47700 #include <linux/stat.h>
47701 #include <linux/fcntl.h>
47702 #include <linux/ptrace.h>
47703 @@ -59,6 +60,8 @@ static int aout_core_dump(struct coredump_params *cprm)
47704 #endif
47705 # define START_STACK(u) ((void __user *)u.start_stack)
47706
47707 + memset(&dump, 0, sizeof(dump));
47708 +
47709 fs = get_fs();
47710 set_fs(KERNEL_DS);
47711 has_dumped = 1;
47712 @@ -70,10 +73,12 @@ static int aout_core_dump(struct coredump_params *cprm)
47713
47714 /* If the size of the dump file exceeds the rlimit, then see what would happen
47715 if we wrote the stack, but not the data area. */
47716 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE, 1);
47717 if ((dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE > cprm->limit)
47718 dump.u_dsize = 0;
47719
47720 /* Make sure we have enough room to write the stack and data areas. */
47721 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_ssize + 1) * PAGE_SIZE, 1);
47722 if ((dump.u_ssize + 1) * PAGE_SIZE > cprm->limit)
47723 dump.u_ssize = 0;
47724
47725 @@ -234,6 +239,8 @@ static int load_aout_binary(struct linux_binprm * bprm)
47726 rlim = rlimit(RLIMIT_DATA);
47727 if (rlim >= RLIM_INFINITY)
47728 rlim = ~0;
47729 +
47730 + gr_learn_resource(current, RLIMIT_DATA, ex.a_data + ex.a_bss, 1);
47731 if (ex.a_data + ex.a_bss > rlim)
47732 return -ENOMEM;
47733
47734 @@ -268,6 +275,27 @@ static int load_aout_binary(struct linux_binprm * bprm)
47735
47736 install_exec_creds(bprm);
47737
47738 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
47739 + current->mm->pax_flags = 0UL;
47740 +#endif
47741 +
47742 +#ifdef CONFIG_PAX_PAGEEXEC
47743 + if (!(N_FLAGS(ex) & F_PAX_PAGEEXEC)) {
47744 + current->mm->pax_flags |= MF_PAX_PAGEEXEC;
47745 +
47746 +#ifdef CONFIG_PAX_EMUTRAMP
47747 + if (N_FLAGS(ex) & F_PAX_EMUTRAMP)
47748 + current->mm->pax_flags |= MF_PAX_EMUTRAMP;
47749 +#endif
47750 +
47751 +#ifdef CONFIG_PAX_MPROTECT
47752 + if (!(N_FLAGS(ex) & F_PAX_MPROTECT))
47753 + current->mm->pax_flags |= MF_PAX_MPROTECT;
47754 +#endif
47755 +
47756 + }
47757 +#endif
47758 +
47759 if (N_MAGIC(ex) == OMAGIC) {
47760 unsigned long text_addr, map_size;
47761 loff_t pos;
47762 @@ -333,7 +361,7 @@ static int load_aout_binary(struct linux_binprm * bprm)
47763 }
47764
47765 error = vm_mmap(bprm->file, N_DATADDR(ex), ex.a_data,
47766 - PROT_READ | PROT_WRITE | PROT_EXEC,
47767 + PROT_READ | PROT_WRITE,
47768 MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE,
47769 fd_offset + ex.a_text);
47770 if (error != N_DATADDR(ex)) {
47771 diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
47772 index 86af964..8a1da7e 100644
47773 --- a/fs/binfmt_elf.c
47774 +++ b/fs/binfmt_elf.c
47775 @@ -34,6 +34,7 @@
47776 #include <linux/utsname.h>
47777 #include <linux/coredump.h>
47778 #include <linux/sched.h>
47779 +#include <linux/xattr.h>
47780 #include <asm/uaccess.h>
47781 #include <asm/param.h>
47782 #include <asm/page.h>
47783 @@ -60,6 +61,10 @@ static int elf_core_dump(struct coredump_params *cprm);
47784 #define elf_core_dump NULL
47785 #endif
47786
47787 +#ifdef CONFIG_PAX_MPROTECT
47788 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags);
47789 +#endif
47790 +
47791 #if ELF_EXEC_PAGESIZE > PAGE_SIZE
47792 #define ELF_MIN_ALIGN ELF_EXEC_PAGESIZE
47793 #else
47794 @@ -79,6 +84,11 @@ static struct linux_binfmt elf_format = {
47795 .load_binary = load_elf_binary,
47796 .load_shlib = load_elf_library,
47797 .core_dump = elf_core_dump,
47798 +
47799 +#ifdef CONFIG_PAX_MPROTECT
47800 + .handle_mprotect= elf_handle_mprotect,
47801 +#endif
47802 +
47803 .min_coredump = ELF_EXEC_PAGESIZE,
47804 };
47805
47806 @@ -86,6 +96,8 @@ static struct linux_binfmt elf_format = {
47807
47808 static int set_brk(unsigned long start, unsigned long end)
47809 {
47810 + unsigned long e = end;
47811 +
47812 start = ELF_PAGEALIGN(start);
47813 end = ELF_PAGEALIGN(end);
47814 if (end > start) {
47815 @@ -94,7 +106,7 @@ static int set_brk(unsigned long start, unsigned long end)
47816 if (BAD_ADDR(addr))
47817 return addr;
47818 }
47819 - current->mm->start_brk = current->mm->brk = end;
47820 + current->mm->start_brk = current->mm->brk = e;
47821 return 0;
47822 }
47823
47824 @@ -155,12 +167,13 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
47825 elf_addr_t __user *u_rand_bytes;
47826 const char *k_platform = ELF_PLATFORM;
47827 const char *k_base_platform = ELF_BASE_PLATFORM;
47828 - unsigned char k_rand_bytes[16];
47829 + u32 k_rand_bytes[4];
47830 int items;
47831 elf_addr_t *elf_info;
47832 int ei_index = 0;
47833 const struct cred *cred = current_cred();
47834 struct vm_area_struct *vma;
47835 + unsigned long saved_auxv[AT_VECTOR_SIZE];
47836
47837 /*
47838 * In some cases (e.g. Hyper-Threading), we want to avoid L1
47839 @@ -202,8 +215,12 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
47840 * Generate 16 random bytes for userspace PRNG seeding.
47841 */
47842 get_random_bytes(k_rand_bytes, sizeof(k_rand_bytes));
47843 - u_rand_bytes = (elf_addr_t __user *)
47844 - STACK_ALLOC(p, sizeof(k_rand_bytes));
47845 + srandom32(k_rand_bytes[0] ^ random32());
47846 + srandom32(k_rand_bytes[1] ^ random32());
47847 + srandom32(k_rand_bytes[2] ^ random32());
47848 + srandom32(k_rand_bytes[3] ^ random32());
47849 + p = STACK_ROUND(p, sizeof(k_rand_bytes));
47850 + u_rand_bytes = (elf_addr_t __user *) p;
47851 if (__copy_to_user(u_rand_bytes, k_rand_bytes, sizeof(k_rand_bytes)))
47852 return -EFAULT;
47853
47854 @@ -315,9 +332,11 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
47855 return -EFAULT;
47856 current->mm->env_end = p;
47857
47858 + memcpy(saved_auxv, elf_info, ei_index * sizeof(elf_addr_t));
47859 +
47860 /* Put the elf_info on the stack in the right place. */
47861 sp = (elf_addr_t __user *)envp + 1;
47862 - if (copy_to_user(sp, elf_info, ei_index * sizeof(elf_addr_t)))
47863 + if (copy_to_user(sp, saved_auxv, ei_index * sizeof(elf_addr_t)))
47864 return -EFAULT;
47865 return 0;
47866 }
47867 @@ -385,15 +404,14 @@ static unsigned long total_mapping_size(struct elf_phdr *cmds, int nr)
47868 an ELF header */
47869
47870 static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
47871 - struct file *interpreter, unsigned long *interp_map_addr,
47872 - unsigned long no_base)
47873 + struct file *interpreter, unsigned long no_base)
47874 {
47875 struct elf_phdr *elf_phdata;
47876 struct elf_phdr *eppnt;
47877 - unsigned long load_addr = 0;
47878 + unsigned long load_addr = 0, pax_task_size = TASK_SIZE;
47879 int load_addr_set = 0;
47880 unsigned long last_bss = 0, elf_bss = 0;
47881 - unsigned long error = ~0UL;
47882 + unsigned long error = -EINVAL;
47883 unsigned long total_size;
47884 int retval, i, size;
47885
47886 @@ -439,6 +457,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
47887 goto out_close;
47888 }
47889
47890 +#ifdef CONFIG_PAX_SEGMEXEC
47891 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
47892 + pax_task_size = SEGMEXEC_TASK_SIZE;
47893 +#endif
47894 +
47895 eppnt = elf_phdata;
47896 for (i = 0; i < interp_elf_ex->e_phnum; i++, eppnt++) {
47897 if (eppnt->p_type == PT_LOAD) {
47898 @@ -462,8 +485,6 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
47899 map_addr = elf_map(interpreter, load_addr + vaddr,
47900 eppnt, elf_prot, elf_type, total_size);
47901 total_size = 0;
47902 - if (!*interp_map_addr)
47903 - *interp_map_addr = map_addr;
47904 error = map_addr;
47905 if (BAD_ADDR(map_addr))
47906 goto out_close;
47907 @@ -482,8 +503,8 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
47908 k = load_addr + eppnt->p_vaddr;
47909 if (BAD_ADDR(k) ||
47910 eppnt->p_filesz > eppnt->p_memsz ||
47911 - eppnt->p_memsz > TASK_SIZE ||
47912 - TASK_SIZE - eppnt->p_memsz < k) {
47913 + eppnt->p_memsz > pax_task_size ||
47914 + pax_task_size - eppnt->p_memsz < k) {
47915 error = -ENOMEM;
47916 goto out_close;
47917 }
47918 @@ -535,6 +556,315 @@ out:
47919 return error;
47920 }
47921
47922 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
47923 +#ifdef CONFIG_PAX_SOFTMODE
47924 +static unsigned long pax_parse_pt_pax_softmode(const struct elf_phdr * const elf_phdata)
47925 +{
47926 + unsigned long pax_flags = 0UL;
47927 +
47928 +#ifdef CONFIG_PAX_PAGEEXEC
47929 + if (elf_phdata->p_flags & PF_PAGEEXEC)
47930 + pax_flags |= MF_PAX_PAGEEXEC;
47931 +#endif
47932 +
47933 +#ifdef CONFIG_PAX_SEGMEXEC
47934 + if (elf_phdata->p_flags & PF_SEGMEXEC)
47935 + pax_flags |= MF_PAX_SEGMEXEC;
47936 +#endif
47937 +
47938 +#ifdef CONFIG_PAX_EMUTRAMP
47939 + if ((elf_phdata->p_flags & PF_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
47940 + pax_flags |= MF_PAX_EMUTRAMP;
47941 +#endif
47942 +
47943 +#ifdef CONFIG_PAX_MPROTECT
47944 + if (elf_phdata->p_flags & PF_MPROTECT)
47945 + pax_flags |= MF_PAX_MPROTECT;
47946 +#endif
47947 +
47948 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
47949 + if (randomize_va_space && (elf_phdata->p_flags & PF_RANDMMAP))
47950 + pax_flags |= MF_PAX_RANDMMAP;
47951 +#endif
47952 +
47953 + return pax_flags;
47954 +}
47955 +#endif
47956 +
47957 +static unsigned long pax_parse_pt_pax_hardmode(const struct elf_phdr * const elf_phdata)
47958 +{
47959 + unsigned long pax_flags = 0UL;
47960 +
47961 +#ifdef CONFIG_PAX_PAGEEXEC
47962 + if (!(elf_phdata->p_flags & PF_NOPAGEEXEC))
47963 + pax_flags |= MF_PAX_PAGEEXEC;
47964 +#endif
47965 +
47966 +#ifdef CONFIG_PAX_SEGMEXEC
47967 + if (!(elf_phdata->p_flags & PF_NOSEGMEXEC))
47968 + pax_flags |= MF_PAX_SEGMEXEC;
47969 +#endif
47970 +
47971 +#ifdef CONFIG_PAX_EMUTRAMP
47972 + if (!(elf_phdata->p_flags & PF_NOEMUTRAMP))
47973 + pax_flags |= MF_PAX_EMUTRAMP;
47974 +#endif
47975 +
47976 +#ifdef CONFIG_PAX_MPROTECT
47977 + if (!(elf_phdata->p_flags & PF_NOMPROTECT))
47978 + pax_flags |= MF_PAX_MPROTECT;
47979 +#endif
47980 +
47981 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
47982 + if (randomize_va_space && !(elf_phdata->p_flags & PF_NORANDMMAP))
47983 + pax_flags |= MF_PAX_RANDMMAP;
47984 +#endif
47985 +
47986 + return pax_flags;
47987 +}
47988 +#endif
47989 +
47990 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
47991 +#ifdef CONFIG_PAX_SOFTMODE
47992 +static unsigned long pax_parse_xattr_pax_softmode(unsigned long pax_flags_softmode)
47993 +{
47994 + unsigned long pax_flags = 0UL;
47995 +
47996 +#ifdef CONFIG_PAX_PAGEEXEC
47997 + if (pax_flags_softmode & MF_PAX_PAGEEXEC)
47998 + pax_flags |= MF_PAX_PAGEEXEC;
47999 +#endif
48000 +
48001 +#ifdef CONFIG_PAX_SEGMEXEC
48002 + if (pax_flags_softmode & MF_PAX_SEGMEXEC)
48003 + pax_flags |= MF_PAX_SEGMEXEC;
48004 +#endif
48005 +
48006 +#ifdef CONFIG_PAX_EMUTRAMP
48007 + if (pax_flags_softmode & MF_PAX_EMUTRAMP)
48008 + pax_flags |= MF_PAX_EMUTRAMP;
48009 +#endif
48010 +
48011 +#ifdef CONFIG_PAX_MPROTECT
48012 + if (pax_flags_softmode & MF_PAX_MPROTECT)
48013 + pax_flags |= MF_PAX_MPROTECT;
48014 +#endif
48015 +
48016 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48017 + if (randomize_va_space && (pax_flags_softmode & MF_PAX_RANDMMAP))
48018 + pax_flags |= MF_PAX_RANDMMAP;
48019 +#endif
48020 +
48021 + return pax_flags;
48022 +}
48023 +#endif
48024 +
48025 +static unsigned long pax_parse_xattr_pax_hardmode(unsigned long pax_flags_hardmode)
48026 +{
48027 + unsigned long pax_flags = 0UL;
48028 +
48029 +#ifdef CONFIG_PAX_PAGEEXEC
48030 + if (!(pax_flags_hardmode & MF_PAX_PAGEEXEC))
48031 + pax_flags |= MF_PAX_PAGEEXEC;
48032 +#endif
48033 +
48034 +#ifdef CONFIG_PAX_SEGMEXEC
48035 + if (!(pax_flags_hardmode & MF_PAX_SEGMEXEC))
48036 + pax_flags |= MF_PAX_SEGMEXEC;
48037 +#endif
48038 +
48039 +#ifdef CONFIG_PAX_EMUTRAMP
48040 + if (!(pax_flags_hardmode & MF_PAX_EMUTRAMP))
48041 + pax_flags |= MF_PAX_EMUTRAMP;
48042 +#endif
48043 +
48044 +#ifdef CONFIG_PAX_MPROTECT
48045 + if (!(pax_flags_hardmode & MF_PAX_MPROTECT))
48046 + pax_flags |= MF_PAX_MPROTECT;
48047 +#endif
48048 +
48049 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48050 + if (randomize_va_space && !(pax_flags_hardmode & MF_PAX_RANDMMAP))
48051 + pax_flags |= MF_PAX_RANDMMAP;
48052 +#endif
48053 +
48054 + return pax_flags;
48055 +}
48056 +#endif
48057 +
48058 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
48059 +static unsigned long pax_parse_ei_pax(const struct elfhdr * const elf_ex)
48060 +{
48061 + unsigned long pax_flags = 0UL;
48062 +
48063 +#ifdef CONFIG_PAX_EI_PAX
48064 +
48065 +#ifdef CONFIG_PAX_PAGEEXEC
48066 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_PAGEEXEC))
48067 + pax_flags |= MF_PAX_PAGEEXEC;
48068 +#endif
48069 +
48070 +#ifdef CONFIG_PAX_SEGMEXEC
48071 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_SEGMEXEC))
48072 + pax_flags |= MF_PAX_SEGMEXEC;
48073 +#endif
48074 +
48075 +#ifdef CONFIG_PAX_EMUTRAMP
48076 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && (elf_ex->e_ident[EI_PAX] & EF_PAX_EMUTRAMP))
48077 + pax_flags |= MF_PAX_EMUTRAMP;
48078 +#endif
48079 +
48080 +#ifdef CONFIG_PAX_MPROTECT
48081 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && !(elf_ex->e_ident[EI_PAX] & EF_PAX_MPROTECT))
48082 + pax_flags |= MF_PAX_MPROTECT;
48083 +#endif
48084 +
48085 +#ifdef CONFIG_PAX_ASLR
48086 + if (randomize_va_space && !(elf_ex->e_ident[EI_PAX] & EF_PAX_RANDMMAP))
48087 + pax_flags |= MF_PAX_RANDMMAP;
48088 +#endif
48089 +
48090 +#else
48091 +
48092 +#ifdef CONFIG_PAX_PAGEEXEC
48093 + pax_flags |= MF_PAX_PAGEEXEC;
48094 +#endif
48095 +
48096 +#ifdef CONFIG_PAX_SEGMEXEC
48097 + pax_flags |= MF_PAX_SEGMEXEC;
48098 +#endif
48099 +
48100 +#ifdef CONFIG_PAX_MPROTECT
48101 + pax_flags |= MF_PAX_MPROTECT;
48102 +#endif
48103 +
48104 +#ifdef CONFIG_PAX_RANDMMAP
48105 + if (randomize_va_space)
48106 + pax_flags |= MF_PAX_RANDMMAP;
48107 +#endif
48108 +
48109 +#endif
48110 +
48111 + return pax_flags;
48112 +}
48113 +
48114 +static unsigned long pax_parse_pt_pax(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata)
48115 +{
48116 +
48117 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
48118 + unsigned long i;
48119 +
48120 + for (i = 0UL; i < elf_ex->e_phnum; i++)
48121 + if (elf_phdata[i].p_type == PT_PAX_FLAGS) {
48122 + if (((elf_phdata[i].p_flags & PF_PAGEEXEC) && (elf_phdata[i].p_flags & PF_NOPAGEEXEC)) ||
48123 + ((elf_phdata[i].p_flags & PF_SEGMEXEC) && (elf_phdata[i].p_flags & PF_NOSEGMEXEC)) ||
48124 + ((elf_phdata[i].p_flags & PF_EMUTRAMP) && (elf_phdata[i].p_flags & PF_NOEMUTRAMP)) ||
48125 + ((elf_phdata[i].p_flags & PF_MPROTECT) && (elf_phdata[i].p_flags & PF_NOMPROTECT)) ||
48126 + ((elf_phdata[i].p_flags & PF_RANDMMAP) && (elf_phdata[i].p_flags & PF_NORANDMMAP)))
48127 + return ~0UL;
48128 +
48129 +#ifdef CONFIG_PAX_SOFTMODE
48130 + if (pax_softmode)
48131 + return pax_parse_pt_pax_softmode(&elf_phdata[i]);
48132 + else
48133 +#endif
48134 +
48135 + return pax_parse_pt_pax_hardmode(&elf_phdata[i]);
48136 + break;
48137 + }
48138 +#endif
48139 +
48140 + return ~0UL;
48141 +}
48142 +
48143 +static unsigned long pax_parse_xattr_pax(struct file * const file)
48144 +{
48145 +
48146 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
48147 + ssize_t xattr_size, i;
48148 + unsigned char xattr_value[sizeof("pemrs") - 1];
48149 + unsigned long pax_flags_hardmode = 0UL, pax_flags_softmode = 0UL;
48150 +
48151 + xattr_size = pax_getxattr(file->f_path.dentry, xattr_value, sizeof xattr_value);
48152 + if (xattr_size <= 0 || xattr_size > sizeof xattr_value)
48153 + return ~0UL;
48154 +
48155 + for (i = 0; i < xattr_size; i++)
48156 + switch (xattr_value[i]) {
48157 + default:
48158 + return ~0UL;
48159 +
48160 +#define parse_flag(option1, option2, flag) \
48161 + case option1: \
48162 + if (pax_flags_hardmode & MF_PAX_##flag) \
48163 + return ~0UL; \
48164 + pax_flags_hardmode |= MF_PAX_##flag; \
48165 + break; \
48166 + case option2: \
48167 + if (pax_flags_softmode & MF_PAX_##flag) \
48168 + return ~0UL; \
48169 + pax_flags_softmode |= MF_PAX_##flag; \
48170 + break;
48171 +
48172 + parse_flag('p', 'P', PAGEEXEC);
48173 + parse_flag('e', 'E', EMUTRAMP);
48174 + parse_flag('m', 'M', MPROTECT);
48175 + parse_flag('r', 'R', RANDMMAP);
48176 + parse_flag('s', 'S', SEGMEXEC);
48177 +
48178 +#undef parse_flag
48179 + }
48180 +
48181 + if (pax_flags_hardmode & pax_flags_softmode)
48182 + return ~0UL;
48183 +
48184 +#ifdef CONFIG_PAX_SOFTMODE
48185 + if (pax_softmode)
48186 + return pax_parse_xattr_pax_softmode(pax_flags_softmode);
48187 + else
48188 +#endif
48189 +
48190 + return pax_parse_xattr_pax_hardmode(pax_flags_hardmode);
48191 +#else
48192 + return ~0UL;
48193 +#endif
48194 +
48195 +}
48196 +
48197 +static long pax_parse_pax_flags(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata, struct file * const file)
48198 +{
48199 + unsigned long pax_flags, pt_pax_flags, xattr_pax_flags;
48200 +
48201 + pax_flags = pax_parse_ei_pax(elf_ex);
48202 + pt_pax_flags = pax_parse_pt_pax(elf_ex, elf_phdata);
48203 + xattr_pax_flags = pax_parse_xattr_pax(file);
48204 +
48205 + if (pt_pax_flags == ~0UL)
48206 + pt_pax_flags = xattr_pax_flags;
48207 + else if (xattr_pax_flags == ~0UL)
48208 + xattr_pax_flags = pt_pax_flags;
48209 + if (pt_pax_flags != xattr_pax_flags)
48210 + return -EINVAL;
48211 + if (pt_pax_flags != ~0UL)
48212 + pax_flags = pt_pax_flags;
48213 +
48214 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_PAX_SEGMEXEC)
48215 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) == (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
48216 + if ((__supported_pte_mask & _PAGE_NX))
48217 + pax_flags &= ~MF_PAX_SEGMEXEC;
48218 + else
48219 + pax_flags &= ~MF_PAX_PAGEEXEC;
48220 + }
48221 +#endif
48222 +
48223 + if (0 > pax_check_flags(&pax_flags))
48224 + return -EINVAL;
48225 +
48226 + current->mm->pax_flags = pax_flags;
48227 + return 0;
48228 +}
48229 +#endif
48230 +
48231 /*
48232 * These are the functions used to load ELF style executables and shared
48233 * libraries. There is no binary dependent code anywhere else.
48234 @@ -551,6 +881,11 @@ static unsigned long randomize_stack_top(unsigned long stack_top)
48235 {
48236 unsigned int random_variable = 0;
48237
48238 +#ifdef CONFIG_PAX_RANDUSTACK
48239 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
48240 + return stack_top - current->mm->delta_stack;
48241 +#endif
48242 +
48243 if ((current->flags & PF_RANDOMIZE) &&
48244 !(current->personality & ADDR_NO_RANDOMIZE)) {
48245 random_variable = get_random_int() & STACK_RND_MASK;
48246 @@ -569,7 +904,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
48247 unsigned long load_addr = 0, load_bias = 0;
48248 int load_addr_set = 0;
48249 char * elf_interpreter = NULL;
48250 - unsigned long error;
48251 + unsigned long error = 0;
48252 struct elf_phdr *elf_ppnt, *elf_phdata;
48253 unsigned long elf_bss, elf_brk;
48254 int retval, i;
48255 @@ -579,12 +914,12 @@ static int load_elf_binary(struct linux_binprm *bprm)
48256 unsigned long start_code, end_code, start_data, end_data;
48257 unsigned long reloc_func_desc __maybe_unused = 0;
48258 int executable_stack = EXSTACK_DEFAULT;
48259 - unsigned long def_flags = 0;
48260 struct pt_regs *regs = current_pt_regs();
48261 struct {
48262 struct elfhdr elf_ex;
48263 struct elfhdr interp_elf_ex;
48264 } *loc;
48265 + unsigned long pax_task_size = TASK_SIZE;
48266
48267 loc = kmalloc(sizeof(*loc), GFP_KERNEL);
48268 if (!loc) {
48269 @@ -720,11 +1055,81 @@ static int load_elf_binary(struct linux_binprm *bprm)
48270 goto out_free_dentry;
48271
48272 /* OK, This is the point of no return */
48273 - current->mm->def_flags = def_flags;
48274 +
48275 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
48276 + current->mm->pax_flags = 0UL;
48277 +#endif
48278 +
48279 +#ifdef CONFIG_PAX_DLRESOLVE
48280 + current->mm->call_dl_resolve = 0UL;
48281 +#endif
48282 +
48283 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
48284 + current->mm->call_syscall = 0UL;
48285 +#endif
48286 +
48287 +#ifdef CONFIG_PAX_ASLR
48288 + current->mm->delta_mmap = 0UL;
48289 + current->mm->delta_stack = 0UL;
48290 +#endif
48291 +
48292 + current->mm->def_flags = 0;
48293 +
48294 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
48295 + if (0 > pax_parse_pax_flags(&loc->elf_ex, elf_phdata, bprm->file)) {
48296 + send_sig(SIGKILL, current, 0);
48297 + goto out_free_dentry;
48298 + }
48299 +#endif
48300 +
48301 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
48302 + pax_set_initial_flags(bprm);
48303 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
48304 + if (pax_set_initial_flags_func)
48305 + (pax_set_initial_flags_func)(bprm);
48306 +#endif
48307 +
48308 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
48309 + if ((current->mm->pax_flags & MF_PAX_PAGEEXEC) && !(__supported_pte_mask & _PAGE_NX)) {
48310 + current->mm->context.user_cs_limit = PAGE_SIZE;
48311 + current->mm->def_flags |= VM_PAGEEXEC | VM_NOHUGEPAGE;
48312 + }
48313 +#endif
48314 +
48315 +#ifdef CONFIG_PAX_SEGMEXEC
48316 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
48317 + current->mm->context.user_cs_base = SEGMEXEC_TASK_SIZE;
48318 + current->mm->context.user_cs_limit = TASK_SIZE-SEGMEXEC_TASK_SIZE;
48319 + pax_task_size = SEGMEXEC_TASK_SIZE;
48320 + current->mm->def_flags |= VM_NOHUGEPAGE;
48321 + }
48322 +#endif
48323 +
48324 +#if defined(CONFIG_ARCH_TRACK_EXEC_LIMIT) || defined(CONFIG_PAX_SEGMEXEC)
48325 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
48326 + set_user_cs(current->mm->context.user_cs_base, current->mm->context.user_cs_limit, get_cpu());
48327 + put_cpu();
48328 + }
48329 +#endif
48330
48331 /* Do this immediately, since STACK_TOP as used in setup_arg_pages
48332 may depend on the personality. */
48333 SET_PERSONALITY(loc->elf_ex);
48334 +
48335 +#ifdef CONFIG_PAX_ASLR
48336 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
48337 + current->mm->delta_mmap = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN)-1)) << PAGE_SHIFT;
48338 + current->mm->delta_stack = (pax_get_random_long() & ((1UL << PAX_DELTA_STACK_LEN)-1)) << PAGE_SHIFT;
48339 + }
48340 +#endif
48341 +
48342 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
48343 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
48344 + executable_stack = EXSTACK_DISABLE_X;
48345 + current->personality &= ~READ_IMPLIES_EXEC;
48346 + } else
48347 +#endif
48348 +
48349 if (elf_read_implies_exec(loc->elf_ex, executable_stack))
48350 current->personality |= READ_IMPLIES_EXEC;
48351
48352 @@ -815,6 +1220,20 @@ static int load_elf_binary(struct linux_binprm *bprm)
48353 #else
48354 load_bias = ELF_PAGESTART(ELF_ET_DYN_BASE - vaddr);
48355 #endif
48356 +
48357 +#ifdef CONFIG_PAX_RANDMMAP
48358 + /* PaX: randomize base address at the default exe base if requested */
48359 + if ((current->mm->pax_flags & MF_PAX_RANDMMAP) && elf_interpreter) {
48360 +#ifdef CONFIG_SPARC64
48361 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << (PAGE_SHIFT+1);
48362 +#else
48363 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << PAGE_SHIFT;
48364 +#endif
48365 + load_bias = ELF_PAGESTART(PAX_ELF_ET_DYN_BASE - vaddr + load_bias);
48366 + elf_flags |= MAP_FIXED;
48367 + }
48368 +#endif
48369 +
48370 }
48371
48372 error = elf_map(bprm->file, load_bias + vaddr, elf_ppnt,
48373 @@ -847,9 +1266,9 @@ static int load_elf_binary(struct linux_binprm *bprm)
48374 * allowed task size. Note that p_filesz must always be
48375 * <= p_memsz so it is only necessary to check p_memsz.
48376 */
48377 - if (BAD_ADDR(k) || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
48378 - elf_ppnt->p_memsz > TASK_SIZE ||
48379 - TASK_SIZE - elf_ppnt->p_memsz < k) {
48380 + if (k >= pax_task_size || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
48381 + elf_ppnt->p_memsz > pax_task_size ||
48382 + pax_task_size - elf_ppnt->p_memsz < k) {
48383 /* set_brk can never work. Avoid overflows. */
48384 send_sig(SIGKILL, current, 0);
48385 retval = -EINVAL;
48386 @@ -888,17 +1307,45 @@ static int load_elf_binary(struct linux_binprm *bprm)
48387 goto out_free_dentry;
48388 }
48389 if (likely(elf_bss != elf_brk) && unlikely(padzero(elf_bss))) {
48390 - send_sig(SIGSEGV, current, 0);
48391 - retval = -EFAULT; /* Nobody gets to see this, but.. */
48392 - goto out_free_dentry;
48393 + /*
48394 + * This bss-zeroing can fail if the ELF
48395 + * file specifies odd protections. So
48396 + * we don't check the return value
48397 + */
48398 }
48399
48400 +#ifdef CONFIG_PAX_RANDMMAP
48401 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
48402 + unsigned long start, size, flags;
48403 + vm_flags_t vm_flags;
48404 +
48405 + start = ELF_PAGEALIGN(elf_brk);
48406 + size = PAGE_SIZE + ((pax_get_random_long() & ((1UL << 22) - 1UL)) << 4);
48407 + flags = MAP_FIXED | MAP_PRIVATE;
48408 + vm_flags = VM_DONTEXPAND | VM_DONTDUMP;
48409 +
48410 + down_write(&current->mm->mmap_sem);
48411 + start = get_unmapped_area(NULL, start, PAGE_ALIGN(size), 0, flags);
48412 + retval = -ENOMEM;
48413 + if (!IS_ERR_VALUE(start) && !find_vma_intersection(current->mm, start, start + size + PAGE_SIZE)) {
48414 +// if (current->personality & ADDR_NO_RANDOMIZE)
48415 +// vm_flags |= VM_READ | VM_MAYREAD;
48416 + start = mmap_region(NULL, start, PAGE_ALIGN(size), vm_flags, 0);
48417 + retval = IS_ERR_VALUE(start) ? start : 0;
48418 + }
48419 + up_write(&current->mm->mmap_sem);
48420 + if (retval == 0)
48421 + retval = set_brk(start + size, start + size + PAGE_SIZE);
48422 + if (retval < 0) {
48423 + send_sig(SIGKILL, current, 0);
48424 + goto out_free_dentry;
48425 + }
48426 + }
48427 +#endif
48428 +
48429 if (elf_interpreter) {
48430 - unsigned long interp_map_addr = 0;
48431 -
48432 elf_entry = load_elf_interp(&loc->interp_elf_ex,
48433 interpreter,
48434 - &interp_map_addr,
48435 load_bias);
48436 if (!IS_ERR((void *)elf_entry)) {
48437 /*
48438 @@ -1120,7 +1567,7 @@ static bool always_dump_vma(struct vm_area_struct *vma)
48439 * Decide what to dump of a segment, part, all or none.
48440 */
48441 static unsigned long vma_dump_size(struct vm_area_struct *vma,
48442 - unsigned long mm_flags)
48443 + unsigned long mm_flags, long signr)
48444 {
48445 #define FILTER(type) (mm_flags & (1UL << MMF_DUMP_##type))
48446
48447 @@ -1158,7 +1605,7 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,
48448 if (vma->vm_file == NULL)
48449 return 0;
48450
48451 - if (FILTER(MAPPED_PRIVATE))
48452 + if (signr == SIGKILL || FILTER(MAPPED_PRIVATE))
48453 goto whole;
48454
48455 /*
48456 @@ -1383,9 +1830,9 @@ static void fill_auxv_note(struct memelfnote *note, struct mm_struct *mm)
48457 {
48458 elf_addr_t *auxv = (elf_addr_t *) mm->saved_auxv;
48459 int i = 0;
48460 - do
48461 + do {
48462 i += 2;
48463 - while (auxv[i - 2] != AT_NULL);
48464 + } while (auxv[i - 2] != AT_NULL);
48465 fill_note(note, "CORE", NT_AUXV, i * sizeof(elf_addr_t), auxv);
48466 }
48467
48468 @@ -2015,14 +2462,14 @@ static void fill_extnum_info(struct elfhdr *elf, struct elf_shdr *shdr4extnum,
48469 }
48470
48471 static size_t elf_core_vma_data_size(struct vm_area_struct *gate_vma,
48472 - unsigned long mm_flags)
48473 + struct coredump_params *cprm)
48474 {
48475 struct vm_area_struct *vma;
48476 size_t size = 0;
48477
48478 for (vma = first_vma(current, gate_vma); vma != NULL;
48479 vma = next_vma(vma, gate_vma))
48480 - size += vma_dump_size(vma, mm_flags);
48481 + size += vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
48482 return size;
48483 }
48484
48485 @@ -2116,7 +2563,7 @@ static int elf_core_dump(struct coredump_params *cprm)
48486
48487 dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);
48488
48489 - offset += elf_core_vma_data_size(gate_vma, cprm->mm_flags);
48490 + offset += elf_core_vma_data_size(gate_vma, cprm);
48491 offset += elf_core_extra_data_size();
48492 e_shoff = offset;
48493
48494 @@ -2130,10 +2577,12 @@ static int elf_core_dump(struct coredump_params *cprm)
48495 offset = dataoff;
48496
48497 size += sizeof(*elf);
48498 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
48499 if (size > cprm->limit || !dump_write(cprm->file, elf, sizeof(*elf)))
48500 goto end_coredump;
48501
48502 size += sizeof(*phdr4note);
48503 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
48504 if (size > cprm->limit
48505 || !dump_write(cprm->file, phdr4note, sizeof(*phdr4note)))
48506 goto end_coredump;
48507 @@ -2147,7 +2596,7 @@ static int elf_core_dump(struct coredump_params *cprm)
48508 phdr.p_offset = offset;
48509 phdr.p_vaddr = vma->vm_start;
48510 phdr.p_paddr = 0;
48511 - phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags);
48512 + phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
48513 phdr.p_memsz = vma->vm_end - vma->vm_start;
48514 offset += phdr.p_filesz;
48515 phdr.p_flags = vma->vm_flags & VM_READ ? PF_R : 0;
48516 @@ -2158,6 +2607,7 @@ static int elf_core_dump(struct coredump_params *cprm)
48517 phdr.p_align = ELF_EXEC_PAGESIZE;
48518
48519 size += sizeof(phdr);
48520 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
48521 if (size > cprm->limit
48522 || !dump_write(cprm->file, &phdr, sizeof(phdr)))
48523 goto end_coredump;
48524 @@ -2182,7 +2632,7 @@ static int elf_core_dump(struct coredump_params *cprm)
48525 unsigned long addr;
48526 unsigned long end;
48527
48528 - end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags);
48529 + end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
48530
48531 for (addr = vma->vm_start; addr < end; addr += PAGE_SIZE) {
48532 struct page *page;
48533 @@ -2191,6 +2641,7 @@ static int elf_core_dump(struct coredump_params *cprm)
48534 page = get_dump_page(addr);
48535 if (page) {
48536 void *kaddr = kmap(page);
48537 + gr_learn_resource(current, RLIMIT_CORE, size + PAGE_SIZE, 1);
48538 stop = ((size += PAGE_SIZE) > cprm->limit) ||
48539 !dump_write(cprm->file, kaddr,
48540 PAGE_SIZE);
48541 @@ -2208,6 +2659,7 @@ static int elf_core_dump(struct coredump_params *cprm)
48542
48543 if (e_phnum == PN_XNUM) {
48544 size += sizeof(*shdr4extnum);
48545 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
48546 if (size > cprm->limit
48547 || !dump_write(cprm->file, shdr4extnum,
48548 sizeof(*shdr4extnum)))
48549 @@ -2228,6 +2680,97 @@ out:
48550
48551 #endif /* CONFIG_ELF_CORE */
48552
48553 +#ifdef CONFIG_PAX_MPROTECT
48554 +/* PaX: non-PIC ELF libraries need relocations on their executable segments
48555 + * therefore we'll grant them VM_MAYWRITE once during their life. Similarly
48556 + * we'll remove VM_MAYWRITE for good on RELRO segments.
48557 + *
48558 + * The checks favour ld-linux.so behaviour which operates on a per ELF segment
48559 + * basis because we want to allow the common case and not the special ones.
48560 + */
48561 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags)
48562 +{
48563 + struct elfhdr elf_h;
48564 + struct elf_phdr elf_p;
48565 + unsigned long i;
48566 + unsigned long oldflags;
48567 + bool is_textrel_rw, is_textrel_rx, is_relro;
48568 +
48569 + if (!(vma->vm_mm->pax_flags & MF_PAX_MPROTECT))
48570 + return;
48571 +
48572 + oldflags = vma->vm_flags & (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ);
48573 + newflags &= VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ;
48574 +
48575 +#ifdef CONFIG_PAX_ELFRELOCS
48576 + /* possible TEXTREL */
48577 + is_textrel_rw = vma->vm_file && !vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYREAD | VM_EXEC | VM_READ) && newflags == (VM_WRITE | VM_READ);
48578 + is_textrel_rx = vma->vm_file && vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_WRITE | VM_READ) && newflags == (VM_EXEC | VM_READ);
48579 +#else
48580 + is_textrel_rw = false;
48581 + is_textrel_rx = false;
48582 +#endif
48583 +
48584 + /* possible RELRO */
48585 + is_relro = vma->vm_file && vma->anon_vma && oldflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ) && newflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ);
48586 +
48587 + if (!is_textrel_rw && !is_textrel_rx && !is_relro)
48588 + return;
48589 +
48590 + if (sizeof(elf_h) != kernel_read(vma->vm_file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
48591 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
48592 +
48593 +#ifdef CONFIG_PAX_ETEXECRELOCS
48594 + ((is_textrel_rw || is_textrel_rx) && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
48595 +#else
48596 + ((is_textrel_rw || is_textrel_rx) && elf_h.e_type != ET_DYN) ||
48597 +#endif
48598 +
48599 + (is_relro && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
48600 + !elf_check_arch(&elf_h) ||
48601 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
48602 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
48603 + return;
48604 +
48605 + for (i = 0UL; i < elf_h.e_phnum; i++) {
48606 + if (sizeof(elf_p) != kernel_read(vma->vm_file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
48607 + return;
48608 + switch (elf_p.p_type) {
48609 + case PT_DYNAMIC:
48610 + if (!is_textrel_rw && !is_textrel_rx)
48611 + continue;
48612 + i = 0UL;
48613 + while ((i+1) * sizeof(elf_dyn) <= elf_p.p_filesz) {
48614 + elf_dyn dyn;
48615 +
48616 + if (sizeof(dyn) != kernel_read(vma->vm_file, elf_p.p_offset + i*sizeof(dyn), (char *)&dyn, sizeof(dyn)))
48617 + return;
48618 + if (dyn.d_tag == DT_NULL)
48619 + return;
48620 + if (dyn.d_tag == DT_TEXTREL || (dyn.d_tag == DT_FLAGS && (dyn.d_un.d_val & DF_TEXTREL))) {
48621 + gr_log_textrel(vma);
48622 + if (is_textrel_rw)
48623 + vma->vm_flags |= VM_MAYWRITE;
48624 + else
48625 + /* PaX: disallow write access after relocs are done, hopefully noone else needs it... */
48626 + vma->vm_flags &= ~VM_MAYWRITE;
48627 + return;
48628 + }
48629 + i++;
48630 + }
48631 + return;
48632 +
48633 + case PT_GNU_RELRO:
48634 + if (!is_relro)
48635 + continue;
48636 + if ((elf_p.p_offset >> PAGE_SHIFT) == vma->vm_pgoff && ELF_PAGEALIGN(elf_p.p_memsz) == vma->vm_end - vma->vm_start)
48637 + vma->vm_flags &= ~VM_MAYWRITE;
48638 + return;
48639 + }
48640 + }
48641 +}
48642 +#endif
48643 +
48644 static int __init init_elf_binfmt(void)
48645 {
48646 register_binfmt(&elf_format);
48647 diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
48648 index 2036d21..b0430d0 100644
48649 --- a/fs/binfmt_flat.c
48650 +++ b/fs/binfmt_flat.c
48651 @@ -562,7 +562,9 @@ static int load_flat_file(struct linux_binprm * bprm,
48652 realdatastart = (unsigned long) -ENOMEM;
48653 printk("Unable to allocate RAM for process data, errno %d\n",
48654 (int)-realdatastart);
48655 + down_write(&current->mm->mmap_sem);
48656 vm_munmap(textpos, text_len);
48657 + up_write(&current->mm->mmap_sem);
48658 ret = realdatastart;
48659 goto err;
48660 }
48661 @@ -586,8 +588,10 @@ static int load_flat_file(struct linux_binprm * bprm,
48662 }
48663 if (IS_ERR_VALUE(result)) {
48664 printk("Unable to read data+bss, errno %d\n", (int)-result);
48665 + down_write(&current->mm->mmap_sem);
48666 vm_munmap(textpos, text_len);
48667 vm_munmap(realdatastart, len);
48668 + up_write(&current->mm->mmap_sem);
48669 ret = result;
48670 goto err;
48671 }
48672 @@ -654,8 +658,10 @@ static int load_flat_file(struct linux_binprm * bprm,
48673 }
48674 if (IS_ERR_VALUE(result)) {
48675 printk("Unable to read code+data+bss, errno %d\n",(int)-result);
48676 + down_write(&current->mm->mmap_sem);
48677 vm_munmap(textpos, text_len + data_len + extra +
48678 MAX_SHARED_LIBS * sizeof(unsigned long));
48679 + up_write(&current->mm->mmap_sem);
48680 ret = result;
48681 goto err;
48682 }
48683 diff --git a/fs/bio.c b/fs/bio.c
48684 index b96fc6c..431d628 100644
48685 --- a/fs/bio.c
48686 +++ b/fs/bio.c
48687 @@ -818,7 +818,7 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
48688 /*
48689 * Overflow, abort
48690 */
48691 - if (end < start)
48692 + if (end < start || end - start > INT_MAX - nr_pages)
48693 return ERR_PTR(-EINVAL);
48694
48695 nr_pages += end - start;
48696 @@ -952,7 +952,7 @@ static struct bio *__bio_map_user_iov(struct request_queue *q,
48697 /*
48698 * Overflow, abort
48699 */
48700 - if (end < start)
48701 + if (end < start || end - start > INT_MAX - nr_pages)
48702 return ERR_PTR(-EINVAL);
48703
48704 nr_pages += end - start;
48705 @@ -1214,7 +1214,7 @@ static void bio_copy_kern_endio(struct bio *bio, int err)
48706 const int read = bio_data_dir(bio) == READ;
48707 struct bio_map_data *bmd = bio->bi_private;
48708 int i;
48709 - char *p = bmd->sgvecs[0].iov_base;
48710 + char *p = (char __force_kernel *)bmd->sgvecs[0].iov_base;
48711
48712 __bio_for_each_segment(bvec, bio, i, 0) {
48713 char *addr = page_address(bvec->bv_page);
48714 diff --git a/fs/block_dev.c b/fs/block_dev.c
48715 index aae187a..fd790ba 100644
48716 --- a/fs/block_dev.c
48717 +++ b/fs/block_dev.c
48718 @@ -652,7 +652,7 @@ static bool bd_may_claim(struct block_device *bdev, struct block_device *whole,
48719 else if (bdev->bd_contains == bdev)
48720 return true; /* is a whole device which isn't held */
48721
48722 - else if (whole->bd_holder == bd_may_claim)
48723 + else if (whole->bd_holder == (void *)bd_may_claim)
48724 return true; /* is a partition of a device that is being partitioned */
48725 else if (whole->bd_holder != NULL)
48726 return false; /* is a partition of a held device */
48727 diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
48728 index ca9d8f1..8c0142d 100644
48729 --- a/fs/btrfs/ctree.c
48730 +++ b/fs/btrfs/ctree.c
48731 @@ -1036,9 +1036,12 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
48732 free_extent_buffer(buf);
48733 add_root_to_dirty_list(root);
48734 } else {
48735 - if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID)
48736 - parent_start = parent->start;
48737 - else
48738 + if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) {
48739 + if (parent)
48740 + parent_start = parent->start;
48741 + else
48742 + parent_start = 0;
48743 + } else
48744 parent_start = 0;
48745
48746 WARN_ON(trans->transid != btrfs_header_generation(parent));
48747 diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
48748 index f49b62f..07834ab 100644
48749 --- a/fs/btrfs/ioctl.c
48750 +++ b/fs/btrfs/ioctl.c
48751 @@ -3077,9 +3077,12 @@ long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
48752 for (i = 0; i < num_types; i++) {
48753 struct btrfs_space_info *tmp;
48754
48755 + /* Don't copy in more than we allocated */
48756 if (!slot_count)
48757 break;
48758
48759 + slot_count--;
48760 +
48761 info = NULL;
48762 rcu_read_lock();
48763 list_for_each_entry_rcu(tmp, &root->fs_info->space_info,
48764 @@ -3101,10 +3104,7 @@ long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
48765 memcpy(dest, &space, sizeof(space));
48766 dest++;
48767 space_args.total_spaces++;
48768 - slot_count--;
48769 }
48770 - if (!slot_count)
48771 - break;
48772 }
48773 up_read(&info->groups_sem);
48774 }
48775 diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
48776 index f6b8859..54fe8c5 100644
48777 --- a/fs/btrfs/super.c
48778 +++ b/fs/btrfs/super.c
48779 @@ -266,7 +266,7 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
48780 function, line, errstr);
48781 return;
48782 }
48783 - ACCESS_ONCE(trans->transaction->aborted) = errno;
48784 + ACCESS_ONCE_RW(trans->transaction->aborted) = errno;
48785 __btrfs_std_error(root->fs_info, function, line, errno, NULL);
48786 }
48787 /*
48788 diff --git a/fs/cachefiles/bind.c b/fs/cachefiles/bind.c
48789 index 622f469..e8d2d55 100644
48790 --- a/fs/cachefiles/bind.c
48791 +++ b/fs/cachefiles/bind.c
48792 @@ -39,13 +39,11 @@ int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args)
48793 args);
48794
48795 /* start by checking things over */
48796 - ASSERT(cache->fstop_percent >= 0 &&
48797 - cache->fstop_percent < cache->fcull_percent &&
48798 + ASSERT(cache->fstop_percent < cache->fcull_percent &&
48799 cache->fcull_percent < cache->frun_percent &&
48800 cache->frun_percent < 100);
48801
48802 - ASSERT(cache->bstop_percent >= 0 &&
48803 - cache->bstop_percent < cache->bcull_percent &&
48804 + ASSERT(cache->bstop_percent < cache->bcull_percent &&
48805 cache->bcull_percent < cache->brun_percent &&
48806 cache->brun_percent < 100);
48807
48808 diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
48809 index 0a1467b..6a53245 100644
48810 --- a/fs/cachefiles/daemon.c
48811 +++ b/fs/cachefiles/daemon.c
48812 @@ -196,7 +196,7 @@ static ssize_t cachefiles_daemon_read(struct file *file, char __user *_buffer,
48813 if (n > buflen)
48814 return -EMSGSIZE;
48815
48816 - if (copy_to_user(_buffer, buffer, n) != 0)
48817 + if (n > sizeof(buffer) || copy_to_user(_buffer, buffer, n) != 0)
48818 return -EFAULT;
48819
48820 return n;
48821 @@ -222,7 +222,7 @@ static ssize_t cachefiles_daemon_write(struct file *file,
48822 if (test_bit(CACHEFILES_DEAD, &cache->flags))
48823 return -EIO;
48824
48825 - if (datalen < 0 || datalen > PAGE_SIZE - 1)
48826 + if (datalen > PAGE_SIZE - 1)
48827 return -EOPNOTSUPP;
48828
48829 /* drag the command string into the kernel so we can parse it */
48830 @@ -386,7 +386,7 @@ static int cachefiles_daemon_fstop(struct cachefiles_cache *cache, char *args)
48831 if (args[0] != '%' || args[1] != '\0')
48832 return -EINVAL;
48833
48834 - if (fstop < 0 || fstop >= cache->fcull_percent)
48835 + if (fstop >= cache->fcull_percent)
48836 return cachefiles_daemon_range_error(cache, args);
48837
48838 cache->fstop_percent = fstop;
48839 @@ -458,7 +458,7 @@ static int cachefiles_daemon_bstop(struct cachefiles_cache *cache, char *args)
48840 if (args[0] != '%' || args[1] != '\0')
48841 return -EINVAL;
48842
48843 - if (bstop < 0 || bstop >= cache->bcull_percent)
48844 + if (bstop >= cache->bcull_percent)
48845 return cachefiles_daemon_range_error(cache, args);
48846
48847 cache->bstop_percent = bstop;
48848 diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h
48849 index 4938251..7e01445 100644
48850 --- a/fs/cachefiles/internal.h
48851 +++ b/fs/cachefiles/internal.h
48852 @@ -59,7 +59,7 @@ struct cachefiles_cache {
48853 wait_queue_head_t daemon_pollwq; /* poll waitqueue for daemon */
48854 struct rb_root active_nodes; /* active nodes (can't be culled) */
48855 rwlock_t active_lock; /* lock for active_nodes */
48856 - atomic_t gravecounter; /* graveyard uniquifier */
48857 + atomic_unchecked_t gravecounter; /* graveyard uniquifier */
48858 unsigned frun_percent; /* when to stop culling (% files) */
48859 unsigned fcull_percent; /* when to start culling (% files) */
48860 unsigned fstop_percent; /* when to stop allocating (% files) */
48861 @@ -171,19 +171,19 @@ extern int cachefiles_check_in_use(struct cachefiles_cache *cache,
48862 * proc.c
48863 */
48864 #ifdef CONFIG_CACHEFILES_HISTOGRAM
48865 -extern atomic_t cachefiles_lookup_histogram[HZ];
48866 -extern atomic_t cachefiles_mkdir_histogram[HZ];
48867 -extern atomic_t cachefiles_create_histogram[HZ];
48868 +extern atomic_unchecked_t cachefiles_lookup_histogram[HZ];
48869 +extern atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
48870 +extern atomic_unchecked_t cachefiles_create_histogram[HZ];
48871
48872 extern int __init cachefiles_proc_init(void);
48873 extern void cachefiles_proc_cleanup(void);
48874 static inline
48875 -void cachefiles_hist(atomic_t histogram[], unsigned long start_jif)
48876 +void cachefiles_hist(atomic_unchecked_t histogram[], unsigned long start_jif)
48877 {
48878 unsigned long jif = jiffies - start_jif;
48879 if (jif >= HZ)
48880 jif = HZ - 1;
48881 - atomic_inc(&histogram[jif]);
48882 + atomic_inc_unchecked(&histogram[jif]);
48883 }
48884
48885 #else
48886 diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
48887 index 8c01c5fc..15f982e 100644
48888 --- a/fs/cachefiles/namei.c
48889 +++ b/fs/cachefiles/namei.c
48890 @@ -317,7 +317,7 @@ try_again:
48891 /* first step is to make up a grave dentry in the graveyard */
48892 sprintf(nbuffer, "%08x%08x",
48893 (uint32_t) get_seconds(),
48894 - (uint32_t) atomic_inc_return(&cache->gravecounter));
48895 + (uint32_t) atomic_inc_return_unchecked(&cache->gravecounter));
48896
48897 /* do the multiway lock magic */
48898 trap = lock_rename(cache->graveyard, dir);
48899 diff --git a/fs/cachefiles/proc.c b/fs/cachefiles/proc.c
48900 index eccd339..4c1d995 100644
48901 --- a/fs/cachefiles/proc.c
48902 +++ b/fs/cachefiles/proc.c
48903 @@ -14,9 +14,9 @@
48904 #include <linux/seq_file.h>
48905 #include "internal.h"
48906
48907 -atomic_t cachefiles_lookup_histogram[HZ];
48908 -atomic_t cachefiles_mkdir_histogram[HZ];
48909 -atomic_t cachefiles_create_histogram[HZ];
48910 +atomic_unchecked_t cachefiles_lookup_histogram[HZ];
48911 +atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
48912 +atomic_unchecked_t cachefiles_create_histogram[HZ];
48913
48914 /*
48915 * display the latency histogram
48916 @@ -35,9 +35,9 @@ static int cachefiles_histogram_show(struct seq_file *m, void *v)
48917 return 0;
48918 default:
48919 index = (unsigned long) v - 3;
48920 - x = atomic_read(&cachefiles_lookup_histogram[index]);
48921 - y = atomic_read(&cachefiles_mkdir_histogram[index]);
48922 - z = atomic_read(&cachefiles_create_histogram[index]);
48923 + x = atomic_read_unchecked(&cachefiles_lookup_histogram[index]);
48924 + y = atomic_read_unchecked(&cachefiles_mkdir_histogram[index]);
48925 + z = atomic_read_unchecked(&cachefiles_create_histogram[index]);
48926 if (x == 0 && y == 0 && z == 0)
48927 return 0;
48928
48929 diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c
48930 index 4809922..aab2c39 100644
48931 --- a/fs/cachefiles/rdwr.c
48932 +++ b/fs/cachefiles/rdwr.c
48933 @@ -965,7 +965,7 @@ int cachefiles_write_page(struct fscache_storage *op, struct page *page)
48934 old_fs = get_fs();
48935 set_fs(KERNEL_DS);
48936 ret = file->f_op->write(
48937 - file, (const void __user *) data, len, &pos);
48938 + file, (const void __force_user *) data, len, &pos);
48939 set_fs(old_fs);
48940 kunmap(page);
48941 if (ret != len)
48942 diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
48943 index 6d797f4..0ace2e5 100644
48944 --- a/fs/ceph/dir.c
48945 +++ b/fs/ceph/dir.c
48946 @@ -243,7 +243,7 @@ static int ceph_readdir(struct file *filp, void *dirent, filldir_t filldir)
48947 struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
48948 struct ceph_mds_client *mdsc = fsc->mdsc;
48949 unsigned frag = fpos_frag(filp->f_pos);
48950 - int off = fpos_off(filp->f_pos);
48951 + unsigned int off = fpos_off(filp->f_pos);
48952 int err;
48953 u32 ftype;
48954 struct ceph_mds_reply_info_parsed *rinfo;
48955 diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
48956 index d9ea6ed..1e6c8ac 100644
48957 --- a/fs/cifs/cifs_debug.c
48958 +++ b/fs/cifs/cifs_debug.c
48959 @@ -267,8 +267,8 @@ static ssize_t cifs_stats_proc_write(struct file *file,
48960
48961 if (c == '1' || c == 'y' || c == 'Y' || c == '0') {
48962 #ifdef CONFIG_CIFS_STATS2
48963 - atomic_set(&totBufAllocCount, 0);
48964 - atomic_set(&totSmBufAllocCount, 0);
48965 + atomic_set_unchecked(&totBufAllocCount, 0);
48966 + atomic_set_unchecked(&totSmBufAllocCount, 0);
48967 #endif /* CONFIG_CIFS_STATS2 */
48968 spin_lock(&cifs_tcp_ses_lock);
48969 list_for_each(tmp1, &cifs_tcp_ses_list) {
48970 @@ -281,7 +281,7 @@ static ssize_t cifs_stats_proc_write(struct file *file,
48971 tcon = list_entry(tmp3,
48972 struct cifs_tcon,
48973 tcon_list);
48974 - atomic_set(&tcon->num_smbs_sent, 0);
48975 + atomic_set_unchecked(&tcon->num_smbs_sent, 0);
48976 if (server->ops->clear_stats)
48977 server->ops->clear_stats(tcon);
48978 }
48979 @@ -313,8 +313,8 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
48980 smBufAllocCount.counter, cifs_min_small);
48981 #ifdef CONFIG_CIFS_STATS2
48982 seq_printf(m, "Total Large %d Small %d Allocations\n",
48983 - atomic_read(&totBufAllocCount),
48984 - atomic_read(&totSmBufAllocCount));
48985 + atomic_read_unchecked(&totBufAllocCount),
48986 + atomic_read_unchecked(&totSmBufAllocCount));
48987 #endif /* CONFIG_CIFS_STATS2 */
48988
48989 seq_printf(m, "Operations (MIDs): %d\n", atomic_read(&midCount));
48990 @@ -343,7 +343,7 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
48991 if (tcon->need_reconnect)
48992 seq_puts(m, "\tDISCONNECTED ");
48993 seq_printf(m, "\nSMBs: %d",
48994 - atomic_read(&tcon->num_smbs_sent));
48995 + atomic_read_unchecked(&tcon->num_smbs_sent));
48996 if (server->ops->print_stats)
48997 server->ops->print_stats(m, tcon);
48998 }
48999 diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
49000 index 345fc89..b2acae5 100644
49001 --- a/fs/cifs/cifsfs.c
49002 +++ b/fs/cifs/cifsfs.c
49003 @@ -1033,7 +1033,7 @@ cifs_init_request_bufs(void)
49004 /* cERROR(1, "CIFSMaxBufSize %d 0x%x",CIFSMaxBufSize,CIFSMaxBufSize); */
49005 cifs_req_cachep = kmem_cache_create("cifs_request",
49006 CIFSMaxBufSize + max_hdr_size, 0,
49007 - SLAB_HWCACHE_ALIGN, NULL);
49008 + SLAB_HWCACHE_ALIGN | SLAB_USERCOPY, NULL);
49009 if (cifs_req_cachep == NULL)
49010 return -ENOMEM;
49011
49012 @@ -1060,7 +1060,7 @@ cifs_init_request_bufs(void)
49013 efficient to alloc 1 per page off the slab compared to 17K (5page)
49014 alloc of large cifs buffers even when page debugging is on */
49015 cifs_sm_req_cachep = kmem_cache_create("cifs_small_rq",
49016 - MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN,
49017 + MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN | SLAB_USERCOPY,
49018 NULL);
49019 if (cifs_sm_req_cachep == NULL) {
49020 mempool_destroy(cifs_req_poolp);
49021 @@ -1145,8 +1145,8 @@ init_cifs(void)
49022 atomic_set(&bufAllocCount, 0);
49023 atomic_set(&smBufAllocCount, 0);
49024 #ifdef CONFIG_CIFS_STATS2
49025 - atomic_set(&totBufAllocCount, 0);
49026 - atomic_set(&totSmBufAllocCount, 0);
49027 + atomic_set_unchecked(&totBufAllocCount, 0);
49028 + atomic_set_unchecked(&totSmBufAllocCount, 0);
49029 #endif /* CONFIG_CIFS_STATS2 */
49030
49031 atomic_set(&midCount, 0);
49032 diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
49033 index 4f07f6f..55de8ce 100644
49034 --- a/fs/cifs/cifsglob.h
49035 +++ b/fs/cifs/cifsglob.h
49036 @@ -751,35 +751,35 @@ struct cifs_tcon {
49037 __u16 Flags; /* optional support bits */
49038 enum statusEnum tidStatus;
49039 #ifdef CONFIG_CIFS_STATS
49040 - atomic_t num_smbs_sent;
49041 + atomic_unchecked_t num_smbs_sent;
49042 union {
49043 struct {
49044 - atomic_t num_writes;
49045 - atomic_t num_reads;
49046 - atomic_t num_flushes;
49047 - atomic_t num_oplock_brks;
49048 - atomic_t num_opens;
49049 - atomic_t num_closes;
49050 - atomic_t num_deletes;
49051 - atomic_t num_mkdirs;
49052 - atomic_t num_posixopens;
49053 - atomic_t num_posixmkdirs;
49054 - atomic_t num_rmdirs;
49055 - atomic_t num_renames;
49056 - atomic_t num_t2renames;
49057 - atomic_t num_ffirst;
49058 - atomic_t num_fnext;
49059 - atomic_t num_fclose;
49060 - atomic_t num_hardlinks;
49061 - atomic_t num_symlinks;
49062 - atomic_t num_locks;
49063 - atomic_t num_acl_get;
49064 - atomic_t num_acl_set;
49065 + atomic_unchecked_t num_writes;
49066 + atomic_unchecked_t num_reads;
49067 + atomic_unchecked_t num_flushes;
49068 + atomic_unchecked_t num_oplock_brks;
49069 + atomic_unchecked_t num_opens;
49070 + atomic_unchecked_t num_closes;
49071 + atomic_unchecked_t num_deletes;
49072 + atomic_unchecked_t num_mkdirs;
49073 + atomic_unchecked_t num_posixopens;
49074 + atomic_unchecked_t num_posixmkdirs;
49075 + atomic_unchecked_t num_rmdirs;
49076 + atomic_unchecked_t num_renames;
49077 + atomic_unchecked_t num_t2renames;
49078 + atomic_unchecked_t num_ffirst;
49079 + atomic_unchecked_t num_fnext;
49080 + atomic_unchecked_t num_fclose;
49081 + atomic_unchecked_t num_hardlinks;
49082 + atomic_unchecked_t num_symlinks;
49083 + atomic_unchecked_t num_locks;
49084 + atomic_unchecked_t num_acl_get;
49085 + atomic_unchecked_t num_acl_set;
49086 } cifs_stats;
49087 #ifdef CONFIG_CIFS_SMB2
49088 struct {
49089 - atomic_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
49090 - atomic_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
49091 + atomic_unchecked_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
49092 + atomic_unchecked_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
49093 } smb2_stats;
49094 #endif /* CONFIG_CIFS_SMB2 */
49095 } stats;
49096 @@ -1080,7 +1080,7 @@ convert_delimiter(char *path, char delim)
49097 }
49098
49099 #ifdef CONFIG_CIFS_STATS
49100 -#define cifs_stats_inc atomic_inc
49101 +#define cifs_stats_inc atomic_inc_unchecked
49102
49103 static inline void cifs_stats_bytes_written(struct cifs_tcon *tcon,
49104 unsigned int bytes)
49105 @@ -1445,8 +1445,8 @@ GLOBAL_EXTERN atomic_t tconInfoReconnectCount;
49106 /* Various Debug counters */
49107 GLOBAL_EXTERN atomic_t bufAllocCount; /* current number allocated */
49108 #ifdef CONFIG_CIFS_STATS2
49109 -GLOBAL_EXTERN atomic_t totBufAllocCount; /* total allocated over all time */
49110 -GLOBAL_EXTERN atomic_t totSmBufAllocCount;
49111 +GLOBAL_EXTERN atomic_unchecked_t totBufAllocCount; /* total allocated over all time */
49112 +GLOBAL_EXTERN atomic_unchecked_t totSmBufAllocCount;
49113 #endif
49114 GLOBAL_EXTERN atomic_t smBufAllocCount;
49115 GLOBAL_EXTERN atomic_t midCount;
49116 diff --git a/fs/cifs/link.c b/fs/cifs/link.c
49117 index 9f6c4c4..8de307a 100644
49118 --- a/fs/cifs/link.c
49119 +++ b/fs/cifs/link.c
49120 @@ -616,7 +616,7 @@ symlink_exit:
49121
49122 void cifs_put_link(struct dentry *direntry, struct nameidata *nd, void *cookie)
49123 {
49124 - char *p = nd_get_link(nd);
49125 + const char *p = nd_get_link(nd);
49126 if (!IS_ERR(p))
49127 kfree(p);
49128 }
49129 diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
49130 index 1b15bf8..1ce489e 100644
49131 --- a/fs/cifs/misc.c
49132 +++ b/fs/cifs/misc.c
49133 @@ -169,7 +169,7 @@ cifs_buf_get(void)
49134 memset(ret_buf, 0, buf_size + 3);
49135 atomic_inc(&bufAllocCount);
49136 #ifdef CONFIG_CIFS_STATS2
49137 - atomic_inc(&totBufAllocCount);
49138 + atomic_inc_unchecked(&totBufAllocCount);
49139 #endif /* CONFIG_CIFS_STATS2 */
49140 }
49141
49142 @@ -204,7 +204,7 @@ cifs_small_buf_get(void)
49143 /* memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/
49144 atomic_inc(&smBufAllocCount);
49145 #ifdef CONFIG_CIFS_STATS2
49146 - atomic_inc(&totSmBufAllocCount);
49147 + atomic_inc_unchecked(&totSmBufAllocCount);
49148 #endif /* CONFIG_CIFS_STATS2 */
49149
49150 }
49151 diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
49152 index 47bc5a8..10decbe 100644
49153 --- a/fs/cifs/smb1ops.c
49154 +++ b/fs/cifs/smb1ops.c
49155 @@ -586,27 +586,27 @@ static void
49156 cifs_clear_stats(struct cifs_tcon *tcon)
49157 {
49158 #ifdef CONFIG_CIFS_STATS
49159 - atomic_set(&tcon->stats.cifs_stats.num_writes, 0);
49160 - atomic_set(&tcon->stats.cifs_stats.num_reads, 0);
49161 - atomic_set(&tcon->stats.cifs_stats.num_flushes, 0);
49162 - atomic_set(&tcon->stats.cifs_stats.num_oplock_brks, 0);
49163 - atomic_set(&tcon->stats.cifs_stats.num_opens, 0);
49164 - atomic_set(&tcon->stats.cifs_stats.num_posixopens, 0);
49165 - atomic_set(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
49166 - atomic_set(&tcon->stats.cifs_stats.num_closes, 0);
49167 - atomic_set(&tcon->stats.cifs_stats.num_deletes, 0);
49168 - atomic_set(&tcon->stats.cifs_stats.num_mkdirs, 0);
49169 - atomic_set(&tcon->stats.cifs_stats.num_rmdirs, 0);
49170 - atomic_set(&tcon->stats.cifs_stats.num_renames, 0);
49171 - atomic_set(&tcon->stats.cifs_stats.num_t2renames, 0);
49172 - atomic_set(&tcon->stats.cifs_stats.num_ffirst, 0);
49173 - atomic_set(&tcon->stats.cifs_stats.num_fnext, 0);
49174 - atomic_set(&tcon->stats.cifs_stats.num_fclose, 0);
49175 - atomic_set(&tcon->stats.cifs_stats.num_hardlinks, 0);
49176 - atomic_set(&tcon->stats.cifs_stats.num_symlinks, 0);
49177 - atomic_set(&tcon->stats.cifs_stats.num_locks, 0);
49178 - atomic_set(&tcon->stats.cifs_stats.num_acl_get, 0);
49179 - atomic_set(&tcon->stats.cifs_stats.num_acl_set, 0);
49180 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_writes, 0);
49181 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_reads, 0);
49182 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_flushes, 0);
49183 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_oplock_brks, 0);
49184 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_opens, 0);
49185 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixopens, 0);
49186 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
49187 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_closes, 0);
49188 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_deletes, 0);
49189 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_mkdirs, 0);
49190 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_rmdirs, 0);
49191 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_renames, 0);
49192 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_t2renames, 0);
49193 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_ffirst, 0);
49194 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fnext, 0);
49195 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fclose, 0);
49196 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_hardlinks, 0);
49197 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_symlinks, 0);
49198 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_locks, 0);
49199 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_get, 0);
49200 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_set, 0);
49201 #endif
49202 }
49203
49204 @@ -615,36 +615,36 @@ cifs_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
49205 {
49206 #ifdef CONFIG_CIFS_STATS
49207 seq_printf(m, " Oplocks breaks: %d",
49208 - atomic_read(&tcon->stats.cifs_stats.num_oplock_brks));
49209 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_oplock_brks));
49210 seq_printf(m, "\nReads: %d Bytes: %llu",
49211 - atomic_read(&tcon->stats.cifs_stats.num_reads),
49212 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_reads),
49213 (long long)(tcon->bytes_read));
49214 seq_printf(m, "\nWrites: %d Bytes: %llu",
49215 - atomic_read(&tcon->stats.cifs_stats.num_writes),
49216 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_writes),
49217 (long long)(tcon->bytes_written));
49218 seq_printf(m, "\nFlushes: %d",
49219 - atomic_read(&tcon->stats.cifs_stats.num_flushes));
49220 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_flushes));
49221 seq_printf(m, "\nLocks: %d HardLinks: %d Symlinks: %d",
49222 - atomic_read(&tcon->stats.cifs_stats.num_locks),
49223 - atomic_read(&tcon->stats.cifs_stats.num_hardlinks),
49224 - atomic_read(&tcon->stats.cifs_stats.num_symlinks));
49225 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_locks),
49226 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_hardlinks),
49227 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_symlinks));
49228 seq_printf(m, "\nOpens: %d Closes: %d Deletes: %d",
49229 - atomic_read(&tcon->stats.cifs_stats.num_opens),
49230 - atomic_read(&tcon->stats.cifs_stats.num_closes),
49231 - atomic_read(&tcon->stats.cifs_stats.num_deletes));
49232 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_opens),
49233 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_closes),
49234 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_deletes));
49235 seq_printf(m, "\nPosix Opens: %d Posix Mkdirs: %d",
49236 - atomic_read(&tcon->stats.cifs_stats.num_posixopens),
49237 - atomic_read(&tcon->stats.cifs_stats.num_posixmkdirs));
49238 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixopens),
49239 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs));
49240 seq_printf(m, "\nMkdirs: %d Rmdirs: %d",
49241 - atomic_read(&tcon->stats.cifs_stats.num_mkdirs),
49242 - atomic_read(&tcon->stats.cifs_stats.num_rmdirs));
49243 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_mkdirs),
49244 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_rmdirs));
49245 seq_printf(m, "\nRenames: %d T2 Renames %d",
49246 - atomic_read(&tcon->stats.cifs_stats.num_renames),
49247 - atomic_read(&tcon->stats.cifs_stats.num_t2renames));
49248 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_renames),
49249 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_t2renames));
49250 seq_printf(m, "\nFindFirst: %d FNext %d FClose %d",
49251 - atomic_read(&tcon->stats.cifs_stats.num_ffirst),
49252 - atomic_read(&tcon->stats.cifs_stats.num_fnext),
49253 - atomic_read(&tcon->stats.cifs_stats.num_fclose));
49254 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_ffirst),
49255 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fnext),
49256 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fclose));
49257 #endif
49258 }
49259
49260 diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
49261 index bceffe7..cd1ae59 100644
49262 --- a/fs/cifs/smb2ops.c
49263 +++ b/fs/cifs/smb2ops.c
49264 @@ -274,8 +274,8 @@ smb2_clear_stats(struct cifs_tcon *tcon)
49265 #ifdef CONFIG_CIFS_STATS
49266 int i;
49267 for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) {
49268 - atomic_set(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
49269 - atomic_set(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
49270 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
49271 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
49272 }
49273 #endif
49274 }
49275 @@ -284,66 +284,66 @@ static void
49276 smb2_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
49277 {
49278 #ifdef CONFIG_CIFS_STATS
49279 - atomic_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
49280 - atomic_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
49281 + atomic_unchecked_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
49282 + atomic_unchecked_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
49283 seq_printf(m, "\nNegotiates: %d sent %d failed",
49284 - atomic_read(&sent[SMB2_NEGOTIATE_HE]),
49285 - atomic_read(&failed[SMB2_NEGOTIATE_HE]));
49286 + atomic_read_unchecked(&sent[SMB2_NEGOTIATE_HE]),
49287 + atomic_read_unchecked(&failed[SMB2_NEGOTIATE_HE]));
49288 seq_printf(m, "\nSessionSetups: %d sent %d failed",
49289 - atomic_read(&sent[SMB2_SESSION_SETUP_HE]),
49290 - atomic_read(&failed[SMB2_SESSION_SETUP_HE]));
49291 + atomic_read_unchecked(&sent[SMB2_SESSION_SETUP_HE]),
49292 + atomic_read_unchecked(&failed[SMB2_SESSION_SETUP_HE]));
49293 #define SMB2LOGOFF 0x0002 /* trivial request/resp */
49294 seq_printf(m, "\nLogoffs: %d sent %d failed",
49295 - atomic_read(&sent[SMB2_LOGOFF_HE]),
49296 - atomic_read(&failed[SMB2_LOGOFF_HE]));
49297 + atomic_read_unchecked(&sent[SMB2_LOGOFF_HE]),
49298 + atomic_read_unchecked(&failed[SMB2_LOGOFF_HE]));
49299 seq_printf(m, "\nTreeConnects: %d sent %d failed",
49300 - atomic_read(&sent[SMB2_TREE_CONNECT_HE]),
49301 - atomic_read(&failed[SMB2_TREE_CONNECT_HE]));
49302 + atomic_read_unchecked(&sent[SMB2_TREE_CONNECT_HE]),
49303 + atomic_read_unchecked(&failed[SMB2_TREE_CONNECT_HE]));
49304 seq_printf(m, "\nTreeDisconnects: %d sent %d failed",
49305 - atomic_read(&sent[SMB2_TREE_DISCONNECT_HE]),
49306 - atomic_read(&failed[SMB2_TREE_DISCONNECT_HE]));
49307 + atomic_read_unchecked(&sent[SMB2_TREE_DISCONNECT_HE]),
49308 + atomic_read_unchecked(&failed[SMB2_TREE_DISCONNECT_HE]));
49309 seq_printf(m, "\nCreates: %d sent %d failed",
49310 - atomic_read(&sent[SMB2_CREATE_HE]),
49311 - atomic_read(&failed[SMB2_CREATE_HE]));
49312 + atomic_read_unchecked(&sent[SMB2_CREATE_HE]),
49313 + atomic_read_unchecked(&failed[SMB2_CREATE_HE]));
49314 seq_printf(m, "\nCloses: %d sent %d failed",
49315 - atomic_read(&sent[SMB2_CLOSE_HE]),
49316 - atomic_read(&failed[SMB2_CLOSE_HE]));
49317 + atomic_read_unchecked(&sent[SMB2_CLOSE_HE]),
49318 + atomic_read_unchecked(&failed[SMB2_CLOSE_HE]));
49319 seq_printf(m, "\nFlushes: %d sent %d failed",
49320 - atomic_read(&sent[SMB2_FLUSH_HE]),
49321 - atomic_read(&failed[SMB2_FLUSH_HE]));
49322 + atomic_read_unchecked(&sent[SMB2_FLUSH_HE]),
49323 + atomic_read_unchecked(&failed[SMB2_FLUSH_HE]));
49324 seq_printf(m, "\nReads: %d sent %d failed",
49325 - atomic_read(&sent[SMB2_READ_HE]),
49326 - atomic_read(&failed[SMB2_READ_HE]));
49327 + atomic_read_unchecked(&sent[SMB2_READ_HE]),
49328 + atomic_read_unchecked(&failed[SMB2_READ_HE]));
49329 seq_printf(m, "\nWrites: %d sent %d failed",
49330 - atomic_read(&sent[SMB2_WRITE_HE]),
49331 - atomic_read(&failed[SMB2_WRITE_HE]));
49332 + atomic_read_unchecked(&sent[SMB2_WRITE_HE]),
49333 + atomic_read_unchecked(&failed[SMB2_WRITE_HE]));
49334 seq_printf(m, "\nLocks: %d sent %d failed",
49335 - atomic_read(&sent[SMB2_LOCK_HE]),
49336 - atomic_read(&failed[SMB2_LOCK_HE]));
49337 + atomic_read_unchecked(&sent[SMB2_LOCK_HE]),
49338 + atomic_read_unchecked(&failed[SMB2_LOCK_HE]));
49339 seq_printf(m, "\nIOCTLs: %d sent %d failed",
49340 - atomic_read(&sent[SMB2_IOCTL_HE]),
49341 - atomic_read(&failed[SMB2_IOCTL_HE]));
49342 + atomic_read_unchecked(&sent[SMB2_IOCTL_HE]),
49343 + atomic_read_unchecked(&failed[SMB2_IOCTL_HE]));
49344 seq_printf(m, "\nCancels: %d sent %d failed",
49345 - atomic_read(&sent[SMB2_CANCEL_HE]),
49346 - atomic_read(&failed[SMB2_CANCEL_HE]));
49347 + atomic_read_unchecked(&sent[SMB2_CANCEL_HE]),
49348 + atomic_read_unchecked(&failed[SMB2_CANCEL_HE]));
49349 seq_printf(m, "\nEchos: %d sent %d failed",
49350 - atomic_read(&sent[SMB2_ECHO_HE]),
49351 - atomic_read(&failed[SMB2_ECHO_HE]));
49352 + atomic_read_unchecked(&sent[SMB2_ECHO_HE]),
49353 + atomic_read_unchecked(&failed[SMB2_ECHO_HE]));
49354 seq_printf(m, "\nQueryDirectories: %d sent %d failed",
49355 - atomic_read(&sent[SMB2_QUERY_DIRECTORY_HE]),
49356 - atomic_read(&failed[SMB2_QUERY_DIRECTORY_HE]));
49357 + atomic_read_unchecked(&sent[SMB2_QUERY_DIRECTORY_HE]),
49358 + atomic_read_unchecked(&failed[SMB2_QUERY_DIRECTORY_HE]));
49359 seq_printf(m, "\nChangeNotifies: %d sent %d failed",
49360 - atomic_read(&sent[SMB2_CHANGE_NOTIFY_HE]),
49361 - atomic_read(&failed[SMB2_CHANGE_NOTIFY_HE]));
49362 + atomic_read_unchecked(&sent[SMB2_CHANGE_NOTIFY_HE]),
49363 + atomic_read_unchecked(&failed[SMB2_CHANGE_NOTIFY_HE]));
49364 seq_printf(m, "\nQueryInfos: %d sent %d failed",
49365 - atomic_read(&sent[SMB2_QUERY_INFO_HE]),
49366 - atomic_read(&failed[SMB2_QUERY_INFO_HE]));
49367 + atomic_read_unchecked(&sent[SMB2_QUERY_INFO_HE]),
49368 + atomic_read_unchecked(&failed[SMB2_QUERY_INFO_HE]));
49369 seq_printf(m, "\nSetInfos: %d sent %d failed",
49370 - atomic_read(&sent[SMB2_SET_INFO_HE]),
49371 - atomic_read(&failed[SMB2_SET_INFO_HE]));
49372 + atomic_read_unchecked(&sent[SMB2_SET_INFO_HE]),
49373 + atomic_read_unchecked(&failed[SMB2_SET_INFO_HE]));
49374 seq_printf(m, "\nOplockBreaks: %d sent %d failed",
49375 - atomic_read(&sent[SMB2_OPLOCK_BREAK_HE]),
49376 - atomic_read(&failed[SMB2_OPLOCK_BREAK_HE]));
49377 + atomic_read_unchecked(&sent[SMB2_OPLOCK_BREAK_HE]),
49378 + atomic_read_unchecked(&failed[SMB2_OPLOCK_BREAK_HE]));
49379 #endif
49380 }
49381
49382 diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
49383 index 41d9d07..dbb4772 100644
49384 --- a/fs/cifs/smb2pdu.c
49385 +++ b/fs/cifs/smb2pdu.c
49386 @@ -1761,8 +1761,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
49387 default:
49388 cERROR(1, "info level %u isn't supported",
49389 srch_inf->info_level);
49390 - rc = -EINVAL;
49391 - goto qdir_exit;
49392 + return -EINVAL;
49393 }
49394
49395 req->FileIndex = cpu_to_le32(index);
49396 diff --git a/fs/coda/cache.c b/fs/coda/cache.c
49397 index 1da168c..8bc7ff6 100644
49398 --- a/fs/coda/cache.c
49399 +++ b/fs/coda/cache.c
49400 @@ -24,7 +24,7 @@
49401 #include "coda_linux.h"
49402 #include "coda_cache.h"
49403
49404 -static atomic_t permission_epoch = ATOMIC_INIT(0);
49405 +static atomic_unchecked_t permission_epoch = ATOMIC_INIT(0);
49406
49407 /* replace or extend an acl cache hit */
49408 void coda_cache_enter(struct inode *inode, int mask)
49409 @@ -32,7 +32,7 @@ void coda_cache_enter(struct inode *inode, int mask)
49410 struct coda_inode_info *cii = ITOC(inode);
49411
49412 spin_lock(&cii->c_lock);
49413 - cii->c_cached_epoch = atomic_read(&permission_epoch);
49414 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch);
49415 if (!uid_eq(cii->c_uid, current_fsuid())) {
49416 cii->c_uid = current_fsuid();
49417 cii->c_cached_perm = mask;
49418 @@ -46,14 +46,14 @@ void coda_cache_clear_inode(struct inode *inode)
49419 {
49420 struct coda_inode_info *cii = ITOC(inode);
49421 spin_lock(&cii->c_lock);
49422 - cii->c_cached_epoch = atomic_read(&permission_epoch) - 1;
49423 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch) - 1;
49424 spin_unlock(&cii->c_lock);
49425 }
49426
49427 /* remove all acl caches */
49428 void coda_cache_clear_all(struct super_block *sb)
49429 {
49430 - atomic_inc(&permission_epoch);
49431 + atomic_inc_unchecked(&permission_epoch);
49432 }
49433
49434
49435 @@ -66,7 +66,7 @@ int coda_cache_check(struct inode *inode, int mask)
49436 spin_lock(&cii->c_lock);
49437 hit = (mask & cii->c_cached_perm) == mask &&
49438 uid_eq(cii->c_uid, current_fsuid()) &&
49439 - cii->c_cached_epoch == atomic_read(&permission_epoch);
49440 + cii->c_cached_epoch == atomic_read_unchecked(&permission_epoch);
49441 spin_unlock(&cii->c_lock);
49442
49443 return hit;
49444 diff --git a/fs/compat.c b/fs/compat.c
49445 index d487985..c9e04b1 100644
49446 --- a/fs/compat.c
49447 +++ b/fs/compat.c
49448 @@ -54,7 +54,7 @@
49449 #include <asm/ioctls.h>
49450 #include "internal.h"
49451
49452 -int compat_log = 1;
49453 +int compat_log = 0;
49454
49455 int compat_printk(const char *fmt, ...)
49456 {
49457 @@ -490,7 +490,7 @@ compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p)
49458
49459 set_fs(KERNEL_DS);
49460 /* The __user pointer cast is valid because of the set_fs() */
49461 - ret = sys_io_setup(nr_reqs, (aio_context_t __user *) &ctx64);
49462 + ret = sys_io_setup(nr_reqs, (aio_context_t __force_user *) &ctx64);
49463 set_fs(oldfs);
49464 /* truncating is ok because it's a user address */
49465 if (!ret)
49466 @@ -548,7 +548,7 @@ ssize_t compat_rw_copy_check_uvector(int type,
49467 goto out;
49468
49469 ret = -EINVAL;
49470 - if (nr_segs > UIO_MAXIOV || nr_segs < 0)
49471 + if (nr_segs > UIO_MAXIOV)
49472 goto out;
49473 if (nr_segs > fast_segs) {
49474 ret = -ENOMEM;
49475 @@ -835,6 +835,7 @@ struct compat_old_linux_dirent {
49476
49477 struct compat_readdir_callback {
49478 struct compat_old_linux_dirent __user *dirent;
49479 + struct file * file;
49480 int result;
49481 };
49482
49483 @@ -852,6 +853,10 @@ static int compat_fillonedir(void *__buf, const char *name, int namlen,
49484 buf->result = -EOVERFLOW;
49485 return -EOVERFLOW;
49486 }
49487 +
49488 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
49489 + return 0;
49490 +
49491 buf->result++;
49492 dirent = buf->dirent;
49493 if (!access_ok(VERIFY_WRITE, dirent,
49494 @@ -882,6 +887,7 @@ asmlinkage long compat_sys_old_readdir(unsigned int fd,
49495
49496 buf.result = 0;
49497 buf.dirent = dirent;
49498 + buf.file = f.file;
49499
49500 error = vfs_readdir(f.file, compat_fillonedir, &buf);
49501 if (buf.result)
49502 @@ -901,6 +907,7 @@ struct compat_linux_dirent {
49503 struct compat_getdents_callback {
49504 struct compat_linux_dirent __user *current_dir;
49505 struct compat_linux_dirent __user *previous;
49506 + struct file * file;
49507 int count;
49508 int error;
49509 };
49510 @@ -922,6 +929,10 @@ static int compat_filldir(void *__buf, const char *name, int namlen,
49511 buf->error = -EOVERFLOW;
49512 return -EOVERFLOW;
49513 }
49514 +
49515 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
49516 + return 0;
49517 +
49518 dirent = buf->previous;
49519 if (dirent) {
49520 if (__put_user(offset, &dirent->d_off))
49521 @@ -967,6 +978,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
49522 buf.previous = NULL;
49523 buf.count = count;
49524 buf.error = 0;
49525 + buf.file = f.file;
49526
49527 error = vfs_readdir(f.file, compat_filldir, &buf);
49528 if (error >= 0)
49529 @@ -987,6 +999,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
49530 struct compat_getdents_callback64 {
49531 struct linux_dirent64 __user *current_dir;
49532 struct linux_dirent64 __user *previous;
49533 + struct file * file;
49534 int count;
49535 int error;
49536 };
49537 @@ -1003,6 +1016,10 @@ static int compat_filldir64(void * __buf, const char * name, int namlen, loff_t
49538 buf->error = -EINVAL; /* only used if we fail.. */
49539 if (reclen > buf->count)
49540 return -EINVAL;
49541 +
49542 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
49543 + return 0;
49544 +
49545 dirent = buf->previous;
49546
49547 if (dirent) {
49548 @@ -1052,13 +1069,14 @@ asmlinkage long compat_sys_getdents64(unsigned int fd,
49549 buf.previous = NULL;
49550 buf.count = count;
49551 buf.error = 0;
49552 + buf.file = f.file;
49553
49554 error = vfs_readdir(f.file, compat_filldir64, &buf);
49555 if (error >= 0)
49556 error = buf.error;
49557 lastdirent = buf.previous;
49558 if (lastdirent) {
49559 - typeof(lastdirent->d_off) d_off = f.file->f_pos;
49560 + typeof(((struct linux_dirent64 *)0)->d_off) d_off = f.file->f_pos;
49561 if (__put_user_unaligned(d_off, &lastdirent->d_off))
49562 error = -EFAULT;
49563 else
49564 diff --git a/fs/compat_binfmt_elf.c b/fs/compat_binfmt_elf.c
49565 index a81147e..20bf2b5 100644
49566 --- a/fs/compat_binfmt_elf.c
49567 +++ b/fs/compat_binfmt_elf.c
49568 @@ -30,11 +30,13 @@
49569 #undef elf_phdr
49570 #undef elf_shdr
49571 #undef elf_note
49572 +#undef elf_dyn
49573 #undef elf_addr_t
49574 #define elfhdr elf32_hdr
49575 #define elf_phdr elf32_phdr
49576 #define elf_shdr elf32_shdr
49577 #define elf_note elf32_note
49578 +#define elf_dyn Elf32_Dyn
49579 #define elf_addr_t Elf32_Addr
49580
49581 /*
49582 diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
49583 index 3ced75f..1eeca06 100644
49584 --- a/fs/compat_ioctl.c
49585 +++ b/fs/compat_ioctl.c
49586 @@ -623,7 +623,7 @@ static int serial_struct_ioctl(unsigned fd, unsigned cmd,
49587 return -EFAULT;
49588 if (__get_user(udata, &ss32->iomem_base))
49589 return -EFAULT;
49590 - ss.iomem_base = compat_ptr(udata);
49591 + ss.iomem_base = (unsigned char __force_kernel *)compat_ptr(udata);
49592 if (__get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
49593 __get_user(ss.port_high, &ss32->port_high))
49594 return -EFAULT;
49595 @@ -798,7 +798,7 @@ static int compat_ioctl_preallocate(struct file *file,
49596 copy_in_user(&p->l_len, &p32->l_len, sizeof(s64)) ||
49597 copy_in_user(&p->l_sysid, &p32->l_sysid, sizeof(s32)) ||
49598 copy_in_user(&p->l_pid, &p32->l_pid, sizeof(u32)) ||
49599 - copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32)))
49600 + copy_in_user(p->l_pad, &p32->l_pad, 4*sizeof(u32)))
49601 return -EFAULT;
49602
49603 return ioctl_preallocate(file, p);
49604 @@ -1620,8 +1620,8 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
49605 static int __init init_sys32_ioctl_cmp(const void *p, const void *q)
49606 {
49607 unsigned int a, b;
49608 - a = *(unsigned int *)p;
49609 - b = *(unsigned int *)q;
49610 + a = *(const unsigned int *)p;
49611 + b = *(const unsigned int *)q;
49612 if (a > b)
49613 return 1;
49614 if (a < b)
49615 diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
49616 index 7aabc6a..34c1197 100644
49617 --- a/fs/configfs/dir.c
49618 +++ b/fs/configfs/dir.c
49619 @@ -1565,7 +1565,8 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir
49620 }
49621 for (p=q->next; p!= &parent_sd->s_children; p=p->next) {
49622 struct configfs_dirent *next;
49623 - const char * name;
49624 + const unsigned char * name;
49625 + char d_name[sizeof(next->s_dentry->d_iname)];
49626 int len;
49627 struct inode *inode = NULL;
49628
49629 @@ -1575,7 +1576,12 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir
49630 continue;
49631
49632 name = configfs_get_name(next);
49633 - len = strlen(name);
49634 + if (next->s_dentry && name == next->s_dentry->d_iname) {
49635 + len = next->s_dentry->d_name.len;
49636 + memcpy(d_name, name, len);
49637 + name = d_name;
49638 + } else
49639 + len = strlen(name);
49640
49641 /*
49642 * We'll have a dentry and an inode for
49643 diff --git a/fs/coredump.c b/fs/coredump.c
49644 index c647965..a77bff3 100644
49645 --- a/fs/coredump.c
49646 +++ b/fs/coredump.c
49647 @@ -52,7 +52,7 @@ struct core_name {
49648 char *corename;
49649 int used, size;
49650 };
49651 -static atomic_t call_count = ATOMIC_INIT(1);
49652 +static atomic_unchecked_t call_count = ATOMIC_INIT(1);
49653
49654 /* The maximal length of core_pattern is also specified in sysctl.c */
49655
49656 @@ -60,7 +60,7 @@ static int expand_corename(struct core_name *cn)
49657 {
49658 char *old_corename = cn->corename;
49659
49660 - cn->size = CORENAME_MAX_SIZE * atomic_inc_return(&call_count);
49661 + cn->size = CORENAME_MAX_SIZE * atomic_inc_return_unchecked(&call_count);
49662 cn->corename = krealloc(old_corename, cn->size, GFP_KERNEL);
49663
49664 if (!cn->corename) {
49665 @@ -157,7 +157,7 @@ static int format_corename(struct core_name *cn, struct coredump_params *cprm)
49666 int pid_in_pattern = 0;
49667 int err = 0;
49668
49669 - cn->size = CORENAME_MAX_SIZE * atomic_read(&call_count);
49670 + cn->size = CORENAME_MAX_SIZE * atomic_read_unchecked(&call_count);
49671 cn->corename = kmalloc(cn->size, GFP_KERNEL);
49672 cn->used = 0;
49673
49674 @@ -414,17 +414,17 @@ static void wait_for_dump_helpers(struct file *file)
49675 pipe = file_inode(file)->i_pipe;
49676
49677 pipe_lock(pipe);
49678 - pipe->readers++;
49679 - pipe->writers--;
49680 + atomic_inc(&pipe->readers);
49681 + atomic_dec(&pipe->writers);
49682
49683 - while ((pipe->readers > 1) && (!signal_pending(current))) {
49684 + while ((atomic_read(&pipe->readers) > 1) && (!signal_pending(current))) {
49685 wake_up_interruptible_sync(&pipe->wait);
49686 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
49687 pipe_wait(pipe);
49688 }
49689
49690 - pipe->readers--;
49691 - pipe->writers++;
49692 + atomic_dec(&pipe->readers);
49693 + atomic_inc(&pipe->writers);
49694 pipe_unlock(pipe);
49695
49696 }
49697 @@ -471,7 +471,8 @@ void do_coredump(siginfo_t *siginfo)
49698 int ispipe;
49699 struct files_struct *displaced;
49700 bool need_nonrelative = false;
49701 - static atomic_t core_dump_count = ATOMIC_INIT(0);
49702 + static atomic_unchecked_t core_dump_count = ATOMIC_INIT(0);
49703 + long signr = siginfo->si_signo;
49704 struct coredump_params cprm = {
49705 .siginfo = siginfo,
49706 .regs = signal_pt_regs(),
49707 @@ -484,7 +485,10 @@ void do_coredump(siginfo_t *siginfo)
49708 .mm_flags = mm->flags,
49709 };
49710
49711 - audit_core_dumps(siginfo->si_signo);
49712 + audit_core_dumps(signr);
49713 +
49714 + if (signr == SIGSEGV || signr == SIGBUS || signr == SIGKILL || signr == SIGILL)
49715 + gr_handle_brute_attach(cprm.mm_flags);
49716
49717 binfmt = mm->binfmt;
49718 if (!binfmt || !binfmt->core_dump)
49719 @@ -508,7 +512,7 @@ void do_coredump(siginfo_t *siginfo)
49720 need_nonrelative = true;
49721 }
49722
49723 - retval = coredump_wait(siginfo->si_signo, &core_state);
49724 + retval = coredump_wait(signr, &core_state);
49725 if (retval < 0)
49726 goto fail_creds;
49727
49728 @@ -556,7 +560,7 @@ void do_coredump(siginfo_t *siginfo)
49729 }
49730 cprm.limit = RLIM_INFINITY;
49731
49732 - dump_count = atomic_inc_return(&core_dump_count);
49733 + dump_count = atomic_inc_return_unchecked(&core_dump_count);
49734 if (core_pipe_limit && (core_pipe_limit < dump_count)) {
49735 printk(KERN_WARNING "Pid %d(%s) over core_pipe_limit\n",
49736 task_tgid_vnr(current), current->comm);
49737 @@ -583,6 +587,8 @@ void do_coredump(siginfo_t *siginfo)
49738 } else {
49739 struct inode *inode;
49740
49741 + gr_learn_resource(current, RLIMIT_CORE, binfmt->min_coredump, 1);
49742 +
49743 if (cprm.limit < binfmt->min_coredump)
49744 goto fail_unlock;
49745
49746 @@ -640,7 +646,7 @@ close_fail:
49747 filp_close(cprm.file, NULL);
49748 fail_dropcount:
49749 if (ispipe)
49750 - atomic_dec(&core_dump_count);
49751 + atomic_dec_unchecked(&core_dump_count);
49752 fail_unlock:
49753 kfree(cn.corename);
49754 fail_corename:
49755 @@ -659,7 +665,7 @@ fail:
49756 */
49757 int dump_write(struct file *file, const void *addr, int nr)
49758 {
49759 - return access_ok(VERIFY_READ, addr, nr) && file->f_op->write(file, addr, nr, &file->f_pos) == nr;
49760 + return access_ok(VERIFY_READ, addr, nr) && file->f_op->write(file, (const char __force_user *)addr, nr, &file->f_pos) == nr;
49761 }
49762 EXPORT_SYMBOL(dump_write);
49763
49764 diff --git a/fs/dcache.c b/fs/dcache.c
49765 index e689268..f36956e 100644
49766 --- a/fs/dcache.c
49767 +++ b/fs/dcache.c
49768 @@ -3100,7 +3100,7 @@ void __init vfs_caches_init(unsigned long mempages)
49769 mempages -= reserve;
49770
49771 names_cachep = kmem_cache_create("names_cache", PATH_MAX, 0,
49772 - SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
49773 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_USERCOPY, NULL);
49774
49775 dcache_init();
49776 inode_init();
49777 diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
49778 index 4888cb3..e0f7cf8 100644
49779 --- a/fs/debugfs/inode.c
49780 +++ b/fs/debugfs/inode.c
49781 @@ -415,7 +415,11 @@ EXPORT_SYMBOL_GPL(debugfs_create_file);
49782 */
49783 struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
49784 {
49785 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
49786 + return __create_file(name, S_IFDIR | S_IRWXU,
49787 +#else
49788 return __create_file(name, S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO,
49789 +#endif
49790 parent, NULL, NULL);
49791 }
49792 EXPORT_SYMBOL_GPL(debugfs_create_dir);
49793 diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
49794 index 5eab400..810a3f5 100644
49795 --- a/fs/ecryptfs/inode.c
49796 +++ b/fs/ecryptfs/inode.c
49797 @@ -674,7 +674,7 @@ static int ecryptfs_readlink_lower(struct dentry *dentry, char **buf,
49798 old_fs = get_fs();
49799 set_fs(get_ds());
49800 rc = lower_dentry->d_inode->i_op->readlink(lower_dentry,
49801 - (char __user *)lower_buf,
49802 + (char __force_user *)lower_buf,
49803 PATH_MAX);
49804 set_fs(old_fs);
49805 if (rc < 0)
49806 @@ -706,7 +706,7 @@ out:
49807 static void
49808 ecryptfs_put_link(struct dentry *dentry, struct nameidata *nd, void *ptr)
49809 {
49810 - char *buf = nd_get_link(nd);
49811 + const char *buf = nd_get_link(nd);
49812 if (!IS_ERR(buf)) {
49813 /* Free the char* */
49814 kfree(buf);
49815 diff --git a/fs/ecryptfs/miscdev.c b/fs/ecryptfs/miscdev.c
49816 index e4141f2..d8263e8 100644
49817 --- a/fs/ecryptfs/miscdev.c
49818 +++ b/fs/ecryptfs/miscdev.c
49819 @@ -304,7 +304,7 @@ check_list:
49820 goto out_unlock_msg_ctx;
49821 i = PKT_TYPE_SIZE + PKT_CTR_SIZE;
49822 if (msg_ctx->msg) {
49823 - if (copy_to_user(&buf[i], packet_length, packet_length_size))
49824 + if (packet_length_size > sizeof(packet_length) || copy_to_user(&buf[i], packet_length, packet_length_size))
49825 goto out_unlock_msg_ctx;
49826 i += packet_length_size;
49827 if (copy_to_user(&buf[i], msg_ctx->msg, msg_ctx->msg_size))
49828 diff --git a/fs/ecryptfs/read_write.c b/fs/ecryptfs/read_write.c
49829 index 6a16053..2155147 100644
49830 --- a/fs/ecryptfs/read_write.c
49831 +++ b/fs/ecryptfs/read_write.c
49832 @@ -240,7 +240,7 @@ int ecryptfs_read_lower(char *data, loff_t offset, size_t size,
49833 return -EIO;
49834 fs_save = get_fs();
49835 set_fs(get_ds());
49836 - rc = vfs_read(lower_file, data, size, &offset);
49837 + rc = vfs_read(lower_file, (char __force_user *)data, size, &offset);
49838 set_fs(fs_save);
49839 return rc;
49840 }
49841 diff --git a/fs/exec.c b/fs/exec.c
49842 index 6d56ff2..fe44505 100644
49843 --- a/fs/exec.c
49844 +++ b/fs/exec.c
49845 @@ -55,8 +55,20 @@
49846 #include <linux/pipe_fs_i.h>
49847 #include <linux/oom.h>
49848 #include <linux/compat.h>
49849 +#include <linux/random.h>
49850 +#include <linux/seq_file.h>
49851 +#include <linux/coredump.h>
49852 +#include <linux/mman.h>
49853 +
49854 +#ifdef CONFIG_PAX_REFCOUNT
49855 +#include <linux/kallsyms.h>
49856 +#include <linux/kdebug.h>
49857 +#endif
49858 +
49859 +#include <trace/events/fs.h>
49860
49861 #include <asm/uaccess.h>
49862 +#include <asm/sections.h>
49863 #include <asm/mmu_context.h>
49864 #include <asm/tlb.h>
49865
49866 @@ -66,6 +78,18 @@
49867
49868 #include <trace/events/sched.h>
49869
49870 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
49871 +void __weak pax_set_initial_flags(struct linux_binprm *bprm)
49872 +{
49873 + 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");
49874 +}
49875 +#endif
49876 +
49877 +#ifdef CONFIG_PAX_HOOK_ACL_FLAGS
49878 +void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
49879 +EXPORT_SYMBOL(pax_set_initial_flags_func);
49880 +#endif
49881 +
49882 int suid_dumpable = 0;
49883
49884 static LIST_HEAD(formats);
49885 @@ -75,8 +99,8 @@ void __register_binfmt(struct linux_binfmt * fmt, int insert)
49886 {
49887 BUG_ON(!fmt);
49888 write_lock(&binfmt_lock);
49889 - insert ? list_add(&fmt->lh, &formats) :
49890 - list_add_tail(&fmt->lh, &formats);
49891 + insert ? pax_list_add((struct list_head *)&fmt->lh, &formats) :
49892 + pax_list_add_tail((struct list_head *)&fmt->lh, &formats);
49893 write_unlock(&binfmt_lock);
49894 }
49895
49896 @@ -85,7 +109,7 @@ EXPORT_SYMBOL(__register_binfmt);
49897 void unregister_binfmt(struct linux_binfmt * fmt)
49898 {
49899 write_lock(&binfmt_lock);
49900 - list_del(&fmt->lh);
49901 + pax_list_del((struct list_head *)&fmt->lh);
49902 write_unlock(&binfmt_lock);
49903 }
49904
49905 @@ -180,18 +204,10 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
49906 int write)
49907 {
49908 struct page *page;
49909 - int ret;
49910
49911 -#ifdef CONFIG_STACK_GROWSUP
49912 - if (write) {
49913 - ret = expand_downwards(bprm->vma, pos);
49914 - if (ret < 0)
49915 - return NULL;
49916 - }
49917 -#endif
49918 - ret = get_user_pages(current, bprm->mm, pos,
49919 - 1, write, 1, &page, NULL);
49920 - if (ret <= 0)
49921 + if (0 > expand_downwards(bprm->vma, pos))
49922 + return NULL;
49923 + if (0 >= get_user_pages(current, bprm->mm, pos, 1, write, 1, &page, NULL))
49924 return NULL;
49925
49926 if (write) {
49927 @@ -207,6 +223,17 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
49928 if (size <= ARG_MAX)
49929 return page;
49930
49931 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
49932 + // only allow 512KB for argv+env on suid/sgid binaries
49933 + // to prevent easy ASLR exhaustion
49934 + if (((!uid_eq(bprm->cred->euid, current_euid())) ||
49935 + (!gid_eq(bprm->cred->egid, current_egid()))) &&
49936 + (size > (512 * 1024))) {
49937 + put_page(page);
49938 + return NULL;
49939 + }
49940 +#endif
49941 +
49942 /*
49943 * Limit to 1/4-th the stack size for the argv+env strings.
49944 * This ensures that:
49945 @@ -266,6 +293,11 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
49946 vma->vm_end = STACK_TOP_MAX;
49947 vma->vm_start = vma->vm_end - PAGE_SIZE;
49948 vma->vm_flags = VM_STACK_FLAGS | VM_STACK_INCOMPLETE_SETUP;
49949 +
49950 +#ifdef CONFIG_PAX_SEGMEXEC
49951 + vma->vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
49952 +#endif
49953 +
49954 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
49955 INIT_LIST_HEAD(&vma->anon_vma_chain);
49956
49957 @@ -276,6 +308,12 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
49958 mm->stack_vm = mm->total_vm = 1;
49959 up_write(&mm->mmap_sem);
49960 bprm->p = vma->vm_end - sizeof(void *);
49961 +
49962 +#ifdef CONFIG_PAX_RANDUSTACK
49963 + if (randomize_va_space)
49964 + bprm->p ^= random32() & ~PAGE_MASK;
49965 +#endif
49966 +
49967 return 0;
49968 err:
49969 up_write(&mm->mmap_sem);
49970 @@ -396,7 +434,7 @@ struct user_arg_ptr {
49971 } ptr;
49972 };
49973
49974 -static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
49975 +const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
49976 {
49977 const char __user *native;
49978
49979 @@ -405,14 +443,14 @@ static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
49980 compat_uptr_t compat;
49981
49982 if (get_user(compat, argv.ptr.compat + nr))
49983 - return ERR_PTR(-EFAULT);
49984 + return (const char __force_user *)ERR_PTR(-EFAULT);
49985
49986 return compat_ptr(compat);
49987 }
49988 #endif
49989
49990 if (get_user(native, argv.ptr.native + nr))
49991 - return ERR_PTR(-EFAULT);
49992 + return (const char __force_user *)ERR_PTR(-EFAULT);
49993
49994 return native;
49995 }
49996 @@ -431,7 +469,7 @@ static int count(struct user_arg_ptr argv, int max)
49997 if (!p)
49998 break;
49999
50000 - if (IS_ERR(p))
50001 + if (IS_ERR((const char __force_kernel *)p))
50002 return -EFAULT;
50003
50004 if (i >= max)
50005 @@ -466,7 +504,7 @@ static int copy_strings(int argc, struct user_arg_ptr argv,
50006
50007 ret = -EFAULT;
50008 str = get_user_arg_ptr(argv, argc);
50009 - if (IS_ERR(str))
50010 + if (IS_ERR((const char __force_kernel *)str))
50011 goto out;
50012
50013 len = strnlen_user(str, MAX_ARG_STRLEN);
50014 @@ -548,7 +586,7 @@ int copy_strings_kernel(int argc, const char *const *__argv,
50015 int r;
50016 mm_segment_t oldfs = get_fs();
50017 struct user_arg_ptr argv = {
50018 - .ptr.native = (const char __user *const __user *)__argv,
50019 + .ptr.native = (const char __force_user *const __force_user *)__argv,
50020 };
50021
50022 set_fs(KERNEL_DS);
50023 @@ -583,7 +621,8 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
50024 unsigned long new_end = old_end - shift;
50025 struct mmu_gather tlb;
50026
50027 - BUG_ON(new_start > new_end);
50028 + if (new_start >= new_end || new_start < mmap_min_addr)
50029 + return -ENOMEM;
50030
50031 /*
50032 * ensure there are no vmas between where we want to go
50033 @@ -592,6 +631,10 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
50034 if (vma != find_vma(mm, new_start))
50035 return -EFAULT;
50036
50037 +#ifdef CONFIG_PAX_SEGMEXEC
50038 + BUG_ON(pax_find_mirror_vma(vma));
50039 +#endif
50040 +
50041 /*
50042 * cover the whole range: [new_start, old_end)
50043 */
50044 @@ -672,10 +715,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
50045 stack_top = arch_align_stack(stack_top);
50046 stack_top = PAGE_ALIGN(stack_top);
50047
50048 - if (unlikely(stack_top < mmap_min_addr) ||
50049 - unlikely(vma->vm_end - vma->vm_start >= stack_top - mmap_min_addr))
50050 - return -ENOMEM;
50051 -
50052 stack_shift = vma->vm_end - stack_top;
50053
50054 bprm->p -= stack_shift;
50055 @@ -687,8 +726,28 @@ int setup_arg_pages(struct linux_binprm *bprm,
50056 bprm->exec -= stack_shift;
50057
50058 down_write(&mm->mmap_sem);
50059 +
50060 + /* Move stack pages down in memory. */
50061 + if (stack_shift) {
50062 + ret = shift_arg_pages(vma, stack_shift);
50063 + if (ret)
50064 + goto out_unlock;
50065 + }
50066 +
50067 vm_flags = VM_STACK_FLAGS;
50068
50069 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
50070 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
50071 + vm_flags &= ~VM_EXEC;
50072 +
50073 +#ifdef CONFIG_PAX_MPROTECT
50074 + if (mm->pax_flags & MF_PAX_MPROTECT)
50075 + vm_flags &= ~VM_MAYEXEC;
50076 +#endif
50077 +
50078 + }
50079 +#endif
50080 +
50081 /*
50082 * Adjust stack execute permissions; explicitly enable for
50083 * EXSTACK_ENABLE_X, disable for EXSTACK_DISABLE_X and leave alone
50084 @@ -707,13 +766,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
50085 goto out_unlock;
50086 BUG_ON(prev != vma);
50087
50088 - /* Move stack pages down in memory. */
50089 - if (stack_shift) {
50090 - ret = shift_arg_pages(vma, stack_shift);
50091 - if (ret)
50092 - goto out_unlock;
50093 - }
50094 -
50095 /* mprotect_fixup is overkill to remove the temporary stack flags */
50096 vma->vm_flags &= ~VM_STACK_INCOMPLETE_SETUP;
50097
50098 @@ -737,6 +789,27 @@ int setup_arg_pages(struct linux_binprm *bprm,
50099 #endif
50100 current->mm->start_stack = bprm->p;
50101 ret = expand_stack(vma, stack_base);
50102 +
50103 +#if !defined(CONFIG_STACK_GROWSUP) && defined(CONFIG_PAX_RANDMMAP)
50104 + if (!ret && (mm->pax_flags & MF_PAX_RANDMMAP) && STACK_TOP <= 0xFFFFFFFFU && STACK_TOP > vma->vm_end) {
50105 + unsigned long size;
50106 + vm_flags_t vm_flags;
50107 +
50108 + size = STACK_TOP - vma->vm_end;
50109 + vm_flags = VM_NONE | VM_DONTEXPAND | VM_DONTDUMP;
50110 +
50111 + ret = vma->vm_end != mmap_region(NULL, vma->vm_end, size, vm_flags, 0);
50112 +
50113 +#ifdef CONFIG_X86
50114 + if (!ret) {
50115 + size = mmap_min_addr + ((mm->delta_mmap ^ mm->delta_stack) & (0xFFUL << PAGE_SHIFT));
50116 + ret = 0 != mmap_region(NULL, 0, PAGE_ALIGN(size), vm_flags, 0);
50117 + }
50118 +#endif
50119 +
50120 + }
50121 +#endif
50122 +
50123 if (ret)
50124 ret = -EFAULT;
50125
50126 @@ -772,6 +845,8 @@ struct file *open_exec(const char *name)
50127
50128 fsnotify_open(file);
50129
50130 + trace_open_exec(name);
50131 +
50132 err = deny_write_access(file);
50133 if (err)
50134 goto exit;
50135 @@ -795,7 +870,7 @@ int kernel_read(struct file *file, loff_t offset,
50136 old_fs = get_fs();
50137 set_fs(get_ds());
50138 /* The cast to a user pointer is valid due to the set_fs() */
50139 - result = vfs_read(file, (void __user *)addr, count, &pos);
50140 + result = vfs_read(file, (void __force_user *)addr, count, &pos);
50141 set_fs(old_fs);
50142 return result;
50143 }
50144 @@ -1250,7 +1325,7 @@ static int check_unsafe_exec(struct linux_binprm *bprm)
50145 }
50146 rcu_read_unlock();
50147
50148 - if (p->fs->users > n_fs) {
50149 + if (atomic_read(&p->fs->users) > n_fs) {
50150 bprm->unsafe |= LSM_UNSAFE_SHARE;
50151 } else {
50152 res = -EAGAIN;
50153 @@ -1450,6 +1525,31 @@ int search_binary_handler(struct linux_binprm *bprm)
50154
50155 EXPORT_SYMBOL(search_binary_handler);
50156
50157 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
50158 +static DEFINE_PER_CPU(u64, exec_counter);
50159 +static int __init init_exec_counters(void)
50160 +{
50161 + unsigned int cpu;
50162 +
50163 + for_each_possible_cpu(cpu) {
50164 + per_cpu(exec_counter, cpu) = (u64)cpu;
50165 + }
50166 +
50167 + return 0;
50168 +}
50169 +early_initcall(init_exec_counters);
50170 +static inline void increment_exec_counter(void)
50171 +{
50172 + BUILD_BUG_ON(NR_CPUS > (1 << 16));
50173 + current->exec_id = this_cpu_add_return(exec_counter, 1 << 16);
50174 +}
50175 +#else
50176 +static inline void increment_exec_counter(void) {}
50177 +#endif
50178 +
50179 +extern void gr_handle_exec_args(struct linux_binprm *bprm,
50180 + struct user_arg_ptr argv);
50181 +
50182 /*
50183 * sys_execve() executes a new program.
50184 */
50185 @@ -1457,6 +1557,11 @@ static int do_execve_common(const char *filename,
50186 struct user_arg_ptr argv,
50187 struct user_arg_ptr envp)
50188 {
50189 +#ifdef CONFIG_GRKERNSEC
50190 + struct file *old_exec_file;
50191 + struct acl_subject_label *old_acl;
50192 + struct rlimit old_rlim[RLIM_NLIMITS];
50193 +#endif
50194 struct linux_binprm *bprm;
50195 struct file *file;
50196 struct files_struct *displaced;
50197 @@ -1464,6 +1569,8 @@ static int do_execve_common(const char *filename,
50198 int retval;
50199 const struct cred *cred = current_cred();
50200
50201 + gr_learn_resource(current, RLIMIT_NPROC, atomic_read(&cred->user->processes), 1);
50202 +
50203 /*
50204 * We move the actual failure in case of RLIMIT_NPROC excess from
50205 * set*uid() to execve() because too many poorly written programs
50206 @@ -1504,12 +1611,27 @@ static int do_execve_common(const char *filename,
50207 if (IS_ERR(file))
50208 goto out_unmark;
50209
50210 + if (gr_ptrace_readexec(file, bprm->unsafe)) {
50211 + retval = -EPERM;
50212 + goto out_file;
50213 + }
50214 +
50215 sched_exec();
50216
50217 bprm->file = file;
50218 bprm->filename = filename;
50219 bprm->interp = filename;
50220
50221 + if (gr_process_user_ban()) {
50222 + retval = -EPERM;
50223 + goto out_file;
50224 + }
50225 +
50226 + if (!gr_acl_handle_execve(file->f_path.dentry, file->f_path.mnt)) {
50227 + retval = -EACCES;
50228 + goto out_file;
50229 + }
50230 +
50231 retval = bprm_mm_init(bprm);
50232 if (retval)
50233 goto out_file;
50234 @@ -1526,24 +1648,65 @@ static int do_execve_common(const char *filename,
50235 if (retval < 0)
50236 goto out;
50237
50238 +#ifdef CONFIG_GRKERNSEC
50239 + old_acl = current->acl;
50240 + memcpy(old_rlim, current->signal->rlim, sizeof(old_rlim));
50241 + old_exec_file = current->exec_file;
50242 + get_file(file);
50243 + current->exec_file = file;
50244 +#endif
50245 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
50246 + /* limit suid stack to 8MB
50247 + * we saved the old limits above and will restore them if this exec fails
50248 + */
50249 + if (((!uid_eq(bprm->cred->euid, current_euid())) || (!gid_eq(bprm->cred->egid, current_egid()))) &&
50250 + (old_rlim[RLIMIT_STACK].rlim_cur > (8 * 1024 * 1024)))
50251 + current->signal->rlim[RLIMIT_STACK].rlim_cur = 8 * 1024 * 1024;
50252 +#endif
50253 +
50254 + if (!gr_tpe_allow(file)) {
50255 + retval = -EACCES;
50256 + goto out_fail;
50257 + }
50258 +
50259 + if (gr_check_crash_exec(file)) {
50260 + retval = -EACCES;
50261 + goto out_fail;
50262 + }
50263 +
50264 + retval = gr_set_proc_label(file->f_path.dentry, file->f_path.mnt,
50265 + bprm->unsafe);
50266 + if (retval < 0)
50267 + goto out_fail;
50268 +
50269 retval = copy_strings_kernel(1, &bprm->filename, bprm);
50270 if (retval < 0)
50271 - goto out;
50272 + goto out_fail;
50273
50274 bprm->exec = bprm->p;
50275 retval = copy_strings(bprm->envc, envp, bprm);
50276 if (retval < 0)
50277 - goto out;
50278 + goto out_fail;
50279
50280 retval = copy_strings(bprm->argc, argv, bprm);
50281 if (retval < 0)
50282 - goto out;
50283 + goto out_fail;
50284 +
50285 + gr_log_chroot_exec(file->f_path.dentry, file->f_path.mnt);
50286 +
50287 + gr_handle_exec_args(bprm, argv);
50288
50289 retval = search_binary_handler(bprm);
50290 if (retval < 0)
50291 - goto out;
50292 + goto out_fail;
50293 +#ifdef CONFIG_GRKERNSEC
50294 + if (old_exec_file)
50295 + fput(old_exec_file);
50296 +#endif
50297
50298 /* execve succeeded */
50299 +
50300 + increment_exec_counter();
50301 current->fs->in_exec = 0;
50302 current->in_execve = 0;
50303 acct_update_integrals(current);
50304 @@ -1552,6 +1715,14 @@ static int do_execve_common(const char *filename,
50305 put_files_struct(displaced);
50306 return retval;
50307
50308 +out_fail:
50309 +#ifdef CONFIG_GRKERNSEC
50310 + current->acl = old_acl;
50311 + memcpy(current->signal->rlim, old_rlim, sizeof(old_rlim));
50312 + fput(current->exec_file);
50313 + current->exec_file = old_exec_file;
50314 +#endif
50315 +
50316 out:
50317 if (bprm->mm) {
50318 acct_arg_size(bprm, 0);
50319 @@ -1700,3 +1871,283 @@ asmlinkage long compat_sys_execve(const char __user * filename,
50320 return error;
50321 }
50322 #endif
50323 +
50324 +int pax_check_flags(unsigned long *flags)
50325 +{
50326 + int retval = 0;
50327 +
50328 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_SEGMEXEC)
50329 + if (*flags & MF_PAX_SEGMEXEC)
50330 + {
50331 + *flags &= ~MF_PAX_SEGMEXEC;
50332 + retval = -EINVAL;
50333 + }
50334 +#endif
50335 +
50336 + if ((*flags & MF_PAX_PAGEEXEC)
50337 +
50338 +#ifdef CONFIG_PAX_PAGEEXEC
50339 + && (*flags & MF_PAX_SEGMEXEC)
50340 +#endif
50341 +
50342 + )
50343 + {
50344 + *flags &= ~MF_PAX_PAGEEXEC;
50345 + retval = -EINVAL;
50346 + }
50347 +
50348 + if ((*flags & MF_PAX_MPROTECT)
50349 +
50350 +#ifdef CONFIG_PAX_MPROTECT
50351 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
50352 +#endif
50353 +
50354 + )
50355 + {
50356 + *flags &= ~MF_PAX_MPROTECT;
50357 + retval = -EINVAL;
50358 + }
50359 +
50360 + if ((*flags & MF_PAX_EMUTRAMP)
50361 +
50362 +#ifdef CONFIG_PAX_EMUTRAMP
50363 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
50364 +#endif
50365 +
50366 + )
50367 + {
50368 + *flags &= ~MF_PAX_EMUTRAMP;
50369 + retval = -EINVAL;
50370 + }
50371 +
50372 + return retval;
50373 +}
50374 +
50375 +EXPORT_SYMBOL(pax_check_flags);
50376 +
50377 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
50378 +void pax_report_fault(struct pt_regs *regs, void *pc, void *sp)
50379 +{
50380 + struct task_struct *tsk = current;
50381 + struct mm_struct *mm = current->mm;
50382 + char *buffer_exec = (char *)__get_free_page(GFP_KERNEL);
50383 + char *buffer_fault = (char *)__get_free_page(GFP_KERNEL);
50384 + char *path_exec = NULL;
50385 + char *path_fault = NULL;
50386 + unsigned long start = 0UL, end = 0UL, offset = 0UL;
50387 + siginfo_t info = { };
50388 +
50389 + if (buffer_exec && buffer_fault) {
50390 + struct vm_area_struct *vma, *vma_exec = NULL, *vma_fault = NULL;
50391 +
50392 + down_read(&mm->mmap_sem);
50393 + vma = mm->mmap;
50394 + while (vma && (!vma_exec || !vma_fault)) {
50395 + if (vma->vm_file && mm->exe_file == vma->vm_file && (vma->vm_flags & VM_EXEC))
50396 + vma_exec = vma;
50397 + if (vma->vm_start <= (unsigned long)pc && (unsigned long)pc < vma->vm_end)
50398 + vma_fault = vma;
50399 + vma = vma->vm_next;
50400 + }
50401 + if (vma_exec) {
50402 + path_exec = d_path(&vma_exec->vm_file->f_path, buffer_exec, PAGE_SIZE);
50403 + if (IS_ERR(path_exec))
50404 + path_exec = "<path too long>";
50405 + else {
50406 + path_exec = mangle_path(buffer_exec, path_exec, "\t\n\\");
50407 + if (path_exec) {
50408 + *path_exec = 0;
50409 + path_exec = buffer_exec;
50410 + } else
50411 + path_exec = "<path too long>";
50412 + }
50413 + }
50414 + if (vma_fault) {
50415 + start = vma_fault->vm_start;
50416 + end = vma_fault->vm_end;
50417 + offset = vma_fault->vm_pgoff << PAGE_SHIFT;
50418 + if (vma_fault->vm_file) {
50419 + path_fault = d_path(&vma_fault->vm_file->f_path, buffer_fault, PAGE_SIZE);
50420 + if (IS_ERR(path_fault))
50421 + path_fault = "<path too long>";
50422 + else {
50423 + path_fault = mangle_path(buffer_fault, path_fault, "\t\n\\");
50424 + if (path_fault) {
50425 + *path_fault = 0;
50426 + path_fault = buffer_fault;
50427 + } else
50428 + path_fault = "<path too long>";
50429 + }
50430 + } else
50431 + path_fault = "<anonymous mapping>";
50432 + }
50433 + up_read(&mm->mmap_sem);
50434 + }
50435 + if (tsk->signal->curr_ip)
50436 + printk(KERN_ERR "PAX: From %pI4: execution attempt in: %s, %08lx-%08lx %08lx\n", &tsk->signal->curr_ip, path_fault, start, end, offset);
50437 + else
50438 + printk(KERN_ERR "PAX: execution attempt in: %s, %08lx-%08lx %08lx\n", path_fault, start, end, offset);
50439 + 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),
50440 + from_kuid_munged(&init_user_ns, task_uid(tsk)), from_kuid_munged(&init_user_ns, task_euid(tsk)), pc, sp);
50441 + free_page((unsigned long)buffer_exec);
50442 + free_page((unsigned long)buffer_fault);
50443 + pax_report_insns(regs, pc, sp);
50444 + info.si_signo = SIGKILL;
50445 + info.si_errno = 0;
50446 + info.si_code = SI_KERNEL;
50447 + info.si_pid = 0;
50448 + info.si_uid = 0;
50449 + do_coredump(&info);
50450 +}
50451 +#endif
50452 +
50453 +#ifdef CONFIG_PAX_REFCOUNT
50454 +void pax_report_refcount_overflow(struct pt_regs *regs)
50455 +{
50456 + if (current->signal->curr_ip)
50457 + printk(KERN_ERR "PAX: From %pI4: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n",
50458 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
50459 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
50460 + else
50461 + printk(KERN_ERR "PAX: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n", current->comm, task_pid_nr(current),
50462 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
50463 + print_symbol(KERN_ERR "PAX: refcount overflow occured at: %s\n", instruction_pointer(regs));
50464 + show_regs(regs);
50465 + force_sig_info(SIGKILL, SEND_SIG_FORCED, current);
50466 +}
50467 +#endif
50468 +
50469 +#ifdef CONFIG_PAX_USERCOPY
50470 +/* 0: not at all, 1: fully, 2: fully inside frame, -1: partially (implies an error) */
50471 +static noinline int check_stack_object(const void *obj, unsigned long len)
50472 +{
50473 + const void * const stack = task_stack_page(current);
50474 + const void * const stackend = stack + THREAD_SIZE;
50475 +
50476 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
50477 + const void *frame = NULL;
50478 + const void *oldframe;
50479 +#endif
50480 +
50481 + if (obj + len < obj)
50482 + return -1;
50483 +
50484 + if (obj + len <= stack || stackend <= obj)
50485 + return 0;
50486 +
50487 + if (obj < stack || stackend < obj + len)
50488 + return -1;
50489 +
50490 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
50491 + oldframe = __builtin_frame_address(1);
50492 + if (oldframe)
50493 + frame = __builtin_frame_address(2);
50494 + /*
50495 + low ----------------------------------------------> high
50496 + [saved bp][saved ip][args][local vars][saved bp][saved ip]
50497 + ^----------------^
50498 + allow copies only within here
50499 + */
50500 + while (stack <= frame && frame < stackend) {
50501 + /* if obj + len extends past the last frame, this
50502 + check won't pass and the next frame will be 0,
50503 + causing us to bail out and correctly report
50504 + the copy as invalid
50505 + */
50506 + if (obj + len <= frame)
50507 + return obj >= oldframe + 2 * sizeof(void *) ? 2 : -1;
50508 + oldframe = frame;
50509 + frame = *(const void * const *)frame;
50510 + }
50511 + return -1;
50512 +#else
50513 + return 1;
50514 +#endif
50515 +}
50516 +
50517 +static __noreturn void pax_report_usercopy(const void *ptr, unsigned long len, bool to_user, const char *type)
50518 +{
50519 + if (current->signal->curr_ip)
50520 + printk(KERN_ERR "PAX: From %pI4: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
50521 + &current->signal->curr_ip, to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
50522 + else
50523 + printk(KERN_ERR "PAX: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
50524 + to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
50525 + dump_stack();
50526 + gr_handle_kernel_exploit();
50527 + do_group_exit(SIGKILL);
50528 +}
50529 +#endif
50530 +
50531 +#ifdef CONFIG_PAX_USERCOPY
50532 +static inline bool check_kernel_text_object(unsigned long low, unsigned long high)
50533 +{
50534 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
50535 + unsigned long textlow = ktla_ktva((unsigned long)_stext);
50536 +#ifdef CONFIG_MODULES
50537 + unsigned long texthigh = (unsigned long)MODULES_EXEC_VADDR;
50538 +#else
50539 + unsigned long texthigh = ktla_ktva((unsigned long)_etext);
50540 +#endif
50541 +
50542 +#else
50543 + unsigned long textlow = _stext;
50544 + unsigned long texthigh = _etext;
50545 +#endif
50546 +
50547 + if (high <= textlow || low > texthigh)
50548 + return false;
50549 + else
50550 + return true;
50551 +}
50552 +#endif
50553 +
50554 +void __check_object_size(const void *ptr, unsigned long n, bool to_user)
50555 +{
50556 +
50557 +#ifdef CONFIG_PAX_USERCOPY
50558 + const char *type;
50559 +
50560 + if (!n)
50561 + return;
50562 +
50563 + type = check_heap_object(ptr, n);
50564 + if (!type) {
50565 + int ret = check_stack_object(ptr, n);
50566 + if (ret == 1 || ret == 2)
50567 + return;
50568 + if (ret == 0) {
50569 + if (check_kernel_text_object((unsigned long)ptr, (unsigned long)ptr + n))
50570 + type = "<kernel text>";
50571 + else
50572 + return;
50573 + } else
50574 + type = "<process stack>";
50575 + }
50576 +
50577 + pax_report_usercopy(ptr, n, to_user, type);
50578 +#endif
50579 +
50580 +}
50581 +EXPORT_SYMBOL(__check_object_size);
50582 +
50583 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
50584 +void pax_track_stack(void)
50585 +{
50586 + unsigned long sp = (unsigned long)&sp;
50587 + if (sp < current_thread_info()->lowest_stack &&
50588 + sp > (unsigned long)task_stack_page(current))
50589 + current_thread_info()->lowest_stack = sp;
50590 +}
50591 +EXPORT_SYMBOL(pax_track_stack);
50592 +#endif
50593 +
50594 +#ifdef CONFIG_PAX_SIZE_OVERFLOW
50595 +void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
50596 +{
50597 + printk(KERN_ERR "PAX: size overflow detected in function %s %s:%u %s", func, file, line, ssa_name);
50598 + dump_stack();
50599 + do_group_exit(SIGKILL);
50600 +}
50601 +EXPORT_SYMBOL(report_size_overflow);
50602 +#endif
50603 diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
50604 index 9f9992b..8b59411 100644
50605 --- a/fs/ext2/balloc.c
50606 +++ b/fs/ext2/balloc.c
50607 @@ -1184,10 +1184,10 @@ static int ext2_has_free_blocks(struct ext2_sb_info *sbi)
50608
50609 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
50610 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
50611 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
50612 + if (free_blocks < root_blocks + 1 &&
50613 !uid_eq(sbi->s_resuid, current_fsuid()) &&
50614 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
50615 - !in_group_p (sbi->s_resgid))) {
50616 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
50617 return 0;
50618 }
50619 return 1;
50620 diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
50621 index 22548f5..41521d8 100644
50622 --- a/fs/ext3/balloc.c
50623 +++ b/fs/ext3/balloc.c
50624 @@ -1438,10 +1438,10 @@ static int ext3_has_free_blocks(struct ext3_sb_info *sbi, int use_reservation)
50625
50626 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
50627 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
50628 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
50629 + if (free_blocks < root_blocks + 1 &&
50630 !use_reservation && !uid_eq(sbi->s_resuid, current_fsuid()) &&
50631 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
50632 - !in_group_p (sbi->s_resgid))) {
50633 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
50634 return 0;
50635 }
50636 return 1;
50637 diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
50638 index 92e68b3..115d987 100644
50639 --- a/fs/ext4/balloc.c
50640 +++ b/fs/ext4/balloc.c
50641 @@ -505,8 +505,8 @@ static int ext4_has_free_clusters(struct ext4_sb_info *sbi,
50642 /* Hm, nope. Are (enough) root reserved clusters available? */
50643 if (uid_eq(sbi->s_resuid, current_fsuid()) ||
50644 (!gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) && in_group_p(sbi->s_resgid)) ||
50645 - capable(CAP_SYS_RESOURCE) ||
50646 - (flags & EXT4_MB_USE_ROOT_BLOCKS)) {
50647 + (flags & EXT4_MB_USE_ROOT_BLOCKS) ||
50648 + capable_nolog(CAP_SYS_RESOURCE)) {
50649
50650 if (free_clusters >= (nclusters + dirty_clusters))
50651 return 1;
50652 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
50653 index 3b83cd6..0f34dcd 100644
50654 --- a/fs/ext4/ext4.h
50655 +++ b/fs/ext4/ext4.h
50656 @@ -1254,19 +1254,19 @@ struct ext4_sb_info {
50657 unsigned long s_mb_last_start;
50658
50659 /* stats for buddy allocator */
50660 - atomic_t s_bal_reqs; /* number of reqs with len > 1 */
50661 - atomic_t s_bal_success; /* we found long enough chunks */
50662 - atomic_t s_bal_allocated; /* in blocks */
50663 - atomic_t s_bal_ex_scanned; /* total extents scanned */
50664 - atomic_t s_bal_goals; /* goal hits */
50665 - atomic_t s_bal_breaks; /* too long searches */
50666 - atomic_t s_bal_2orders; /* 2^order hits */
50667 + atomic_unchecked_t s_bal_reqs; /* number of reqs with len > 1 */
50668 + atomic_unchecked_t s_bal_success; /* we found long enough chunks */
50669 + atomic_unchecked_t s_bal_allocated; /* in blocks */
50670 + atomic_unchecked_t s_bal_ex_scanned; /* total extents scanned */
50671 + atomic_unchecked_t s_bal_goals; /* goal hits */
50672 + atomic_unchecked_t s_bal_breaks; /* too long searches */
50673 + atomic_unchecked_t s_bal_2orders; /* 2^order hits */
50674 spinlock_t s_bal_lock;
50675 unsigned long s_mb_buddies_generated;
50676 unsigned long long s_mb_generation_time;
50677 - atomic_t s_mb_lost_chunks;
50678 - atomic_t s_mb_preallocated;
50679 - atomic_t s_mb_discarded;
50680 + atomic_unchecked_t s_mb_lost_chunks;
50681 + atomic_unchecked_t s_mb_preallocated;
50682 + atomic_unchecked_t s_mb_discarded;
50683 atomic_t s_lock_busy;
50684
50685 /* locality groups */
50686 diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
50687 index f3190ab..84ffb21 100644
50688 --- a/fs/ext4/mballoc.c
50689 +++ b/fs/ext4/mballoc.c
50690 @@ -1754,7 +1754,7 @@ void ext4_mb_simple_scan_group(struct ext4_allocation_context *ac,
50691 BUG_ON(ac->ac_b_ex.fe_len != ac->ac_g_ex.fe_len);
50692
50693 if (EXT4_SB(sb)->s_mb_stats)
50694 - atomic_inc(&EXT4_SB(sb)->s_bal_2orders);
50695 + atomic_inc_unchecked(&EXT4_SB(sb)->s_bal_2orders);
50696
50697 break;
50698 }
50699 @@ -2059,7 +2059,7 @@ repeat:
50700 ac->ac_status = AC_STATUS_CONTINUE;
50701 ac->ac_flags |= EXT4_MB_HINT_FIRST;
50702 cr = 3;
50703 - atomic_inc(&sbi->s_mb_lost_chunks);
50704 + atomic_inc_unchecked(&sbi->s_mb_lost_chunks);
50705 goto repeat;
50706 }
50707 }
50708 @@ -2567,25 +2567,25 @@ int ext4_mb_release(struct super_block *sb)
50709 if (sbi->s_mb_stats) {
50710 ext4_msg(sb, KERN_INFO,
50711 "mballoc: %u blocks %u reqs (%u success)",
50712 - atomic_read(&sbi->s_bal_allocated),
50713 - atomic_read(&sbi->s_bal_reqs),
50714 - atomic_read(&sbi->s_bal_success));
50715 + atomic_read_unchecked(&sbi->s_bal_allocated),
50716 + atomic_read_unchecked(&sbi->s_bal_reqs),
50717 + atomic_read_unchecked(&sbi->s_bal_success));
50718 ext4_msg(sb, KERN_INFO,
50719 "mballoc: %u extents scanned, %u goal hits, "
50720 "%u 2^N hits, %u breaks, %u lost",
50721 - atomic_read(&sbi->s_bal_ex_scanned),
50722 - atomic_read(&sbi->s_bal_goals),
50723 - atomic_read(&sbi->s_bal_2orders),
50724 - atomic_read(&sbi->s_bal_breaks),
50725 - atomic_read(&sbi->s_mb_lost_chunks));
50726 + atomic_read_unchecked(&sbi->s_bal_ex_scanned),
50727 + atomic_read_unchecked(&sbi->s_bal_goals),
50728 + atomic_read_unchecked(&sbi->s_bal_2orders),
50729 + atomic_read_unchecked(&sbi->s_bal_breaks),
50730 + atomic_read_unchecked(&sbi->s_mb_lost_chunks));
50731 ext4_msg(sb, KERN_INFO,
50732 "mballoc: %lu generated and it took %Lu",
50733 sbi->s_mb_buddies_generated,
50734 sbi->s_mb_generation_time);
50735 ext4_msg(sb, KERN_INFO,
50736 "mballoc: %u preallocated, %u discarded",
50737 - atomic_read(&sbi->s_mb_preallocated),
50738 - atomic_read(&sbi->s_mb_discarded));
50739 + atomic_read_unchecked(&sbi->s_mb_preallocated),
50740 + atomic_read_unchecked(&sbi->s_mb_discarded));
50741 }
50742
50743 free_percpu(sbi->s_locality_groups);
50744 @@ -3039,16 +3039,16 @@ static void ext4_mb_collect_stats(struct ext4_allocation_context *ac)
50745 struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb);
50746
50747 if (sbi->s_mb_stats && ac->ac_g_ex.fe_len > 1) {
50748 - atomic_inc(&sbi->s_bal_reqs);
50749 - atomic_add(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
50750 + atomic_inc_unchecked(&sbi->s_bal_reqs);
50751 + atomic_add_unchecked(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
50752 if (ac->ac_b_ex.fe_len >= ac->ac_o_ex.fe_len)
50753 - atomic_inc(&sbi->s_bal_success);
50754 - atomic_add(ac->ac_found, &sbi->s_bal_ex_scanned);
50755 + atomic_inc_unchecked(&sbi->s_bal_success);
50756 + atomic_add_unchecked(ac->ac_found, &sbi->s_bal_ex_scanned);
50757 if (ac->ac_g_ex.fe_start == ac->ac_b_ex.fe_start &&
50758 ac->ac_g_ex.fe_group == ac->ac_b_ex.fe_group)
50759 - atomic_inc(&sbi->s_bal_goals);
50760 + atomic_inc_unchecked(&sbi->s_bal_goals);
50761 if (ac->ac_found > sbi->s_mb_max_to_scan)
50762 - atomic_inc(&sbi->s_bal_breaks);
50763 + atomic_inc_unchecked(&sbi->s_bal_breaks);
50764 }
50765
50766 if (ac->ac_op == EXT4_MB_HISTORY_ALLOC)
50767 @@ -3448,7 +3448,7 @@ ext4_mb_new_inode_pa(struct ext4_allocation_context *ac)
50768 trace_ext4_mb_new_inode_pa(ac, pa);
50769
50770 ext4_mb_use_inode_pa(ac, pa);
50771 - atomic_add(pa->pa_free, &sbi->s_mb_preallocated);
50772 + atomic_add_unchecked(pa->pa_free, &sbi->s_mb_preallocated);
50773
50774 ei = EXT4_I(ac->ac_inode);
50775 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
50776 @@ -3508,7 +3508,7 @@ ext4_mb_new_group_pa(struct ext4_allocation_context *ac)
50777 trace_ext4_mb_new_group_pa(ac, pa);
50778
50779 ext4_mb_use_group_pa(ac, pa);
50780 - atomic_add(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
50781 + atomic_add_unchecked(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
50782
50783 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
50784 lg = ac->ac_lg;
50785 @@ -3597,7 +3597,7 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh,
50786 * from the bitmap and continue.
50787 */
50788 }
50789 - atomic_add(free, &sbi->s_mb_discarded);
50790 + atomic_add_unchecked(free, &sbi->s_mb_discarded);
50791
50792 return err;
50793 }
50794 @@ -3615,7 +3615,7 @@ ext4_mb_release_group_pa(struct ext4_buddy *e4b,
50795 ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit);
50796 BUG_ON(group != e4b->bd_group && pa->pa_len != 0);
50797 mb_free_blocks(pa->pa_inode, e4b, bit, pa->pa_len);
50798 - atomic_add(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
50799 + atomic_add_unchecked(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
50800 trace_ext4_mballoc_discard(sb, NULL, group, bit, pa->pa_len);
50801
50802 return 0;
50803 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
50804 index febbe0e..782c4fd 100644
50805 --- a/fs/ext4/super.c
50806 +++ b/fs/ext4/super.c
50807 @@ -2380,7 +2380,7 @@ struct ext4_attr {
50808 ssize_t (*store)(struct ext4_attr *, struct ext4_sb_info *,
50809 const char *, size_t);
50810 int offset;
50811 -};
50812 +} __do_const;
50813
50814 static int parse_strtoul(const char *buf,
50815 unsigned long max, unsigned long *value)
50816 diff --git a/fs/fcntl.c b/fs/fcntl.c
50817 index 6599222..e7bf0de 100644
50818 --- a/fs/fcntl.c
50819 +++ b/fs/fcntl.c
50820 @@ -107,6 +107,11 @@ int __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
50821 if (err)
50822 return err;
50823
50824 + if (gr_handle_chroot_fowner(pid, type))
50825 + return -ENOENT;
50826 + if (gr_check_protected_task_fowner(pid, type))
50827 + return -EACCES;
50828 +
50829 f_modown(filp, pid, type, force);
50830 return 0;
50831 }
50832 diff --git a/fs/fhandle.c b/fs/fhandle.c
50833 index 999ff5c..41f4109 100644
50834 --- a/fs/fhandle.c
50835 +++ b/fs/fhandle.c
50836 @@ -67,8 +67,7 @@ static long do_sys_name_to_handle(struct path *path,
50837 } else
50838 retval = 0;
50839 /* copy the mount id */
50840 - if (copy_to_user(mnt_id, &real_mount(path->mnt)->mnt_id,
50841 - sizeof(*mnt_id)) ||
50842 + if (put_user(real_mount(path->mnt)->mnt_id, mnt_id) ||
50843 copy_to_user(ufh, handle,
50844 sizeof(struct file_handle) + handle_bytes))
50845 retval = -EFAULT;
50846 diff --git a/fs/fifo.c b/fs/fifo.c
50847 index cf6f434..3d7942c 100644
50848 --- a/fs/fifo.c
50849 +++ b/fs/fifo.c
50850 @@ -59,10 +59,10 @@ static int fifo_open(struct inode *inode, struct file *filp)
50851 */
50852 filp->f_op = &read_pipefifo_fops;
50853 pipe->r_counter++;
50854 - if (pipe->readers++ == 0)
50855 + if (atomic_inc_return(&pipe->readers) == 1)
50856 wake_up_partner(inode);
50857
50858 - if (!pipe->writers) {
50859 + if (!atomic_read(&pipe->writers)) {
50860 if ((filp->f_flags & O_NONBLOCK)) {
50861 /* suppress POLLHUP until we have
50862 * seen a writer */
50863 @@ -81,15 +81,15 @@ static int fifo_open(struct inode *inode, struct file *filp)
50864 * errno=ENXIO when there is no process reading the FIFO.
50865 */
50866 ret = -ENXIO;
50867 - if ((filp->f_flags & O_NONBLOCK) && !pipe->readers)
50868 + if ((filp->f_flags & O_NONBLOCK) && !atomic_read(&pipe->readers))
50869 goto err;
50870
50871 filp->f_op = &write_pipefifo_fops;
50872 pipe->w_counter++;
50873 - if (!pipe->writers++)
50874 + if (atomic_inc_return(&pipe->writers) == 1)
50875 wake_up_partner(inode);
50876
50877 - if (!pipe->readers) {
50878 + if (!atomic_read(&pipe->readers)) {
50879 if (wait_for_partner(inode, &pipe->r_counter))
50880 goto err_wr;
50881 }
50882 @@ -104,11 +104,11 @@ static int fifo_open(struct inode *inode, struct file *filp)
50883 */
50884 filp->f_op = &rdwr_pipefifo_fops;
50885
50886 - pipe->readers++;
50887 - pipe->writers++;
50888 + atomic_inc(&pipe->readers);
50889 + atomic_inc(&pipe->writers);
50890 pipe->r_counter++;
50891 pipe->w_counter++;
50892 - if (pipe->readers == 1 || pipe->writers == 1)
50893 + if (atomic_read(&pipe->readers) == 1 || atomic_read(&pipe->writers) == 1)
50894 wake_up_partner(inode);
50895 break;
50896
50897 @@ -122,19 +122,19 @@ static int fifo_open(struct inode *inode, struct file *filp)
50898 return 0;
50899
50900 err_rd:
50901 - if (!--pipe->readers)
50902 + if (atomic_dec_and_test(&pipe->readers))
50903 wake_up_interruptible(&pipe->wait);
50904 ret = -ERESTARTSYS;
50905 goto err;
50906
50907 err_wr:
50908 - if (!--pipe->writers)
50909 + if (atomic_dec_and_test(&pipe->writers))
50910 wake_up_interruptible(&pipe->wait);
50911 ret = -ERESTARTSYS;
50912 goto err;
50913
50914 err:
50915 - if (!pipe->readers && !pipe->writers)
50916 + if (!atomic_read(&pipe->readers) && !atomic_read(&pipe->writers))
50917 free_pipe_info(inode);
50918
50919 err_nocleanup:
50920 diff --git a/fs/file.c b/fs/file.c
50921 index 3906d95..5fe379b 100644
50922 --- a/fs/file.c
50923 +++ b/fs/file.c
50924 @@ -16,6 +16,7 @@
50925 #include <linux/slab.h>
50926 #include <linux/vmalloc.h>
50927 #include <linux/file.h>
50928 +#include <linux/security.h>
50929 #include <linux/fdtable.h>
50930 #include <linux/bitops.h>
50931 #include <linux/interrupt.h>
50932 @@ -892,6 +893,7 @@ int replace_fd(unsigned fd, struct file *file, unsigned flags)
50933 if (!file)
50934 return __close_fd(files, fd);
50935
50936 + gr_learn_resource(current, RLIMIT_NOFILE, fd, 0);
50937 if (fd >= rlimit(RLIMIT_NOFILE))
50938 return -EBADF;
50939
50940 @@ -918,6 +920,7 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldfd, unsigned int, newfd, int, flags)
50941 if (unlikely(oldfd == newfd))
50942 return -EINVAL;
50943
50944 + gr_learn_resource(current, RLIMIT_NOFILE, newfd, 0);
50945 if (newfd >= rlimit(RLIMIT_NOFILE))
50946 return -EBADF;
50947
50948 @@ -973,6 +976,7 @@ SYSCALL_DEFINE1(dup, unsigned int, fildes)
50949 int f_dupfd(unsigned int from, struct file *file, unsigned flags)
50950 {
50951 int err;
50952 + gr_learn_resource(current, RLIMIT_NOFILE, from, 0);
50953 if (from >= rlimit(RLIMIT_NOFILE))
50954 return -EINVAL;
50955 err = alloc_fd(from, flags);
50956 diff --git a/fs/filesystems.c b/fs/filesystems.c
50957 index 92567d9..fcd8cbf 100644
50958 --- a/fs/filesystems.c
50959 +++ b/fs/filesystems.c
50960 @@ -273,7 +273,11 @@ struct file_system_type *get_fs_type(const char *name)
50961 int len = dot ? dot - name : strlen(name);
50962
50963 fs = __get_fs_type(name, len);
50964 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
50965 + if (!fs && (___request_module(true, "grsec_modharden_fs", "fs-%.*s", len, name) == 0))
50966 +#else
50967 if (!fs && (request_module("fs-%.*s", len, name) == 0))
50968 +#endif
50969 fs = __get_fs_type(name, len);
50970
50971 if (dot && fs && !(fs->fs_flags & FS_HAS_SUBTYPE)) {
50972 diff --git a/fs/fs_struct.c b/fs/fs_struct.c
50973 index d8ac61d..79a36f0 100644
50974 --- a/fs/fs_struct.c
50975 +++ b/fs/fs_struct.c
50976 @@ -4,6 +4,7 @@
50977 #include <linux/path.h>
50978 #include <linux/slab.h>
50979 #include <linux/fs_struct.h>
50980 +#include <linux/grsecurity.h>
50981 #include "internal.h"
50982
50983 /*
50984 @@ -19,6 +20,7 @@ void set_fs_root(struct fs_struct *fs, const struct path *path)
50985 write_seqcount_begin(&fs->seq);
50986 old_root = fs->root;
50987 fs->root = *path;
50988 + gr_set_chroot_entries(current, path);
50989 write_seqcount_end(&fs->seq);
50990 spin_unlock(&fs->lock);
50991 if (old_root.dentry)
50992 @@ -67,6 +69,10 @@ void chroot_fs_refs(const struct path *old_root, const struct path *new_root)
50993 int hits = 0;
50994 spin_lock(&fs->lock);
50995 write_seqcount_begin(&fs->seq);
50996 + /* this root replacement is only done by pivot_root,
50997 + leave grsec's chroot tagging alone for this task
50998 + so that a pivoted root isn't treated as a chroot
50999 + */
51000 hits += replace_path(&fs->root, old_root, new_root);
51001 hits += replace_path(&fs->pwd, old_root, new_root);
51002 write_seqcount_end(&fs->seq);
51003 @@ -99,7 +105,8 @@ void exit_fs(struct task_struct *tsk)
51004 task_lock(tsk);
51005 spin_lock(&fs->lock);
51006 tsk->fs = NULL;
51007 - kill = !--fs->users;
51008 + gr_clear_chroot_entries(tsk);
51009 + kill = !atomic_dec_return(&fs->users);
51010 spin_unlock(&fs->lock);
51011 task_unlock(tsk);
51012 if (kill)
51013 @@ -112,7 +119,7 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
51014 struct fs_struct *fs = kmem_cache_alloc(fs_cachep, GFP_KERNEL);
51015 /* We don't need to lock fs - think why ;-) */
51016 if (fs) {
51017 - fs->users = 1;
51018 + atomic_set(&fs->users, 1);
51019 fs->in_exec = 0;
51020 spin_lock_init(&fs->lock);
51021 seqcount_init(&fs->seq);
51022 @@ -121,6 +128,9 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
51023 spin_lock(&old->lock);
51024 fs->root = old->root;
51025 path_get(&fs->root);
51026 + /* instead of calling gr_set_chroot_entries here,
51027 + we call it from every caller of this function
51028 + */
51029 fs->pwd = old->pwd;
51030 path_get(&fs->pwd);
51031 spin_unlock(&old->lock);
51032 @@ -139,8 +149,9 @@ int unshare_fs_struct(void)
51033
51034 task_lock(current);
51035 spin_lock(&fs->lock);
51036 - kill = !--fs->users;
51037 + kill = !atomic_dec_return(&fs->users);
51038 current->fs = new_fs;
51039 + gr_set_chroot_entries(current, &new_fs->root);
51040 spin_unlock(&fs->lock);
51041 task_unlock(current);
51042
51043 @@ -153,13 +164,13 @@ EXPORT_SYMBOL_GPL(unshare_fs_struct);
51044
51045 int current_umask(void)
51046 {
51047 - return current->fs->umask;
51048 + return current->fs->umask | gr_acl_umask();
51049 }
51050 EXPORT_SYMBOL(current_umask);
51051
51052 /* to be mentioned only in INIT_TASK */
51053 struct fs_struct init_fs = {
51054 - .users = 1,
51055 + .users = ATOMIC_INIT(1),
51056 .lock = __SPIN_LOCK_UNLOCKED(init_fs.lock),
51057 .seq = SEQCNT_ZERO,
51058 .umask = 0022,
51059 diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
51060 index e2cba1f..17a25bb 100644
51061 --- a/fs/fscache/cookie.c
51062 +++ b/fs/fscache/cookie.c
51063 @@ -68,11 +68,11 @@ struct fscache_cookie *__fscache_acquire_cookie(
51064 parent ? (char *) parent->def->name : "<no-parent>",
51065 def->name, netfs_data);
51066
51067 - fscache_stat(&fscache_n_acquires);
51068 + fscache_stat_unchecked(&fscache_n_acquires);
51069
51070 /* if there's no parent cookie, then we don't create one here either */
51071 if (!parent) {
51072 - fscache_stat(&fscache_n_acquires_null);
51073 + fscache_stat_unchecked(&fscache_n_acquires_null);
51074 _leave(" [no parent]");
51075 return NULL;
51076 }
51077 @@ -87,7 +87,7 @@ struct fscache_cookie *__fscache_acquire_cookie(
51078 /* allocate and initialise a cookie */
51079 cookie = kmem_cache_alloc(fscache_cookie_jar, GFP_KERNEL);
51080 if (!cookie) {
51081 - fscache_stat(&fscache_n_acquires_oom);
51082 + fscache_stat_unchecked(&fscache_n_acquires_oom);
51083 _leave(" [ENOMEM]");
51084 return NULL;
51085 }
51086 @@ -109,13 +109,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
51087
51088 switch (cookie->def->type) {
51089 case FSCACHE_COOKIE_TYPE_INDEX:
51090 - fscache_stat(&fscache_n_cookie_index);
51091 + fscache_stat_unchecked(&fscache_n_cookie_index);
51092 break;
51093 case FSCACHE_COOKIE_TYPE_DATAFILE:
51094 - fscache_stat(&fscache_n_cookie_data);
51095 + fscache_stat_unchecked(&fscache_n_cookie_data);
51096 break;
51097 default:
51098 - fscache_stat(&fscache_n_cookie_special);
51099 + fscache_stat_unchecked(&fscache_n_cookie_special);
51100 break;
51101 }
51102
51103 @@ -126,13 +126,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
51104 if (fscache_acquire_non_index_cookie(cookie) < 0) {
51105 atomic_dec(&parent->n_children);
51106 __fscache_cookie_put(cookie);
51107 - fscache_stat(&fscache_n_acquires_nobufs);
51108 + fscache_stat_unchecked(&fscache_n_acquires_nobufs);
51109 _leave(" = NULL");
51110 return NULL;
51111 }
51112 }
51113
51114 - fscache_stat(&fscache_n_acquires_ok);
51115 + fscache_stat_unchecked(&fscache_n_acquires_ok);
51116 _leave(" = %p", cookie);
51117 return cookie;
51118 }
51119 @@ -168,7 +168,7 @@ static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie)
51120 cache = fscache_select_cache_for_object(cookie->parent);
51121 if (!cache) {
51122 up_read(&fscache_addremove_sem);
51123 - fscache_stat(&fscache_n_acquires_no_cache);
51124 + fscache_stat_unchecked(&fscache_n_acquires_no_cache);
51125 _leave(" = -ENOMEDIUM [no cache]");
51126 return -ENOMEDIUM;
51127 }
51128 @@ -255,12 +255,12 @@ static int fscache_alloc_object(struct fscache_cache *cache,
51129 object = cache->ops->alloc_object(cache, cookie);
51130 fscache_stat_d(&fscache_n_cop_alloc_object);
51131 if (IS_ERR(object)) {
51132 - fscache_stat(&fscache_n_object_no_alloc);
51133 + fscache_stat_unchecked(&fscache_n_object_no_alloc);
51134 ret = PTR_ERR(object);
51135 goto error;
51136 }
51137
51138 - fscache_stat(&fscache_n_object_alloc);
51139 + fscache_stat_unchecked(&fscache_n_object_alloc);
51140
51141 object->debug_id = atomic_inc_return(&fscache_object_debug_id);
51142
51143 @@ -376,7 +376,7 @@ void __fscache_invalidate(struct fscache_cookie *cookie)
51144
51145 _enter("{%s}", cookie->def->name);
51146
51147 - fscache_stat(&fscache_n_invalidates);
51148 + fscache_stat_unchecked(&fscache_n_invalidates);
51149
51150 /* Only permit invalidation of data files. Invalidating an index will
51151 * require the caller to release all its attachments to the tree rooted
51152 @@ -434,10 +434,10 @@ void __fscache_update_cookie(struct fscache_cookie *cookie)
51153 {
51154 struct fscache_object *object;
51155
51156 - fscache_stat(&fscache_n_updates);
51157 + fscache_stat_unchecked(&fscache_n_updates);
51158
51159 if (!cookie) {
51160 - fscache_stat(&fscache_n_updates_null);
51161 + fscache_stat_unchecked(&fscache_n_updates_null);
51162 _leave(" [no cookie]");
51163 return;
51164 }
51165 @@ -471,12 +471,12 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
51166 struct fscache_object *object;
51167 unsigned long event;
51168
51169 - fscache_stat(&fscache_n_relinquishes);
51170 + fscache_stat_unchecked(&fscache_n_relinquishes);
51171 if (retire)
51172 - fscache_stat(&fscache_n_relinquishes_retire);
51173 + fscache_stat_unchecked(&fscache_n_relinquishes_retire);
51174
51175 if (!cookie) {
51176 - fscache_stat(&fscache_n_relinquishes_null);
51177 + fscache_stat_unchecked(&fscache_n_relinquishes_null);
51178 _leave(" [no cookie]");
51179 return;
51180 }
51181 @@ -492,7 +492,7 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
51182
51183 /* wait for the cookie to finish being instantiated (or to fail) */
51184 if (test_bit(FSCACHE_COOKIE_CREATING, &cookie->flags)) {
51185 - fscache_stat(&fscache_n_relinquishes_waitcrt);
51186 + fscache_stat_unchecked(&fscache_n_relinquishes_waitcrt);
51187 wait_on_bit(&cookie->flags, FSCACHE_COOKIE_CREATING,
51188 fscache_wait_bit, TASK_UNINTERRUPTIBLE);
51189 }
51190 diff --git a/fs/fscache/internal.h b/fs/fscache/internal.h
51191 index ee38fef..0a326d4 100644
51192 --- a/fs/fscache/internal.h
51193 +++ b/fs/fscache/internal.h
51194 @@ -148,101 +148,101 @@ extern void fscache_proc_cleanup(void);
51195 * stats.c
51196 */
51197 #ifdef CONFIG_FSCACHE_STATS
51198 -extern atomic_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
51199 -extern atomic_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
51200 +extern atomic_unchecked_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
51201 +extern atomic_unchecked_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
51202
51203 -extern atomic_t fscache_n_op_pend;
51204 -extern atomic_t fscache_n_op_run;
51205 -extern atomic_t fscache_n_op_enqueue;
51206 -extern atomic_t fscache_n_op_deferred_release;
51207 -extern atomic_t fscache_n_op_release;
51208 -extern atomic_t fscache_n_op_gc;
51209 -extern atomic_t fscache_n_op_cancelled;
51210 -extern atomic_t fscache_n_op_rejected;
51211 +extern atomic_unchecked_t fscache_n_op_pend;
51212 +extern atomic_unchecked_t fscache_n_op_run;
51213 +extern atomic_unchecked_t fscache_n_op_enqueue;
51214 +extern atomic_unchecked_t fscache_n_op_deferred_release;
51215 +extern atomic_unchecked_t fscache_n_op_release;
51216 +extern atomic_unchecked_t fscache_n_op_gc;
51217 +extern atomic_unchecked_t fscache_n_op_cancelled;
51218 +extern atomic_unchecked_t fscache_n_op_rejected;
51219
51220 -extern atomic_t fscache_n_attr_changed;
51221 -extern atomic_t fscache_n_attr_changed_ok;
51222 -extern atomic_t fscache_n_attr_changed_nobufs;
51223 -extern atomic_t fscache_n_attr_changed_nomem;
51224 -extern atomic_t fscache_n_attr_changed_calls;
51225 +extern atomic_unchecked_t fscache_n_attr_changed;
51226 +extern atomic_unchecked_t fscache_n_attr_changed_ok;
51227 +extern atomic_unchecked_t fscache_n_attr_changed_nobufs;
51228 +extern atomic_unchecked_t fscache_n_attr_changed_nomem;
51229 +extern atomic_unchecked_t fscache_n_attr_changed_calls;
51230
51231 -extern atomic_t fscache_n_allocs;
51232 -extern atomic_t fscache_n_allocs_ok;
51233 -extern atomic_t fscache_n_allocs_wait;
51234 -extern atomic_t fscache_n_allocs_nobufs;
51235 -extern atomic_t fscache_n_allocs_intr;
51236 -extern atomic_t fscache_n_allocs_object_dead;
51237 -extern atomic_t fscache_n_alloc_ops;
51238 -extern atomic_t fscache_n_alloc_op_waits;
51239 +extern atomic_unchecked_t fscache_n_allocs;
51240 +extern atomic_unchecked_t fscache_n_allocs_ok;
51241 +extern atomic_unchecked_t fscache_n_allocs_wait;
51242 +extern atomic_unchecked_t fscache_n_allocs_nobufs;
51243 +extern atomic_unchecked_t fscache_n_allocs_intr;
51244 +extern atomic_unchecked_t fscache_n_allocs_object_dead;
51245 +extern atomic_unchecked_t fscache_n_alloc_ops;
51246 +extern atomic_unchecked_t fscache_n_alloc_op_waits;
51247
51248 -extern atomic_t fscache_n_retrievals;
51249 -extern atomic_t fscache_n_retrievals_ok;
51250 -extern atomic_t fscache_n_retrievals_wait;
51251 -extern atomic_t fscache_n_retrievals_nodata;
51252 -extern atomic_t fscache_n_retrievals_nobufs;
51253 -extern atomic_t fscache_n_retrievals_intr;
51254 -extern atomic_t fscache_n_retrievals_nomem;
51255 -extern atomic_t fscache_n_retrievals_object_dead;
51256 -extern atomic_t fscache_n_retrieval_ops;
51257 -extern atomic_t fscache_n_retrieval_op_waits;
51258 +extern atomic_unchecked_t fscache_n_retrievals;
51259 +extern atomic_unchecked_t fscache_n_retrievals_ok;
51260 +extern atomic_unchecked_t fscache_n_retrievals_wait;
51261 +extern atomic_unchecked_t fscache_n_retrievals_nodata;
51262 +extern atomic_unchecked_t fscache_n_retrievals_nobufs;
51263 +extern atomic_unchecked_t fscache_n_retrievals_intr;
51264 +extern atomic_unchecked_t fscache_n_retrievals_nomem;
51265 +extern atomic_unchecked_t fscache_n_retrievals_object_dead;
51266 +extern atomic_unchecked_t fscache_n_retrieval_ops;
51267 +extern atomic_unchecked_t fscache_n_retrieval_op_waits;
51268
51269 -extern atomic_t fscache_n_stores;
51270 -extern atomic_t fscache_n_stores_ok;
51271 -extern atomic_t fscache_n_stores_again;
51272 -extern atomic_t fscache_n_stores_nobufs;
51273 -extern atomic_t fscache_n_stores_oom;
51274 -extern atomic_t fscache_n_store_ops;
51275 -extern atomic_t fscache_n_store_calls;
51276 -extern atomic_t fscache_n_store_pages;
51277 -extern atomic_t fscache_n_store_radix_deletes;
51278 -extern atomic_t fscache_n_store_pages_over_limit;
51279 +extern atomic_unchecked_t fscache_n_stores;
51280 +extern atomic_unchecked_t fscache_n_stores_ok;
51281 +extern atomic_unchecked_t fscache_n_stores_again;
51282 +extern atomic_unchecked_t fscache_n_stores_nobufs;
51283 +extern atomic_unchecked_t fscache_n_stores_oom;
51284 +extern atomic_unchecked_t fscache_n_store_ops;
51285 +extern atomic_unchecked_t fscache_n_store_calls;
51286 +extern atomic_unchecked_t fscache_n_store_pages;
51287 +extern atomic_unchecked_t fscache_n_store_radix_deletes;
51288 +extern atomic_unchecked_t fscache_n_store_pages_over_limit;
51289
51290 -extern atomic_t fscache_n_store_vmscan_not_storing;
51291 -extern atomic_t fscache_n_store_vmscan_gone;
51292 -extern atomic_t fscache_n_store_vmscan_busy;
51293 -extern atomic_t fscache_n_store_vmscan_cancelled;
51294 -extern atomic_t fscache_n_store_vmscan_wait;
51295 +extern atomic_unchecked_t fscache_n_store_vmscan_not_storing;
51296 +extern atomic_unchecked_t fscache_n_store_vmscan_gone;
51297 +extern atomic_unchecked_t fscache_n_store_vmscan_busy;
51298 +extern atomic_unchecked_t fscache_n_store_vmscan_cancelled;
51299 +extern atomic_unchecked_t fscache_n_store_vmscan_wait;
51300
51301 -extern atomic_t fscache_n_marks;
51302 -extern atomic_t fscache_n_uncaches;
51303 +extern atomic_unchecked_t fscache_n_marks;
51304 +extern atomic_unchecked_t fscache_n_uncaches;
51305
51306 -extern atomic_t fscache_n_acquires;
51307 -extern atomic_t fscache_n_acquires_null;
51308 -extern atomic_t fscache_n_acquires_no_cache;
51309 -extern atomic_t fscache_n_acquires_ok;
51310 -extern atomic_t fscache_n_acquires_nobufs;
51311 -extern atomic_t fscache_n_acquires_oom;
51312 +extern atomic_unchecked_t fscache_n_acquires;
51313 +extern atomic_unchecked_t fscache_n_acquires_null;
51314 +extern atomic_unchecked_t fscache_n_acquires_no_cache;
51315 +extern atomic_unchecked_t fscache_n_acquires_ok;
51316 +extern atomic_unchecked_t fscache_n_acquires_nobufs;
51317 +extern atomic_unchecked_t fscache_n_acquires_oom;
51318
51319 -extern atomic_t fscache_n_invalidates;
51320 -extern atomic_t fscache_n_invalidates_run;
51321 +extern atomic_unchecked_t fscache_n_invalidates;
51322 +extern atomic_unchecked_t fscache_n_invalidates_run;
51323
51324 -extern atomic_t fscache_n_updates;
51325 -extern atomic_t fscache_n_updates_null;
51326 -extern atomic_t fscache_n_updates_run;
51327 +extern atomic_unchecked_t fscache_n_updates;
51328 +extern atomic_unchecked_t fscache_n_updates_null;
51329 +extern atomic_unchecked_t fscache_n_updates_run;
51330
51331 -extern atomic_t fscache_n_relinquishes;
51332 -extern atomic_t fscache_n_relinquishes_null;
51333 -extern atomic_t fscache_n_relinquishes_waitcrt;
51334 -extern atomic_t fscache_n_relinquishes_retire;
51335 +extern atomic_unchecked_t fscache_n_relinquishes;
51336 +extern atomic_unchecked_t fscache_n_relinquishes_null;
51337 +extern atomic_unchecked_t fscache_n_relinquishes_waitcrt;
51338 +extern atomic_unchecked_t fscache_n_relinquishes_retire;
51339
51340 -extern atomic_t fscache_n_cookie_index;
51341 -extern atomic_t fscache_n_cookie_data;
51342 -extern atomic_t fscache_n_cookie_special;
51343 +extern atomic_unchecked_t fscache_n_cookie_index;
51344 +extern atomic_unchecked_t fscache_n_cookie_data;
51345 +extern atomic_unchecked_t fscache_n_cookie_special;
51346
51347 -extern atomic_t fscache_n_object_alloc;
51348 -extern atomic_t fscache_n_object_no_alloc;
51349 -extern atomic_t fscache_n_object_lookups;
51350 -extern atomic_t fscache_n_object_lookups_negative;
51351 -extern atomic_t fscache_n_object_lookups_positive;
51352 -extern atomic_t fscache_n_object_lookups_timed_out;
51353 -extern atomic_t fscache_n_object_created;
51354 -extern atomic_t fscache_n_object_avail;
51355 -extern atomic_t fscache_n_object_dead;
51356 +extern atomic_unchecked_t fscache_n_object_alloc;
51357 +extern atomic_unchecked_t fscache_n_object_no_alloc;
51358 +extern atomic_unchecked_t fscache_n_object_lookups;
51359 +extern atomic_unchecked_t fscache_n_object_lookups_negative;
51360 +extern atomic_unchecked_t fscache_n_object_lookups_positive;
51361 +extern atomic_unchecked_t fscache_n_object_lookups_timed_out;
51362 +extern atomic_unchecked_t fscache_n_object_created;
51363 +extern atomic_unchecked_t fscache_n_object_avail;
51364 +extern atomic_unchecked_t fscache_n_object_dead;
51365
51366 -extern atomic_t fscache_n_checkaux_none;
51367 -extern atomic_t fscache_n_checkaux_okay;
51368 -extern atomic_t fscache_n_checkaux_update;
51369 -extern atomic_t fscache_n_checkaux_obsolete;
51370 +extern atomic_unchecked_t fscache_n_checkaux_none;
51371 +extern atomic_unchecked_t fscache_n_checkaux_okay;
51372 +extern atomic_unchecked_t fscache_n_checkaux_update;
51373 +extern atomic_unchecked_t fscache_n_checkaux_obsolete;
51374
51375 extern atomic_t fscache_n_cop_alloc_object;
51376 extern atomic_t fscache_n_cop_lookup_object;
51377 @@ -267,6 +267,11 @@ static inline void fscache_stat(atomic_t *stat)
51378 atomic_inc(stat);
51379 }
51380
51381 +static inline void fscache_stat_unchecked(atomic_unchecked_t *stat)
51382 +{
51383 + atomic_inc_unchecked(stat);
51384 +}
51385 +
51386 static inline void fscache_stat_d(atomic_t *stat)
51387 {
51388 atomic_dec(stat);
51389 @@ -279,6 +284,7 @@ extern const struct file_operations fscache_stats_fops;
51390
51391 #define __fscache_stat(stat) (NULL)
51392 #define fscache_stat(stat) do {} while (0)
51393 +#define fscache_stat_unchecked(stat) do {} while (0)
51394 #define fscache_stat_d(stat) do {} while (0)
51395 #endif
51396
51397 diff --git a/fs/fscache/object.c b/fs/fscache/object.c
51398 index 50d41c1..10ee117 100644
51399 --- a/fs/fscache/object.c
51400 +++ b/fs/fscache/object.c
51401 @@ -143,7 +143,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
51402 /* Invalidate an object on disk */
51403 case FSCACHE_OBJECT_INVALIDATING:
51404 clear_bit(FSCACHE_OBJECT_EV_INVALIDATE, &object->events);
51405 - fscache_stat(&fscache_n_invalidates_run);
51406 + fscache_stat_unchecked(&fscache_n_invalidates_run);
51407 fscache_stat(&fscache_n_cop_invalidate_object);
51408 fscache_invalidate_object(object);
51409 fscache_stat_d(&fscache_n_cop_invalidate_object);
51410 @@ -153,7 +153,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
51411 /* update the object metadata on disk */
51412 case FSCACHE_OBJECT_UPDATING:
51413 clear_bit(FSCACHE_OBJECT_EV_UPDATE, &object->events);
51414 - fscache_stat(&fscache_n_updates_run);
51415 + fscache_stat_unchecked(&fscache_n_updates_run);
51416 fscache_stat(&fscache_n_cop_update_object);
51417 object->cache->ops->update_object(object);
51418 fscache_stat_d(&fscache_n_cop_update_object);
51419 @@ -242,7 +242,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
51420 spin_lock(&object->lock);
51421 object->state = FSCACHE_OBJECT_DEAD;
51422 spin_unlock(&object->lock);
51423 - fscache_stat(&fscache_n_object_dead);
51424 + fscache_stat_unchecked(&fscache_n_object_dead);
51425 goto terminal_transit;
51426
51427 /* handle the parent cache of this object being withdrawn from
51428 @@ -257,7 +257,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
51429 spin_lock(&object->lock);
51430 object->state = FSCACHE_OBJECT_DEAD;
51431 spin_unlock(&object->lock);
51432 - fscache_stat(&fscache_n_object_dead);
51433 + fscache_stat_unchecked(&fscache_n_object_dead);
51434 goto terminal_transit;
51435
51436 /* complain about the object being woken up once it is
51437 @@ -495,7 +495,7 @@ static void fscache_lookup_object(struct fscache_object *object)
51438 parent->cookie->def->name, cookie->def->name,
51439 object->cache->tag->name);
51440
51441 - fscache_stat(&fscache_n_object_lookups);
51442 + fscache_stat_unchecked(&fscache_n_object_lookups);
51443 fscache_stat(&fscache_n_cop_lookup_object);
51444 ret = object->cache->ops->lookup_object(object);
51445 fscache_stat_d(&fscache_n_cop_lookup_object);
51446 @@ -506,7 +506,7 @@ static void fscache_lookup_object(struct fscache_object *object)
51447 if (ret == -ETIMEDOUT) {
51448 /* probably stuck behind another object, so move this one to
51449 * the back of the queue */
51450 - fscache_stat(&fscache_n_object_lookups_timed_out);
51451 + fscache_stat_unchecked(&fscache_n_object_lookups_timed_out);
51452 set_bit(FSCACHE_OBJECT_EV_REQUEUE, &object->events);
51453 }
51454
51455 @@ -529,7 +529,7 @@ void fscache_object_lookup_negative(struct fscache_object *object)
51456
51457 spin_lock(&object->lock);
51458 if (object->state == FSCACHE_OBJECT_LOOKING_UP) {
51459 - fscache_stat(&fscache_n_object_lookups_negative);
51460 + fscache_stat_unchecked(&fscache_n_object_lookups_negative);
51461
51462 /* transit here to allow write requests to begin stacking up
51463 * and read requests to begin returning ENODATA */
51464 @@ -575,7 +575,7 @@ void fscache_obtained_object(struct fscache_object *object)
51465 * result, in which case there may be data available */
51466 spin_lock(&object->lock);
51467 if (object->state == FSCACHE_OBJECT_LOOKING_UP) {
51468 - fscache_stat(&fscache_n_object_lookups_positive);
51469 + fscache_stat_unchecked(&fscache_n_object_lookups_positive);
51470
51471 clear_bit(FSCACHE_COOKIE_NO_DATA_YET, &cookie->flags);
51472
51473 @@ -589,7 +589,7 @@ void fscache_obtained_object(struct fscache_object *object)
51474 set_bit(FSCACHE_OBJECT_EV_REQUEUE, &object->events);
51475 } else {
51476 ASSERTCMP(object->state, ==, FSCACHE_OBJECT_CREATING);
51477 - fscache_stat(&fscache_n_object_created);
51478 + fscache_stat_unchecked(&fscache_n_object_created);
51479
51480 object->state = FSCACHE_OBJECT_AVAILABLE;
51481 spin_unlock(&object->lock);
51482 @@ -634,7 +634,7 @@ static void fscache_object_available(struct fscache_object *object)
51483 fscache_enqueue_dependents(object);
51484
51485 fscache_hist(fscache_obj_instantiate_histogram, object->lookup_jif);
51486 - fscache_stat(&fscache_n_object_avail);
51487 + fscache_stat_unchecked(&fscache_n_object_avail);
51488
51489 _leave("");
51490 }
51491 @@ -894,7 +894,7 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
51492 enum fscache_checkaux result;
51493
51494 if (!object->cookie->def->check_aux) {
51495 - fscache_stat(&fscache_n_checkaux_none);
51496 + fscache_stat_unchecked(&fscache_n_checkaux_none);
51497 return FSCACHE_CHECKAUX_OKAY;
51498 }
51499
51500 @@ -903,17 +903,17 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
51501 switch (result) {
51502 /* entry okay as is */
51503 case FSCACHE_CHECKAUX_OKAY:
51504 - fscache_stat(&fscache_n_checkaux_okay);
51505 + fscache_stat_unchecked(&fscache_n_checkaux_okay);
51506 break;
51507
51508 /* entry requires update */
51509 case FSCACHE_CHECKAUX_NEEDS_UPDATE:
51510 - fscache_stat(&fscache_n_checkaux_update);
51511 + fscache_stat_unchecked(&fscache_n_checkaux_update);
51512 break;
51513
51514 /* entry requires deletion */
51515 case FSCACHE_CHECKAUX_OBSOLETE:
51516 - fscache_stat(&fscache_n_checkaux_obsolete);
51517 + fscache_stat_unchecked(&fscache_n_checkaux_obsolete);
51518 break;
51519
51520 default:
51521 diff --git a/fs/fscache/operation.c b/fs/fscache/operation.c
51522 index 762a9ec..2023284 100644
51523 --- a/fs/fscache/operation.c
51524 +++ b/fs/fscache/operation.c
51525 @@ -17,7 +17,7 @@
51526 #include <linux/slab.h>
51527 #include "internal.h"
51528
51529 -atomic_t fscache_op_debug_id;
51530 +atomic_unchecked_t fscache_op_debug_id;
51531 EXPORT_SYMBOL(fscache_op_debug_id);
51532
51533 /**
51534 @@ -39,7 +39,7 @@ void fscache_enqueue_operation(struct fscache_operation *op)
51535 ASSERTCMP(atomic_read(&op->usage), >, 0);
51536 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_IN_PROGRESS);
51537
51538 - fscache_stat(&fscache_n_op_enqueue);
51539 + fscache_stat_unchecked(&fscache_n_op_enqueue);
51540 switch (op->flags & FSCACHE_OP_TYPE) {
51541 case FSCACHE_OP_ASYNC:
51542 _debug("queue async");
51543 @@ -73,7 +73,7 @@ static void fscache_run_op(struct fscache_object *object,
51544 wake_up_bit(&op->flags, FSCACHE_OP_WAITING);
51545 if (op->processor)
51546 fscache_enqueue_operation(op);
51547 - fscache_stat(&fscache_n_op_run);
51548 + fscache_stat_unchecked(&fscache_n_op_run);
51549 }
51550
51551 /*
51552 @@ -105,11 +105,11 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
51553 if (object->n_in_progress > 0) {
51554 atomic_inc(&op->usage);
51555 list_add_tail(&op->pend_link, &object->pending_ops);
51556 - fscache_stat(&fscache_n_op_pend);
51557 + fscache_stat_unchecked(&fscache_n_op_pend);
51558 } else if (!list_empty(&object->pending_ops)) {
51559 atomic_inc(&op->usage);
51560 list_add_tail(&op->pend_link, &object->pending_ops);
51561 - fscache_stat(&fscache_n_op_pend);
51562 + fscache_stat_unchecked(&fscache_n_op_pend);
51563 fscache_start_operations(object);
51564 } else {
51565 ASSERTCMP(object->n_in_progress, ==, 0);
51566 @@ -125,7 +125,7 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
51567 object->n_exclusive++; /* reads and writes must wait */
51568 atomic_inc(&op->usage);
51569 list_add_tail(&op->pend_link, &object->pending_ops);
51570 - fscache_stat(&fscache_n_op_pend);
51571 + fscache_stat_unchecked(&fscache_n_op_pend);
51572 ret = 0;
51573 } else {
51574 /* If we're in any other state, there must have been an I/O
51575 @@ -215,11 +215,11 @@ int fscache_submit_op(struct fscache_object *object,
51576 if (object->n_exclusive > 0) {
51577 atomic_inc(&op->usage);
51578 list_add_tail(&op->pend_link, &object->pending_ops);
51579 - fscache_stat(&fscache_n_op_pend);
51580 + fscache_stat_unchecked(&fscache_n_op_pend);
51581 } else if (!list_empty(&object->pending_ops)) {
51582 atomic_inc(&op->usage);
51583 list_add_tail(&op->pend_link, &object->pending_ops);
51584 - fscache_stat(&fscache_n_op_pend);
51585 + fscache_stat_unchecked(&fscache_n_op_pend);
51586 fscache_start_operations(object);
51587 } else {
51588 ASSERTCMP(object->n_exclusive, ==, 0);
51589 @@ -231,12 +231,12 @@ int fscache_submit_op(struct fscache_object *object,
51590 object->n_ops++;
51591 atomic_inc(&op->usage);
51592 list_add_tail(&op->pend_link, &object->pending_ops);
51593 - fscache_stat(&fscache_n_op_pend);
51594 + fscache_stat_unchecked(&fscache_n_op_pend);
51595 ret = 0;
51596 } else if (object->state == FSCACHE_OBJECT_DYING ||
51597 object->state == FSCACHE_OBJECT_LC_DYING ||
51598 object->state == FSCACHE_OBJECT_WITHDRAWING) {
51599 - fscache_stat(&fscache_n_op_rejected);
51600 + fscache_stat_unchecked(&fscache_n_op_rejected);
51601 op->state = FSCACHE_OP_ST_CANCELLED;
51602 ret = -ENOBUFS;
51603 } else if (!test_bit(FSCACHE_IOERROR, &object->cache->flags)) {
51604 @@ -315,7 +315,7 @@ int fscache_cancel_op(struct fscache_operation *op,
51605 ret = -EBUSY;
51606 if (op->state == FSCACHE_OP_ST_PENDING) {
51607 ASSERT(!list_empty(&op->pend_link));
51608 - fscache_stat(&fscache_n_op_cancelled);
51609 + fscache_stat_unchecked(&fscache_n_op_cancelled);
51610 list_del_init(&op->pend_link);
51611 if (do_cancel)
51612 do_cancel(op);
51613 @@ -347,7 +347,7 @@ void fscache_cancel_all_ops(struct fscache_object *object)
51614 while (!list_empty(&object->pending_ops)) {
51615 op = list_entry(object->pending_ops.next,
51616 struct fscache_operation, pend_link);
51617 - fscache_stat(&fscache_n_op_cancelled);
51618 + fscache_stat_unchecked(&fscache_n_op_cancelled);
51619 list_del_init(&op->pend_link);
51620
51621 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_PENDING);
51622 @@ -419,7 +419,7 @@ void fscache_put_operation(struct fscache_operation *op)
51623 op->state, ==, FSCACHE_OP_ST_CANCELLED);
51624 op->state = FSCACHE_OP_ST_DEAD;
51625
51626 - fscache_stat(&fscache_n_op_release);
51627 + fscache_stat_unchecked(&fscache_n_op_release);
51628
51629 if (op->release) {
51630 op->release(op);
51631 @@ -442,7 +442,7 @@ void fscache_put_operation(struct fscache_operation *op)
51632 * lock, and defer it otherwise */
51633 if (!spin_trylock(&object->lock)) {
51634 _debug("defer put");
51635 - fscache_stat(&fscache_n_op_deferred_release);
51636 + fscache_stat_unchecked(&fscache_n_op_deferred_release);
51637
51638 cache = object->cache;
51639 spin_lock(&cache->op_gc_list_lock);
51640 @@ -495,7 +495,7 @@ void fscache_operation_gc(struct work_struct *work)
51641
51642 _debug("GC DEFERRED REL OBJ%x OP%x",
51643 object->debug_id, op->debug_id);
51644 - fscache_stat(&fscache_n_op_gc);
51645 + fscache_stat_unchecked(&fscache_n_op_gc);
51646
51647 ASSERTCMP(atomic_read(&op->usage), ==, 0);
51648 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_DEAD);
51649 diff --git a/fs/fscache/page.c b/fs/fscache/page.c
51650 index ff000e5..c44ec6d 100644
51651 --- a/fs/fscache/page.c
51652 +++ b/fs/fscache/page.c
51653 @@ -61,7 +61,7 @@ try_again:
51654 val = radix_tree_lookup(&cookie->stores, page->index);
51655 if (!val) {
51656 rcu_read_unlock();
51657 - fscache_stat(&fscache_n_store_vmscan_not_storing);
51658 + fscache_stat_unchecked(&fscache_n_store_vmscan_not_storing);
51659 __fscache_uncache_page(cookie, page);
51660 return true;
51661 }
51662 @@ -91,11 +91,11 @@ try_again:
51663 spin_unlock(&cookie->stores_lock);
51664
51665 if (xpage) {
51666 - fscache_stat(&fscache_n_store_vmscan_cancelled);
51667 - fscache_stat(&fscache_n_store_radix_deletes);
51668 + fscache_stat_unchecked(&fscache_n_store_vmscan_cancelled);
51669 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
51670 ASSERTCMP(xpage, ==, page);
51671 } else {
51672 - fscache_stat(&fscache_n_store_vmscan_gone);
51673 + fscache_stat_unchecked(&fscache_n_store_vmscan_gone);
51674 }
51675
51676 wake_up_bit(&cookie->flags, 0);
51677 @@ -110,11 +110,11 @@ page_busy:
51678 * sleeping on memory allocation, so we may need to impose a timeout
51679 * too. */
51680 if (!(gfp & __GFP_WAIT)) {
51681 - fscache_stat(&fscache_n_store_vmscan_busy);
51682 + fscache_stat_unchecked(&fscache_n_store_vmscan_busy);
51683 return false;
51684 }
51685
51686 - fscache_stat(&fscache_n_store_vmscan_wait);
51687 + fscache_stat_unchecked(&fscache_n_store_vmscan_wait);
51688 __fscache_wait_on_page_write(cookie, page);
51689 gfp &= ~__GFP_WAIT;
51690 goto try_again;
51691 @@ -140,7 +140,7 @@ static void fscache_end_page_write(struct fscache_object *object,
51692 FSCACHE_COOKIE_STORING_TAG);
51693 if (!radix_tree_tag_get(&cookie->stores, page->index,
51694 FSCACHE_COOKIE_PENDING_TAG)) {
51695 - fscache_stat(&fscache_n_store_radix_deletes);
51696 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
51697 xpage = radix_tree_delete(&cookie->stores, page->index);
51698 }
51699 spin_unlock(&cookie->stores_lock);
51700 @@ -161,7 +161,7 @@ static void fscache_attr_changed_op(struct fscache_operation *op)
51701
51702 _enter("{OBJ%x OP%x}", object->debug_id, op->debug_id);
51703
51704 - fscache_stat(&fscache_n_attr_changed_calls);
51705 + fscache_stat_unchecked(&fscache_n_attr_changed_calls);
51706
51707 if (fscache_object_is_active(object)) {
51708 fscache_stat(&fscache_n_cop_attr_changed);
51709 @@ -187,11 +187,11 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
51710
51711 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
51712
51713 - fscache_stat(&fscache_n_attr_changed);
51714 + fscache_stat_unchecked(&fscache_n_attr_changed);
51715
51716 op = kzalloc(sizeof(*op), GFP_KERNEL);
51717 if (!op) {
51718 - fscache_stat(&fscache_n_attr_changed_nomem);
51719 + fscache_stat_unchecked(&fscache_n_attr_changed_nomem);
51720 _leave(" = -ENOMEM");
51721 return -ENOMEM;
51722 }
51723 @@ -209,7 +209,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
51724 if (fscache_submit_exclusive_op(object, op) < 0)
51725 goto nobufs;
51726 spin_unlock(&cookie->lock);
51727 - fscache_stat(&fscache_n_attr_changed_ok);
51728 + fscache_stat_unchecked(&fscache_n_attr_changed_ok);
51729 fscache_put_operation(op);
51730 _leave(" = 0");
51731 return 0;
51732 @@ -217,7 +217,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
51733 nobufs:
51734 spin_unlock(&cookie->lock);
51735 kfree(op);
51736 - fscache_stat(&fscache_n_attr_changed_nobufs);
51737 + fscache_stat_unchecked(&fscache_n_attr_changed_nobufs);
51738 _leave(" = %d", -ENOBUFS);
51739 return -ENOBUFS;
51740 }
51741 @@ -255,7 +255,7 @@ static struct fscache_retrieval *fscache_alloc_retrieval(
51742 /* allocate a retrieval operation and attempt to submit it */
51743 op = kzalloc(sizeof(*op), GFP_NOIO);
51744 if (!op) {
51745 - fscache_stat(&fscache_n_retrievals_nomem);
51746 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
51747 return NULL;
51748 }
51749
51750 @@ -283,13 +283,13 @@ static int fscache_wait_for_deferred_lookup(struct fscache_cookie *cookie)
51751 return 0;
51752 }
51753
51754 - fscache_stat(&fscache_n_retrievals_wait);
51755 + fscache_stat_unchecked(&fscache_n_retrievals_wait);
51756
51757 jif = jiffies;
51758 if (wait_on_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP,
51759 fscache_wait_bit_interruptible,
51760 TASK_INTERRUPTIBLE) != 0) {
51761 - fscache_stat(&fscache_n_retrievals_intr);
51762 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
51763 _leave(" = -ERESTARTSYS");
51764 return -ERESTARTSYS;
51765 }
51766 @@ -318,8 +318,8 @@ static void fscache_do_cancel_retrieval(struct fscache_operation *_op)
51767 */
51768 static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
51769 struct fscache_retrieval *op,
51770 - atomic_t *stat_op_waits,
51771 - atomic_t *stat_object_dead)
51772 + atomic_unchecked_t *stat_op_waits,
51773 + atomic_unchecked_t *stat_object_dead)
51774 {
51775 int ret;
51776
51777 @@ -327,7 +327,7 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
51778 goto check_if_dead;
51779
51780 _debug(">>> WT");
51781 - fscache_stat(stat_op_waits);
51782 + fscache_stat_unchecked(stat_op_waits);
51783 if (wait_on_bit(&op->op.flags, FSCACHE_OP_WAITING,
51784 fscache_wait_bit_interruptible,
51785 TASK_INTERRUPTIBLE) != 0) {
51786 @@ -344,14 +344,14 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
51787
51788 check_if_dead:
51789 if (op->op.state == FSCACHE_OP_ST_CANCELLED) {
51790 - fscache_stat(stat_object_dead);
51791 + fscache_stat_unchecked(stat_object_dead);
51792 _leave(" = -ENOBUFS [cancelled]");
51793 return -ENOBUFS;
51794 }
51795 if (unlikely(fscache_object_is_dead(object))) {
51796 pr_err("%s() = -ENOBUFS [obj dead %d]\n", __func__, op->op.state);
51797 fscache_cancel_op(&op->op, fscache_do_cancel_retrieval);
51798 - fscache_stat(stat_object_dead);
51799 + fscache_stat_unchecked(stat_object_dead);
51800 return -ENOBUFS;
51801 }
51802 return 0;
51803 @@ -378,7 +378,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
51804
51805 _enter("%p,%p,,,", cookie, page);
51806
51807 - fscache_stat(&fscache_n_retrievals);
51808 + fscache_stat_unchecked(&fscache_n_retrievals);
51809
51810 if (hlist_empty(&cookie->backing_objects))
51811 goto nobufs;
51812 @@ -417,7 +417,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
51813 goto nobufs_unlock_dec;
51814 spin_unlock(&cookie->lock);
51815
51816 - fscache_stat(&fscache_n_retrieval_ops);
51817 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
51818
51819 /* pin the netfs read context in case we need to do the actual netfs
51820 * read because we've encountered a cache read failure */
51821 @@ -447,15 +447,15 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
51822
51823 error:
51824 if (ret == -ENOMEM)
51825 - fscache_stat(&fscache_n_retrievals_nomem);
51826 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
51827 else if (ret == -ERESTARTSYS)
51828 - fscache_stat(&fscache_n_retrievals_intr);
51829 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
51830 else if (ret == -ENODATA)
51831 - fscache_stat(&fscache_n_retrievals_nodata);
51832 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
51833 else if (ret < 0)
51834 - fscache_stat(&fscache_n_retrievals_nobufs);
51835 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
51836 else
51837 - fscache_stat(&fscache_n_retrievals_ok);
51838 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
51839
51840 fscache_put_retrieval(op);
51841 _leave(" = %d", ret);
51842 @@ -467,7 +467,7 @@ nobufs_unlock:
51843 spin_unlock(&cookie->lock);
51844 kfree(op);
51845 nobufs:
51846 - fscache_stat(&fscache_n_retrievals_nobufs);
51847 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
51848 _leave(" = -ENOBUFS");
51849 return -ENOBUFS;
51850 }
51851 @@ -505,7 +505,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
51852
51853 _enter("%p,,%d,,,", cookie, *nr_pages);
51854
51855 - fscache_stat(&fscache_n_retrievals);
51856 + fscache_stat_unchecked(&fscache_n_retrievals);
51857
51858 if (hlist_empty(&cookie->backing_objects))
51859 goto nobufs;
51860 @@ -541,7 +541,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
51861 goto nobufs_unlock_dec;
51862 spin_unlock(&cookie->lock);
51863
51864 - fscache_stat(&fscache_n_retrieval_ops);
51865 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
51866
51867 /* pin the netfs read context in case we need to do the actual netfs
51868 * read because we've encountered a cache read failure */
51869 @@ -571,15 +571,15 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
51870
51871 error:
51872 if (ret == -ENOMEM)
51873 - fscache_stat(&fscache_n_retrievals_nomem);
51874 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
51875 else if (ret == -ERESTARTSYS)
51876 - fscache_stat(&fscache_n_retrievals_intr);
51877 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
51878 else if (ret == -ENODATA)
51879 - fscache_stat(&fscache_n_retrievals_nodata);
51880 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
51881 else if (ret < 0)
51882 - fscache_stat(&fscache_n_retrievals_nobufs);
51883 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
51884 else
51885 - fscache_stat(&fscache_n_retrievals_ok);
51886 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
51887
51888 fscache_put_retrieval(op);
51889 _leave(" = %d", ret);
51890 @@ -591,7 +591,7 @@ nobufs_unlock:
51891 spin_unlock(&cookie->lock);
51892 kfree(op);
51893 nobufs:
51894 - fscache_stat(&fscache_n_retrievals_nobufs);
51895 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
51896 _leave(" = -ENOBUFS");
51897 return -ENOBUFS;
51898 }
51899 @@ -615,7 +615,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
51900
51901 _enter("%p,%p,,,", cookie, page);
51902
51903 - fscache_stat(&fscache_n_allocs);
51904 + fscache_stat_unchecked(&fscache_n_allocs);
51905
51906 if (hlist_empty(&cookie->backing_objects))
51907 goto nobufs;
51908 @@ -647,7 +647,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
51909 goto nobufs_unlock;
51910 spin_unlock(&cookie->lock);
51911
51912 - fscache_stat(&fscache_n_alloc_ops);
51913 + fscache_stat_unchecked(&fscache_n_alloc_ops);
51914
51915 ret = fscache_wait_for_retrieval_activation(
51916 object, op,
51917 @@ -663,11 +663,11 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
51918
51919 error:
51920 if (ret == -ERESTARTSYS)
51921 - fscache_stat(&fscache_n_allocs_intr);
51922 + fscache_stat_unchecked(&fscache_n_allocs_intr);
51923 else if (ret < 0)
51924 - fscache_stat(&fscache_n_allocs_nobufs);
51925 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
51926 else
51927 - fscache_stat(&fscache_n_allocs_ok);
51928 + fscache_stat_unchecked(&fscache_n_allocs_ok);
51929
51930 fscache_put_retrieval(op);
51931 _leave(" = %d", ret);
51932 @@ -677,7 +677,7 @@ nobufs_unlock:
51933 spin_unlock(&cookie->lock);
51934 kfree(op);
51935 nobufs:
51936 - fscache_stat(&fscache_n_allocs_nobufs);
51937 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
51938 _leave(" = -ENOBUFS");
51939 return -ENOBUFS;
51940 }
51941 @@ -736,7 +736,7 @@ static void fscache_write_op(struct fscache_operation *_op)
51942
51943 spin_lock(&cookie->stores_lock);
51944
51945 - fscache_stat(&fscache_n_store_calls);
51946 + fscache_stat_unchecked(&fscache_n_store_calls);
51947
51948 /* find a page to store */
51949 page = NULL;
51950 @@ -747,7 +747,7 @@ static void fscache_write_op(struct fscache_operation *_op)
51951 page = results[0];
51952 _debug("gang %d [%lx]", n, page->index);
51953 if (page->index > op->store_limit) {
51954 - fscache_stat(&fscache_n_store_pages_over_limit);
51955 + fscache_stat_unchecked(&fscache_n_store_pages_over_limit);
51956 goto superseded;
51957 }
51958
51959 @@ -759,7 +759,7 @@ static void fscache_write_op(struct fscache_operation *_op)
51960 spin_unlock(&cookie->stores_lock);
51961 spin_unlock(&object->lock);
51962
51963 - fscache_stat(&fscache_n_store_pages);
51964 + fscache_stat_unchecked(&fscache_n_store_pages);
51965 fscache_stat(&fscache_n_cop_write_page);
51966 ret = object->cache->ops->write_page(op, page);
51967 fscache_stat_d(&fscache_n_cop_write_page);
51968 @@ -860,7 +860,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
51969 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
51970 ASSERT(PageFsCache(page));
51971
51972 - fscache_stat(&fscache_n_stores);
51973 + fscache_stat_unchecked(&fscache_n_stores);
51974
51975 if (test_bit(FSCACHE_COOKIE_INVALIDATING, &cookie->flags)) {
51976 _leave(" = -ENOBUFS [invalidating]");
51977 @@ -916,7 +916,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
51978 spin_unlock(&cookie->stores_lock);
51979 spin_unlock(&object->lock);
51980
51981 - op->op.debug_id = atomic_inc_return(&fscache_op_debug_id);
51982 + op->op.debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
51983 op->store_limit = object->store_limit;
51984
51985 if (fscache_submit_op(object, &op->op) < 0)
51986 @@ -924,8 +924,8 @@ int __fscache_write_page(struct fscache_cookie *cookie,
51987
51988 spin_unlock(&cookie->lock);
51989 radix_tree_preload_end();
51990 - fscache_stat(&fscache_n_store_ops);
51991 - fscache_stat(&fscache_n_stores_ok);
51992 + fscache_stat_unchecked(&fscache_n_store_ops);
51993 + fscache_stat_unchecked(&fscache_n_stores_ok);
51994
51995 /* the work queue now carries its own ref on the object */
51996 fscache_put_operation(&op->op);
51997 @@ -933,14 +933,14 @@ int __fscache_write_page(struct fscache_cookie *cookie,
51998 return 0;
51999
52000 already_queued:
52001 - fscache_stat(&fscache_n_stores_again);
52002 + fscache_stat_unchecked(&fscache_n_stores_again);
52003 already_pending:
52004 spin_unlock(&cookie->stores_lock);
52005 spin_unlock(&object->lock);
52006 spin_unlock(&cookie->lock);
52007 radix_tree_preload_end();
52008 kfree(op);
52009 - fscache_stat(&fscache_n_stores_ok);
52010 + fscache_stat_unchecked(&fscache_n_stores_ok);
52011 _leave(" = 0");
52012 return 0;
52013
52014 @@ -959,14 +959,14 @@ nobufs:
52015 spin_unlock(&cookie->lock);
52016 radix_tree_preload_end();
52017 kfree(op);
52018 - fscache_stat(&fscache_n_stores_nobufs);
52019 + fscache_stat_unchecked(&fscache_n_stores_nobufs);
52020 _leave(" = -ENOBUFS");
52021 return -ENOBUFS;
52022
52023 nomem_free:
52024 kfree(op);
52025 nomem:
52026 - fscache_stat(&fscache_n_stores_oom);
52027 + fscache_stat_unchecked(&fscache_n_stores_oom);
52028 _leave(" = -ENOMEM");
52029 return -ENOMEM;
52030 }
52031 @@ -984,7 +984,7 @@ void __fscache_uncache_page(struct fscache_cookie *cookie, struct page *page)
52032 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
52033 ASSERTCMP(page, !=, NULL);
52034
52035 - fscache_stat(&fscache_n_uncaches);
52036 + fscache_stat_unchecked(&fscache_n_uncaches);
52037
52038 /* cache withdrawal may beat us to it */
52039 if (!PageFsCache(page))
52040 @@ -1035,7 +1035,7 @@ void fscache_mark_page_cached(struct fscache_retrieval *op, struct page *page)
52041 struct fscache_cookie *cookie = op->op.object->cookie;
52042
52043 #ifdef CONFIG_FSCACHE_STATS
52044 - atomic_inc(&fscache_n_marks);
52045 + atomic_inc_unchecked(&fscache_n_marks);
52046 #endif
52047
52048 _debug("- mark %p{%lx}", page, page->index);
52049 diff --git a/fs/fscache/stats.c b/fs/fscache/stats.c
52050 index 40d13c7..ddf52b9 100644
52051 --- a/fs/fscache/stats.c
52052 +++ b/fs/fscache/stats.c
52053 @@ -18,99 +18,99 @@
52054 /*
52055 * operation counters
52056 */
52057 -atomic_t fscache_n_op_pend;
52058 -atomic_t fscache_n_op_run;
52059 -atomic_t fscache_n_op_enqueue;
52060 -atomic_t fscache_n_op_requeue;
52061 -atomic_t fscache_n_op_deferred_release;
52062 -atomic_t fscache_n_op_release;
52063 -atomic_t fscache_n_op_gc;
52064 -atomic_t fscache_n_op_cancelled;
52065 -atomic_t fscache_n_op_rejected;
52066 +atomic_unchecked_t fscache_n_op_pend;
52067 +atomic_unchecked_t fscache_n_op_run;
52068 +atomic_unchecked_t fscache_n_op_enqueue;
52069 +atomic_unchecked_t fscache_n_op_requeue;
52070 +atomic_unchecked_t fscache_n_op_deferred_release;
52071 +atomic_unchecked_t fscache_n_op_release;
52072 +atomic_unchecked_t fscache_n_op_gc;
52073 +atomic_unchecked_t fscache_n_op_cancelled;
52074 +atomic_unchecked_t fscache_n_op_rejected;
52075
52076 -atomic_t fscache_n_attr_changed;
52077 -atomic_t fscache_n_attr_changed_ok;
52078 -atomic_t fscache_n_attr_changed_nobufs;
52079 -atomic_t fscache_n_attr_changed_nomem;
52080 -atomic_t fscache_n_attr_changed_calls;
52081 +atomic_unchecked_t fscache_n_attr_changed;
52082 +atomic_unchecked_t fscache_n_attr_changed_ok;
52083 +atomic_unchecked_t fscache_n_attr_changed_nobufs;
52084 +atomic_unchecked_t fscache_n_attr_changed_nomem;
52085 +atomic_unchecked_t fscache_n_attr_changed_calls;
52086
52087 -atomic_t fscache_n_allocs;
52088 -atomic_t fscache_n_allocs_ok;
52089 -atomic_t fscache_n_allocs_wait;
52090 -atomic_t fscache_n_allocs_nobufs;
52091 -atomic_t fscache_n_allocs_intr;
52092 -atomic_t fscache_n_allocs_object_dead;
52093 -atomic_t fscache_n_alloc_ops;
52094 -atomic_t fscache_n_alloc_op_waits;
52095 +atomic_unchecked_t fscache_n_allocs;
52096 +atomic_unchecked_t fscache_n_allocs_ok;
52097 +atomic_unchecked_t fscache_n_allocs_wait;
52098 +atomic_unchecked_t fscache_n_allocs_nobufs;
52099 +atomic_unchecked_t fscache_n_allocs_intr;
52100 +atomic_unchecked_t fscache_n_allocs_object_dead;
52101 +atomic_unchecked_t fscache_n_alloc_ops;
52102 +atomic_unchecked_t fscache_n_alloc_op_waits;
52103
52104 -atomic_t fscache_n_retrievals;
52105 -atomic_t fscache_n_retrievals_ok;
52106 -atomic_t fscache_n_retrievals_wait;
52107 -atomic_t fscache_n_retrievals_nodata;
52108 -atomic_t fscache_n_retrievals_nobufs;
52109 -atomic_t fscache_n_retrievals_intr;
52110 -atomic_t fscache_n_retrievals_nomem;
52111 -atomic_t fscache_n_retrievals_object_dead;
52112 -atomic_t fscache_n_retrieval_ops;
52113 -atomic_t fscache_n_retrieval_op_waits;
52114 +atomic_unchecked_t fscache_n_retrievals;
52115 +atomic_unchecked_t fscache_n_retrievals_ok;
52116 +atomic_unchecked_t fscache_n_retrievals_wait;
52117 +atomic_unchecked_t fscache_n_retrievals_nodata;
52118 +atomic_unchecked_t fscache_n_retrievals_nobufs;
52119 +atomic_unchecked_t fscache_n_retrievals_intr;
52120 +atomic_unchecked_t fscache_n_retrievals_nomem;
52121 +atomic_unchecked_t fscache_n_retrievals_object_dead;
52122 +atomic_unchecked_t fscache_n_retrieval_ops;
52123 +atomic_unchecked_t fscache_n_retrieval_op_waits;
52124
52125 -atomic_t fscache_n_stores;
52126 -atomic_t fscache_n_stores_ok;
52127 -atomic_t fscache_n_stores_again;
52128 -atomic_t fscache_n_stores_nobufs;
52129 -atomic_t fscache_n_stores_oom;
52130 -atomic_t fscache_n_store_ops;
52131 -atomic_t fscache_n_store_calls;
52132 -atomic_t fscache_n_store_pages;
52133 -atomic_t fscache_n_store_radix_deletes;
52134 -atomic_t fscache_n_store_pages_over_limit;
52135 +atomic_unchecked_t fscache_n_stores;
52136 +atomic_unchecked_t fscache_n_stores_ok;
52137 +atomic_unchecked_t fscache_n_stores_again;
52138 +atomic_unchecked_t fscache_n_stores_nobufs;
52139 +atomic_unchecked_t fscache_n_stores_oom;
52140 +atomic_unchecked_t fscache_n_store_ops;
52141 +atomic_unchecked_t fscache_n_store_calls;
52142 +atomic_unchecked_t fscache_n_store_pages;
52143 +atomic_unchecked_t fscache_n_store_radix_deletes;
52144 +atomic_unchecked_t fscache_n_store_pages_over_limit;
52145
52146 -atomic_t fscache_n_store_vmscan_not_storing;
52147 -atomic_t fscache_n_store_vmscan_gone;
52148 -atomic_t fscache_n_store_vmscan_busy;
52149 -atomic_t fscache_n_store_vmscan_cancelled;
52150 -atomic_t fscache_n_store_vmscan_wait;
52151 +atomic_unchecked_t fscache_n_store_vmscan_not_storing;
52152 +atomic_unchecked_t fscache_n_store_vmscan_gone;
52153 +atomic_unchecked_t fscache_n_store_vmscan_busy;
52154 +atomic_unchecked_t fscache_n_store_vmscan_cancelled;
52155 +atomic_unchecked_t fscache_n_store_vmscan_wait;
52156
52157 -atomic_t fscache_n_marks;
52158 -atomic_t fscache_n_uncaches;
52159 +atomic_unchecked_t fscache_n_marks;
52160 +atomic_unchecked_t fscache_n_uncaches;
52161
52162 -atomic_t fscache_n_acquires;
52163 -atomic_t fscache_n_acquires_null;
52164 -atomic_t fscache_n_acquires_no_cache;
52165 -atomic_t fscache_n_acquires_ok;
52166 -atomic_t fscache_n_acquires_nobufs;
52167 -atomic_t fscache_n_acquires_oom;
52168 +atomic_unchecked_t fscache_n_acquires;
52169 +atomic_unchecked_t fscache_n_acquires_null;
52170 +atomic_unchecked_t fscache_n_acquires_no_cache;
52171 +atomic_unchecked_t fscache_n_acquires_ok;
52172 +atomic_unchecked_t fscache_n_acquires_nobufs;
52173 +atomic_unchecked_t fscache_n_acquires_oom;
52174
52175 -atomic_t fscache_n_invalidates;
52176 -atomic_t fscache_n_invalidates_run;
52177 +atomic_unchecked_t fscache_n_invalidates;
52178 +atomic_unchecked_t fscache_n_invalidates_run;
52179
52180 -atomic_t fscache_n_updates;
52181 -atomic_t fscache_n_updates_null;
52182 -atomic_t fscache_n_updates_run;
52183 +atomic_unchecked_t fscache_n_updates;
52184 +atomic_unchecked_t fscache_n_updates_null;
52185 +atomic_unchecked_t fscache_n_updates_run;
52186
52187 -atomic_t fscache_n_relinquishes;
52188 -atomic_t fscache_n_relinquishes_null;
52189 -atomic_t fscache_n_relinquishes_waitcrt;
52190 -atomic_t fscache_n_relinquishes_retire;
52191 +atomic_unchecked_t fscache_n_relinquishes;
52192 +atomic_unchecked_t fscache_n_relinquishes_null;
52193 +atomic_unchecked_t fscache_n_relinquishes_waitcrt;
52194 +atomic_unchecked_t fscache_n_relinquishes_retire;
52195
52196 -atomic_t fscache_n_cookie_index;
52197 -atomic_t fscache_n_cookie_data;
52198 -atomic_t fscache_n_cookie_special;
52199 +atomic_unchecked_t fscache_n_cookie_index;
52200 +atomic_unchecked_t fscache_n_cookie_data;
52201 +atomic_unchecked_t fscache_n_cookie_special;
52202
52203 -atomic_t fscache_n_object_alloc;
52204 -atomic_t fscache_n_object_no_alloc;
52205 -atomic_t fscache_n_object_lookups;
52206 -atomic_t fscache_n_object_lookups_negative;
52207 -atomic_t fscache_n_object_lookups_positive;
52208 -atomic_t fscache_n_object_lookups_timed_out;
52209 -atomic_t fscache_n_object_created;
52210 -atomic_t fscache_n_object_avail;
52211 -atomic_t fscache_n_object_dead;
52212 +atomic_unchecked_t fscache_n_object_alloc;
52213 +atomic_unchecked_t fscache_n_object_no_alloc;
52214 +atomic_unchecked_t fscache_n_object_lookups;
52215 +atomic_unchecked_t fscache_n_object_lookups_negative;
52216 +atomic_unchecked_t fscache_n_object_lookups_positive;
52217 +atomic_unchecked_t fscache_n_object_lookups_timed_out;
52218 +atomic_unchecked_t fscache_n_object_created;
52219 +atomic_unchecked_t fscache_n_object_avail;
52220 +atomic_unchecked_t fscache_n_object_dead;
52221
52222 -atomic_t fscache_n_checkaux_none;
52223 -atomic_t fscache_n_checkaux_okay;
52224 -atomic_t fscache_n_checkaux_update;
52225 -atomic_t fscache_n_checkaux_obsolete;
52226 +atomic_unchecked_t fscache_n_checkaux_none;
52227 +atomic_unchecked_t fscache_n_checkaux_okay;
52228 +atomic_unchecked_t fscache_n_checkaux_update;
52229 +atomic_unchecked_t fscache_n_checkaux_obsolete;
52230
52231 atomic_t fscache_n_cop_alloc_object;
52232 atomic_t fscache_n_cop_lookup_object;
52233 @@ -138,118 +138,118 @@ static int fscache_stats_show(struct seq_file *m, void *v)
52234 seq_puts(m, "FS-Cache statistics\n");
52235
52236 seq_printf(m, "Cookies: idx=%u dat=%u spc=%u\n",
52237 - atomic_read(&fscache_n_cookie_index),
52238 - atomic_read(&fscache_n_cookie_data),
52239 - atomic_read(&fscache_n_cookie_special));
52240 + atomic_read_unchecked(&fscache_n_cookie_index),
52241 + atomic_read_unchecked(&fscache_n_cookie_data),
52242 + atomic_read_unchecked(&fscache_n_cookie_special));
52243
52244 seq_printf(m, "Objects: alc=%u nal=%u avl=%u ded=%u\n",
52245 - atomic_read(&fscache_n_object_alloc),
52246 - atomic_read(&fscache_n_object_no_alloc),
52247 - atomic_read(&fscache_n_object_avail),
52248 - atomic_read(&fscache_n_object_dead));
52249 + atomic_read_unchecked(&fscache_n_object_alloc),
52250 + atomic_read_unchecked(&fscache_n_object_no_alloc),
52251 + atomic_read_unchecked(&fscache_n_object_avail),
52252 + atomic_read_unchecked(&fscache_n_object_dead));
52253 seq_printf(m, "ChkAux : non=%u ok=%u upd=%u obs=%u\n",
52254 - atomic_read(&fscache_n_checkaux_none),
52255 - atomic_read(&fscache_n_checkaux_okay),
52256 - atomic_read(&fscache_n_checkaux_update),
52257 - atomic_read(&fscache_n_checkaux_obsolete));
52258 + atomic_read_unchecked(&fscache_n_checkaux_none),
52259 + atomic_read_unchecked(&fscache_n_checkaux_okay),
52260 + atomic_read_unchecked(&fscache_n_checkaux_update),
52261 + atomic_read_unchecked(&fscache_n_checkaux_obsolete));
52262
52263 seq_printf(m, "Pages : mrk=%u unc=%u\n",
52264 - atomic_read(&fscache_n_marks),
52265 - atomic_read(&fscache_n_uncaches));
52266 + atomic_read_unchecked(&fscache_n_marks),
52267 + atomic_read_unchecked(&fscache_n_uncaches));
52268
52269 seq_printf(m, "Acquire: n=%u nul=%u noc=%u ok=%u nbf=%u"
52270 " oom=%u\n",
52271 - atomic_read(&fscache_n_acquires),
52272 - atomic_read(&fscache_n_acquires_null),
52273 - atomic_read(&fscache_n_acquires_no_cache),
52274 - atomic_read(&fscache_n_acquires_ok),
52275 - atomic_read(&fscache_n_acquires_nobufs),
52276 - atomic_read(&fscache_n_acquires_oom));
52277 + atomic_read_unchecked(&fscache_n_acquires),
52278 + atomic_read_unchecked(&fscache_n_acquires_null),
52279 + atomic_read_unchecked(&fscache_n_acquires_no_cache),
52280 + atomic_read_unchecked(&fscache_n_acquires_ok),
52281 + atomic_read_unchecked(&fscache_n_acquires_nobufs),
52282 + atomic_read_unchecked(&fscache_n_acquires_oom));
52283
52284 seq_printf(m, "Lookups: n=%u neg=%u pos=%u crt=%u tmo=%u\n",
52285 - atomic_read(&fscache_n_object_lookups),
52286 - atomic_read(&fscache_n_object_lookups_negative),
52287 - atomic_read(&fscache_n_object_lookups_positive),
52288 - atomic_read(&fscache_n_object_created),
52289 - atomic_read(&fscache_n_object_lookups_timed_out));
52290 + atomic_read_unchecked(&fscache_n_object_lookups),
52291 + atomic_read_unchecked(&fscache_n_object_lookups_negative),
52292 + atomic_read_unchecked(&fscache_n_object_lookups_positive),
52293 + atomic_read_unchecked(&fscache_n_object_created),
52294 + atomic_read_unchecked(&fscache_n_object_lookups_timed_out));
52295
52296 seq_printf(m, "Invals : n=%u run=%u\n",
52297 - atomic_read(&fscache_n_invalidates),
52298 - atomic_read(&fscache_n_invalidates_run));
52299 + atomic_read_unchecked(&fscache_n_invalidates),
52300 + atomic_read_unchecked(&fscache_n_invalidates_run));
52301
52302 seq_printf(m, "Updates: n=%u nul=%u run=%u\n",
52303 - atomic_read(&fscache_n_updates),
52304 - atomic_read(&fscache_n_updates_null),
52305 - atomic_read(&fscache_n_updates_run));
52306 + atomic_read_unchecked(&fscache_n_updates),
52307 + atomic_read_unchecked(&fscache_n_updates_null),
52308 + atomic_read_unchecked(&fscache_n_updates_run));
52309
52310 seq_printf(m, "Relinqs: n=%u nul=%u wcr=%u rtr=%u\n",
52311 - atomic_read(&fscache_n_relinquishes),
52312 - atomic_read(&fscache_n_relinquishes_null),
52313 - atomic_read(&fscache_n_relinquishes_waitcrt),
52314 - atomic_read(&fscache_n_relinquishes_retire));
52315 + atomic_read_unchecked(&fscache_n_relinquishes),
52316 + atomic_read_unchecked(&fscache_n_relinquishes_null),
52317 + atomic_read_unchecked(&fscache_n_relinquishes_waitcrt),
52318 + atomic_read_unchecked(&fscache_n_relinquishes_retire));
52319
52320 seq_printf(m, "AttrChg: n=%u ok=%u nbf=%u oom=%u run=%u\n",
52321 - atomic_read(&fscache_n_attr_changed),
52322 - atomic_read(&fscache_n_attr_changed_ok),
52323 - atomic_read(&fscache_n_attr_changed_nobufs),
52324 - atomic_read(&fscache_n_attr_changed_nomem),
52325 - atomic_read(&fscache_n_attr_changed_calls));
52326 + atomic_read_unchecked(&fscache_n_attr_changed),
52327 + atomic_read_unchecked(&fscache_n_attr_changed_ok),
52328 + atomic_read_unchecked(&fscache_n_attr_changed_nobufs),
52329 + atomic_read_unchecked(&fscache_n_attr_changed_nomem),
52330 + atomic_read_unchecked(&fscache_n_attr_changed_calls));
52331
52332 seq_printf(m, "Allocs : n=%u ok=%u wt=%u nbf=%u int=%u\n",
52333 - atomic_read(&fscache_n_allocs),
52334 - atomic_read(&fscache_n_allocs_ok),
52335 - atomic_read(&fscache_n_allocs_wait),
52336 - atomic_read(&fscache_n_allocs_nobufs),
52337 - atomic_read(&fscache_n_allocs_intr));
52338 + atomic_read_unchecked(&fscache_n_allocs),
52339 + atomic_read_unchecked(&fscache_n_allocs_ok),
52340 + atomic_read_unchecked(&fscache_n_allocs_wait),
52341 + atomic_read_unchecked(&fscache_n_allocs_nobufs),
52342 + atomic_read_unchecked(&fscache_n_allocs_intr));
52343 seq_printf(m, "Allocs : ops=%u owt=%u abt=%u\n",
52344 - atomic_read(&fscache_n_alloc_ops),
52345 - atomic_read(&fscache_n_alloc_op_waits),
52346 - atomic_read(&fscache_n_allocs_object_dead));
52347 + atomic_read_unchecked(&fscache_n_alloc_ops),
52348 + atomic_read_unchecked(&fscache_n_alloc_op_waits),
52349 + atomic_read_unchecked(&fscache_n_allocs_object_dead));
52350
52351 seq_printf(m, "Retrvls: n=%u ok=%u wt=%u nod=%u nbf=%u"
52352 " int=%u oom=%u\n",
52353 - atomic_read(&fscache_n_retrievals),
52354 - atomic_read(&fscache_n_retrievals_ok),
52355 - atomic_read(&fscache_n_retrievals_wait),
52356 - atomic_read(&fscache_n_retrievals_nodata),
52357 - atomic_read(&fscache_n_retrievals_nobufs),
52358 - atomic_read(&fscache_n_retrievals_intr),
52359 - atomic_read(&fscache_n_retrievals_nomem));
52360 + atomic_read_unchecked(&fscache_n_retrievals),
52361 + atomic_read_unchecked(&fscache_n_retrievals_ok),
52362 + atomic_read_unchecked(&fscache_n_retrievals_wait),
52363 + atomic_read_unchecked(&fscache_n_retrievals_nodata),
52364 + atomic_read_unchecked(&fscache_n_retrievals_nobufs),
52365 + atomic_read_unchecked(&fscache_n_retrievals_intr),
52366 + atomic_read_unchecked(&fscache_n_retrievals_nomem));
52367 seq_printf(m, "Retrvls: ops=%u owt=%u abt=%u\n",
52368 - atomic_read(&fscache_n_retrieval_ops),
52369 - atomic_read(&fscache_n_retrieval_op_waits),
52370 - atomic_read(&fscache_n_retrievals_object_dead));
52371 + atomic_read_unchecked(&fscache_n_retrieval_ops),
52372 + atomic_read_unchecked(&fscache_n_retrieval_op_waits),
52373 + atomic_read_unchecked(&fscache_n_retrievals_object_dead));
52374
52375 seq_printf(m, "Stores : n=%u ok=%u agn=%u nbf=%u oom=%u\n",
52376 - atomic_read(&fscache_n_stores),
52377 - atomic_read(&fscache_n_stores_ok),
52378 - atomic_read(&fscache_n_stores_again),
52379 - atomic_read(&fscache_n_stores_nobufs),
52380 - atomic_read(&fscache_n_stores_oom));
52381 + atomic_read_unchecked(&fscache_n_stores),
52382 + atomic_read_unchecked(&fscache_n_stores_ok),
52383 + atomic_read_unchecked(&fscache_n_stores_again),
52384 + atomic_read_unchecked(&fscache_n_stores_nobufs),
52385 + atomic_read_unchecked(&fscache_n_stores_oom));
52386 seq_printf(m, "Stores : ops=%u run=%u pgs=%u rxd=%u olm=%u\n",
52387 - atomic_read(&fscache_n_store_ops),
52388 - atomic_read(&fscache_n_store_calls),
52389 - atomic_read(&fscache_n_store_pages),
52390 - atomic_read(&fscache_n_store_radix_deletes),
52391 - atomic_read(&fscache_n_store_pages_over_limit));
52392 + atomic_read_unchecked(&fscache_n_store_ops),
52393 + atomic_read_unchecked(&fscache_n_store_calls),
52394 + atomic_read_unchecked(&fscache_n_store_pages),
52395 + atomic_read_unchecked(&fscache_n_store_radix_deletes),
52396 + atomic_read_unchecked(&fscache_n_store_pages_over_limit));
52397
52398 seq_printf(m, "VmScan : nos=%u gon=%u bsy=%u can=%u wt=%u\n",
52399 - atomic_read(&fscache_n_store_vmscan_not_storing),
52400 - atomic_read(&fscache_n_store_vmscan_gone),
52401 - atomic_read(&fscache_n_store_vmscan_busy),
52402 - atomic_read(&fscache_n_store_vmscan_cancelled),
52403 - atomic_read(&fscache_n_store_vmscan_wait));
52404 + atomic_read_unchecked(&fscache_n_store_vmscan_not_storing),
52405 + atomic_read_unchecked(&fscache_n_store_vmscan_gone),
52406 + atomic_read_unchecked(&fscache_n_store_vmscan_busy),
52407 + atomic_read_unchecked(&fscache_n_store_vmscan_cancelled),
52408 + atomic_read_unchecked(&fscache_n_store_vmscan_wait));
52409
52410 seq_printf(m, "Ops : pend=%u run=%u enq=%u can=%u rej=%u\n",
52411 - atomic_read(&fscache_n_op_pend),
52412 - atomic_read(&fscache_n_op_run),
52413 - atomic_read(&fscache_n_op_enqueue),
52414 - atomic_read(&fscache_n_op_cancelled),
52415 - atomic_read(&fscache_n_op_rejected));
52416 + atomic_read_unchecked(&fscache_n_op_pend),
52417 + atomic_read_unchecked(&fscache_n_op_run),
52418 + atomic_read_unchecked(&fscache_n_op_enqueue),
52419 + atomic_read_unchecked(&fscache_n_op_cancelled),
52420 + atomic_read_unchecked(&fscache_n_op_rejected));
52421 seq_printf(m, "Ops : dfr=%u rel=%u gc=%u\n",
52422 - atomic_read(&fscache_n_op_deferred_release),
52423 - atomic_read(&fscache_n_op_release),
52424 - atomic_read(&fscache_n_op_gc));
52425 + atomic_read_unchecked(&fscache_n_op_deferred_release),
52426 + atomic_read_unchecked(&fscache_n_op_release),
52427 + atomic_read_unchecked(&fscache_n_op_gc));
52428
52429 seq_printf(m, "CacheOp: alo=%d luo=%d luc=%d gro=%d\n",
52430 atomic_read(&fscache_n_cop_alloc_object),
52431 diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
52432 index 6f96a8d..6019bb9 100644
52433 --- a/fs/fuse/cuse.c
52434 +++ b/fs/fuse/cuse.c
52435 @@ -597,10 +597,12 @@ static int __init cuse_init(void)
52436 INIT_LIST_HEAD(&cuse_conntbl[i]);
52437
52438 /* inherit and extend fuse_dev_operations */
52439 - cuse_channel_fops = fuse_dev_operations;
52440 - cuse_channel_fops.owner = THIS_MODULE;
52441 - cuse_channel_fops.open = cuse_channel_open;
52442 - cuse_channel_fops.release = cuse_channel_release;
52443 + pax_open_kernel();
52444 + memcpy((void *)&cuse_channel_fops, &fuse_dev_operations, sizeof(fuse_dev_operations));
52445 + *(void **)&cuse_channel_fops.owner = THIS_MODULE;
52446 + *(void **)&cuse_channel_fops.open = cuse_channel_open;
52447 + *(void **)&cuse_channel_fops.release = cuse_channel_release;
52448 + pax_close_kernel();
52449
52450 cuse_class = class_create(THIS_MODULE, "cuse");
52451 if (IS_ERR(cuse_class))
52452 diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
52453 index 11dfa0c..6f64416 100644
52454 --- a/fs/fuse/dev.c
52455 +++ b/fs/fuse/dev.c
52456 @@ -1294,7 +1294,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
52457 ret = 0;
52458 pipe_lock(pipe);
52459
52460 - if (!pipe->readers) {
52461 + if (!atomic_read(&pipe->readers)) {
52462 send_sig(SIGPIPE, current, 0);
52463 if (!ret)
52464 ret = -EPIPE;
52465 diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
52466 index ff15522..092a0f6 100644
52467 --- a/fs/fuse/dir.c
52468 +++ b/fs/fuse/dir.c
52469 @@ -1409,7 +1409,7 @@ static char *read_link(struct dentry *dentry)
52470 return link;
52471 }
52472
52473 -static void free_link(char *link)
52474 +static void free_link(const char *link)
52475 {
52476 if (!IS_ERR(link))
52477 free_page((unsigned long) link);
52478 diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
52479 index cc00bd1..3edb692 100644
52480 --- a/fs/gfs2/inode.c
52481 +++ b/fs/gfs2/inode.c
52482 @@ -1500,7 +1500,7 @@ out:
52483
52484 static void gfs2_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
52485 {
52486 - char *s = nd_get_link(nd);
52487 + const char *s = nd_get_link(nd);
52488 if (!IS_ERR(s))
52489 kfree(s);
52490 }
52491 diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
52492 index a3f868a..bb308ae 100644
52493 --- a/fs/hugetlbfs/inode.c
52494 +++ b/fs/hugetlbfs/inode.c
52495 @@ -152,6 +152,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
52496 struct mm_struct *mm = current->mm;
52497 struct vm_area_struct *vma;
52498 struct hstate *h = hstate_file(file);
52499 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
52500 struct vm_unmapped_area_info info;
52501
52502 if (len & ~huge_page_mask(h))
52503 @@ -165,17 +166,26 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
52504 return addr;
52505 }
52506
52507 +#ifdef CONFIG_PAX_RANDMMAP
52508 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
52509 +#endif
52510 +
52511 if (addr) {
52512 addr = ALIGN(addr, huge_page_size(h));
52513 vma = find_vma(mm, addr);
52514 - if (TASK_SIZE - len >= addr &&
52515 - (!vma || addr + len <= vma->vm_start))
52516 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
52517 return addr;
52518 }
52519
52520 info.flags = 0;
52521 info.length = len;
52522 info.low_limit = TASK_UNMAPPED_BASE;
52523 +
52524 +#ifdef CONFIG_PAX_RANDMMAP
52525 + if (mm->pax_flags & MF_PAX_RANDMMAP)
52526 + info.low_limit += mm->delta_mmap;
52527 +#endif
52528 +
52529 info.high_limit = TASK_SIZE;
52530 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
52531 info.align_offset = 0;
52532 @@ -898,7 +908,7 @@ static struct file_system_type hugetlbfs_fs_type = {
52533 };
52534 MODULE_ALIAS_FS("hugetlbfs");
52535
52536 -static struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
52537 +struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
52538
52539 static int can_do_hugetlb_shm(void)
52540 {
52541 diff --git a/fs/inode.c b/fs/inode.c
52542 index a898b3d..9b5a214 100644
52543 --- a/fs/inode.c
52544 +++ b/fs/inode.c
52545 @@ -878,8 +878,8 @@ unsigned int get_next_ino(void)
52546
52547 #ifdef CONFIG_SMP
52548 if (unlikely((res & (LAST_INO_BATCH-1)) == 0)) {
52549 - static atomic_t shared_last_ino;
52550 - int next = atomic_add_return(LAST_INO_BATCH, &shared_last_ino);
52551 + static atomic_unchecked_t shared_last_ino;
52552 + int next = atomic_add_return_unchecked(LAST_INO_BATCH, &shared_last_ino);
52553
52554 res = next - LAST_INO_BATCH;
52555 }
52556 diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
52557 index 4a6cf28..d3a29d3 100644
52558 --- a/fs/jffs2/erase.c
52559 +++ b/fs/jffs2/erase.c
52560 @@ -452,7 +452,8 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
52561 struct jffs2_unknown_node marker = {
52562 .magic = cpu_to_je16(JFFS2_MAGIC_BITMASK),
52563 .nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
52564 - .totlen = cpu_to_je32(c->cleanmarker_size)
52565 + .totlen = cpu_to_je32(c->cleanmarker_size),
52566 + .hdr_crc = cpu_to_je32(0)
52567 };
52568
52569 jffs2_prealloc_raw_node_refs(c, jeb, 1);
52570 diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
52571 index a6597d6..41b30ec 100644
52572 --- a/fs/jffs2/wbuf.c
52573 +++ b/fs/jffs2/wbuf.c
52574 @@ -1023,7 +1023,8 @@ static const struct jffs2_unknown_node oob_cleanmarker =
52575 {
52576 .magic = constant_cpu_to_je16(JFFS2_MAGIC_BITMASK),
52577 .nodetype = constant_cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
52578 - .totlen = constant_cpu_to_je32(8)
52579 + .totlen = constant_cpu_to_je32(8),
52580 + .hdr_crc = constant_cpu_to_je32(0)
52581 };
52582
52583 /*
52584 diff --git a/fs/jfs/super.c b/fs/jfs/super.c
52585 index 2003e83..40db287 100644
52586 --- a/fs/jfs/super.c
52587 +++ b/fs/jfs/super.c
52588 @@ -856,7 +856,7 @@ static int __init init_jfs_fs(void)
52589
52590 jfs_inode_cachep =
52591 kmem_cache_create("jfs_ip", sizeof(struct jfs_inode_info), 0,
52592 - SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
52593 + SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|SLAB_USERCOPY,
52594 init_once);
52595 if (jfs_inode_cachep == NULL)
52596 return -ENOMEM;
52597 diff --git a/fs/libfs.c b/fs/libfs.c
52598 index 916da8c..1588998 100644
52599 --- a/fs/libfs.c
52600 +++ b/fs/libfs.c
52601 @@ -165,6 +165,9 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
52602
52603 for (p=q->next; p != &dentry->d_subdirs; p=p->next) {
52604 struct dentry *next;
52605 + char d_name[sizeof(next->d_iname)];
52606 + const unsigned char *name;
52607 +
52608 next = list_entry(p, struct dentry, d_u.d_child);
52609 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
52610 if (!simple_positive(next)) {
52611 @@ -174,7 +177,12 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
52612
52613 spin_unlock(&next->d_lock);
52614 spin_unlock(&dentry->d_lock);
52615 - if (filldir(dirent, next->d_name.name,
52616 + name = next->d_name.name;
52617 + if (name == next->d_iname) {
52618 + memcpy(d_name, name, next->d_name.len);
52619 + name = d_name;
52620 + }
52621 + if (filldir(dirent, name,
52622 next->d_name.len, filp->f_pos,
52623 next->d_inode->i_ino,
52624 dt_type(next->d_inode)) < 0)
52625 diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
52626 index 9760ecb..9b838ef 100644
52627 --- a/fs/lockd/clntproc.c
52628 +++ b/fs/lockd/clntproc.c
52629 @@ -36,11 +36,11 @@ static const struct rpc_call_ops nlmclnt_cancel_ops;
52630 /*
52631 * Cookie counter for NLM requests
52632 */
52633 -static atomic_t nlm_cookie = ATOMIC_INIT(0x1234);
52634 +static atomic_unchecked_t nlm_cookie = ATOMIC_INIT(0x1234);
52635
52636 void nlmclnt_next_cookie(struct nlm_cookie *c)
52637 {
52638 - u32 cookie = atomic_inc_return(&nlm_cookie);
52639 + u32 cookie = atomic_inc_return_unchecked(&nlm_cookie);
52640
52641 memcpy(c->data, &cookie, 4);
52642 c->len=4;
52643 diff --git a/fs/locks.c b/fs/locks.c
52644 index cb424a4..850e4dd 100644
52645 --- a/fs/locks.c
52646 +++ b/fs/locks.c
52647 @@ -2064,16 +2064,16 @@ void locks_remove_flock(struct file *filp)
52648 return;
52649
52650 if (filp->f_op && filp->f_op->flock) {
52651 - struct file_lock fl = {
52652 + struct file_lock flock = {
52653 .fl_pid = current->tgid,
52654 .fl_file = filp,
52655 .fl_flags = FL_FLOCK,
52656 .fl_type = F_UNLCK,
52657 .fl_end = OFFSET_MAX,
52658 };
52659 - filp->f_op->flock(filp, F_SETLKW, &fl);
52660 - if (fl.fl_ops && fl.fl_ops->fl_release_private)
52661 - fl.fl_ops->fl_release_private(&fl);
52662 + filp->f_op->flock(filp, F_SETLKW, &flock);
52663 + if (flock.fl_ops && flock.fl_ops->fl_release_private)
52664 + flock.fl_ops->fl_release_private(&flock);
52665 }
52666
52667 lock_flocks();
52668 diff --git a/fs/namei.c b/fs/namei.c
52669 index 85e40d1..b66744e 100644
52670 --- a/fs/namei.c
52671 +++ b/fs/namei.c
52672 @@ -319,16 +319,32 @@ int generic_permission(struct inode *inode, int mask)
52673 if (ret != -EACCES)
52674 return ret;
52675
52676 +#ifdef CONFIG_GRKERNSEC
52677 + /* we'll block if we have to log due to a denied capability use */
52678 + if (mask & MAY_NOT_BLOCK)
52679 + return -ECHILD;
52680 +#endif
52681 +
52682 if (S_ISDIR(inode->i_mode)) {
52683 /* DACs are overridable for directories */
52684 - if (inode_capable(inode, CAP_DAC_OVERRIDE))
52685 - return 0;
52686 if (!(mask & MAY_WRITE))
52687 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
52688 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
52689 + inode_capable(inode, CAP_DAC_READ_SEARCH))
52690 return 0;
52691 + if (inode_capable(inode, CAP_DAC_OVERRIDE))
52692 + return 0;
52693 return -EACCES;
52694 }
52695 /*
52696 + * Searching includes executable on directories, else just read.
52697 + */
52698 + mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
52699 + if (mask == MAY_READ)
52700 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
52701 + inode_capable(inode, CAP_DAC_READ_SEARCH))
52702 + return 0;
52703 +
52704 + /*
52705 * Read/write DACs are always overridable.
52706 * Executable DACs are overridable when there is
52707 * at least one exec bit set.
52708 @@ -337,14 +353,6 @@ int generic_permission(struct inode *inode, int mask)
52709 if (inode_capable(inode, CAP_DAC_OVERRIDE))
52710 return 0;
52711
52712 - /*
52713 - * Searching includes executable on directories, else just read.
52714 - */
52715 - mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
52716 - if (mask == MAY_READ)
52717 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
52718 - return 0;
52719 -
52720 return -EACCES;
52721 }
52722
52723 @@ -820,7 +828,7 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
52724 {
52725 struct dentry *dentry = link->dentry;
52726 int error;
52727 - char *s;
52728 + const char *s;
52729
52730 BUG_ON(nd->flags & LOOKUP_RCU);
52731
52732 @@ -841,6 +849,12 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
52733 if (error)
52734 goto out_put_nd_path;
52735
52736 + if (gr_handle_follow_link(dentry->d_parent->d_inode,
52737 + dentry->d_inode, dentry, nd->path.mnt)) {
52738 + error = -EACCES;
52739 + goto out_put_nd_path;
52740 + }
52741 +
52742 nd->last_type = LAST_BIND;
52743 *p = dentry->d_inode->i_op->follow_link(dentry, nd);
52744 error = PTR_ERR(*p);
52745 @@ -1588,6 +1602,8 @@ static inline int nested_symlink(struct path *path, struct nameidata *nd)
52746 if (res)
52747 break;
52748 res = walk_component(nd, path, LOOKUP_FOLLOW);
52749 + if (res >= 0 && gr_handle_symlink_owner(&link, nd->inode))
52750 + res = -EACCES;
52751 put_link(nd, &link, cookie);
52752 } while (res > 0);
52753
52754 @@ -1686,7 +1702,7 @@ EXPORT_SYMBOL(full_name_hash);
52755 static inline unsigned long hash_name(const char *name, unsigned int *hashp)
52756 {
52757 unsigned long a, b, adata, bdata, mask, hash, len;
52758 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
52759 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
52760
52761 hash = a = 0;
52762 len = -sizeof(unsigned long);
52763 @@ -1968,6 +1984,8 @@ static int path_lookupat(int dfd, const char *name,
52764 if (err)
52765 break;
52766 err = lookup_last(nd, &path);
52767 + if (!err && gr_handle_symlink_owner(&link, nd->inode))
52768 + err = -EACCES;
52769 put_link(nd, &link, cookie);
52770 }
52771 }
52772 @@ -1975,6 +1993,13 @@ static int path_lookupat(int dfd, const char *name,
52773 if (!err)
52774 err = complete_walk(nd);
52775
52776 + if (!err && !(nd->flags & LOOKUP_PARENT)) {
52777 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
52778 + path_put(&nd->path);
52779 + err = -ENOENT;
52780 + }
52781 + }
52782 +
52783 if (!err && nd->flags & LOOKUP_DIRECTORY) {
52784 if (!nd->inode->i_op->lookup) {
52785 path_put(&nd->path);
52786 @@ -2002,8 +2027,15 @@ static int filename_lookup(int dfd, struct filename *name,
52787 retval = path_lookupat(dfd, name->name,
52788 flags | LOOKUP_REVAL, nd);
52789
52790 - if (likely(!retval))
52791 + if (likely(!retval)) {
52792 audit_inode(name, nd->path.dentry, flags & LOOKUP_PARENT);
52793 + if (name->name[0] != '/' && nd->path.dentry && nd->inode) {
52794 + if (!gr_chroot_fchdir(nd->path.dentry, nd->path.mnt)) {
52795 + path_put(&nd->path);
52796 + return -ENOENT;
52797 + }
52798 + }
52799 + }
52800 return retval;
52801 }
52802
52803 @@ -2381,6 +2413,13 @@ static int may_open(struct path *path, int acc_mode, int flag)
52804 if (flag & O_NOATIME && !inode_owner_or_capable(inode))
52805 return -EPERM;
52806
52807 + if (gr_handle_rofs_blockwrite(dentry, path->mnt, acc_mode))
52808 + return -EPERM;
52809 + if (gr_handle_rawio(inode))
52810 + return -EPERM;
52811 + if (!gr_acl_handle_open(dentry, path->mnt, acc_mode))
52812 + return -EACCES;
52813 +
52814 return 0;
52815 }
52816
52817 @@ -2602,7 +2641,7 @@ looked_up:
52818 * cleared otherwise prior to returning.
52819 */
52820 static int lookup_open(struct nameidata *nd, struct path *path,
52821 - struct file *file,
52822 + struct path *link, struct file *file,
52823 const struct open_flags *op,
52824 bool got_write, int *opened)
52825 {
52826 @@ -2637,6 +2676,17 @@ static int lookup_open(struct nameidata *nd, struct path *path,
52827 /* Negative dentry, just create the file */
52828 if (!dentry->d_inode && (op->open_flag & O_CREAT)) {
52829 umode_t mode = op->mode;
52830 +
52831 + if (link && gr_handle_symlink_owner(link, dir->d_inode)) {
52832 + error = -EACCES;
52833 + goto out_dput;
52834 + }
52835 +
52836 + if (!gr_acl_handle_creat(dentry, dir, nd->path.mnt, op->open_flag, op->acc_mode, mode)) {
52837 + error = -EACCES;
52838 + goto out_dput;
52839 + }
52840 +
52841 if (!IS_POSIXACL(dir->d_inode))
52842 mode &= ~current_umask();
52843 /*
52844 @@ -2658,6 +2708,8 @@ static int lookup_open(struct nameidata *nd, struct path *path,
52845 nd->flags & LOOKUP_EXCL);
52846 if (error)
52847 goto out_dput;
52848 + else
52849 + gr_handle_create(dentry, nd->path.mnt);
52850 }
52851 out_no_open:
52852 path->dentry = dentry;
52853 @@ -2672,7 +2724,7 @@ out_dput:
52854 /*
52855 * Handle the last step of open()
52856 */
52857 -static int do_last(struct nameidata *nd, struct path *path,
52858 +static int do_last(struct nameidata *nd, struct path *path, struct path *link,
52859 struct file *file, const struct open_flags *op,
52860 int *opened, struct filename *name)
52861 {
52862 @@ -2701,16 +2753,32 @@ static int do_last(struct nameidata *nd, struct path *path,
52863 error = complete_walk(nd);
52864 if (error)
52865 return error;
52866 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
52867 + error = -ENOENT;
52868 + goto out;
52869 + }
52870 audit_inode(name, nd->path.dentry, 0);
52871 if (open_flag & O_CREAT) {
52872 error = -EISDIR;
52873 goto out;
52874 }
52875 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
52876 + error = -EACCES;
52877 + goto out;
52878 + }
52879 goto finish_open;
52880 case LAST_BIND:
52881 error = complete_walk(nd);
52882 if (error)
52883 return error;
52884 + if (!gr_acl_handle_hidden_file(dir, nd->path.mnt)) {
52885 + error = -ENOENT;
52886 + goto out;
52887 + }
52888 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
52889 + error = -EACCES;
52890 + goto out;
52891 + }
52892 audit_inode(name, dir, 0);
52893 goto finish_open;
52894 }
52895 @@ -2759,7 +2827,7 @@ retry_lookup:
52896 */
52897 }
52898 mutex_lock(&dir->d_inode->i_mutex);
52899 - error = lookup_open(nd, path, file, op, got_write, opened);
52900 + error = lookup_open(nd, path, link, file, op, got_write, opened);
52901 mutex_unlock(&dir->d_inode->i_mutex);
52902
52903 if (error <= 0) {
52904 @@ -2783,11 +2851,28 @@ retry_lookup:
52905 goto finish_open_created;
52906 }
52907
52908 + if (!gr_acl_handle_hidden_file(path->dentry, nd->path.mnt)) {
52909 + error = -ENOENT;
52910 + goto exit_dput;
52911 + }
52912 + if (link && gr_handle_symlink_owner(link, path->dentry->d_inode)) {
52913 + error = -EACCES;
52914 + goto exit_dput;
52915 + }
52916 +
52917 /*
52918 * create/update audit record if it already exists.
52919 */
52920 - if (path->dentry->d_inode)
52921 + if (path->dentry->d_inode) {
52922 + /* only check if O_CREAT is specified, all other checks need to go
52923 + into may_open */
52924 + if (gr_handle_fifo(path->dentry, path->mnt, dir, open_flag, acc_mode)) {
52925 + error = -EACCES;
52926 + goto exit_dput;
52927 + }
52928 +
52929 audit_inode(name, path->dentry, 0);
52930 + }
52931
52932 /*
52933 * If atomic_open() acquired write access it is dropped now due to
52934 @@ -2828,6 +2913,11 @@ finish_lookup:
52935 }
52936 }
52937 BUG_ON(inode != path->dentry->d_inode);
52938 + /* if we're resolving a symlink to another symlink */
52939 + if (link && gr_handle_symlink_owner(link, inode)) {
52940 + error = -EACCES;
52941 + goto out;
52942 + }
52943 return 1;
52944 }
52945
52946 @@ -2837,7 +2927,6 @@ finish_lookup:
52947 save_parent.dentry = nd->path.dentry;
52948 save_parent.mnt = mntget(path->mnt);
52949 nd->path.dentry = path->dentry;
52950 -
52951 }
52952 nd->inode = inode;
52953 /* Why this, you ask? _Now_ we might have grown LOOKUP_JUMPED... */
52954 @@ -2846,6 +2935,16 @@ finish_lookup:
52955 path_put(&save_parent);
52956 return error;
52957 }
52958 +
52959 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
52960 + error = -ENOENT;
52961 + goto out;
52962 + }
52963 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
52964 + error = -EACCES;
52965 + goto out;
52966 + }
52967 +
52968 error = -EISDIR;
52969 if ((open_flag & O_CREAT) && S_ISDIR(nd->inode->i_mode))
52970 goto out;
52971 @@ -2944,7 +3043,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
52972 if (unlikely(error))
52973 goto out;
52974
52975 - error = do_last(nd, &path, file, op, &opened, pathname);
52976 + error = do_last(nd, &path, NULL, file, op, &opened, pathname);
52977 while (unlikely(error > 0)) { /* trailing symlink */
52978 struct path link = path;
52979 void *cookie;
52980 @@ -2962,7 +3061,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
52981 error = follow_link(&link, nd, &cookie);
52982 if (unlikely(error))
52983 break;
52984 - error = do_last(nd, &path, file, op, &opened, pathname);
52985 + error = do_last(nd, &path, &link, file, op, &opened, pathname);
52986 put_link(nd, &link, cookie);
52987 }
52988 out:
52989 @@ -3062,8 +3161,12 @@ struct dentry *kern_path_create(int dfd, const char *pathname,
52990 goto unlock;
52991
52992 error = -EEXIST;
52993 - if (dentry->d_inode)
52994 + if (dentry->d_inode) {
52995 + if (!gr_acl_handle_hidden_file(dentry, nd.path.mnt)) {
52996 + error = -ENOENT;
52997 + }
52998 goto fail;
52999 + }
53000 /*
53001 * Special case - lookup gave negative, but... we had foo/bar/
53002 * From the vfs_mknod() POV we just have a negative dentry -
53003 @@ -3115,6 +3218,20 @@ struct dentry *user_path_create(int dfd, const char __user *pathname,
53004 }
53005 EXPORT_SYMBOL(user_path_create);
53006
53007 +static struct dentry *user_path_create_with_name(int dfd, const char __user *pathname, struct path *path, struct filename **to, unsigned int lookup_flags)
53008 +{
53009 + struct filename *tmp = getname(pathname);
53010 + struct dentry *res;
53011 + if (IS_ERR(tmp))
53012 + return ERR_CAST(tmp);
53013 + res = kern_path_create(dfd, tmp->name, path, lookup_flags);
53014 + if (IS_ERR(res))
53015 + putname(tmp);
53016 + else
53017 + *to = tmp;
53018 + return res;
53019 +}
53020 +
53021 int vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
53022 {
53023 int error = may_create(dir, dentry);
53024 @@ -3177,6 +3294,17 @@ retry:
53025
53026 if (!IS_POSIXACL(path.dentry->d_inode))
53027 mode &= ~current_umask();
53028 +
53029 + if (gr_handle_chroot_mknod(dentry, path.mnt, mode)) {
53030 + error = -EPERM;
53031 + goto out;
53032 + }
53033 +
53034 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
53035 + error = -EACCES;
53036 + goto out;
53037 + }
53038 +
53039 error = security_path_mknod(&path, dentry, mode, dev);
53040 if (error)
53041 goto out;
53042 @@ -3193,6 +3321,8 @@ retry:
53043 break;
53044 }
53045 out:
53046 + if (!error)
53047 + gr_handle_create(dentry, path.mnt);
53048 done_path_create(&path, dentry);
53049 if (retry_estale(error, lookup_flags)) {
53050 lookup_flags |= LOOKUP_REVAL;
53051 @@ -3245,9 +3375,16 @@ retry:
53052
53053 if (!IS_POSIXACL(path.dentry->d_inode))
53054 mode &= ~current_umask();
53055 + if (!gr_acl_handle_mkdir(dentry, path.dentry, path.mnt)) {
53056 + error = -EACCES;
53057 + goto out;
53058 + }
53059 error = security_path_mkdir(&path, dentry, mode);
53060 if (!error)
53061 error = vfs_mkdir(path.dentry->d_inode, dentry, mode);
53062 + if (!error)
53063 + gr_handle_create(dentry, path.mnt);
53064 +out:
53065 done_path_create(&path, dentry);
53066 if (retry_estale(error, lookup_flags)) {
53067 lookup_flags |= LOOKUP_REVAL;
53068 @@ -3328,6 +3465,8 @@ static long do_rmdir(int dfd, const char __user *pathname)
53069 struct filename *name;
53070 struct dentry *dentry;
53071 struct nameidata nd;
53072 + ino_t saved_ino = 0;
53073 + dev_t saved_dev = 0;
53074 unsigned int lookup_flags = 0;
53075 retry:
53076 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
53077 @@ -3360,10 +3499,21 @@ retry:
53078 error = -ENOENT;
53079 goto exit3;
53080 }
53081 +
53082 + saved_ino = dentry->d_inode->i_ino;
53083 + saved_dev = gr_get_dev_from_dentry(dentry);
53084 +
53085 + if (!gr_acl_handle_rmdir(dentry, nd.path.mnt)) {
53086 + error = -EACCES;
53087 + goto exit3;
53088 + }
53089 +
53090 error = security_path_rmdir(&nd.path, dentry);
53091 if (error)
53092 goto exit3;
53093 error = vfs_rmdir(nd.path.dentry->d_inode, dentry);
53094 + if (!error && (saved_dev || saved_ino))
53095 + gr_handle_delete(saved_ino, saved_dev);
53096 exit3:
53097 dput(dentry);
53098 exit2:
53099 @@ -3429,6 +3579,8 @@ static long do_unlinkat(int dfd, const char __user *pathname)
53100 struct dentry *dentry;
53101 struct nameidata nd;
53102 struct inode *inode = NULL;
53103 + ino_t saved_ino = 0;
53104 + dev_t saved_dev = 0;
53105 unsigned int lookup_flags = 0;
53106 retry:
53107 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
53108 @@ -3455,10 +3607,22 @@ retry:
53109 if (!inode)
53110 goto slashes;
53111 ihold(inode);
53112 +
53113 + if (inode->i_nlink <= 1) {
53114 + saved_ino = inode->i_ino;
53115 + saved_dev = gr_get_dev_from_dentry(dentry);
53116 + }
53117 + if (!gr_acl_handle_unlink(dentry, nd.path.mnt)) {
53118 + error = -EACCES;
53119 + goto exit2;
53120 + }
53121 +
53122 error = security_path_unlink(&nd.path, dentry);
53123 if (error)
53124 goto exit2;
53125 error = vfs_unlink(nd.path.dentry->d_inode, dentry);
53126 + if (!error && (saved_ino || saved_dev))
53127 + gr_handle_delete(saved_ino, saved_dev);
53128 exit2:
53129 dput(dentry);
53130 }
53131 @@ -3536,9 +3700,17 @@ retry:
53132 if (IS_ERR(dentry))
53133 goto out_putname;
53134
53135 + if (!gr_acl_handle_symlink(dentry, path.dentry, path.mnt, from)) {
53136 + error = -EACCES;
53137 + goto out;
53138 + }
53139 +
53140 error = security_path_symlink(&path, dentry, from->name);
53141 if (!error)
53142 error = vfs_symlink(path.dentry->d_inode, dentry, from->name);
53143 + if (!error)
53144 + gr_handle_create(dentry, path.mnt);
53145 +out:
53146 done_path_create(&path, dentry);
53147 if (retry_estale(error, lookup_flags)) {
53148 lookup_flags |= LOOKUP_REVAL;
53149 @@ -3612,6 +3784,7 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,
53150 {
53151 struct dentry *new_dentry;
53152 struct path old_path, new_path;
53153 + struct filename *to = NULL;
53154 int how = 0;
53155 int error;
53156
53157 @@ -3635,7 +3808,7 @@ retry:
53158 if (error)
53159 return error;
53160
53161 - new_dentry = user_path_create(newdfd, newname, &new_path,
53162 + new_dentry = user_path_create_with_name(newdfd, newname, &new_path, &to,
53163 (how & LOOKUP_REVAL));
53164 error = PTR_ERR(new_dentry);
53165 if (IS_ERR(new_dentry))
53166 @@ -3647,11 +3820,28 @@ retry:
53167 error = may_linkat(&old_path);
53168 if (unlikely(error))
53169 goto out_dput;
53170 +
53171 + if (gr_handle_hardlink(old_path.dentry, old_path.mnt,
53172 + old_path.dentry->d_inode,
53173 + old_path.dentry->d_inode->i_mode, to)) {
53174 + error = -EACCES;
53175 + goto out_dput;
53176 + }
53177 +
53178 + if (!gr_acl_handle_link(new_dentry, new_path.dentry, new_path.mnt,
53179 + old_path.dentry, old_path.mnt, to)) {
53180 + error = -EACCES;
53181 + goto out_dput;
53182 + }
53183 +
53184 error = security_path_link(old_path.dentry, &new_path, new_dentry);
53185 if (error)
53186 goto out_dput;
53187 error = vfs_link(old_path.dentry, new_path.dentry->d_inode, new_dentry);
53188 + if (!error)
53189 + gr_handle_create(new_dentry, new_path.mnt);
53190 out_dput:
53191 + putname(to);
53192 done_path_create(&new_path, new_dentry);
53193 if (retry_estale(error, how)) {
53194 how |= LOOKUP_REVAL;
53195 @@ -3897,12 +4087,21 @@ retry:
53196 if (new_dentry == trap)
53197 goto exit5;
53198
53199 + error = gr_acl_handle_rename(new_dentry, new_dir, newnd.path.mnt,
53200 + old_dentry, old_dir->d_inode, oldnd.path.mnt,
53201 + to);
53202 + if (error)
53203 + goto exit5;
53204 +
53205 error = security_path_rename(&oldnd.path, old_dentry,
53206 &newnd.path, new_dentry);
53207 if (error)
53208 goto exit5;
53209 error = vfs_rename(old_dir->d_inode, old_dentry,
53210 new_dir->d_inode, new_dentry);
53211 + if (!error)
53212 + gr_handle_rename(old_dir->d_inode, new_dir->d_inode, old_dentry,
53213 + new_dentry, oldnd.path.mnt, new_dentry->d_inode ? 1 : 0);
53214 exit5:
53215 dput(new_dentry);
53216 exit4:
53217 @@ -3934,6 +4133,8 @@ SYSCALL_DEFINE2(rename, const char __user *, oldname, const char __user *, newna
53218
53219 int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const char *link)
53220 {
53221 + char tmpbuf[64];
53222 + const char *newlink;
53223 int len;
53224
53225 len = PTR_ERR(link);
53226 @@ -3943,7 +4144,14 @@ int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const c
53227 len = strlen(link);
53228 if (len > (unsigned) buflen)
53229 len = buflen;
53230 - if (copy_to_user(buffer, link, len))
53231 +
53232 + if (len < sizeof(tmpbuf)) {
53233 + memcpy(tmpbuf, link, len);
53234 + newlink = tmpbuf;
53235 + } else
53236 + newlink = link;
53237 +
53238 + if (copy_to_user(buffer, newlink, len))
53239 len = -EFAULT;
53240 out:
53241 return len;
53242 diff --git a/fs/namespace.c b/fs/namespace.c
53243 index e945b81..1dd8104 100644
53244 --- a/fs/namespace.c
53245 +++ b/fs/namespace.c
53246 @@ -1219,6 +1219,9 @@ static int do_umount(struct mount *mnt, int flags)
53247 if (!(sb->s_flags & MS_RDONLY))
53248 retval = do_remount_sb(sb, MS_RDONLY, NULL, 0);
53249 up_write(&sb->s_umount);
53250 +
53251 + gr_log_remount(mnt->mnt_devname, retval);
53252 +
53253 return retval;
53254 }
53255
53256 @@ -1238,6 +1241,9 @@ static int do_umount(struct mount *mnt, int flags)
53257 br_write_unlock(&vfsmount_lock);
53258 up_write(&namespace_sem);
53259 release_mounts(&umount_list);
53260 +
53261 + gr_log_unmount(mnt->mnt_devname, retval);
53262 +
53263 return retval;
53264 }
53265
53266 @@ -2267,6 +2273,16 @@ long do_mount(const char *dev_name, const char *dir_name,
53267 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
53268 MS_STRICTATIME);
53269
53270 + if (gr_handle_rofs_mount(path.dentry, path.mnt, mnt_flags)) {
53271 + retval = -EPERM;
53272 + goto dput_out;
53273 + }
53274 +
53275 + if (gr_handle_chroot_mount(path.dentry, path.mnt, dev_name)) {
53276 + retval = -EPERM;
53277 + goto dput_out;
53278 + }
53279 +
53280 if (flags & MS_REMOUNT)
53281 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
53282 data_page);
53283 @@ -2281,6 +2297,9 @@ long do_mount(const char *dev_name, const char *dir_name,
53284 dev_name, data_page);
53285 dput_out:
53286 path_put(&path);
53287 +
53288 + gr_log_mount(dev_name, dir_name, retval);
53289 +
53290 return retval;
53291 }
53292
53293 @@ -2567,6 +2586,11 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
53294 if (error)
53295 goto out2;
53296
53297 + if (gr_handle_chroot_pivot()) {
53298 + error = -EPERM;
53299 + goto out2;
53300 + }
53301 +
53302 get_fs_root(current->fs, &root);
53303 error = lock_mount(&old);
53304 if (error)
53305 @@ -2815,7 +2839,7 @@ static int mntns_install(struct nsproxy *nsproxy, void *ns)
53306 !nsown_capable(CAP_SYS_ADMIN))
53307 return -EPERM;
53308
53309 - if (fs->users != 1)
53310 + if (atomic_read(&fs->users) != 1)
53311 return -EINVAL;
53312
53313 get_mnt_ns(mnt_ns);
53314 diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
53315 index 59461c9..b17c57e 100644
53316 --- a/fs/nfs/callback_xdr.c
53317 +++ b/fs/nfs/callback_xdr.c
53318 @@ -51,7 +51,7 @@ struct callback_op {
53319 callback_decode_arg_t decode_args;
53320 callback_encode_res_t encode_res;
53321 long res_maxsize;
53322 -};
53323 +} __do_const;
53324
53325 static struct callback_op callback_ops[];
53326
53327 diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
53328 index 1f94167..79c4ce4 100644
53329 --- a/fs/nfs/inode.c
53330 +++ b/fs/nfs/inode.c
53331 @@ -1041,16 +1041,16 @@ static int nfs_size_need_update(const struct inode *inode, const struct nfs_fatt
53332 return nfs_size_to_loff_t(fattr->size) > i_size_read(inode);
53333 }
53334
53335 -static atomic_long_t nfs_attr_generation_counter;
53336 +static atomic_long_unchecked_t nfs_attr_generation_counter;
53337
53338 static unsigned long nfs_read_attr_generation_counter(void)
53339 {
53340 - return atomic_long_read(&nfs_attr_generation_counter);
53341 + return atomic_long_read_unchecked(&nfs_attr_generation_counter);
53342 }
53343
53344 unsigned long nfs_inc_attr_generation_counter(void)
53345 {
53346 - return atomic_long_inc_return(&nfs_attr_generation_counter);
53347 + return atomic_long_inc_return_unchecked(&nfs_attr_generation_counter);
53348 }
53349
53350 void nfs_fattr_init(struct nfs_fattr *fattr)
53351 diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
53352 index d401d01..10b3e62 100644
53353 --- a/fs/nfsd/nfs4proc.c
53354 +++ b/fs/nfsd/nfs4proc.c
53355 @@ -1109,7 +1109,7 @@ struct nfsd4_operation {
53356 nfsd4op_rsize op_rsize_bop;
53357 stateid_getter op_get_currentstateid;
53358 stateid_setter op_set_currentstateid;
53359 -};
53360 +} __do_const;
53361
53362 static struct nfsd4_operation nfsd4_ops[];
53363
53364 diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
53365 index 6eb0dc5..29067a9 100644
53366 --- a/fs/nfsd/nfs4xdr.c
53367 +++ b/fs/nfsd/nfs4xdr.c
53368 @@ -1457,7 +1457,7 @@ nfsd4_decode_notsupp(struct nfsd4_compoundargs *argp, void *p)
53369
53370 typedef __be32(*nfsd4_dec)(struct nfsd4_compoundargs *argp, void *);
53371
53372 -static nfsd4_dec nfsd4_dec_ops[] = {
53373 +static const nfsd4_dec nfsd4_dec_ops[] = {
53374 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
53375 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
53376 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
53377 @@ -1497,7 +1497,7 @@ static nfsd4_dec nfsd4_dec_ops[] = {
53378 [OP_RELEASE_LOCKOWNER] = (nfsd4_dec)nfsd4_decode_release_lockowner,
53379 };
53380
53381 -static nfsd4_dec nfsd41_dec_ops[] = {
53382 +static const nfsd4_dec nfsd41_dec_ops[] = {
53383 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
53384 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
53385 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
53386 @@ -1559,7 +1559,7 @@ static nfsd4_dec nfsd41_dec_ops[] = {
53387 };
53388
53389 struct nfsd4_minorversion_ops {
53390 - nfsd4_dec *decoders;
53391 + const nfsd4_dec *decoders;
53392 int nops;
53393 };
53394
53395 diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c
53396 index ca05f6d..411a576 100644
53397 --- a/fs/nfsd/nfscache.c
53398 +++ b/fs/nfsd/nfscache.c
53399 @@ -461,13 +461,15 @@ nfsd_cache_update(struct svc_rqst *rqstp, int cachetype, __be32 *statp)
53400 {
53401 struct svc_cacherep *rp = rqstp->rq_cacherep;
53402 struct kvec *resv = &rqstp->rq_res.head[0], *cachv;
53403 - int len;
53404 + long len;
53405
53406 if (!rp)
53407 return;
53408
53409 - len = resv->iov_len - ((char*)statp - (char*)resv->iov_base);
53410 - len >>= 2;
53411 + if (statp) {
53412 + len = resv->iov_len - ((char*)statp - (char*)resv->iov_base);
53413 + len >>= 2;
53414 + }
53415
53416 /* Don't cache excessive amounts of data and XDR failures */
53417 if (!statp || len > (256 >> 2)) {
53418 diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
53419 index 2b2e239..c915b48 100644
53420 --- a/fs/nfsd/vfs.c
53421 +++ b/fs/nfsd/vfs.c
53422 @@ -939,7 +939,7 @@ nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
53423 } else {
53424 oldfs = get_fs();
53425 set_fs(KERNEL_DS);
53426 - host_err = vfs_readv(file, (struct iovec __user *)vec, vlen, &offset);
53427 + host_err = vfs_readv(file, (struct iovec __force_user *)vec, vlen, &offset);
53428 set_fs(oldfs);
53429 }
53430
53431 @@ -1026,7 +1026,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
53432
53433 /* Write the data. */
53434 oldfs = get_fs(); set_fs(KERNEL_DS);
53435 - host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &pos);
53436 + host_err = vfs_writev(file, (struct iovec __force_user *)vec, vlen, &pos);
53437 set_fs(oldfs);
53438 if (host_err < 0)
53439 goto out_nfserr;
53440 @@ -1572,7 +1572,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
53441 */
53442
53443 oldfs = get_fs(); set_fs(KERNEL_DS);
53444 - host_err = inode->i_op->readlink(path.dentry, (char __user *)buf, *lenp);
53445 + host_err = inode->i_op->readlink(path.dentry, (char __force_user *)buf, *lenp);
53446 set_fs(oldfs);
53447
53448 if (host_err < 0)
53449 diff --git a/fs/nls/nls_base.c b/fs/nls/nls_base.c
53450 index fea6bd5..8ee9d81 100644
53451 --- a/fs/nls/nls_base.c
53452 +++ b/fs/nls/nls_base.c
53453 @@ -234,20 +234,22 @@ EXPORT_SYMBOL(utf16s_to_utf8s);
53454
53455 int register_nls(struct nls_table * nls)
53456 {
53457 - struct nls_table ** tmp = &tables;
53458 + struct nls_table *tmp = tables;
53459
53460 if (nls->next)
53461 return -EBUSY;
53462
53463 spin_lock(&nls_lock);
53464 - while (*tmp) {
53465 - if (nls == *tmp) {
53466 + while (tmp) {
53467 + if (nls == tmp) {
53468 spin_unlock(&nls_lock);
53469 return -EBUSY;
53470 }
53471 - tmp = &(*tmp)->next;
53472 + tmp = tmp->next;
53473 }
53474 - nls->next = tables;
53475 + pax_open_kernel();
53476 + *(struct nls_table **)&nls->next = tables;
53477 + pax_close_kernel();
53478 tables = nls;
53479 spin_unlock(&nls_lock);
53480 return 0;
53481 @@ -255,12 +257,14 @@ int register_nls(struct nls_table * nls)
53482
53483 int unregister_nls(struct nls_table * nls)
53484 {
53485 - struct nls_table ** tmp = &tables;
53486 + struct nls_table * const * tmp = &tables;
53487
53488 spin_lock(&nls_lock);
53489 while (*tmp) {
53490 if (nls == *tmp) {
53491 - *tmp = nls->next;
53492 + pax_open_kernel();
53493 + *(struct nls_table **)tmp = nls->next;
53494 + pax_close_kernel();
53495 spin_unlock(&nls_lock);
53496 return 0;
53497 }
53498 diff --git a/fs/nls/nls_euc-jp.c b/fs/nls/nls_euc-jp.c
53499 index 7424929..35f6be5 100644
53500 --- a/fs/nls/nls_euc-jp.c
53501 +++ b/fs/nls/nls_euc-jp.c
53502 @@ -561,8 +561,10 @@ static int __init init_nls_euc_jp(void)
53503 p_nls = load_nls("cp932");
53504
53505 if (p_nls) {
53506 - table.charset2upper = p_nls->charset2upper;
53507 - table.charset2lower = p_nls->charset2lower;
53508 + pax_open_kernel();
53509 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
53510 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
53511 + pax_close_kernel();
53512 return register_nls(&table);
53513 }
53514
53515 diff --git a/fs/nls/nls_koi8-ru.c b/fs/nls/nls_koi8-ru.c
53516 index e7bc1d7..06bd4bb 100644
53517 --- a/fs/nls/nls_koi8-ru.c
53518 +++ b/fs/nls/nls_koi8-ru.c
53519 @@ -63,8 +63,10 @@ static int __init init_nls_koi8_ru(void)
53520 p_nls = load_nls("koi8-u");
53521
53522 if (p_nls) {
53523 - table.charset2upper = p_nls->charset2upper;
53524 - table.charset2lower = p_nls->charset2lower;
53525 + pax_open_kernel();
53526 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
53527 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
53528 + pax_close_kernel();
53529 return register_nls(&table);
53530 }
53531
53532 diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
53533 index 5d84442..bf24453 100644
53534 --- a/fs/notify/fanotify/fanotify_user.c
53535 +++ b/fs/notify/fanotify/fanotify_user.c
53536 @@ -251,8 +251,8 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
53537
53538 fd = fanotify_event_metadata.fd;
53539 ret = -EFAULT;
53540 - if (copy_to_user(buf, &fanotify_event_metadata,
53541 - fanotify_event_metadata.event_len))
53542 + if (fanotify_event_metadata.event_len > sizeof fanotify_event_metadata ||
53543 + copy_to_user(buf, &fanotify_event_metadata, fanotify_event_metadata.event_len))
53544 goto out_close_fd;
53545
53546 ret = prepare_for_access_response(group, event, fd);
53547 diff --git a/fs/notify/notification.c b/fs/notify/notification.c
53548 index 7b51b05..5ea5ef6 100644
53549 --- a/fs/notify/notification.c
53550 +++ b/fs/notify/notification.c
53551 @@ -57,7 +57,7 @@ static struct kmem_cache *fsnotify_event_holder_cachep;
53552 * get set to 0 so it will never get 'freed'
53553 */
53554 static struct fsnotify_event *q_overflow_event;
53555 -static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
53556 +static atomic_unchecked_t fsnotify_sync_cookie = ATOMIC_INIT(0);
53557
53558 /**
53559 * fsnotify_get_cookie - return a unique cookie for use in synchronizing events.
53560 @@ -65,7 +65,7 @@ static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
53561 */
53562 u32 fsnotify_get_cookie(void)
53563 {
53564 - return atomic_inc_return(&fsnotify_sync_cookie);
53565 + return atomic_inc_return_unchecked(&fsnotify_sync_cookie);
53566 }
53567 EXPORT_SYMBOL_GPL(fsnotify_get_cookie);
53568
53569 diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
53570 index aa411c3..c260a84 100644
53571 --- a/fs/ntfs/dir.c
53572 +++ b/fs/ntfs/dir.c
53573 @@ -1329,7 +1329,7 @@ find_next_index_buffer:
53574 ia = (INDEX_ALLOCATION*)(kaddr + (ia_pos & ~PAGE_CACHE_MASK &
53575 ~(s64)(ndir->itype.index.block_size - 1)));
53576 /* Bounds checks. */
53577 - if (unlikely((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
53578 + if (unlikely(!kaddr || (u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
53579 ntfs_error(sb, "Out of bounds check failed. Corrupt directory "
53580 "inode 0x%lx or driver bug.", vdir->i_ino);
53581 goto err_out;
53582 diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
53583 index 5b2d4f0..c6de396 100644
53584 --- a/fs/ntfs/file.c
53585 +++ b/fs/ntfs/file.c
53586 @@ -2242,6 +2242,6 @@ const struct inode_operations ntfs_file_inode_ops = {
53587 #endif /* NTFS_RW */
53588 };
53589
53590 -const struct file_operations ntfs_empty_file_ops = {};
53591 +const struct file_operations ntfs_empty_file_ops __read_only;
53592
53593 -const struct inode_operations ntfs_empty_inode_ops = {};
53594 +const struct inode_operations ntfs_empty_inode_ops __read_only;
53595 diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
53596 index aebeacd..0dcdd26 100644
53597 --- a/fs/ocfs2/localalloc.c
53598 +++ b/fs/ocfs2/localalloc.c
53599 @@ -1278,7 +1278,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
53600 goto bail;
53601 }
53602
53603 - atomic_inc(&osb->alloc_stats.moves);
53604 + atomic_inc_unchecked(&osb->alloc_stats.moves);
53605
53606 bail:
53607 if (handle)
53608 diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
53609 index d355e6e..578d905 100644
53610 --- a/fs/ocfs2/ocfs2.h
53611 +++ b/fs/ocfs2/ocfs2.h
53612 @@ -235,11 +235,11 @@ enum ocfs2_vol_state
53613
53614 struct ocfs2_alloc_stats
53615 {
53616 - atomic_t moves;
53617 - atomic_t local_data;
53618 - atomic_t bitmap_data;
53619 - atomic_t bg_allocs;
53620 - atomic_t bg_extends;
53621 + atomic_unchecked_t moves;
53622 + atomic_unchecked_t local_data;
53623 + atomic_unchecked_t bitmap_data;
53624 + atomic_unchecked_t bg_allocs;
53625 + atomic_unchecked_t bg_extends;
53626 };
53627
53628 enum ocfs2_local_alloc_state
53629 diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
53630 index b7e74b5..19c6536 100644
53631 --- a/fs/ocfs2/suballoc.c
53632 +++ b/fs/ocfs2/suballoc.c
53633 @@ -872,7 +872,7 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb,
53634 mlog_errno(status);
53635 goto bail;
53636 }
53637 - atomic_inc(&osb->alloc_stats.bg_extends);
53638 + atomic_inc_unchecked(&osb->alloc_stats.bg_extends);
53639
53640 /* You should never ask for this much metadata */
53641 BUG_ON(bits_wanted >
53642 @@ -2007,7 +2007,7 @@ int ocfs2_claim_metadata(handle_t *handle,
53643 mlog_errno(status);
53644 goto bail;
53645 }
53646 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
53647 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
53648
53649 *suballoc_loc = res.sr_bg_blkno;
53650 *suballoc_bit_start = res.sr_bit_offset;
53651 @@ -2171,7 +2171,7 @@ int ocfs2_claim_new_inode_at_loc(handle_t *handle,
53652 trace_ocfs2_claim_new_inode_at_loc((unsigned long long)di_blkno,
53653 res->sr_bits);
53654
53655 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
53656 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
53657
53658 BUG_ON(res->sr_bits != 1);
53659
53660 @@ -2213,7 +2213,7 @@ int ocfs2_claim_new_inode(handle_t *handle,
53661 mlog_errno(status);
53662 goto bail;
53663 }
53664 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
53665 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
53666
53667 BUG_ON(res.sr_bits != 1);
53668
53669 @@ -2317,7 +2317,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
53670 cluster_start,
53671 num_clusters);
53672 if (!status)
53673 - atomic_inc(&osb->alloc_stats.local_data);
53674 + atomic_inc_unchecked(&osb->alloc_stats.local_data);
53675 } else {
53676 if (min_clusters > (osb->bitmap_cpg - 1)) {
53677 /* The only paths asking for contiguousness
53678 @@ -2343,7 +2343,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
53679 ocfs2_desc_bitmap_to_cluster_off(ac->ac_inode,
53680 res.sr_bg_blkno,
53681 res.sr_bit_offset);
53682 - atomic_inc(&osb->alloc_stats.bitmap_data);
53683 + atomic_inc_unchecked(&osb->alloc_stats.bitmap_data);
53684 *num_clusters = res.sr_bits;
53685 }
53686 }
53687 diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
53688 index 01b8516..579c4df 100644
53689 --- a/fs/ocfs2/super.c
53690 +++ b/fs/ocfs2/super.c
53691 @@ -301,11 +301,11 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len)
53692 "%10s => GlobalAllocs: %d LocalAllocs: %d "
53693 "SubAllocs: %d LAWinMoves: %d SAExtends: %d\n",
53694 "Stats",
53695 - atomic_read(&osb->alloc_stats.bitmap_data),
53696 - atomic_read(&osb->alloc_stats.local_data),
53697 - atomic_read(&osb->alloc_stats.bg_allocs),
53698 - atomic_read(&osb->alloc_stats.moves),
53699 - atomic_read(&osb->alloc_stats.bg_extends));
53700 + atomic_read_unchecked(&osb->alloc_stats.bitmap_data),
53701 + atomic_read_unchecked(&osb->alloc_stats.local_data),
53702 + atomic_read_unchecked(&osb->alloc_stats.bg_allocs),
53703 + atomic_read_unchecked(&osb->alloc_stats.moves),
53704 + atomic_read_unchecked(&osb->alloc_stats.bg_extends));
53705
53706 out += snprintf(buf + out, len - out,
53707 "%10s => State: %u Descriptor: %llu Size: %u bits "
53708 @@ -2122,11 +2122,11 @@ static int ocfs2_initialize_super(struct super_block *sb,
53709 spin_lock_init(&osb->osb_xattr_lock);
53710 ocfs2_init_steal_slots(osb);
53711
53712 - atomic_set(&osb->alloc_stats.moves, 0);
53713 - atomic_set(&osb->alloc_stats.local_data, 0);
53714 - atomic_set(&osb->alloc_stats.bitmap_data, 0);
53715 - atomic_set(&osb->alloc_stats.bg_allocs, 0);
53716 - atomic_set(&osb->alloc_stats.bg_extends, 0);
53717 + atomic_set_unchecked(&osb->alloc_stats.moves, 0);
53718 + atomic_set_unchecked(&osb->alloc_stats.local_data, 0);
53719 + atomic_set_unchecked(&osb->alloc_stats.bitmap_data, 0);
53720 + atomic_set_unchecked(&osb->alloc_stats.bg_allocs, 0);
53721 + atomic_set_unchecked(&osb->alloc_stats.bg_extends, 0);
53722
53723 /* Copy the blockcheck stats from the superblock probe */
53724 osb->osb_ecc_stats = *stats;
53725 diff --git a/fs/open.c b/fs/open.c
53726 index 6835446..eadf09f 100644
53727 --- a/fs/open.c
53728 +++ b/fs/open.c
53729 @@ -32,6 +32,8 @@
53730 #include <linux/dnotify.h>
53731 #include <linux/compat.h>
53732
53733 +#define CREATE_TRACE_POINTS
53734 +#include <trace/events/fs.h>
53735 #include "internal.h"
53736
53737 int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
53738 @@ -102,6 +104,8 @@ long vfs_truncate(struct path *path, loff_t length)
53739 error = locks_verify_truncate(inode, NULL, length);
53740 if (!error)
53741 error = security_path_truncate(path);
53742 + if (!error && !gr_acl_handle_truncate(path->dentry, path->mnt))
53743 + error = -EACCES;
53744 if (!error)
53745 error = do_truncate(path->dentry, length, 0, NULL);
53746
53747 @@ -186,6 +190,8 @@ static long do_sys_ftruncate(unsigned int fd, loff_t length, int small)
53748 error = locks_verify_truncate(inode, f.file, length);
53749 if (!error)
53750 error = security_path_truncate(&f.file->f_path);
53751 + if (!error && !gr_acl_handle_truncate(f.file->f_path.dentry, f.file->f_path.mnt))
53752 + error = -EACCES;
53753 if (!error)
53754 error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, f.file);
53755 sb_end_write(inode->i_sb);
53756 @@ -388,6 +394,9 @@ retry:
53757 if (__mnt_is_readonly(path.mnt))
53758 res = -EROFS;
53759
53760 + if (!res && !gr_acl_handle_access(path.dentry, path.mnt, mode))
53761 + res = -EACCES;
53762 +
53763 out_path_release:
53764 path_put(&path);
53765 if (retry_estale(res, lookup_flags)) {
53766 @@ -419,6 +428,8 @@ retry:
53767 if (error)
53768 goto dput_and_out;
53769
53770 + gr_log_chdir(path.dentry, path.mnt);
53771 +
53772 set_fs_pwd(current->fs, &path);
53773
53774 dput_and_out:
53775 @@ -448,6 +459,13 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
53776 goto out_putf;
53777
53778 error = inode_permission(inode, MAY_EXEC | MAY_CHDIR);
53779 +
53780 + if (!error && !gr_chroot_fchdir(f.file->f_path.dentry, f.file->f_path.mnt))
53781 + error = -EPERM;
53782 +
53783 + if (!error)
53784 + gr_log_chdir(f.file->f_path.dentry, f.file->f_path.mnt);
53785 +
53786 if (!error)
53787 set_fs_pwd(current->fs, &f.file->f_path);
53788 out_putf:
53789 @@ -477,7 +495,13 @@ retry:
53790 if (error)
53791 goto dput_and_out;
53792
53793 + if (gr_handle_chroot_chroot(path.dentry, path.mnt))
53794 + goto dput_and_out;
53795 +
53796 set_fs_root(current->fs, &path);
53797 +
53798 + gr_handle_chroot_chdir(&path);
53799 +
53800 error = 0;
53801 dput_and_out:
53802 path_put(&path);
53803 @@ -499,6 +523,16 @@ static int chmod_common(struct path *path, umode_t mode)
53804 if (error)
53805 return error;
53806 mutex_lock(&inode->i_mutex);
53807 +
53808 + if (!gr_acl_handle_chmod(path->dentry, path->mnt, &mode)) {
53809 + error = -EACCES;
53810 + goto out_unlock;
53811 + }
53812 + if (gr_handle_chroot_chmod(path->dentry, path->mnt, mode)) {
53813 + error = -EACCES;
53814 + goto out_unlock;
53815 + }
53816 +
53817 error = security_path_chmod(path, mode);
53818 if (error)
53819 goto out_unlock;
53820 @@ -559,6 +593,9 @@ static int chown_common(struct path *path, uid_t user, gid_t group)
53821 uid = make_kuid(current_user_ns(), user);
53822 gid = make_kgid(current_user_ns(), group);
53823
53824 + if (!gr_acl_handle_chown(path->dentry, path->mnt))
53825 + return -EACCES;
53826 +
53827 newattrs.ia_valid = ATTR_CTIME;
53828 if (user != (uid_t) -1) {
53829 if (!uid_valid(uid))
53830 @@ -974,6 +1011,7 @@ long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode)
53831 } else {
53832 fsnotify_open(f);
53833 fd_install(fd, f);
53834 + trace_do_sys_open(tmp->name, flags, mode);
53835 }
53836 }
53837 putname(tmp);
53838 diff --git a/fs/pipe.c b/fs/pipe.c
53839 index 2234f3f..f9083a1 100644
53840 --- a/fs/pipe.c
53841 +++ b/fs/pipe.c
53842 @@ -438,9 +438,9 @@ redo:
53843 }
53844 if (bufs) /* More to do? */
53845 continue;
53846 - if (!pipe->writers)
53847 + if (!atomic_read(&pipe->writers))
53848 break;
53849 - if (!pipe->waiting_writers) {
53850 + if (!atomic_read(&pipe->waiting_writers)) {
53851 /* syscall merging: Usually we must not sleep
53852 * if O_NONBLOCK is set, or if we got some data.
53853 * But if a writer sleeps in kernel space, then
53854 @@ -504,7 +504,7 @@ pipe_write(struct kiocb *iocb, const struct iovec *_iov,
53855 mutex_lock(&inode->i_mutex);
53856 pipe = inode->i_pipe;
53857
53858 - if (!pipe->readers) {
53859 + if (!atomic_read(&pipe->readers)) {
53860 send_sig(SIGPIPE, current, 0);
53861 ret = -EPIPE;
53862 goto out;
53863 @@ -553,7 +553,7 @@ redo1:
53864 for (;;) {
53865 int bufs;
53866
53867 - if (!pipe->readers) {
53868 + if (!atomic_read(&pipe->readers)) {
53869 send_sig(SIGPIPE, current, 0);
53870 if (!ret)
53871 ret = -EPIPE;
53872 @@ -644,9 +644,9 @@ redo2:
53873 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
53874 do_wakeup = 0;
53875 }
53876 - pipe->waiting_writers++;
53877 + atomic_inc(&pipe->waiting_writers);
53878 pipe_wait(pipe);
53879 - pipe->waiting_writers--;
53880 + atomic_dec(&pipe->waiting_writers);
53881 }
53882 out:
53883 mutex_unlock(&inode->i_mutex);
53884 @@ -716,7 +716,7 @@ pipe_poll(struct file *filp, poll_table *wait)
53885 mask = 0;
53886 if (filp->f_mode & FMODE_READ) {
53887 mask = (nrbufs > 0) ? POLLIN | POLLRDNORM : 0;
53888 - if (!pipe->writers && filp->f_version != pipe->w_counter)
53889 + if (!atomic_read(&pipe->writers) && filp->f_version != pipe->w_counter)
53890 mask |= POLLHUP;
53891 }
53892
53893 @@ -726,7 +726,7 @@ pipe_poll(struct file *filp, poll_table *wait)
53894 * Most Unices do not set POLLERR for FIFOs but on Linux they
53895 * behave exactly like pipes for poll().
53896 */
53897 - if (!pipe->readers)
53898 + if (!atomic_read(&pipe->readers))
53899 mask |= POLLERR;
53900 }
53901
53902 @@ -740,10 +740,10 @@ pipe_release(struct inode *inode, int decr, int decw)
53903
53904 mutex_lock(&inode->i_mutex);
53905 pipe = inode->i_pipe;
53906 - pipe->readers -= decr;
53907 - pipe->writers -= decw;
53908 + atomic_sub(decr, &pipe->readers);
53909 + atomic_sub(decw, &pipe->writers);
53910
53911 - if (!pipe->readers && !pipe->writers) {
53912 + if (!atomic_read(&pipe->readers) && !atomic_read(&pipe->writers)) {
53913 free_pipe_info(inode);
53914 } else {
53915 wake_up_interruptible_sync_poll(&pipe->wait, POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM | POLLERR | POLLHUP);
53916 @@ -833,7 +833,7 @@ pipe_read_open(struct inode *inode, struct file *filp)
53917
53918 if (inode->i_pipe) {
53919 ret = 0;
53920 - inode->i_pipe->readers++;
53921 + atomic_inc(&inode->i_pipe->readers);
53922 }
53923
53924 mutex_unlock(&inode->i_mutex);
53925 @@ -850,7 +850,7 @@ pipe_write_open(struct inode *inode, struct file *filp)
53926
53927 if (inode->i_pipe) {
53928 ret = 0;
53929 - inode->i_pipe->writers++;
53930 + atomic_inc(&inode->i_pipe->writers);
53931 }
53932
53933 mutex_unlock(&inode->i_mutex);
53934 @@ -871,9 +871,9 @@ pipe_rdwr_open(struct inode *inode, struct file *filp)
53935 if (inode->i_pipe) {
53936 ret = 0;
53937 if (filp->f_mode & FMODE_READ)
53938 - inode->i_pipe->readers++;
53939 + atomic_inc(&inode->i_pipe->readers);
53940 if (filp->f_mode & FMODE_WRITE)
53941 - inode->i_pipe->writers++;
53942 + atomic_inc(&inode->i_pipe->writers);
53943 }
53944
53945 mutex_unlock(&inode->i_mutex);
53946 @@ -965,7 +965,7 @@ void free_pipe_info(struct inode *inode)
53947 inode->i_pipe = NULL;
53948 }
53949
53950 -static struct vfsmount *pipe_mnt __read_mostly;
53951 +struct vfsmount *pipe_mnt __read_mostly;
53952
53953 /*
53954 * pipefs_dname() is called from d_path().
53955 @@ -995,7 +995,8 @@ static struct inode * get_pipe_inode(void)
53956 goto fail_iput;
53957 inode->i_pipe = pipe;
53958
53959 - pipe->readers = pipe->writers = 1;
53960 + atomic_set(&pipe->readers, 1);
53961 + atomic_set(&pipe->writers, 1);
53962 inode->i_fop = &rdwr_pipefifo_fops;
53963
53964 /*
53965 diff --git a/fs/proc/Kconfig b/fs/proc/Kconfig
53966 index 15af622..0e9f4467 100644
53967 --- a/fs/proc/Kconfig
53968 +++ b/fs/proc/Kconfig
53969 @@ -30,12 +30,12 @@ config PROC_FS
53970
53971 config PROC_KCORE
53972 bool "/proc/kcore support" if !ARM
53973 - depends on PROC_FS && MMU
53974 + depends on PROC_FS && MMU && !GRKERNSEC_PROC_ADD
53975
53976 config PROC_VMCORE
53977 bool "/proc/vmcore support"
53978 - depends on PROC_FS && CRASH_DUMP
53979 - default y
53980 + depends on PROC_FS && CRASH_DUMP && !GRKERNSEC
53981 + default n
53982 help
53983 Exports the dump image of crashed kernel in ELF format.
53984
53985 @@ -59,8 +59,8 @@ config PROC_SYSCTL
53986 limited in memory.
53987
53988 config PROC_PAGE_MONITOR
53989 - default y
53990 - depends on PROC_FS && MMU
53991 + default n
53992 + depends on PROC_FS && MMU && !GRKERNSEC
53993 bool "Enable /proc page monitoring" if EXPERT
53994 help
53995 Various /proc files exist to monitor process memory utilization:
53996 diff --git a/fs/proc/array.c b/fs/proc/array.c
53997 index cbd0f1b..adec3f0 100644
53998 --- a/fs/proc/array.c
53999 +++ b/fs/proc/array.c
54000 @@ -60,6 +60,7 @@
54001 #include <linux/tty.h>
54002 #include <linux/string.h>
54003 #include <linux/mman.h>
54004 +#include <linux/grsecurity.h>
54005 #include <linux/proc_fs.h>
54006 #include <linux/ioport.h>
54007 #include <linux/uaccess.h>
54008 @@ -363,6 +364,21 @@ static void task_cpus_allowed(struct seq_file *m, struct task_struct *task)
54009 seq_putc(m, '\n');
54010 }
54011
54012 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
54013 +static inline void task_pax(struct seq_file *m, struct task_struct *p)
54014 +{
54015 + if (p->mm)
54016 + seq_printf(m, "PaX:\t%c%c%c%c%c\n",
54017 + p->mm->pax_flags & MF_PAX_PAGEEXEC ? 'P' : 'p',
54018 + p->mm->pax_flags & MF_PAX_EMUTRAMP ? 'E' : 'e',
54019 + p->mm->pax_flags & MF_PAX_MPROTECT ? 'M' : 'm',
54020 + p->mm->pax_flags & MF_PAX_RANDMMAP ? 'R' : 'r',
54021 + p->mm->pax_flags & MF_PAX_SEGMEXEC ? 'S' : 's');
54022 + else
54023 + seq_printf(m, "PaX:\t-----\n");
54024 +}
54025 +#endif
54026 +
54027 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
54028 struct pid *pid, struct task_struct *task)
54029 {
54030 @@ -381,9 +397,24 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
54031 task_cpus_allowed(m, task);
54032 cpuset_task_status_allowed(m, task);
54033 task_context_switch_counts(m, task);
54034 +
54035 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
54036 + task_pax(m, task);
54037 +#endif
54038 +
54039 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
54040 + task_grsec_rbac(m, task);
54041 +#endif
54042 +
54043 return 0;
54044 }
54045
54046 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54047 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
54048 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
54049 + _mm->pax_flags & MF_PAX_SEGMEXEC))
54050 +#endif
54051 +
54052 static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
54053 struct pid *pid, struct task_struct *task, int whole)
54054 {
54055 @@ -405,6 +436,13 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
54056 char tcomm[sizeof(task->comm)];
54057 unsigned long flags;
54058
54059 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54060 + if (current->exec_id != m->exec_id) {
54061 + gr_log_badprocpid("stat");
54062 + return 0;
54063 + }
54064 +#endif
54065 +
54066 state = *get_task_state(task);
54067 vsize = eip = esp = 0;
54068 permitted = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
54069 @@ -476,6 +514,19 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
54070 gtime = task_gtime(task);
54071 }
54072
54073 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54074 + if (PAX_RAND_FLAGS(mm)) {
54075 + eip = 0;
54076 + esp = 0;
54077 + wchan = 0;
54078 + }
54079 +#endif
54080 +#ifdef CONFIG_GRKERNSEC_HIDESYM
54081 + wchan = 0;
54082 + eip =0;
54083 + esp =0;
54084 +#endif
54085 +
54086 /* scale priority and nice values from timeslices to -20..20 */
54087 /* to make it look like a "normal" Unix priority/nice value */
54088 priority = task_prio(task);
54089 @@ -512,9 +563,15 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
54090 seq_put_decimal_ull(m, ' ', vsize);
54091 seq_put_decimal_ull(m, ' ', mm ? get_mm_rss(mm) : 0);
54092 seq_put_decimal_ull(m, ' ', rsslim);
54093 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54094 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->start_code : 1) : 0));
54095 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->end_code : 1) : 0));
54096 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 0 : ((permitted && mm) ? mm->start_stack : 0));
54097 +#else
54098 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->start_code : 1) : 0);
54099 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->end_code : 1) : 0);
54100 seq_put_decimal_ull(m, ' ', (permitted && mm) ? mm->start_stack : 0);
54101 +#endif
54102 seq_put_decimal_ull(m, ' ', esp);
54103 seq_put_decimal_ull(m, ' ', eip);
54104 /* The signal information here is obsolete.
54105 @@ -536,7 +593,11 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
54106 seq_put_decimal_ull(m, ' ', cputime_to_clock_t(gtime));
54107 seq_put_decimal_ll(m, ' ', cputime_to_clock_t(cgtime));
54108
54109 - if (mm && permitted) {
54110 + if (mm && permitted
54111 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54112 + && !PAX_RAND_FLAGS(mm)
54113 +#endif
54114 + ) {
54115 seq_put_decimal_ull(m, ' ', mm->start_data);
54116 seq_put_decimal_ull(m, ' ', mm->end_data);
54117 seq_put_decimal_ull(m, ' ', mm->start_brk);
54118 @@ -574,8 +635,15 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
54119 struct pid *pid, struct task_struct *task)
54120 {
54121 unsigned long size = 0, resident = 0, shared = 0, text = 0, data = 0;
54122 - struct mm_struct *mm = get_task_mm(task);
54123 + struct mm_struct *mm;
54124
54125 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54126 + if (current->exec_id != m->exec_id) {
54127 + gr_log_badprocpid("statm");
54128 + return 0;
54129 + }
54130 +#endif
54131 + mm = get_task_mm(task);
54132 if (mm) {
54133 size = task_statm(mm, &shared, &text, &data, &resident);
54134 mmput(mm);
54135 @@ -598,6 +666,13 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
54136 return 0;
54137 }
54138
54139 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
54140 +int proc_pid_ipaddr(struct task_struct *task, char *buffer)
54141 +{
54142 + return sprintf(buffer, "%pI4\n", &task->signal->curr_ip);
54143 +}
54144 +#endif
54145 +
54146 #ifdef CONFIG_CHECKPOINT_RESTORE
54147 static struct pid *
54148 get_children_pid(struct inode *inode, struct pid *pid_prev, loff_t pos)
54149 diff --git a/fs/proc/base.c b/fs/proc/base.c
54150 index 69078c7..3e12a75 100644
54151 --- a/fs/proc/base.c
54152 +++ b/fs/proc/base.c
54153 @@ -112,6 +112,14 @@ struct pid_entry {
54154 union proc_op op;
54155 };
54156
54157 +struct getdents_callback {
54158 + struct linux_dirent __user * current_dir;
54159 + struct linux_dirent __user * previous;
54160 + struct file * file;
54161 + int count;
54162 + int error;
54163 +};
54164 +
54165 #define NOD(NAME, MODE, IOP, FOP, OP) { \
54166 .name = (NAME), \
54167 .len = sizeof(NAME) - 1, \
54168 @@ -209,6 +217,9 @@ static int proc_pid_cmdline(struct task_struct *task, char * buffer)
54169 if (!mm->arg_end)
54170 goto out_mm; /* Shh! No looking before we're done */
54171
54172 + if (gr_acl_handle_procpidmem(task))
54173 + goto out_mm;
54174 +
54175 len = mm->arg_end - mm->arg_start;
54176
54177 if (len > PAGE_SIZE)
54178 @@ -236,12 +247,28 @@ out:
54179 return res;
54180 }
54181
54182 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54183 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
54184 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
54185 + _mm->pax_flags & MF_PAX_SEGMEXEC))
54186 +#endif
54187 +
54188 static int proc_pid_auxv(struct task_struct *task, char *buffer)
54189 {
54190 struct mm_struct *mm = mm_access(task, PTRACE_MODE_READ);
54191 int res = PTR_ERR(mm);
54192 if (mm && !IS_ERR(mm)) {
54193 unsigned int nwords = 0;
54194 +
54195 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54196 + /* allow if we're currently ptracing this task */
54197 + if (PAX_RAND_FLAGS(mm) &&
54198 + (!(task->ptrace & PT_PTRACED) || (task->parent != current))) {
54199 + mmput(mm);
54200 + return 0;
54201 + }
54202 +#endif
54203 +
54204 do {
54205 nwords += 2;
54206 } while (mm->saved_auxv[nwords - 2] != 0); /* AT_NULL */
54207 @@ -255,7 +282,7 @@ static int proc_pid_auxv(struct task_struct *task, char *buffer)
54208 }
54209
54210
54211 -#ifdef CONFIG_KALLSYMS
54212 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
54213 /*
54214 * Provides a wchan file via kallsyms in a proper one-value-per-file format.
54215 * Returns the resolved symbol. If that fails, simply return the address.
54216 @@ -294,7 +321,7 @@ static void unlock_trace(struct task_struct *task)
54217 mutex_unlock(&task->signal->cred_guard_mutex);
54218 }
54219
54220 -#ifdef CONFIG_STACKTRACE
54221 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
54222
54223 #define MAX_STACK_TRACE_DEPTH 64
54224
54225 @@ -486,7 +513,7 @@ static int proc_pid_limits(struct task_struct *task, char *buffer)
54226 return count;
54227 }
54228
54229 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
54230 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
54231 static int proc_pid_syscall(struct task_struct *task, char *buffer)
54232 {
54233 long nr;
54234 @@ -515,7 +542,7 @@ static int proc_pid_syscall(struct task_struct *task, char *buffer)
54235 /************************************************************************/
54236
54237 /* permission checks */
54238 -static int proc_fd_access_allowed(struct inode *inode)
54239 +static int proc_fd_access_allowed(struct inode *inode, unsigned int log)
54240 {
54241 struct task_struct *task;
54242 int allowed = 0;
54243 @@ -525,7 +552,10 @@ static int proc_fd_access_allowed(struct inode *inode)
54244 */
54245 task = get_proc_task(inode);
54246 if (task) {
54247 - allowed = ptrace_may_access(task, PTRACE_MODE_READ);
54248 + if (log)
54249 + allowed = ptrace_may_access(task, PTRACE_MODE_READ);
54250 + else
54251 + allowed = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
54252 put_task_struct(task);
54253 }
54254 return allowed;
54255 @@ -556,10 +586,35 @@ static bool has_pid_permissions(struct pid_namespace *pid,
54256 struct task_struct *task,
54257 int hide_pid_min)
54258 {
54259 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
54260 + return false;
54261 +
54262 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
54263 + rcu_read_lock();
54264 + {
54265 + const struct cred *tmpcred = current_cred();
54266 + const struct cred *cred = __task_cred(task);
54267 +
54268 + if (uid_eq(tmpcred->uid, GLOBAL_ROOT_UID) || uid_eq(tmpcred->uid, cred->uid)
54269 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
54270 + || in_group_p(grsec_proc_gid)
54271 +#endif
54272 + ) {
54273 + rcu_read_unlock();
54274 + return true;
54275 + }
54276 + }
54277 + rcu_read_unlock();
54278 +
54279 + if (!pid->hide_pid)
54280 + return false;
54281 +#endif
54282 +
54283 if (pid->hide_pid < hide_pid_min)
54284 return true;
54285 if (in_group_p(pid->pid_gid))
54286 return true;
54287 +
54288 return ptrace_may_access(task, PTRACE_MODE_READ);
54289 }
54290
54291 @@ -577,7 +632,11 @@ static int proc_pid_permission(struct inode *inode, int mask)
54292 put_task_struct(task);
54293
54294 if (!has_perms) {
54295 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
54296 + {
54297 +#else
54298 if (pid->hide_pid == 2) {
54299 +#endif
54300 /*
54301 * Let's make getdents(), stat(), and open()
54302 * consistent with each other. If a process
54303 @@ -675,6 +734,11 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
54304 if (!task)
54305 return -ESRCH;
54306
54307 + if (gr_acl_handle_procpidmem(task)) {
54308 + put_task_struct(task);
54309 + return -EPERM;
54310 + }
54311 +
54312 mm = mm_access(task, mode);
54313 put_task_struct(task);
54314
54315 @@ -690,6 +754,10 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
54316
54317 file->private_data = mm;
54318
54319 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54320 + file->f_version = current->exec_id;
54321 +#endif
54322 +
54323 return 0;
54324 }
54325
54326 @@ -711,6 +779,17 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
54327 ssize_t copied;
54328 char *page;
54329
54330 +#ifdef CONFIG_GRKERNSEC
54331 + if (write)
54332 + return -EPERM;
54333 +#endif
54334 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54335 + if (file->f_version != current->exec_id) {
54336 + gr_log_badprocpid("mem");
54337 + return 0;
54338 + }
54339 +#endif
54340 +
54341 if (!mm)
54342 return 0;
54343
54344 @@ -723,7 +802,7 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
54345 goto free;
54346
54347 while (count > 0) {
54348 - int this_len = min_t(int, count, PAGE_SIZE);
54349 + ssize_t this_len = min_t(ssize_t, count, PAGE_SIZE);
54350
54351 if (write && copy_from_user(page, buf, this_len)) {
54352 copied = -EFAULT;
54353 @@ -815,6 +894,13 @@ static ssize_t environ_read(struct file *file, char __user *buf,
54354 if (!mm)
54355 return 0;
54356
54357 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54358 + if (file->f_version != current->exec_id) {
54359 + gr_log_badprocpid("environ");
54360 + return 0;
54361 + }
54362 +#endif
54363 +
54364 page = (char *)__get_free_page(GFP_TEMPORARY);
54365 if (!page)
54366 return -ENOMEM;
54367 @@ -824,7 +910,7 @@ static ssize_t environ_read(struct file *file, char __user *buf,
54368 goto free;
54369 while (count > 0) {
54370 size_t this_len, max_len;
54371 - int retval;
54372 + ssize_t retval;
54373
54374 if (src >= (mm->env_end - mm->env_start))
54375 break;
54376 @@ -1430,7 +1516,7 @@ static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd)
54377 int error = -EACCES;
54378
54379 /* Are we allowed to snoop on the tasks file descriptors? */
54380 - if (!proc_fd_access_allowed(inode))
54381 + if (!proc_fd_access_allowed(inode, 0))
54382 goto out;
54383
54384 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
54385 @@ -1474,8 +1560,18 @@ static int proc_pid_readlink(struct dentry * dentry, char __user * buffer, int b
54386 struct path path;
54387
54388 /* Are we allowed to snoop on the tasks file descriptors? */
54389 - if (!proc_fd_access_allowed(inode))
54390 - goto out;
54391 + /* logging this is needed for learning on chromium to work properly,
54392 + but we don't want to flood the logs from 'ps' which does a readlink
54393 + on /proc/fd/2 of tasks in the listing, nor do we want 'ps' to learn
54394 + CAP_SYS_PTRACE as it's not necessary for its basic functionality
54395 + */
54396 + if (dentry->d_name.name[0] == '2' && dentry->d_name.name[1] == '\0') {
54397 + if (!proc_fd_access_allowed(inode,0))
54398 + goto out;
54399 + } else {
54400 + if (!proc_fd_access_allowed(inode,1))
54401 + goto out;
54402 + }
54403
54404 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
54405 if (error)
54406 @@ -1525,7 +1621,11 @@ struct inode *proc_pid_make_inode(struct super_block * sb, struct task_struct *t
54407 rcu_read_lock();
54408 cred = __task_cred(task);
54409 inode->i_uid = cred->euid;
54410 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
54411 + inode->i_gid = grsec_proc_gid;
54412 +#else
54413 inode->i_gid = cred->egid;
54414 +#endif
54415 rcu_read_unlock();
54416 }
54417 security_task_to_inode(task, inode);
54418 @@ -1561,10 +1661,19 @@ int pid_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
54419 return -ENOENT;
54420 }
54421 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
54422 +#ifdef CONFIG_GRKERNSEC_PROC_USER
54423 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
54424 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
54425 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
54426 +#endif
54427 task_dumpable(task)) {
54428 cred = __task_cred(task);
54429 stat->uid = cred->euid;
54430 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
54431 + stat->gid = grsec_proc_gid;
54432 +#else
54433 stat->gid = cred->egid;
54434 +#endif
54435 }
54436 }
54437 rcu_read_unlock();
54438 @@ -1602,11 +1711,20 @@ int pid_revalidate(struct dentry *dentry, unsigned int flags)
54439
54440 if (task) {
54441 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
54442 +#ifdef CONFIG_GRKERNSEC_PROC_USER
54443 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
54444 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
54445 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
54446 +#endif
54447 task_dumpable(task)) {
54448 rcu_read_lock();
54449 cred = __task_cred(task);
54450 inode->i_uid = cred->euid;
54451 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
54452 + inode->i_gid = grsec_proc_gid;
54453 +#else
54454 inode->i_gid = cred->egid;
54455 +#endif
54456 rcu_read_unlock();
54457 } else {
54458 inode->i_uid = GLOBAL_ROOT_UID;
54459 @@ -2059,6 +2177,9 @@ static struct dentry *proc_pident_lookup(struct inode *dir,
54460 if (!task)
54461 goto out_no_task;
54462
54463 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
54464 + goto out;
54465 +
54466 /*
54467 * Yes, it does not scale. And it should not. Don't add
54468 * new entries into /proc/<tgid>/ without very good reasons.
54469 @@ -2103,6 +2224,9 @@ static int proc_pident_readdir(struct file *filp,
54470 if (!task)
54471 goto out_no_task;
54472
54473 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
54474 + goto out;
54475 +
54476 ret = 0;
54477 i = filp->f_pos;
54478 switch (i) {
54479 @@ -2516,7 +2640,7 @@ static const struct pid_entry tgid_base_stuff[] = {
54480 REG("autogroup", S_IRUGO|S_IWUSR, proc_pid_sched_autogroup_operations),
54481 #endif
54482 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
54483 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
54484 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
54485 INF("syscall", S_IRUGO, proc_pid_syscall),
54486 #endif
54487 INF("cmdline", S_IRUGO, proc_pid_cmdline),
54488 @@ -2541,10 +2665,10 @@ static const struct pid_entry tgid_base_stuff[] = {
54489 #ifdef CONFIG_SECURITY
54490 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
54491 #endif
54492 -#ifdef CONFIG_KALLSYMS
54493 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
54494 INF("wchan", S_IRUGO, proc_pid_wchan),
54495 #endif
54496 -#ifdef CONFIG_STACKTRACE
54497 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
54498 ONE("stack", S_IRUGO, proc_pid_stack),
54499 #endif
54500 #ifdef CONFIG_SCHEDSTATS
54501 @@ -2578,6 +2702,9 @@ static const struct pid_entry tgid_base_stuff[] = {
54502 #ifdef CONFIG_HARDWALL
54503 INF("hardwall", S_IRUGO, proc_pid_hardwall),
54504 #endif
54505 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
54506 + INF("ipaddr", S_IRUSR, proc_pid_ipaddr),
54507 +#endif
54508 #ifdef CONFIG_USER_NS
54509 REG("uid_map", S_IRUGO|S_IWUSR, proc_uid_map_operations),
54510 REG("gid_map", S_IRUGO|S_IWUSR, proc_gid_map_operations),
54511 @@ -2707,7 +2834,14 @@ static struct dentry *proc_pid_instantiate(struct inode *dir,
54512 if (!inode)
54513 goto out;
54514
54515 +#ifdef CONFIG_GRKERNSEC_PROC_USER
54516 + inode->i_mode = S_IFDIR|S_IRUSR|S_IXUSR;
54517 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
54518 + inode->i_gid = grsec_proc_gid;
54519 + inode->i_mode = S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP;
54520 +#else
54521 inode->i_mode = S_IFDIR|S_IRUGO|S_IXUGO;
54522 +#endif
54523 inode->i_op = &proc_tgid_base_inode_operations;
54524 inode->i_fop = &proc_tgid_base_operations;
54525 inode->i_flags|=S_IMMUTABLE;
54526 @@ -2745,7 +2879,11 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, unsign
54527 if (!task)
54528 goto out;
54529
54530 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
54531 + goto out_put_task;
54532 +
54533 result = proc_pid_instantiate(dir, dentry, task, NULL);
54534 +out_put_task:
54535 put_task_struct(task);
54536 out:
54537 return result;
54538 @@ -2808,6 +2946,8 @@ static int proc_pid_fill_cache(struct file *filp, void *dirent, filldir_t filldi
54539 static int fake_filldir(void *buf, const char *name, int namelen,
54540 loff_t offset, u64 ino, unsigned d_type)
54541 {
54542 + struct getdents_callback * __buf = (struct getdents_callback *) buf;
54543 + __buf->error = -EINVAL;
54544 return 0;
54545 }
54546
54547 @@ -2859,7 +2999,7 @@ static const struct pid_entry tid_base_stuff[] = {
54548 REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations),
54549 #endif
54550 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
54551 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
54552 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
54553 INF("syscall", S_IRUGO, proc_pid_syscall),
54554 #endif
54555 INF("cmdline", S_IRUGO, proc_pid_cmdline),
54556 @@ -2886,10 +3026,10 @@ static const struct pid_entry tid_base_stuff[] = {
54557 #ifdef CONFIG_SECURITY
54558 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
54559 #endif
54560 -#ifdef CONFIG_KALLSYMS
54561 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
54562 INF("wchan", S_IRUGO, proc_pid_wchan),
54563 #endif
54564 -#ifdef CONFIG_STACKTRACE
54565 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
54566 ONE("stack", S_IRUGO, proc_pid_stack),
54567 #endif
54568 #ifdef CONFIG_SCHEDSTATS
54569 diff --git a/fs/proc/cmdline.c b/fs/proc/cmdline.c
54570 index 82676e3..5f8518a 100644
54571 --- a/fs/proc/cmdline.c
54572 +++ b/fs/proc/cmdline.c
54573 @@ -23,7 +23,11 @@ static const struct file_operations cmdline_proc_fops = {
54574
54575 static int __init proc_cmdline_init(void)
54576 {
54577 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
54578 + proc_create_grsec("cmdline", 0, NULL, &cmdline_proc_fops);
54579 +#else
54580 proc_create("cmdline", 0, NULL, &cmdline_proc_fops);
54581 +#endif
54582 return 0;
54583 }
54584 module_init(proc_cmdline_init);
54585 diff --git a/fs/proc/devices.c b/fs/proc/devices.c
54586 index b143471..bb105e5 100644
54587 --- a/fs/proc/devices.c
54588 +++ b/fs/proc/devices.c
54589 @@ -64,7 +64,11 @@ static const struct file_operations proc_devinfo_operations = {
54590
54591 static int __init proc_devices_init(void)
54592 {
54593 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
54594 + proc_create_grsec("devices", 0, NULL, &proc_devinfo_operations);
54595 +#else
54596 proc_create("devices", 0, NULL, &proc_devinfo_operations);
54597 +#endif
54598 return 0;
54599 }
54600 module_init(proc_devices_init);
54601 diff --git a/fs/proc/fd.c b/fs/proc/fd.c
54602 index d7a4a28..0201742 100644
54603 --- a/fs/proc/fd.c
54604 +++ b/fs/proc/fd.c
54605 @@ -25,7 +25,8 @@ static int seq_show(struct seq_file *m, void *v)
54606 if (!task)
54607 return -ENOENT;
54608
54609 - files = get_files_struct(task);
54610 + if (!gr_acl_handle_procpidmem(task))
54611 + files = get_files_struct(task);
54612 put_task_struct(task);
54613
54614 if (files) {
54615 @@ -302,11 +303,21 @@ static struct dentry *proc_lookupfd(struct inode *dir, struct dentry *dentry,
54616 */
54617 int proc_fd_permission(struct inode *inode, int mask)
54618 {
54619 + struct task_struct *task;
54620 int rv = generic_permission(inode, mask);
54621 - if (rv == 0)
54622 - return 0;
54623 +
54624 if (task_pid(current) == proc_pid(inode))
54625 rv = 0;
54626 +
54627 + task = get_proc_task(inode);
54628 + if (task == NULL)
54629 + return rv;
54630 +
54631 + if (gr_acl_handle_procpidmem(task))
54632 + rv = -EACCES;
54633 +
54634 + put_task_struct(task);
54635 +
54636 return rv;
54637 }
54638
54639 diff --git a/fs/proc/inode.c b/fs/proc/inode.c
54640 index 869116c..820cb27 100644
54641 --- a/fs/proc/inode.c
54642 +++ b/fs/proc/inode.c
54643 @@ -22,11 +22,17 @@
54644 #include <linux/seq_file.h>
54645 #include <linux/slab.h>
54646 #include <linux/mount.h>
54647 +#include <linux/grsecurity.h>
54648
54649 #include <asm/uaccess.h>
54650
54651 #include "internal.h"
54652
54653 +#ifdef CONFIG_PROC_SYSCTL
54654 +extern const struct inode_operations proc_sys_inode_operations;
54655 +extern const struct inode_operations proc_sys_dir_operations;
54656 +#endif
54657 +
54658 static void proc_evict_inode(struct inode *inode)
54659 {
54660 struct proc_dir_entry *de;
54661 @@ -54,6 +60,13 @@ static void proc_evict_inode(struct inode *inode)
54662 ns = PROC_I(inode)->ns;
54663 if (ns_ops && ns)
54664 ns_ops->put(ns);
54665 +
54666 +#ifdef CONFIG_PROC_SYSCTL
54667 + if (inode->i_op == &proc_sys_inode_operations ||
54668 + inode->i_op == &proc_sys_dir_operations)
54669 + gr_handle_delete(inode->i_ino, inode->i_sb->s_dev);
54670 +#endif
54671 +
54672 }
54673
54674 static struct kmem_cache * proc_inode_cachep;
54675 @@ -456,7 +469,11 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
54676 if (de->mode) {
54677 inode->i_mode = de->mode;
54678 inode->i_uid = de->uid;
54679 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
54680 + inode->i_gid = grsec_proc_gid;
54681 +#else
54682 inode->i_gid = de->gid;
54683 +#endif
54684 }
54685 if (de->size)
54686 inode->i_size = de->size;
54687 diff --git a/fs/proc/internal.h b/fs/proc/internal.h
54688 index 85ff3a4..a512bd8 100644
54689 --- a/fs/proc/internal.h
54690 +++ b/fs/proc/internal.h
54691 @@ -56,6 +56,9 @@ extern int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
54692 struct pid *pid, struct task_struct *task);
54693 extern int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
54694 struct pid *pid, struct task_struct *task);
54695 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
54696 +extern int proc_pid_ipaddr(struct task_struct *task, char *buffer);
54697 +#endif
54698 extern loff_t mem_lseek(struct file *file, loff_t offset, int orig);
54699
54700 extern const struct file_operations proc_tid_children_operations;
54701 diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
54702 index eda6f01..006ae24 100644
54703 --- a/fs/proc/kcore.c
54704 +++ b/fs/proc/kcore.c
54705 @@ -481,9 +481,10 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
54706 * the addresses in the elf_phdr on our list.
54707 */
54708 start = kc_offset_to_vaddr(*fpos - elf_buflen);
54709 - if ((tsz = (PAGE_SIZE - (start & ~PAGE_MASK))) > buflen)
54710 + tsz = PAGE_SIZE - (start & ~PAGE_MASK);
54711 + if (tsz > buflen)
54712 tsz = buflen;
54713 -
54714 +
54715 while (buflen) {
54716 struct kcore_list *m;
54717
54718 @@ -512,20 +513,23 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
54719 kfree(elf_buf);
54720 } else {
54721 if (kern_addr_valid(start)) {
54722 - unsigned long n;
54723 + char *elf_buf;
54724 + mm_segment_t oldfs;
54725
54726 - n = copy_to_user(buffer, (char *)start, tsz);
54727 - /*
54728 - * We cannot distinguish between fault on source
54729 - * and fault on destination. When this happens
54730 - * we clear too and hope it will trigger the
54731 - * EFAULT again.
54732 - */
54733 - if (n) {
54734 - if (clear_user(buffer + tsz - n,
54735 - n))
54736 + elf_buf = kmalloc(tsz, GFP_KERNEL);
54737 + if (!elf_buf)
54738 + return -ENOMEM;
54739 + oldfs = get_fs();
54740 + set_fs(KERNEL_DS);
54741 + if (!__copy_from_user(elf_buf, (const void __user *)start, tsz)) {
54742 + set_fs(oldfs);
54743 + if (copy_to_user(buffer, elf_buf, tsz)) {
54744 + kfree(elf_buf);
54745 return -EFAULT;
54746 + }
54747 }
54748 + set_fs(oldfs);
54749 + kfree(elf_buf);
54750 } else {
54751 if (clear_user(buffer, tsz))
54752 return -EFAULT;
54753 @@ -545,6 +549,9 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
54754
54755 static int open_kcore(struct inode *inode, struct file *filp)
54756 {
54757 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
54758 + return -EPERM;
54759 +#endif
54760 if (!capable(CAP_SYS_RAWIO))
54761 return -EPERM;
54762 if (kcore_need_update)
54763 diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
54764 index 1efaaa1..834e49a 100644
54765 --- a/fs/proc/meminfo.c
54766 +++ b/fs/proc/meminfo.c
54767 @@ -158,7 +158,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
54768 vmi.used >> 10,
54769 vmi.largest_chunk >> 10
54770 #ifdef CONFIG_MEMORY_FAILURE
54771 - ,atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT - 10)
54772 + ,atomic_long_read_unchecked(&num_poisoned_pages) << (PAGE_SHIFT - 10)
54773 #endif
54774 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
54775 ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
54776 diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
54777 index ccfd99b..1b7e255 100644
54778 --- a/fs/proc/nommu.c
54779 +++ b/fs/proc/nommu.c
54780 @@ -66,7 +66,7 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
54781 if (len < 1)
54782 len = 1;
54783 seq_printf(m, "%*c", len, ' ');
54784 - seq_path(m, &file->f_path, "");
54785 + seq_path(m, &file->f_path, "\n\\");
54786 }
54787
54788 seq_putc(m, '\n');
54789 diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c
54790 index b4ac657..0842bd2 100644
54791 --- a/fs/proc/proc_net.c
54792 +++ b/fs/proc/proc_net.c
54793 @@ -23,6 +23,7 @@
54794 #include <linux/nsproxy.h>
54795 #include <net/net_namespace.h>
54796 #include <linux/seq_file.h>
54797 +#include <linux/grsecurity.h>
54798
54799 #include "internal.h"
54800
54801 @@ -105,6 +106,17 @@ static struct net *get_proc_task_net(struct inode *dir)
54802 struct task_struct *task;
54803 struct nsproxy *ns;
54804 struct net *net = NULL;
54805 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
54806 + const struct cred *cred = current_cred();
54807 +#endif
54808 +
54809 +#ifdef CONFIG_GRKERNSEC_PROC_USER
54810 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID))
54811 + return net;
54812 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
54813 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID) && !in_group_p(grsec_proc_gid))
54814 + return net;
54815 +#endif
54816
54817 rcu_read_lock();
54818 task = pid_task(proc_pid(dir), PIDTYPE_PID);
54819 diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
54820 index ac05f33..1e6dc7e 100644
54821 --- a/fs/proc/proc_sysctl.c
54822 +++ b/fs/proc/proc_sysctl.c
54823 @@ -13,11 +13,15 @@
54824 #include <linux/module.h>
54825 #include "internal.h"
54826
54827 +extern int gr_handle_chroot_sysctl(const int op);
54828 +extern int gr_handle_sysctl_mod(const char *dirname, const char *name,
54829 + const int op);
54830 +
54831 static const struct dentry_operations proc_sys_dentry_operations;
54832 static const struct file_operations proc_sys_file_operations;
54833 -static const struct inode_operations proc_sys_inode_operations;
54834 +const struct inode_operations proc_sys_inode_operations;
54835 static const struct file_operations proc_sys_dir_file_operations;
54836 -static const struct inode_operations proc_sys_dir_operations;
54837 +const struct inode_operations proc_sys_dir_operations;
54838
54839 void proc_sys_poll_notify(struct ctl_table_poll *poll)
54840 {
54841 @@ -467,6 +471,9 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
54842
54843 err = NULL;
54844 d_set_d_op(dentry, &proc_sys_dentry_operations);
54845 +
54846 + gr_handle_proc_create(dentry, inode);
54847 +
54848 d_add(dentry, inode);
54849
54850 out:
54851 @@ -482,6 +489,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
54852 struct inode *inode = file_inode(filp);
54853 struct ctl_table_header *head = grab_header(inode);
54854 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
54855 + int op = write ? MAY_WRITE : MAY_READ;
54856 ssize_t error;
54857 size_t res;
54858
54859 @@ -493,7 +501,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
54860 * and won't be until we finish.
54861 */
54862 error = -EPERM;
54863 - if (sysctl_perm(head, table, write ? MAY_WRITE : MAY_READ))
54864 + if (sysctl_perm(head, table, op))
54865 goto out;
54866
54867 /* if that can happen at all, it should be -EINVAL, not -EISDIR */
54868 @@ -501,6 +509,22 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
54869 if (!table->proc_handler)
54870 goto out;
54871
54872 +#ifdef CONFIG_GRKERNSEC
54873 + error = -EPERM;
54874 + if (gr_handle_chroot_sysctl(op))
54875 + goto out;
54876 + dget(filp->f_path.dentry);
54877 + if (gr_handle_sysctl_mod(filp->f_path.dentry->d_parent->d_name.name, table->procname, op)) {
54878 + dput(filp->f_path.dentry);
54879 + goto out;
54880 + }
54881 + dput(filp->f_path.dentry);
54882 + if (!gr_acl_handle_open(filp->f_path.dentry, filp->f_path.mnt, op))
54883 + goto out;
54884 + if (write && !capable(CAP_SYS_ADMIN))
54885 + goto out;
54886 +#endif
54887 +
54888 /* careful: calling conventions are nasty here */
54889 res = count;
54890 error = table->proc_handler(table, write, buf, &res, ppos);
54891 @@ -598,6 +622,9 @@ static int proc_sys_fill_cache(struct file *filp, void *dirent,
54892 return -ENOMEM;
54893 } else {
54894 d_set_d_op(child, &proc_sys_dentry_operations);
54895 +
54896 + gr_handle_proc_create(child, inode);
54897 +
54898 d_add(child, inode);
54899 }
54900 } else {
54901 @@ -641,6 +668,9 @@ static int scan(struct ctl_table_header *head, ctl_table *table,
54902 if ((*pos)++ < file->f_pos)
54903 return 0;
54904
54905 + if (!gr_acl_handle_hidden_file(file->f_path.dentry, file->f_path.mnt))
54906 + return 0;
54907 +
54908 if (unlikely(S_ISLNK(table->mode)))
54909 res = proc_sys_link_fill_cache(file, dirent, filldir, head, table);
54910 else
54911 @@ -751,6 +781,9 @@ static int proc_sys_getattr(struct vfsmount *mnt, struct dentry *dentry, struct
54912 if (IS_ERR(head))
54913 return PTR_ERR(head);
54914
54915 + if (table && !gr_acl_handle_hidden_file(dentry, mnt))
54916 + return -ENOENT;
54917 +
54918 generic_fillattr(inode, stat);
54919 if (table)
54920 stat->mode = (stat->mode & S_IFMT) | table->mode;
54921 @@ -773,13 +806,13 @@ static const struct file_operations proc_sys_dir_file_operations = {
54922 .llseek = generic_file_llseek,
54923 };
54924
54925 -static const struct inode_operations proc_sys_inode_operations = {
54926 +const struct inode_operations proc_sys_inode_operations = {
54927 .permission = proc_sys_permission,
54928 .setattr = proc_sys_setattr,
54929 .getattr = proc_sys_getattr,
54930 };
54931
54932 -static const struct inode_operations proc_sys_dir_operations = {
54933 +const struct inode_operations proc_sys_dir_operations = {
54934 .lookup = proc_sys_lookup,
54935 .permission = proc_sys_permission,
54936 .setattr = proc_sys_setattr,
54937 @@ -855,7 +888,7 @@ static struct ctl_dir *find_subdir(struct ctl_dir *dir,
54938 static struct ctl_dir *new_dir(struct ctl_table_set *set,
54939 const char *name, int namelen)
54940 {
54941 - struct ctl_table *table;
54942 + ctl_table_no_const *table;
54943 struct ctl_dir *new;
54944 struct ctl_node *node;
54945 char *new_name;
54946 @@ -867,7 +900,7 @@ static struct ctl_dir *new_dir(struct ctl_table_set *set,
54947 return NULL;
54948
54949 node = (struct ctl_node *)(new + 1);
54950 - table = (struct ctl_table *)(node + 1);
54951 + table = (ctl_table_no_const *)(node + 1);
54952 new_name = (char *)(table + 2);
54953 memcpy(new_name, name, namelen);
54954 new_name[namelen] = '\0';
54955 @@ -1036,7 +1069,8 @@ static int sysctl_check_table(const char *path, struct ctl_table *table)
54956 static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table *table,
54957 struct ctl_table_root *link_root)
54958 {
54959 - struct ctl_table *link_table, *entry, *link;
54960 + ctl_table_no_const *link_table, *link;
54961 + struct ctl_table *entry;
54962 struct ctl_table_header *links;
54963 struct ctl_node *node;
54964 char *link_name;
54965 @@ -1059,7 +1093,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table
54966 return NULL;
54967
54968 node = (struct ctl_node *)(links + 1);
54969 - link_table = (struct ctl_table *)(node + nr_entries);
54970 + link_table = (ctl_table_no_const *)(node + nr_entries);
54971 link_name = (char *)&link_table[nr_entries + 1];
54972
54973 for (link = link_table, entry = table; entry->procname; link++, entry++) {
54974 @@ -1307,8 +1341,8 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
54975 struct ctl_table_header ***subheader, struct ctl_table_set *set,
54976 struct ctl_table *table)
54977 {
54978 - struct ctl_table *ctl_table_arg = NULL;
54979 - struct ctl_table *entry, *files;
54980 + ctl_table_no_const *ctl_table_arg = NULL, *files = NULL;
54981 + struct ctl_table *entry;
54982 int nr_files = 0;
54983 int nr_dirs = 0;
54984 int err = -ENOMEM;
54985 @@ -1320,10 +1354,9 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
54986 nr_files++;
54987 }
54988
54989 - files = table;
54990 /* If there are mixed files and directories we need a new table */
54991 if (nr_dirs && nr_files) {
54992 - struct ctl_table *new;
54993 + ctl_table_no_const *new;
54994 files = kzalloc(sizeof(struct ctl_table) * (nr_files + 1),
54995 GFP_KERNEL);
54996 if (!files)
54997 @@ -1341,7 +1374,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
54998 /* Register everything except a directory full of subdirectories */
54999 if (nr_files || !nr_dirs) {
55000 struct ctl_table_header *header;
55001 - header = __register_sysctl_table(set, path, files);
55002 + header = __register_sysctl_table(set, path, files ? files : table);
55003 if (!header) {
55004 kfree(ctl_table_arg);
55005 goto out;
55006 diff --git a/fs/proc/root.c b/fs/proc/root.c
55007 index 9c7fab1..ed1c8e0 100644
55008 --- a/fs/proc/root.c
55009 +++ b/fs/proc/root.c
55010 @@ -180,7 +180,15 @@ void __init proc_root_init(void)
55011 #ifdef CONFIG_PROC_DEVICETREE
55012 proc_device_tree_init();
55013 #endif
55014 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
55015 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55016 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR, NULL);
55017 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55018 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
55019 +#endif
55020 +#else
55021 proc_mkdir("bus", NULL);
55022 +#endif
55023 proc_sys_init();
55024 }
55025
55026 diff --git a/fs/proc/self.c b/fs/proc/self.c
55027 index aa5cc3b..c91a5d0 100644
55028 --- a/fs/proc/self.c
55029 +++ b/fs/proc/self.c
55030 @@ -37,7 +37,7 @@ static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
55031 static void proc_self_put_link(struct dentry *dentry, struct nameidata *nd,
55032 void *cookie)
55033 {
55034 - char *s = nd_get_link(nd);
55035 + const char *s = nd_get_link(nd);
55036 if (!IS_ERR(s))
55037 kfree(s);
55038 }
55039 diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
55040 index 3e636d8..83e3b71 100644
55041 --- a/fs/proc/task_mmu.c
55042 +++ b/fs/proc/task_mmu.c
55043 @@ -11,12 +11,19 @@
55044 #include <linux/rmap.h>
55045 #include <linux/swap.h>
55046 #include <linux/swapops.h>
55047 +#include <linux/grsecurity.h>
55048
55049 #include <asm/elf.h>
55050 #include <asm/uaccess.h>
55051 #include <asm/tlbflush.h>
55052 #include "internal.h"
55053
55054 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55055 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
55056 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
55057 + _mm->pax_flags & MF_PAX_SEGMEXEC))
55058 +#endif
55059 +
55060 void task_mem(struct seq_file *m, struct mm_struct *mm)
55061 {
55062 unsigned long data, text, lib, swap;
55063 @@ -52,8 +59,13 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
55064 "VmExe:\t%8lu kB\n"
55065 "VmLib:\t%8lu kB\n"
55066 "VmPTE:\t%8lu kB\n"
55067 - "VmSwap:\t%8lu kB\n",
55068 - hiwater_vm << (PAGE_SHIFT-10),
55069 + "VmSwap:\t%8lu kB\n"
55070 +
55071 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
55072 + "CsBase:\t%8lx\nCsLim:\t%8lx\n"
55073 +#endif
55074 +
55075 + ,hiwater_vm << (PAGE_SHIFT-10),
55076 total_vm << (PAGE_SHIFT-10),
55077 mm->locked_vm << (PAGE_SHIFT-10),
55078 mm->pinned_vm << (PAGE_SHIFT-10),
55079 @@ -62,7 +74,19 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
55080 data << (PAGE_SHIFT-10),
55081 mm->stack_vm << (PAGE_SHIFT-10), text, lib,
55082 (PTRS_PER_PTE*sizeof(pte_t)*mm->nr_ptes) >> 10,
55083 - swap << (PAGE_SHIFT-10));
55084 + swap << (PAGE_SHIFT-10)
55085 +
55086 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
55087 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55088 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_base
55089 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_limit
55090 +#else
55091 + , mm->context.user_cs_base
55092 + , mm->context.user_cs_limit
55093 +#endif
55094 +#endif
55095 +
55096 + );
55097 }
55098
55099 unsigned long task_vsize(struct mm_struct *mm)
55100 @@ -277,13 +301,13 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
55101 pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
55102 }
55103
55104 - /* We don't show the stack guard page in /proc/maps */
55105 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55106 + start = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_start;
55107 + end = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_end;
55108 +#else
55109 start = vma->vm_start;
55110 - if (stack_guard_page_start(vma, start))
55111 - start += PAGE_SIZE;
55112 end = vma->vm_end;
55113 - if (stack_guard_page_end(vma, end))
55114 - end -= PAGE_SIZE;
55115 +#endif
55116
55117 seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
55118 start,
55119 @@ -292,7 +316,11 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
55120 flags & VM_WRITE ? 'w' : '-',
55121 flags & VM_EXEC ? 'x' : '-',
55122 flags & VM_MAYSHARE ? 's' : 'p',
55123 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55124 + PAX_RAND_FLAGS(mm) ? 0UL : pgoff,
55125 +#else
55126 pgoff,
55127 +#endif
55128 MAJOR(dev), MINOR(dev), ino, &len);
55129
55130 /*
55131 @@ -301,7 +329,7 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
55132 */
55133 if (file) {
55134 pad_len_spaces(m, len);
55135 - seq_path(m, &file->f_path, "\n");
55136 + seq_path(m, &file->f_path, "\n\\");
55137 goto done;
55138 }
55139
55140 @@ -327,8 +355,9 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
55141 * Thread stack in /proc/PID/task/TID/maps or
55142 * the main process stack.
55143 */
55144 - if (!is_pid || (vma->vm_start <= mm->start_stack &&
55145 - vma->vm_end >= mm->start_stack)) {
55146 + if (!is_pid || (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP)) ||
55147 + (vma->vm_start <= mm->start_stack &&
55148 + vma->vm_end >= mm->start_stack)) {
55149 name = "[stack]";
55150 } else {
55151 /* Thread stack in /proc/PID/maps */
55152 @@ -352,6 +381,13 @@ static int show_map(struct seq_file *m, void *v, int is_pid)
55153 struct proc_maps_private *priv = m->private;
55154 struct task_struct *task = priv->task;
55155
55156 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55157 + if (current->exec_id != m->exec_id) {
55158 + gr_log_badprocpid("maps");
55159 + return 0;
55160 + }
55161 +#endif
55162 +
55163 show_map_vma(m, vma, is_pid);
55164
55165 if (m->count < m->size) /* vma is copied successfully */
55166 @@ -589,12 +625,23 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
55167 .private = &mss,
55168 };
55169
55170 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55171 + if (current->exec_id != m->exec_id) {
55172 + gr_log_badprocpid("smaps");
55173 + return 0;
55174 + }
55175 +#endif
55176 memset(&mss, 0, sizeof mss);
55177 - mss.vma = vma;
55178 - /* mmap_sem is held in m_start */
55179 - if (vma->vm_mm && !is_vm_hugetlb_page(vma))
55180 - walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
55181 -
55182 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55183 + if (!PAX_RAND_FLAGS(vma->vm_mm)) {
55184 +#endif
55185 + mss.vma = vma;
55186 + /* mmap_sem is held in m_start */
55187 + if (vma->vm_mm && !is_vm_hugetlb_page(vma))
55188 + walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
55189 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55190 + }
55191 +#endif
55192 show_map_vma(m, vma, is_pid);
55193
55194 seq_printf(m,
55195 @@ -612,7 +659,11 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
55196 "KernelPageSize: %8lu kB\n"
55197 "MMUPageSize: %8lu kB\n"
55198 "Locked: %8lu kB\n",
55199 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55200 + PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : (vma->vm_end - vma->vm_start) >> 10,
55201 +#else
55202 (vma->vm_end - vma->vm_start) >> 10,
55203 +#endif
55204 mss.resident >> 10,
55205 (unsigned long)(mss.pss >> (10 + PSS_SHIFT)),
55206 mss.shared_clean >> 10,
55207 @@ -1264,6 +1315,13 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
55208 int n;
55209 char buffer[50];
55210
55211 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55212 + if (current->exec_id != m->exec_id) {
55213 + gr_log_badprocpid("numa_maps");
55214 + return 0;
55215 + }
55216 +#endif
55217 +
55218 if (!mm)
55219 return 0;
55220
55221 @@ -1281,11 +1339,15 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
55222 mpol_to_str(buffer, sizeof(buffer), pol);
55223 mpol_cond_put(pol);
55224
55225 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55226 + seq_printf(m, "%08lx %s", PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : vma->vm_start, buffer);
55227 +#else
55228 seq_printf(m, "%08lx %s", vma->vm_start, buffer);
55229 +#endif
55230
55231 if (file) {
55232 seq_printf(m, " file=");
55233 - seq_path(m, &file->f_path, "\n\t= ");
55234 + seq_path(m, &file->f_path, "\n\t\\= ");
55235 } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) {
55236 seq_printf(m, " heap");
55237 } else {
55238 diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
55239 index 56123a6..5a2f6ec 100644
55240 --- a/fs/proc/task_nommu.c
55241 +++ b/fs/proc/task_nommu.c
55242 @@ -51,7 +51,7 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
55243 else
55244 bytes += kobjsize(mm);
55245
55246 - if (current->fs && current->fs->users > 1)
55247 + if (current->fs && atomic_read(&current->fs->users) > 1)
55248 sbytes += kobjsize(current->fs);
55249 else
55250 bytes += kobjsize(current->fs);
55251 @@ -168,7 +168,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
55252
55253 if (file) {
55254 pad_len_spaces(m, len);
55255 - seq_path(m, &file->f_path, "");
55256 + seq_path(m, &file->f_path, "\n\\");
55257 } else if (mm) {
55258 pid_t tid = vm_is_stack(priv->task, vma, is_pid);
55259
55260 diff --git a/fs/qnx6/qnx6.h b/fs/qnx6/qnx6.h
55261 index b00fcc9..e0c6381 100644
55262 --- a/fs/qnx6/qnx6.h
55263 +++ b/fs/qnx6/qnx6.h
55264 @@ -74,7 +74,7 @@ enum {
55265 BYTESEX_BE,
55266 };
55267
55268 -static inline __u64 fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
55269 +static inline __u64 __intentional_overflow(-1) fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
55270 {
55271 if (sbi->s_bytesex == BYTESEX_LE)
55272 return le64_to_cpu((__force __le64)n);
55273 @@ -90,7 +90,7 @@ static inline __fs64 cpu_to_fs64(struct qnx6_sb_info *sbi, __u64 n)
55274 return (__force __fs64)cpu_to_be64(n);
55275 }
55276
55277 -static inline __u32 fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
55278 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
55279 {
55280 if (sbi->s_bytesex == BYTESEX_LE)
55281 return le32_to_cpu((__force __le32)n);
55282 diff --git a/fs/quota/netlink.c b/fs/quota/netlink.c
55283 index 16e8abb..2dcf914 100644
55284 --- a/fs/quota/netlink.c
55285 +++ b/fs/quota/netlink.c
55286 @@ -33,7 +33,7 @@ static struct genl_family quota_genl_family = {
55287 void quota_send_warning(struct kqid qid, dev_t dev,
55288 const char warntype)
55289 {
55290 - static atomic_t seq;
55291 + static atomic_unchecked_t seq;
55292 struct sk_buff *skb;
55293 void *msg_head;
55294 int ret;
55295 @@ -49,7 +49,7 @@ void quota_send_warning(struct kqid qid, dev_t dev,
55296 "VFS: Not enough memory to send quota warning.\n");
55297 return;
55298 }
55299 - msg_head = genlmsg_put(skb, 0, atomic_add_return(1, &seq),
55300 + msg_head = genlmsg_put(skb, 0, atomic_add_return_unchecked(1, &seq),
55301 &quota_genl_family, 0, QUOTA_NL_C_WARNING);
55302 if (!msg_head) {
55303 printk(KERN_ERR
55304 diff --git a/fs/readdir.c b/fs/readdir.c
55305 index fee38e0..12fdf47 100644
55306 --- a/fs/readdir.c
55307 +++ b/fs/readdir.c
55308 @@ -17,6 +17,7 @@
55309 #include <linux/security.h>
55310 #include <linux/syscalls.h>
55311 #include <linux/unistd.h>
55312 +#include <linux/namei.h>
55313
55314 #include <asm/uaccess.h>
55315
55316 @@ -67,6 +68,7 @@ struct old_linux_dirent {
55317
55318 struct readdir_callback {
55319 struct old_linux_dirent __user * dirent;
55320 + struct file * file;
55321 int result;
55322 };
55323
55324 @@ -84,6 +86,10 @@ static int fillonedir(void * __buf, const char * name, int namlen, loff_t offset
55325 buf->result = -EOVERFLOW;
55326 return -EOVERFLOW;
55327 }
55328 +
55329 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
55330 + return 0;
55331 +
55332 buf->result++;
55333 dirent = buf->dirent;
55334 if (!access_ok(VERIFY_WRITE, dirent,
55335 @@ -114,6 +120,7 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd,
55336
55337 buf.result = 0;
55338 buf.dirent = dirent;
55339 + buf.file = f.file;
55340
55341 error = vfs_readdir(f.file, fillonedir, &buf);
55342 if (buf.result)
55343 @@ -139,6 +146,7 @@ struct linux_dirent {
55344 struct getdents_callback {
55345 struct linux_dirent __user * current_dir;
55346 struct linux_dirent __user * previous;
55347 + struct file * file;
55348 int count;
55349 int error;
55350 };
55351 @@ -160,6 +168,10 @@ static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
55352 buf->error = -EOVERFLOW;
55353 return -EOVERFLOW;
55354 }
55355 +
55356 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
55357 + return 0;
55358 +
55359 dirent = buf->previous;
55360 if (dirent) {
55361 if (__put_user(offset, &dirent->d_off))
55362 @@ -205,6 +217,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
55363 buf.previous = NULL;
55364 buf.count = count;
55365 buf.error = 0;
55366 + buf.file = f.file;
55367
55368 error = vfs_readdir(f.file, filldir, &buf);
55369 if (error >= 0)
55370 @@ -223,6 +236,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
55371 struct getdents_callback64 {
55372 struct linux_dirent64 __user * current_dir;
55373 struct linux_dirent64 __user * previous;
55374 + struct file *file;
55375 int count;
55376 int error;
55377 };
55378 @@ -238,6 +252,10 @@ static int filldir64(void * __buf, const char * name, int namlen, loff_t offset,
55379 buf->error = -EINVAL; /* only used if we fail.. */
55380 if (reclen > buf->count)
55381 return -EINVAL;
55382 +
55383 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
55384 + return 0;
55385 +
55386 dirent = buf->previous;
55387 if (dirent) {
55388 if (__put_user(offset, &dirent->d_off))
55389 @@ -283,6 +301,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
55390
55391 buf.current_dir = dirent;
55392 buf.previous = NULL;
55393 + buf.file = f.file;
55394 buf.count = count;
55395 buf.error = 0;
55396
55397 @@ -291,7 +310,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
55398 error = buf.error;
55399 lastdirent = buf.previous;
55400 if (lastdirent) {
55401 - typeof(lastdirent->d_off) d_off = f.file->f_pos;
55402 + typeof(((struct linux_dirent64 *)0)->d_off) d_off = f.file->f_pos;
55403 if (__put_user(d_off, &lastdirent->d_off))
55404 error = -EFAULT;
55405 else
55406 diff --git a/fs/reiserfs/do_balan.c b/fs/reiserfs/do_balan.c
55407 index 2b7882b..1c5ef48 100644
55408 --- a/fs/reiserfs/do_balan.c
55409 +++ b/fs/reiserfs/do_balan.c
55410 @@ -2051,7 +2051,7 @@ void do_balance(struct tree_balance *tb, /* tree_balance structure */
55411 return;
55412 }
55413
55414 - atomic_inc(&(fs_generation(tb->tb_sb)));
55415 + atomic_inc_unchecked(&(fs_generation(tb->tb_sb)));
55416 do_balance_starts(tb);
55417
55418 /* balance leaf returns 0 except if combining L R and S into
55419 diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c
55420 index 9cc0740a..46bf953 100644
55421 --- a/fs/reiserfs/procfs.c
55422 +++ b/fs/reiserfs/procfs.c
55423 @@ -112,7 +112,7 @@ static int show_super(struct seq_file *m, struct super_block *sb)
55424 "SMALL_TAILS " : "NO_TAILS ",
55425 replay_only(sb) ? "REPLAY_ONLY " : "",
55426 convert_reiserfs(sb) ? "CONV " : "",
55427 - atomic_read(&r->s_generation_counter),
55428 + atomic_read_unchecked(&r->s_generation_counter),
55429 SF(s_disk_reads), SF(s_disk_writes), SF(s_fix_nodes),
55430 SF(s_do_balance), SF(s_unneeded_left_neighbor),
55431 SF(s_good_search_by_key_reada), SF(s_bmaps),
55432 diff --git a/fs/reiserfs/reiserfs.h b/fs/reiserfs/reiserfs.h
55433 index 157e474..65a6114 100644
55434 --- a/fs/reiserfs/reiserfs.h
55435 +++ b/fs/reiserfs/reiserfs.h
55436 @@ -453,7 +453,7 @@ struct reiserfs_sb_info {
55437 /* Comment? -Hans */
55438 wait_queue_head_t s_wait;
55439 /* To be obsoleted soon by per buffer seals.. -Hans */
55440 - atomic_t s_generation_counter; // increased by one every time the
55441 + atomic_unchecked_t s_generation_counter; // increased by one every time the
55442 // tree gets re-balanced
55443 unsigned long s_properties; /* File system properties. Currently holds
55444 on-disk FS format */
55445 @@ -1978,7 +1978,7 @@ static inline loff_t max_reiserfs_offset(struct inode *inode)
55446 #define REISERFS_USER_MEM 1 /* reiserfs user memory mode */
55447
55448 #define fs_generation(s) (REISERFS_SB(s)->s_generation_counter)
55449 -#define get_generation(s) atomic_read (&fs_generation(s))
55450 +#define get_generation(s) atomic_read_unchecked (&fs_generation(s))
55451 #define FILESYSTEM_CHANGED_TB(tb) (get_generation((tb)->tb_sb) != (tb)->fs_gen)
55452 #define __fs_changed(gen,s) (gen != get_generation (s))
55453 #define fs_changed(gen,s) \
55454 diff --git a/fs/select.c b/fs/select.c
55455 index 8c1c96c..a0f9b6d 100644
55456 --- a/fs/select.c
55457 +++ b/fs/select.c
55458 @@ -20,6 +20,7 @@
55459 #include <linux/export.h>
55460 #include <linux/slab.h>
55461 #include <linux/poll.h>
55462 +#include <linux/security.h>
55463 #include <linux/personality.h> /* for STICKY_TIMEOUTS */
55464 #include <linux/file.h>
55465 #include <linux/fdtable.h>
55466 @@ -827,6 +828,7 @@ int do_sys_poll(struct pollfd __user *ufds, unsigned int nfds,
55467 struct poll_list *walk = head;
55468 unsigned long todo = nfds;
55469
55470 + gr_learn_resource(current, RLIMIT_NOFILE, nfds, 1);
55471 if (nfds > rlimit(RLIMIT_NOFILE))
55472 return -EINVAL;
55473
55474 diff --git a/fs/seq_file.c b/fs/seq_file.c
55475 index 38bb59f..a304f9d 100644
55476 --- a/fs/seq_file.c
55477 +++ b/fs/seq_file.c
55478 @@ -10,6 +10,7 @@
55479 #include <linux/seq_file.h>
55480 #include <linux/slab.h>
55481 #include <linux/cred.h>
55482 +#include <linux/sched.h>
55483
55484 #include <asm/uaccess.h>
55485 #include <asm/page.h>
55486 @@ -60,6 +61,9 @@ int seq_open(struct file *file, const struct seq_operations *op)
55487 #ifdef CONFIG_USER_NS
55488 p->user_ns = file->f_cred->user_ns;
55489 #endif
55490 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55491 + p->exec_id = current->exec_id;
55492 +#endif
55493
55494 /*
55495 * Wrappers around seq_open(e.g. swaps_open) need to be
55496 @@ -96,7 +100,7 @@ static int traverse(struct seq_file *m, loff_t offset)
55497 return 0;
55498 }
55499 if (!m->buf) {
55500 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
55501 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
55502 if (!m->buf)
55503 return -ENOMEM;
55504 }
55505 @@ -136,7 +140,7 @@ static int traverse(struct seq_file *m, loff_t offset)
55506 Eoverflow:
55507 m->op->stop(m, p);
55508 kfree(m->buf);
55509 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
55510 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
55511 return !m->buf ? -ENOMEM : -EAGAIN;
55512 }
55513
55514 @@ -191,7 +195,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
55515
55516 /* grab buffer if we didn't have one */
55517 if (!m->buf) {
55518 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
55519 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
55520 if (!m->buf)
55521 goto Enomem;
55522 }
55523 @@ -232,7 +236,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
55524 goto Fill;
55525 m->op->stop(m, p);
55526 kfree(m->buf);
55527 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
55528 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
55529 if (!m->buf)
55530 goto Enomem;
55531 m->count = 0;
55532 @@ -581,7 +585,7 @@ static void single_stop(struct seq_file *p, void *v)
55533 int single_open(struct file *file, int (*show)(struct seq_file *, void *),
55534 void *data)
55535 {
55536 - struct seq_operations *op = kmalloc(sizeof(*op), GFP_KERNEL);
55537 + seq_operations_no_const *op = kzalloc(sizeof(*op), GFP_KERNEL);
55538 int res = -ENOMEM;
55539
55540 if (op) {
55541 diff --git a/fs/splice.c b/fs/splice.c
55542 index 29e394e..b13c247 100644
55543 --- a/fs/splice.c
55544 +++ b/fs/splice.c
55545 @@ -195,7 +195,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
55546 pipe_lock(pipe);
55547
55548 for (;;) {
55549 - if (!pipe->readers) {
55550 + if (!atomic_read(&pipe->readers)) {
55551 send_sig(SIGPIPE, current, 0);
55552 if (!ret)
55553 ret = -EPIPE;
55554 @@ -249,9 +249,9 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
55555 do_wakeup = 0;
55556 }
55557
55558 - pipe->waiting_writers++;
55559 + atomic_inc(&pipe->waiting_writers);
55560 pipe_wait(pipe);
55561 - pipe->waiting_writers--;
55562 + atomic_dec(&pipe->waiting_writers);
55563 }
55564
55565 pipe_unlock(pipe);
55566 @@ -564,7 +564,7 @@ static ssize_t kernel_readv(struct file *file, const struct iovec *vec,
55567 old_fs = get_fs();
55568 set_fs(get_ds());
55569 /* The cast to a user pointer is valid due to the set_fs() */
55570 - res = vfs_readv(file, (const struct iovec __user *)vec, vlen, &pos);
55571 + res = vfs_readv(file, (const struct iovec __force_user *)vec, vlen, &pos);
55572 set_fs(old_fs);
55573
55574 return res;
55575 @@ -579,7 +579,7 @@ ssize_t kernel_write(struct file *file, const char *buf, size_t count,
55576 old_fs = get_fs();
55577 set_fs(get_ds());
55578 /* The cast to a user pointer is valid due to the set_fs() */
55579 - res = vfs_write(file, (__force const char __user *)buf, count, &pos);
55580 + res = vfs_write(file, (const char __force_user *)buf, count, &pos);
55581 set_fs(old_fs);
55582
55583 return res;
55584 @@ -632,7 +632,7 @@ ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
55585 goto err;
55586
55587 this_len = min_t(size_t, len, PAGE_CACHE_SIZE - offset);
55588 - vec[i].iov_base = (void __user *) page_address(page);
55589 + vec[i].iov_base = (void __force_user *) page_address(page);
55590 vec[i].iov_len = this_len;
55591 spd.pages[i] = page;
55592 spd.nr_pages++;
55593 @@ -853,10 +853,10 @@ EXPORT_SYMBOL(splice_from_pipe_feed);
55594 int splice_from_pipe_next(struct pipe_inode_info *pipe, struct splice_desc *sd)
55595 {
55596 while (!pipe->nrbufs) {
55597 - if (!pipe->writers)
55598 + if (!atomic_read(&pipe->writers))
55599 return 0;
55600
55601 - if (!pipe->waiting_writers && sd->num_spliced)
55602 + if (!atomic_read(&pipe->waiting_writers) && sd->num_spliced)
55603 return 0;
55604
55605 if (sd->flags & SPLICE_F_NONBLOCK)
55606 @@ -1192,7 +1192,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
55607 * out of the pipe right after the splice_to_pipe(). So set
55608 * PIPE_READERS appropriately.
55609 */
55610 - pipe->readers = 1;
55611 + atomic_set(&pipe->readers, 1);
55612
55613 current->splice_pipe = pipe;
55614 }
55615 @@ -1741,9 +1741,9 @@ static int ipipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
55616 ret = -ERESTARTSYS;
55617 break;
55618 }
55619 - if (!pipe->writers)
55620 + if (!atomic_read(&pipe->writers))
55621 break;
55622 - if (!pipe->waiting_writers) {
55623 + if (!atomic_read(&pipe->waiting_writers)) {
55624 if (flags & SPLICE_F_NONBLOCK) {
55625 ret = -EAGAIN;
55626 break;
55627 @@ -1775,7 +1775,7 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
55628 pipe_lock(pipe);
55629
55630 while (pipe->nrbufs >= pipe->buffers) {
55631 - if (!pipe->readers) {
55632 + if (!atomic_read(&pipe->readers)) {
55633 send_sig(SIGPIPE, current, 0);
55634 ret = -EPIPE;
55635 break;
55636 @@ -1788,9 +1788,9 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
55637 ret = -ERESTARTSYS;
55638 break;
55639 }
55640 - pipe->waiting_writers++;
55641 + atomic_inc(&pipe->waiting_writers);
55642 pipe_wait(pipe);
55643 - pipe->waiting_writers--;
55644 + atomic_dec(&pipe->waiting_writers);
55645 }
55646
55647 pipe_unlock(pipe);
55648 @@ -1826,14 +1826,14 @@ retry:
55649 pipe_double_lock(ipipe, opipe);
55650
55651 do {
55652 - if (!opipe->readers) {
55653 + if (!atomic_read(&opipe->readers)) {
55654 send_sig(SIGPIPE, current, 0);
55655 if (!ret)
55656 ret = -EPIPE;
55657 break;
55658 }
55659
55660 - if (!ipipe->nrbufs && !ipipe->writers)
55661 + if (!ipipe->nrbufs && !atomic_read(&ipipe->writers))
55662 break;
55663
55664 /*
55665 @@ -1930,7 +1930,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
55666 pipe_double_lock(ipipe, opipe);
55667
55668 do {
55669 - if (!opipe->readers) {
55670 + if (!atomic_read(&opipe->readers)) {
55671 send_sig(SIGPIPE, current, 0);
55672 if (!ret)
55673 ret = -EPIPE;
55674 @@ -1975,7 +1975,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
55675 * return EAGAIN if we have the potential of some data in the
55676 * future, otherwise just return 0
55677 */
55678 - if (!ret && ipipe->waiting_writers && (flags & SPLICE_F_NONBLOCK))
55679 + if (!ret && atomic_read(&ipipe->waiting_writers) && (flags & SPLICE_F_NONBLOCK))
55680 ret = -EAGAIN;
55681
55682 pipe_unlock(ipipe);
55683 diff --git a/fs/stat.c b/fs/stat.c
55684 index 04ce1ac..a13dd1e 100644
55685 --- a/fs/stat.c
55686 +++ b/fs/stat.c
55687 @@ -28,8 +28,13 @@ void generic_fillattr(struct inode *inode, struct kstat *stat)
55688 stat->gid = inode->i_gid;
55689 stat->rdev = inode->i_rdev;
55690 stat->size = i_size_read(inode);
55691 - stat->atime = inode->i_atime;
55692 - stat->mtime = inode->i_mtime;
55693 + if (is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
55694 + stat->atime = inode->i_ctime;
55695 + stat->mtime = inode->i_ctime;
55696 + } else {
55697 + stat->atime = inode->i_atime;
55698 + stat->mtime = inode->i_mtime;
55699 + }
55700 stat->ctime = inode->i_ctime;
55701 stat->blksize = (1 << inode->i_blkbits);
55702 stat->blocks = inode->i_blocks;
55703 @@ -46,8 +51,14 @@ int vfs_getattr(struct path *path, struct kstat *stat)
55704 if (retval)
55705 return retval;
55706
55707 - if (inode->i_op->getattr)
55708 - return inode->i_op->getattr(path->mnt, path->dentry, stat);
55709 + if (inode->i_op->getattr) {
55710 + retval = inode->i_op->getattr(path->mnt, path->dentry, stat);
55711 + if (!retval && is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
55712 + stat->atime = stat->ctime;
55713 + stat->mtime = stat->ctime;
55714 + }
55715 + return retval;
55716 + }
55717
55718 generic_fillattr(inode, stat);
55719 return 0;
55720 diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c
55721 index 15c68f9..36a8b3e 100644
55722 --- a/fs/sysfs/bin.c
55723 +++ b/fs/sysfs/bin.c
55724 @@ -235,13 +235,13 @@ static int bin_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
55725 return ret;
55726 }
55727
55728 -static int bin_access(struct vm_area_struct *vma, unsigned long addr,
55729 - void *buf, int len, int write)
55730 +static ssize_t bin_access(struct vm_area_struct *vma, unsigned long addr,
55731 + void *buf, size_t len, int write)
55732 {
55733 struct file *file = vma->vm_file;
55734 struct bin_buffer *bb = file->private_data;
55735 struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata;
55736 - int ret;
55737 + ssize_t ret;
55738
55739 if (!bb->vm_ops)
55740 return -EINVAL;
55741 diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
55742 index 6f31590..3c87c8a 100644
55743 --- a/fs/sysfs/dir.c
55744 +++ b/fs/sysfs/dir.c
55745 @@ -40,7 +40,7 @@ static DEFINE_IDA(sysfs_ino_ida);
55746 *
55747 * Returns 31 bit hash of ns + name (so it fits in an off_t )
55748 */
55749 -static unsigned int sysfs_name_hash(const void *ns, const char *name)
55750 +static unsigned int sysfs_name_hash(const void *ns, const unsigned char *name)
55751 {
55752 unsigned long hash = init_name_hash();
55753 unsigned int len = strlen(name);
55754 @@ -685,6 +685,18 @@ static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd,
55755 struct sysfs_dirent *sd;
55756 int rc;
55757
55758 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
55759 + const char *parent_name = parent_sd->s_name;
55760 +
55761 + mode = S_IFDIR | S_IRWXU;
55762 +
55763 + if ((!strcmp(parent_name, "") && (!strcmp(name, "devices") || !strcmp(name, "fs"))) ||
55764 + (!strcmp(parent_name, "devices") && !strcmp(name, "system")) ||
55765 + (!strcmp(parent_name, "fs") && (!strcmp(name, "selinux") || !strcmp(name, "fuse"))) ||
55766 + (!strcmp(parent_name, "system") && !strcmp(name, "cpu")))
55767 + mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
55768 +#endif
55769 +
55770 /* allocate */
55771 sd = sysfs_new_dirent(name, mode, SYSFS_DIR);
55772 if (!sd)
55773 diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
55774 index 602f56d..6853db8 100644
55775 --- a/fs/sysfs/file.c
55776 +++ b/fs/sysfs/file.c
55777 @@ -37,7 +37,7 @@ static DEFINE_SPINLOCK(sysfs_open_dirent_lock);
55778
55779 struct sysfs_open_dirent {
55780 atomic_t refcnt;
55781 - atomic_t event;
55782 + atomic_unchecked_t event;
55783 wait_queue_head_t poll;
55784 struct list_head buffers; /* goes through sysfs_buffer.list */
55785 };
55786 @@ -81,7 +81,7 @@ static int fill_read_buffer(struct dentry * dentry, struct sysfs_buffer * buffer
55787 if (!sysfs_get_active(attr_sd))
55788 return -ENODEV;
55789
55790 - buffer->event = atomic_read(&attr_sd->s_attr.open->event);
55791 + buffer->event = atomic_read_unchecked(&attr_sd->s_attr.open->event);
55792 count = ops->show(kobj, attr_sd->s_attr.attr, buffer->page);
55793
55794 sysfs_put_active(attr_sd);
55795 @@ -287,7 +287,7 @@ static int sysfs_get_open_dirent(struct sysfs_dirent *sd,
55796 return -ENOMEM;
55797
55798 atomic_set(&new_od->refcnt, 0);
55799 - atomic_set(&new_od->event, 1);
55800 + atomic_set_unchecked(&new_od->event, 1);
55801 init_waitqueue_head(&new_od->poll);
55802 INIT_LIST_HEAD(&new_od->buffers);
55803 goto retry;
55804 @@ -432,7 +432,7 @@ static unsigned int sysfs_poll(struct file *filp, poll_table *wait)
55805
55806 sysfs_put_active(attr_sd);
55807
55808 - if (buffer->event != atomic_read(&od->event))
55809 + if (buffer->event != atomic_read_unchecked(&od->event))
55810 goto trigger;
55811
55812 return DEFAULT_POLLMASK;
55813 @@ -451,7 +451,7 @@ void sysfs_notify_dirent(struct sysfs_dirent *sd)
55814
55815 od = sd->s_attr.open;
55816 if (od) {
55817 - atomic_inc(&od->event);
55818 + atomic_inc_unchecked(&od->event);
55819 wake_up_interruptible(&od->poll);
55820 }
55821
55822 diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
55823 index 8c940df..25b733e 100644
55824 --- a/fs/sysfs/symlink.c
55825 +++ b/fs/sysfs/symlink.c
55826 @@ -305,7 +305,7 @@ static void *sysfs_follow_link(struct dentry *dentry, struct nameidata *nd)
55827
55828 static void sysfs_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
55829 {
55830 - char *page = nd_get_link(nd);
55831 + const char *page = nd_get_link(nd);
55832 if (!IS_ERR(page))
55833 free_page((unsigned long)page);
55834 }
55835 diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h
55836 index 69d4889..a810bd4 100644
55837 --- a/fs/sysv/sysv.h
55838 +++ b/fs/sysv/sysv.h
55839 @@ -188,7 +188,7 @@ static inline u32 PDP_swab(u32 x)
55840 #endif
55841 }
55842
55843 -static inline __u32 fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
55844 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
55845 {
55846 if (sbi->s_bytesex == BYTESEX_PDP)
55847 return PDP_swab((__force __u32)n);
55848 diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c
55849 index e18b988..f1d4ad0f 100644
55850 --- a/fs/ubifs/io.c
55851 +++ b/fs/ubifs/io.c
55852 @@ -155,7 +155,7 @@ int ubifs_leb_change(struct ubifs_info *c, int lnum, const void *buf, int len)
55853 return err;
55854 }
55855
55856 -int ubifs_leb_unmap(struct ubifs_info *c, int lnum)
55857 +int __intentional_overflow(-1) ubifs_leb_unmap(struct ubifs_info *c, int lnum)
55858 {
55859 int err;
55860
55861 diff --git a/fs/udf/misc.c b/fs/udf/misc.c
55862 index c175b4d..8f36a16 100644
55863 --- a/fs/udf/misc.c
55864 +++ b/fs/udf/misc.c
55865 @@ -289,7 +289,7 @@ void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum,
55866
55867 u8 udf_tag_checksum(const struct tag *t)
55868 {
55869 - u8 *data = (u8 *)t;
55870 + const u8 *data = (const u8 *)t;
55871 u8 checksum = 0;
55872 int i;
55873 for (i = 0; i < sizeof(struct tag); ++i)
55874 diff --git a/fs/ufs/swab.h b/fs/ufs/swab.h
55875 index 8d974c4..b82f6ec 100644
55876 --- a/fs/ufs/swab.h
55877 +++ b/fs/ufs/swab.h
55878 @@ -22,7 +22,7 @@ enum {
55879 BYTESEX_BE
55880 };
55881
55882 -static inline u64
55883 +static inline u64 __intentional_overflow(-1)
55884 fs64_to_cpu(struct super_block *sbp, __fs64 n)
55885 {
55886 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
55887 @@ -40,7 +40,7 @@ cpu_to_fs64(struct super_block *sbp, u64 n)
55888 return (__force __fs64)cpu_to_be64(n);
55889 }
55890
55891 -static inline u32
55892 +static inline u32 __intentional_overflow(-1)
55893 fs32_to_cpu(struct super_block *sbp, __fs32 n)
55894 {
55895 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
55896 diff --git a/fs/utimes.c b/fs/utimes.c
55897 index f4fb7ec..3fe03c0 100644
55898 --- a/fs/utimes.c
55899 +++ b/fs/utimes.c
55900 @@ -1,6 +1,7 @@
55901 #include <linux/compiler.h>
55902 #include <linux/file.h>
55903 #include <linux/fs.h>
55904 +#include <linux/security.h>
55905 #include <linux/linkage.h>
55906 #include <linux/mount.h>
55907 #include <linux/namei.h>
55908 @@ -101,6 +102,12 @@ static int utimes_common(struct path *path, struct timespec *times)
55909 goto mnt_drop_write_and_out;
55910 }
55911 }
55912 +
55913 + if (!gr_acl_handle_utime(path->dentry, path->mnt)) {
55914 + error = -EACCES;
55915 + goto mnt_drop_write_and_out;
55916 + }
55917 +
55918 mutex_lock(&inode->i_mutex);
55919 error = notify_change(path->dentry, &newattrs);
55920 mutex_unlock(&inode->i_mutex);
55921 diff --git a/fs/xattr.c b/fs/xattr.c
55922 index 3377dff..4d074d9 100644
55923 --- a/fs/xattr.c
55924 +++ b/fs/xattr.c
55925 @@ -227,6 +227,27 @@ int vfs_xattr_cmp(struct dentry *dentry, const char *xattr_name,
55926 return rc;
55927 }
55928
55929 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
55930 +ssize_t
55931 +pax_getxattr(struct dentry *dentry, void *value, size_t size)
55932 +{
55933 + struct inode *inode = dentry->d_inode;
55934 + ssize_t error;
55935 +
55936 + error = inode_permission(inode, MAY_EXEC);
55937 + if (error)
55938 + return error;
55939 +
55940 + if (inode->i_op->getxattr)
55941 + error = inode->i_op->getxattr(dentry, XATTR_NAME_PAX_FLAGS, value, size);
55942 + else
55943 + error = -EOPNOTSUPP;
55944 +
55945 + return error;
55946 +}
55947 +EXPORT_SYMBOL(pax_getxattr);
55948 +#endif
55949 +
55950 ssize_t
55951 vfs_getxattr(struct dentry *dentry, const char *name, void *value, size_t size)
55952 {
55953 @@ -319,7 +340,7 @@ EXPORT_SYMBOL_GPL(vfs_removexattr);
55954 * Extended attribute SET operations
55955 */
55956 static long
55957 -setxattr(struct dentry *d, const char __user *name, const void __user *value,
55958 +setxattr(struct path *path, const char __user *name, const void __user *value,
55959 size_t size, int flags)
55960 {
55961 int error;
55962 @@ -355,7 +376,12 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value,
55963 posix_acl_fix_xattr_from_user(kvalue, size);
55964 }
55965
55966 - error = vfs_setxattr(d, kname, kvalue, size, flags);
55967 + if (!gr_acl_handle_setxattr(path->dentry, path->mnt)) {
55968 + error = -EACCES;
55969 + goto out;
55970 + }
55971 +
55972 + error = vfs_setxattr(path->dentry, kname, kvalue, size, flags);
55973 out:
55974 if (vvalue)
55975 vfree(vvalue);
55976 @@ -377,7 +403,7 @@ retry:
55977 return error;
55978 error = mnt_want_write(path.mnt);
55979 if (!error) {
55980 - error = setxattr(path.dentry, name, value, size, flags);
55981 + error = setxattr(&path, name, value, size, flags);
55982 mnt_drop_write(path.mnt);
55983 }
55984 path_put(&path);
55985 @@ -401,7 +427,7 @@ retry:
55986 return error;
55987 error = mnt_want_write(path.mnt);
55988 if (!error) {
55989 - error = setxattr(path.dentry, name, value, size, flags);
55990 + error = setxattr(&path, name, value, size, flags);
55991 mnt_drop_write(path.mnt);
55992 }
55993 path_put(&path);
55994 @@ -416,16 +442,14 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
55995 const void __user *,value, size_t, size, int, flags)
55996 {
55997 struct fd f = fdget(fd);
55998 - struct dentry *dentry;
55999 int error = -EBADF;
56000
56001 if (!f.file)
56002 return error;
56003 - dentry = f.file->f_path.dentry;
56004 - audit_inode(NULL, dentry, 0);
56005 + audit_inode(NULL, f.file->f_path.dentry, 0);
56006 error = mnt_want_write_file(f.file);
56007 if (!error) {
56008 - error = setxattr(dentry, name, value, size, flags);
56009 + error = setxattr(&f.file->f_path, name, value, size, flags);
56010 mnt_drop_write_file(f.file);
56011 }
56012 fdput(f);
56013 diff --git a/fs/xattr_acl.c b/fs/xattr_acl.c
56014 index 9fbea87..6b19972 100644
56015 --- a/fs/xattr_acl.c
56016 +++ b/fs/xattr_acl.c
56017 @@ -76,8 +76,8 @@ struct posix_acl *
56018 posix_acl_from_xattr(struct user_namespace *user_ns,
56019 const void *value, size_t size)
56020 {
56021 - posix_acl_xattr_header *header = (posix_acl_xattr_header *)value;
56022 - posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end;
56023 + const posix_acl_xattr_header *header = (const posix_acl_xattr_header *)value;
56024 + const posix_acl_xattr_entry *entry = (const posix_acl_xattr_entry *)(header+1), *end;
56025 int count;
56026 struct posix_acl *acl;
56027 struct posix_acl_entry *acl_e;
56028 diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
56029 index b44af92..06073da 100644
56030 --- a/fs/xfs/xfs_bmap.c
56031 +++ b/fs/xfs/xfs_bmap.c
56032 @@ -192,7 +192,7 @@ xfs_bmap_validate_ret(
56033 int nmap,
56034 int ret_nmap);
56035 #else
56036 -#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap)
56037 +#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap) do {} while (0)
56038 #endif /* DEBUG */
56039
56040 STATIC int
56041 diff --git a/fs/xfs/xfs_dir2_sf.c b/fs/xfs/xfs_dir2_sf.c
56042 index 1b9fc3e..e1bdde0 100644
56043 --- a/fs/xfs/xfs_dir2_sf.c
56044 +++ b/fs/xfs/xfs_dir2_sf.c
56045 @@ -851,7 +851,15 @@ xfs_dir2_sf_getdents(
56046 }
56047
56048 ino = xfs_dir2_sfe_get_ino(sfp, sfep);
56049 - if (filldir(dirent, (char *)sfep->name, sfep->namelen,
56050 + if (dp->i_df.if_u1.if_data == dp->i_df.if_u2.if_inline_data) {
56051 + char name[sfep->namelen];
56052 + memcpy(name, sfep->name, sfep->namelen);
56053 + if (filldir(dirent, name, sfep->namelen,
56054 + off & 0x7fffffff, ino, DT_UNKNOWN)) {
56055 + *offset = off & 0x7fffffff;
56056 + return 0;
56057 + }
56058 + } else if (filldir(dirent, (char *)sfep->name, sfep->namelen,
56059 off & 0x7fffffff, ino, DT_UNKNOWN)) {
56060 *offset = off & 0x7fffffff;
56061 return 0;
56062 diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
56063 index d681e34..2a3f5ab 100644
56064 --- a/fs/xfs/xfs_ioctl.c
56065 +++ b/fs/xfs/xfs_ioctl.c
56066 @@ -127,7 +127,7 @@ xfs_find_handle(
56067 }
56068
56069 error = -EFAULT;
56070 - if (copy_to_user(hreq->ohandle, &handle, hsize) ||
56071 + if (hsize > sizeof handle || copy_to_user(hreq->ohandle, &handle, hsize) ||
56072 copy_to_user(hreq->ohandlen, &hsize, sizeof(__s32)))
56073 goto out_put;
56074
56075 diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
56076 index d82efaa..0904a8e 100644
56077 --- a/fs/xfs/xfs_iops.c
56078 +++ b/fs/xfs/xfs_iops.c
56079 @@ -395,7 +395,7 @@ xfs_vn_put_link(
56080 struct nameidata *nd,
56081 void *p)
56082 {
56083 - char *s = nd_get_link(nd);
56084 + const char *s = nd_get_link(nd);
56085
56086 if (!IS_ERR(s))
56087 kfree(s);
56088 diff --git a/grsecurity/Kconfig b/grsecurity/Kconfig
56089 new file mode 100644
56090 index 0000000..7174794
56091 --- /dev/null
56092 +++ b/grsecurity/Kconfig
56093 @@ -0,0 +1,1031 @@
56094 +#
56095 +# grecurity configuration
56096 +#
56097 +menu "Memory Protections"
56098 +depends on GRKERNSEC
56099 +
56100 +config GRKERNSEC_KMEM
56101 + bool "Deny reading/writing to /dev/kmem, /dev/mem, and /dev/port"
56102 + default y if GRKERNSEC_CONFIG_AUTO
56103 + select STRICT_DEVMEM if (X86 || ARM || TILE || S390)
56104 + help
56105 + If you say Y here, /dev/kmem and /dev/mem won't be allowed to
56106 + be written to or read from to modify or leak the contents of the running
56107 + kernel. /dev/port will also not be allowed to be opened and support
56108 + for /dev/cpu/*/msr will be removed. If you have module
56109 + support disabled, enabling this will close up five ways that are
56110 + currently used to insert malicious code into the running kernel.
56111 +
56112 + Even with all these features enabled, we still highly recommend that
56113 + you use the RBAC system, as it is still possible for an attacker to
56114 + modify the running kernel through privileged I/O granted by ioperm/iopl.
56115 +
56116 + If you are not using XFree86, you may be able to stop this additional
56117 + case by enabling the 'Disable privileged I/O' option. Though nothing
56118 + legitimately writes to /dev/kmem, XFree86 does need to write to /dev/mem,
56119 + but only to video memory, which is the only writing we allow in this
56120 + case. If /dev/kmem or /dev/mem are mmaped without PROT_WRITE, they will
56121 + not be allowed to mprotect it with PROT_WRITE later.
56122 + Enabling this feature will prevent the "cpupower" and "powertop" tools
56123 + from working.
56124 +
56125 + It is highly recommended that you say Y here if you meet all the
56126 + conditions above.
56127 +
56128 +config GRKERNSEC_VM86
56129 + bool "Restrict VM86 mode"
56130 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
56131 + depends on X86_32
56132 +
56133 + help
56134 + If you say Y here, only processes with CAP_SYS_RAWIO will be able to
56135 + make use of a special execution mode on 32bit x86 processors called
56136 + Virtual 8086 (VM86) mode. XFree86 may need vm86 mode for certain
56137 + video cards and will still work with this option enabled. The purpose
56138 + of the option is to prevent exploitation of emulation errors in
56139 + virtualization of vm86 mode like the one discovered in VMWare in 2009.
56140 + Nearly all users should be able to enable this option.
56141 +
56142 +config GRKERNSEC_IO
56143 + bool "Disable privileged I/O"
56144 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
56145 + depends on X86
56146 + select RTC_CLASS
56147 + select RTC_INTF_DEV
56148 + select RTC_DRV_CMOS
56149 +
56150 + help
56151 + If you say Y here, all ioperm and iopl calls will return an error.
56152 + Ioperm and iopl can be used to modify the running kernel.
56153 + Unfortunately, some programs need this access to operate properly,
56154 + the most notable of which are XFree86 and hwclock. hwclock can be
56155 + remedied by having RTC support in the kernel, so real-time
56156 + clock support is enabled if this option is enabled, to ensure
56157 + that hwclock operates correctly. XFree86 still will not
56158 + operate correctly with this option enabled, so DO NOT CHOOSE Y
56159 + IF YOU USE XFree86. If you use XFree86 and you still want to
56160 + protect your kernel against modification, use the RBAC system.
56161 +
56162 +config GRKERNSEC_JIT_HARDEN
56163 + bool "Harden BPF JIT against spray attacks"
56164 + default y if GRKERNSEC_CONFIG_AUTO
56165 + depends on BPF_JIT
56166 + help
56167 + If you say Y here, the native code generated by the kernel's Berkeley
56168 + Packet Filter (BPF) JIT engine will be hardened against JIT-spraying
56169 + attacks that attempt to fit attacker-beneficial instructions in
56170 + 32bit immediate fields of JIT-generated native instructions. The
56171 + attacker will generally aim to cause an unintended instruction sequence
56172 + of JIT-generated native code to execute by jumping into the middle of
56173 + a generated instruction. This feature effectively randomizes the 32bit
56174 + immediate constants present in the generated code to thwart such attacks.
56175 +
56176 + If you're using KERNEXEC, it's recommended that you enable this option
56177 + to supplement the hardening of the kernel.
56178 +
56179 +config GRKERNSEC_RAND_THREADSTACK
56180 + bool "Insert random gaps between thread stacks"
56181 + default y if GRKERNSEC_CONFIG_AUTO
56182 + depends on PAX_RANDMMAP && !PPC && BROKEN
56183 + help
56184 + If you say Y here, a random-sized gap will be enforced between allocated
56185 + thread stacks. Glibc's NPTL and other threading libraries that
56186 + pass MAP_STACK to the kernel for thread stack allocation are supported.
56187 + The implementation currently provides 8 bits of entropy for the gap.
56188 +
56189 + Many distributions do not compile threaded remote services with the
56190 + -fstack-check argument to GCC, causing the variable-sized stack-based
56191 + allocator, alloca(), to not probe the stack on allocation. This
56192 + permits an unbounded alloca() to skip over any guard page and potentially
56193 + modify another thread's stack reliably. An enforced random gap
56194 + reduces the reliability of such an attack and increases the chance
56195 + that such a read/write to another thread's stack instead lands in
56196 + an unmapped area, causing a crash and triggering grsecurity's
56197 + anti-bruteforcing logic.
56198 +
56199 +config GRKERNSEC_PROC_MEMMAP
56200 + bool "Harden ASLR against information leaks and entropy reduction"
56201 + default y if (GRKERNSEC_CONFIG_AUTO || PAX_NOEXEC || PAX_ASLR)
56202 + depends on PAX_NOEXEC || PAX_ASLR
56203 + help
56204 + If you say Y here, the /proc/<pid>/maps and /proc/<pid>/stat files will
56205 + give no information about the addresses of its mappings if
56206 + PaX features that rely on random addresses are enabled on the task.
56207 + In addition to sanitizing this information and disabling other
56208 + dangerous sources of information, this option causes reads of sensitive
56209 + /proc/<pid> entries where the file descriptor was opened in a different
56210 + task than the one performing the read. Such attempts are logged.
56211 + This option also limits argv/env strings for suid/sgid binaries
56212 + to 512KB to prevent a complete exhaustion of the stack entropy provided
56213 + by ASLR. Finally, it places an 8MB stack resource limit on suid/sgid
56214 + binaries to prevent alternative mmap layouts from being abused.
56215 +
56216 + If you use PaX it is essential that you say Y here as it closes up
56217 + several holes that make full ASLR useless locally.
56218 +
56219 +config GRKERNSEC_BRUTE
56220 + bool "Deter exploit bruteforcing"
56221 + default y if GRKERNSEC_CONFIG_AUTO
56222 + help
56223 + If you say Y here, attempts to bruteforce exploits against forking
56224 + daemons such as apache or sshd, as well as against suid/sgid binaries
56225 + will be deterred. When a child of a forking daemon is killed by PaX
56226 + or crashes due to an illegal instruction or other suspicious signal,
56227 + the parent process will be delayed 30 seconds upon every subsequent
56228 + fork until the administrator is able to assess the situation and
56229 + restart the daemon.
56230 + In the suid/sgid case, the attempt is logged, the user has all their
56231 + processes terminated, and they are prevented from executing any further
56232 + processes for 15 minutes.
56233 + It is recommended that you also enable signal logging in the auditing
56234 + section so that logs are generated when a process triggers a suspicious
56235 + signal.
56236 + If the sysctl option is enabled, a sysctl option with name
56237 + "deter_bruteforce" is created.
56238 +
56239 +
56240 +config GRKERNSEC_MODHARDEN
56241 + bool "Harden module auto-loading"
56242 + default y if GRKERNSEC_CONFIG_AUTO
56243 + depends on MODULES
56244 + help
56245 + If you say Y here, module auto-loading in response to use of some
56246 + feature implemented by an unloaded module will be restricted to
56247 + root users. Enabling this option helps defend against attacks
56248 + by unprivileged users who abuse the auto-loading behavior to
56249 + cause a vulnerable module to load that is then exploited.
56250 +
56251 + If this option prevents a legitimate use of auto-loading for a
56252 + non-root user, the administrator can execute modprobe manually
56253 + with the exact name of the module mentioned in the alert log.
56254 + Alternatively, the administrator can add the module to the list
56255 + of modules loaded at boot by modifying init scripts.
56256 +
56257 + Modification of init scripts will most likely be needed on
56258 + Ubuntu servers with encrypted home directory support enabled,
56259 + as the first non-root user logging in will cause the ecb(aes),
56260 + ecb(aes)-all, cbc(aes), and cbc(aes)-all modules to be loaded.
56261 +
56262 +config GRKERNSEC_HIDESYM
56263 + bool "Hide kernel symbols"
56264 + default y if GRKERNSEC_CONFIG_AUTO
56265 + select PAX_USERCOPY_SLABS
56266 + help
56267 + If you say Y here, getting information on loaded modules, and
56268 + displaying all kernel symbols through a syscall will be restricted
56269 + to users with CAP_SYS_MODULE. For software compatibility reasons,
56270 + /proc/kallsyms will be restricted to the root user. The RBAC
56271 + system can hide that entry even from root.
56272 +
56273 + This option also prevents leaking of kernel addresses through
56274 + several /proc entries.
56275 +
56276 + Note that this option is only effective provided the following
56277 + conditions are met:
56278 + 1) The kernel using grsecurity is not precompiled by some distribution
56279 + 2) You have also enabled GRKERNSEC_DMESG
56280 + 3) You are using the RBAC system and hiding other files such as your
56281 + kernel image and System.map. Alternatively, enabling this option
56282 + causes the permissions on /boot, /lib/modules, and the kernel
56283 + source directory to change at compile time to prevent
56284 + reading by non-root users.
56285 + If the above conditions are met, this option will aid in providing a
56286 + useful protection against local kernel exploitation of overflows
56287 + and arbitrary read/write vulnerabilities.
56288 +
56289 +config GRKERNSEC_KERN_LOCKOUT
56290 + bool "Active kernel exploit response"
56291 + default y if GRKERNSEC_CONFIG_AUTO
56292 + depends on X86 || ARM || PPC || SPARC
56293 + help
56294 + If you say Y here, when a PaX alert is triggered due to suspicious
56295 + activity in the kernel (from KERNEXEC/UDEREF/USERCOPY)
56296 + or an OOPS occurs due to bad memory accesses, instead of just
56297 + terminating the offending process (and potentially allowing
56298 + a subsequent exploit from the same user), we will take one of two
56299 + actions:
56300 + If the user was root, we will panic the system
56301 + If the user was non-root, we will log the attempt, terminate
56302 + all processes owned by the user, then prevent them from creating
56303 + any new processes until the system is restarted
56304 + This deters repeated kernel exploitation/bruteforcing attempts
56305 + and is useful for later forensics.
56306 +
56307 +endmenu
56308 +menu "Role Based Access Control Options"
56309 +depends on GRKERNSEC
56310 +
56311 +config GRKERNSEC_RBAC_DEBUG
56312 + bool
56313 +
56314 +config GRKERNSEC_NO_RBAC
56315 + bool "Disable RBAC system"
56316 + help
56317 + If you say Y here, the /dev/grsec device will be removed from the kernel,
56318 + preventing the RBAC system from being enabled. You should only say Y
56319 + here if you have no intention of using the RBAC system, so as to prevent
56320 + an attacker with root access from misusing the RBAC system to hide files
56321 + and processes when loadable module support and /dev/[k]mem have been
56322 + locked down.
56323 +
56324 +config GRKERNSEC_ACL_HIDEKERN
56325 + bool "Hide kernel processes"
56326 + help
56327 + If you say Y here, all kernel threads will be hidden to all
56328 + processes but those whose subject has the "view hidden processes"
56329 + flag.
56330 +
56331 +config GRKERNSEC_ACL_MAXTRIES
56332 + int "Maximum tries before password lockout"
56333 + default 3
56334 + help
56335 + This option enforces the maximum number of times a user can attempt
56336 + to authorize themselves with the grsecurity RBAC system before being
56337 + denied the ability to attempt authorization again for a specified time.
56338 + The lower the number, the harder it will be to brute-force a password.
56339 +
56340 +config GRKERNSEC_ACL_TIMEOUT
56341 + int "Time to wait after max password tries, in seconds"
56342 + default 30
56343 + help
56344 + This option specifies the time the user must wait after attempting to
56345 + authorize to the RBAC system with the maximum number of invalid
56346 + passwords. The higher the number, the harder it will be to brute-force
56347 + a password.
56348 +
56349 +endmenu
56350 +menu "Filesystem Protections"
56351 +depends on GRKERNSEC
56352 +
56353 +config GRKERNSEC_PROC
56354 + bool "Proc restrictions"
56355 + default y if GRKERNSEC_CONFIG_AUTO
56356 + help
56357 + If you say Y here, the permissions of the /proc filesystem
56358 + will be altered to enhance system security and privacy. You MUST
56359 + choose either a user only restriction or a user and group restriction.
56360 + Depending upon the option you choose, you can either restrict users to
56361 + see only the processes they themselves run, or choose a group that can
56362 + view all processes and files normally restricted to root if you choose
56363 + the "restrict to user only" option. NOTE: If you're running identd or
56364 + ntpd as a non-root user, you will have to run it as the group you
56365 + specify here.
56366 +
56367 +config GRKERNSEC_PROC_USER
56368 + bool "Restrict /proc to user only"
56369 + depends on GRKERNSEC_PROC
56370 + help
56371 + If you say Y here, non-root users will only be able to view their own
56372 + processes, and restricts them from viewing network-related information,
56373 + and viewing kernel symbol and module information.
56374 +
56375 +config GRKERNSEC_PROC_USERGROUP
56376 + bool "Allow special group"
56377 + default y if GRKERNSEC_CONFIG_AUTO
56378 + depends on GRKERNSEC_PROC && !GRKERNSEC_PROC_USER
56379 + help
56380 + If you say Y here, you will be able to select a group that will be
56381 + able to view all processes and network-related information. If you've
56382 + enabled GRKERNSEC_HIDESYM, kernel and symbol information may still
56383 + remain hidden. This option is useful if you want to run identd as
56384 + a non-root user. The group you select may also be chosen at boot time
56385 + via "grsec_proc_gid=" on the kernel commandline.
56386 +
56387 +config GRKERNSEC_PROC_GID
56388 + int "GID for special group"
56389 + depends on GRKERNSEC_PROC_USERGROUP
56390 + default 1001
56391 +
56392 +config GRKERNSEC_PROC_ADD
56393 + bool "Additional restrictions"
56394 + default y if GRKERNSEC_CONFIG_AUTO
56395 + depends on GRKERNSEC_PROC_USER || GRKERNSEC_PROC_USERGROUP
56396 + help
56397 + If you say Y here, additional restrictions will be placed on
56398 + /proc that keep normal users from viewing device information and
56399 + slabinfo information that could be useful for exploits.
56400 +
56401 +config GRKERNSEC_LINK
56402 + bool "Linking restrictions"
56403 + default y if GRKERNSEC_CONFIG_AUTO
56404 + help
56405 + If you say Y here, /tmp race exploits will be prevented, since users
56406 + will no longer be able to follow symlinks owned by other users in
56407 + world-writable +t directories (e.g. /tmp), unless the owner of the
56408 + symlink is the owner of the directory. users will also not be
56409 + able to hardlink to files they do not own. If the sysctl option is
56410 + enabled, a sysctl option with name "linking_restrictions" is created.
56411 +
56412 +config GRKERNSEC_SYMLINKOWN
56413 + bool "Kernel-enforced SymlinksIfOwnerMatch"
56414 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
56415 + help
56416 + Apache's SymlinksIfOwnerMatch option has an inherent race condition
56417 + that prevents it from being used as a security feature. As Apache
56418 + verifies the symlink by performing a stat() against the target of
56419 + the symlink before it is followed, an attacker can setup a symlink
56420 + to point to a same-owned file, then replace the symlink with one
56421 + that targets another user's file just after Apache "validates" the
56422 + symlink -- a classic TOCTOU race. If you say Y here, a complete,
56423 + race-free replacement for Apache's "SymlinksIfOwnerMatch" option
56424 + will be in place for the group you specify. If the sysctl option
56425 + is enabled, a sysctl option with name "enforce_symlinksifowner" is
56426 + created.
56427 +
56428 +config GRKERNSEC_SYMLINKOWN_GID
56429 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
56430 + depends on GRKERNSEC_SYMLINKOWN
56431 + default 1006
56432 + help
56433 + Setting this GID determines what group kernel-enforced
56434 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
56435 + is enabled, a sysctl option with name "symlinkown_gid" is created.
56436 +
56437 +config GRKERNSEC_FIFO
56438 + bool "FIFO restrictions"
56439 + default y if GRKERNSEC_CONFIG_AUTO
56440 + help
56441 + If you say Y here, users will not be able to write to FIFOs they don't
56442 + own in world-writable +t directories (e.g. /tmp), unless the owner of
56443 + the FIFO is the same owner of the directory it's held in. If the sysctl
56444 + option is enabled, a sysctl option with name "fifo_restrictions" is
56445 + created.
56446 +
56447 +config GRKERNSEC_SYSFS_RESTRICT
56448 + bool "Sysfs/debugfs restriction"
56449 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
56450 + depends on SYSFS
56451 + help
56452 + If you say Y here, sysfs (the pseudo-filesystem mounted at /sys) and
56453 + any filesystem normally mounted under it (e.g. debugfs) will be
56454 + mostly accessible only by root. These filesystems generally provide access
56455 + to hardware and debug information that isn't appropriate for unprivileged
56456 + users of the system. Sysfs and debugfs have also become a large source
56457 + of new vulnerabilities, ranging from infoleaks to local compromise.
56458 + There has been very little oversight with an eye toward security involved
56459 + in adding new exporters of information to these filesystems, so their
56460 + use is discouraged.
56461 + For reasons of compatibility, a few directories have been whitelisted
56462 + for access by non-root users:
56463 + /sys/fs/selinux
56464 + /sys/fs/fuse
56465 + /sys/devices/system/cpu
56466 +
56467 +config GRKERNSEC_ROFS
56468 + bool "Runtime read-only mount protection"
56469 + help
56470 + If you say Y here, a sysctl option with name "romount_protect" will
56471 + be created. By setting this option to 1 at runtime, filesystems
56472 + will be protected in the following ways:
56473 + * No new writable mounts will be allowed
56474 + * Existing read-only mounts won't be able to be remounted read/write
56475 + * Write operations will be denied on all block devices
56476 + This option acts independently of grsec_lock: once it is set to 1,
56477 + it cannot be turned off. Therefore, please be mindful of the resulting
56478 + behavior if this option is enabled in an init script on a read-only
56479 + filesystem. This feature is mainly intended for secure embedded systems.
56480 +
56481 +config GRKERNSEC_DEVICE_SIDECHANNEL
56482 + bool "Eliminate stat/notify-based device sidechannels"
56483 + default y if GRKERNSEC_CONFIG_AUTO
56484 + help
56485 + If you say Y here, timing analyses on block or character
56486 + devices like /dev/ptmx using stat or inotify/dnotify/fanotify
56487 + will be thwarted for unprivileged users. If a process without
56488 + CAP_MKNOD stats such a device, the last access and last modify times
56489 + will match the device's create time. No access or modify events
56490 + will be triggered through inotify/dnotify/fanotify for such devices.
56491 + This feature will prevent attacks that may at a minimum
56492 + allow an attacker to determine the administrator's password length.
56493 +
56494 +config GRKERNSEC_CHROOT
56495 + bool "Chroot jail restrictions"
56496 + default y if GRKERNSEC_CONFIG_AUTO
56497 + help
56498 + If you say Y here, you will be able to choose several options that will
56499 + make breaking out of a chrooted jail much more difficult. If you
56500 + encounter no software incompatibilities with the following options, it
56501 + is recommended that you enable each one.
56502 +
56503 +config GRKERNSEC_CHROOT_MOUNT
56504 + bool "Deny mounts"
56505 + default y if GRKERNSEC_CONFIG_AUTO
56506 + depends on GRKERNSEC_CHROOT
56507 + help
56508 + If you say Y here, processes inside a chroot will not be able to
56509 + mount or remount filesystems. If the sysctl option is enabled, a
56510 + sysctl option with name "chroot_deny_mount" is created.
56511 +
56512 +config GRKERNSEC_CHROOT_DOUBLE
56513 + bool "Deny double-chroots"
56514 + default y if GRKERNSEC_CONFIG_AUTO
56515 + depends on GRKERNSEC_CHROOT
56516 + help
56517 + If you say Y here, processes inside a chroot will not be able to chroot
56518 + again outside the chroot. This is a widely used method of breaking
56519 + out of a chroot jail and should not be allowed. If the sysctl
56520 + option is enabled, a sysctl option with name
56521 + "chroot_deny_chroot" is created.
56522 +
56523 +config GRKERNSEC_CHROOT_PIVOT
56524 + bool "Deny pivot_root in chroot"
56525 + default y if GRKERNSEC_CONFIG_AUTO
56526 + depends on GRKERNSEC_CHROOT
56527 + help
56528 + If you say Y here, processes inside a chroot will not be able to use
56529 + a function called pivot_root() that was introduced in Linux 2.3.41. It
56530 + works similar to chroot in that it changes the root filesystem. This
56531 + function could be misused in a chrooted process to attempt to break out
56532 + of the chroot, and therefore should not be allowed. If the sysctl
56533 + option is enabled, a sysctl option with name "chroot_deny_pivot" is
56534 + created.
56535 +
56536 +config GRKERNSEC_CHROOT_CHDIR
56537 + bool "Enforce chdir(\"/\") on all chroots"
56538 + default y if GRKERNSEC_CONFIG_AUTO
56539 + depends on GRKERNSEC_CHROOT
56540 + help
56541 + If you say Y here, the current working directory of all newly-chrooted
56542 + applications will be set to the the root directory of the chroot.
56543 + The man page on chroot(2) states:
56544 + Note that this call does not change the current working
56545 + directory, so that `.' can be outside the tree rooted at
56546 + `/'. In particular, the super-user can escape from a
56547 + `chroot jail' by doing `mkdir foo; chroot foo; cd ..'.
56548 +
56549 + It is recommended that you say Y here, since it's not known to break
56550 + any software. If the sysctl option is enabled, a sysctl option with
56551 + name "chroot_enforce_chdir" is created.
56552 +
56553 +config GRKERNSEC_CHROOT_CHMOD
56554 + bool "Deny (f)chmod +s"
56555 + default y if GRKERNSEC_CONFIG_AUTO
56556 + depends on GRKERNSEC_CHROOT
56557 + help
56558 + If you say Y here, processes inside a chroot will not be able to chmod
56559 + or fchmod files to make them have suid or sgid bits. This protects
56560 + against another published method of breaking a chroot. If the sysctl
56561 + option is enabled, a sysctl option with name "chroot_deny_chmod" is
56562 + created.
56563 +
56564 +config GRKERNSEC_CHROOT_FCHDIR
56565 + bool "Deny fchdir out of chroot"
56566 + default y if GRKERNSEC_CONFIG_AUTO
56567 + depends on GRKERNSEC_CHROOT
56568 + help
56569 + If you say Y here, a well-known method of breaking chroots by fchdir'ing
56570 + to a file descriptor of the chrooting process that points to a directory
56571 + outside the filesystem will be stopped. If the sysctl option
56572 + is enabled, a sysctl option with name "chroot_deny_fchdir" is created.
56573 +
56574 +config GRKERNSEC_CHROOT_MKNOD
56575 + bool "Deny mknod"
56576 + default y if GRKERNSEC_CONFIG_AUTO
56577 + depends on GRKERNSEC_CHROOT
56578 + help
56579 + If you say Y here, processes inside a chroot will not be allowed to
56580 + mknod. The problem with using mknod inside a chroot is that it
56581 + would allow an attacker to create a device entry that is the same
56582 + as one on the physical root of your system, which could range from
56583 + anything from the console device to a device for your harddrive (which
56584 + they could then use to wipe the drive or steal data). It is recommended
56585 + that you say Y here, unless you run into software incompatibilities.
56586 + If the sysctl option is enabled, a sysctl option with name
56587 + "chroot_deny_mknod" is created.
56588 +
56589 +config GRKERNSEC_CHROOT_SHMAT
56590 + bool "Deny shmat() out of chroot"
56591 + default y if GRKERNSEC_CONFIG_AUTO
56592 + depends on GRKERNSEC_CHROOT
56593 + help
56594 + If you say Y here, processes inside a chroot will not be able to attach
56595 + to shared memory segments that were created outside of the chroot jail.
56596 + It is recommended that you say Y here. If the sysctl option is enabled,
56597 + a sysctl option with name "chroot_deny_shmat" is created.
56598 +
56599 +config GRKERNSEC_CHROOT_UNIX
56600 + bool "Deny access to abstract AF_UNIX sockets out of chroot"
56601 + default y if GRKERNSEC_CONFIG_AUTO
56602 + depends on GRKERNSEC_CHROOT
56603 + help
56604 + If you say Y here, processes inside a chroot will not be able to
56605 + connect to abstract (meaning not belonging to a filesystem) Unix
56606 + domain sockets that were bound outside of a chroot. It is recommended
56607 + that you say Y here. If the sysctl option is enabled, a sysctl option
56608 + with name "chroot_deny_unix" is created.
56609 +
56610 +config GRKERNSEC_CHROOT_FINDTASK
56611 + bool "Protect outside processes"
56612 + default y if GRKERNSEC_CONFIG_AUTO
56613 + depends on GRKERNSEC_CHROOT
56614 + help
56615 + If you say Y here, processes inside a chroot will not be able to
56616 + kill, send signals with fcntl, ptrace, capget, getpgid, setpgid,
56617 + getsid, or view any process outside of the chroot. If the sysctl
56618 + option is enabled, a sysctl option with name "chroot_findtask" is
56619 + created.
56620 +
56621 +config GRKERNSEC_CHROOT_NICE
56622 + bool "Restrict priority changes"
56623 + default y if GRKERNSEC_CONFIG_AUTO
56624 + depends on GRKERNSEC_CHROOT
56625 + help
56626 + If you say Y here, processes inside a chroot will not be able to raise
56627 + the priority of processes in the chroot, or alter the priority of
56628 + processes outside the chroot. This provides more security than simply
56629 + removing CAP_SYS_NICE from the process' capability set. If the
56630 + sysctl option is enabled, a sysctl option with name "chroot_restrict_nice"
56631 + is created.
56632 +
56633 +config GRKERNSEC_CHROOT_SYSCTL
56634 + bool "Deny sysctl writes"
56635 + default y if GRKERNSEC_CONFIG_AUTO
56636 + depends on GRKERNSEC_CHROOT
56637 + help
56638 + If you say Y here, an attacker in a chroot will not be able to
56639 + write to sysctl entries, either by sysctl(2) or through a /proc
56640 + interface. It is strongly recommended that you say Y here. If the
56641 + sysctl option is enabled, a sysctl option with name
56642 + "chroot_deny_sysctl" is created.
56643 +
56644 +config GRKERNSEC_CHROOT_CAPS
56645 + bool "Capability restrictions"
56646 + default y if GRKERNSEC_CONFIG_AUTO
56647 + depends on GRKERNSEC_CHROOT
56648 + help
56649 + If you say Y here, the capabilities on all processes within a
56650 + chroot jail will be lowered to stop module insertion, raw i/o,
56651 + system and net admin tasks, rebooting the system, modifying immutable
56652 + files, modifying IPC owned by another, and changing the system time.
56653 + This is left an option because it can break some apps. Disable this
56654 + if your chrooted apps are having problems performing those kinds of
56655 + tasks. If the sysctl option is enabled, a sysctl option with
56656 + name "chroot_caps" is created.
56657 +
56658 +config GRKERNSEC_CHROOT_INITRD
56659 + bool "Exempt initrd tasks from restrictions"
56660 + default y if GRKERNSEC_CONFIG_AUTO
56661 + depends on GRKERNSEC_CHROOT && BLK_DEV_RAM
56662 + help
56663 + If you say Y here, tasks started prior to init will be exempted from
56664 + grsecurity's chroot restrictions. This option is mainly meant to
56665 + resolve Plymouth's performing privileged operations unnecessarily
56666 + in a chroot.
56667 +
56668 +endmenu
56669 +menu "Kernel Auditing"
56670 +depends on GRKERNSEC
56671 +
56672 +config GRKERNSEC_AUDIT_GROUP
56673 + bool "Single group for auditing"
56674 + help
56675 + If you say Y here, the exec and chdir logging features will only operate
56676 + on a group you specify. This option is recommended if you only want to
56677 + watch certain users instead of having a large amount of logs from the
56678 + entire system. If the sysctl option is enabled, a sysctl option with
56679 + name "audit_group" is created.
56680 +
56681 +config GRKERNSEC_AUDIT_GID
56682 + int "GID for auditing"
56683 + depends on GRKERNSEC_AUDIT_GROUP
56684 + default 1007
56685 +
56686 +config GRKERNSEC_EXECLOG
56687 + bool "Exec logging"
56688 + help
56689 + If you say Y here, all execve() calls will be logged (since the
56690 + other exec*() calls are frontends to execve(), all execution
56691 + will be logged). Useful for shell-servers that like to keep track
56692 + of their users. If the sysctl option is enabled, a sysctl option with
56693 + name "exec_logging" is created.
56694 + WARNING: This option when enabled will produce a LOT of logs, especially
56695 + on an active system.
56696 +
56697 +config GRKERNSEC_RESLOG
56698 + bool "Resource logging"
56699 + default y if GRKERNSEC_CONFIG_AUTO
56700 + help
56701 + If you say Y here, all attempts to overstep resource limits will
56702 + be logged with the resource name, the requested size, and the current
56703 + limit. It is highly recommended that you say Y here. If the sysctl
56704 + option is enabled, a sysctl option with name "resource_logging" is
56705 + created. If the RBAC system is enabled, the sysctl value is ignored.
56706 +
56707 +config GRKERNSEC_CHROOT_EXECLOG
56708 + bool "Log execs within chroot"
56709 + help
56710 + If you say Y here, all executions inside a chroot jail will be logged
56711 + to syslog. This can cause a large amount of logs if certain
56712 + applications (eg. djb's daemontools) are installed on the system, and
56713 + is therefore left as an option. If the sysctl option is enabled, a
56714 + sysctl option with name "chroot_execlog" is created.
56715 +
56716 +config GRKERNSEC_AUDIT_PTRACE
56717 + bool "Ptrace logging"
56718 + help
56719 + If you say Y here, all attempts to attach to a process via ptrace
56720 + will be logged. If the sysctl option is enabled, a sysctl option
56721 + with name "audit_ptrace" is created.
56722 +
56723 +config GRKERNSEC_AUDIT_CHDIR
56724 + bool "Chdir logging"
56725 + help
56726 + If you say Y here, all chdir() calls will be logged. If the sysctl
56727 + option is enabled, a sysctl option with name "audit_chdir" is created.
56728 +
56729 +config GRKERNSEC_AUDIT_MOUNT
56730 + bool "(Un)Mount logging"
56731 + help
56732 + If you say Y here, all mounts and unmounts will be logged. If the
56733 + sysctl option is enabled, a sysctl option with name "audit_mount" is
56734 + created.
56735 +
56736 +config GRKERNSEC_SIGNAL
56737 + bool "Signal logging"
56738 + default y if GRKERNSEC_CONFIG_AUTO
56739 + help
56740 + If you say Y here, certain important signals will be logged, such as
56741 + SIGSEGV, which will as a result inform you of when a error in a program
56742 + occurred, which in some cases could mean a possible exploit attempt.
56743 + If the sysctl option is enabled, a sysctl option with name
56744 + "signal_logging" is created.
56745 +
56746 +config GRKERNSEC_FORKFAIL
56747 + bool "Fork failure logging"
56748 + help
56749 + If you say Y here, all failed fork() attempts will be logged.
56750 + This could suggest a fork bomb, or someone attempting to overstep
56751 + their process limit. If the sysctl option is enabled, a sysctl option
56752 + with name "forkfail_logging" is created.
56753 +
56754 +config GRKERNSEC_TIME
56755 + bool "Time change logging"
56756 + default y if GRKERNSEC_CONFIG_AUTO
56757 + help
56758 + If you say Y here, any changes of the system clock will be logged.
56759 + If the sysctl option is enabled, a sysctl option with name
56760 + "timechange_logging" is created.
56761 +
56762 +config GRKERNSEC_PROC_IPADDR
56763 + bool "/proc/<pid>/ipaddr support"
56764 + default y if GRKERNSEC_CONFIG_AUTO
56765 + help
56766 + If you say Y here, a new entry will be added to each /proc/<pid>
56767 + directory that contains the IP address of the person using the task.
56768 + The IP is carried across local TCP and AF_UNIX stream sockets.
56769 + This information can be useful for IDS/IPSes to perform remote response
56770 + to a local attack. The entry is readable by only the owner of the
56771 + process (and root if he has CAP_DAC_OVERRIDE, which can be removed via
56772 + the RBAC system), and thus does not create privacy concerns.
56773 +
56774 +config GRKERNSEC_RWXMAP_LOG
56775 + bool 'Denied RWX mmap/mprotect logging'
56776 + default y if GRKERNSEC_CONFIG_AUTO
56777 + depends on PAX_MPROTECT && !PAX_EMUPLT && !PAX_EMUSIGRT
56778 + help
56779 + If you say Y here, calls to mmap() and mprotect() with explicit
56780 + usage of PROT_WRITE and PROT_EXEC together will be logged when
56781 + denied by the PAX_MPROTECT feature. If the sysctl option is
56782 + enabled, a sysctl option with name "rwxmap_logging" is created.
56783 +
56784 +config GRKERNSEC_AUDIT_TEXTREL
56785 + bool 'ELF text relocations logging (READ HELP)'
56786 + depends on PAX_MPROTECT
56787 + help
56788 + If you say Y here, text relocations will be logged with the filename
56789 + of the offending library or binary. The purpose of the feature is
56790 + to help Linux distribution developers get rid of libraries and
56791 + binaries that need text relocations which hinder the future progress
56792 + of PaX. Only Linux distribution developers should say Y here, and
56793 + never on a production machine, as this option creates an information
56794 + leak that could aid an attacker in defeating the randomization of
56795 + a single memory region. If the sysctl option is enabled, a sysctl
56796 + option with name "audit_textrel" is created.
56797 +
56798 +endmenu
56799 +
56800 +menu "Executable Protections"
56801 +depends on GRKERNSEC
56802 +
56803 +config GRKERNSEC_DMESG
56804 + bool "Dmesg(8) restriction"
56805 + default y if GRKERNSEC_CONFIG_AUTO
56806 + help
56807 + If you say Y here, non-root users will not be able to use dmesg(8)
56808 + to view the contents of the kernel's circular log buffer.
56809 + The kernel's log buffer often contains kernel addresses and other
56810 + identifying information useful to an attacker in fingerprinting a
56811 + system for a targeted exploit.
56812 + If the sysctl option is enabled, a sysctl option with name "dmesg" is
56813 + created.
56814 +
56815 +config GRKERNSEC_HARDEN_PTRACE
56816 + bool "Deter ptrace-based process snooping"
56817 + default y if GRKERNSEC_CONFIG_AUTO
56818 + help
56819 + If you say Y here, TTY sniffers and other malicious monitoring
56820 + programs implemented through ptrace will be defeated. If you
56821 + have been using the RBAC system, this option has already been
56822 + enabled for several years for all users, with the ability to make
56823 + fine-grained exceptions.
56824 +
56825 + This option only affects the ability of non-root users to ptrace
56826 + processes that are not a descendent of the ptracing process.
56827 + This means that strace ./binary and gdb ./binary will still work,
56828 + but attaching to arbitrary processes will not. If the sysctl
56829 + option is enabled, a sysctl option with name "harden_ptrace" is
56830 + created.
56831 +
56832 +config GRKERNSEC_PTRACE_READEXEC
56833 + bool "Require read access to ptrace sensitive binaries"
56834 + default y if GRKERNSEC_CONFIG_AUTO
56835 + help
56836 + If you say Y here, unprivileged users will not be able to ptrace unreadable
56837 + binaries. This option is useful in environments that
56838 + remove the read bits (e.g. file mode 4711) from suid binaries to
56839 + prevent infoleaking of their contents. This option adds
56840 + consistency to the use of that file mode, as the binary could normally
56841 + be read out when run without privileges while ptracing.
56842 +
56843 + If the sysctl option is enabled, a sysctl option with name "ptrace_readexec"
56844 + is created.
56845 +
56846 +config GRKERNSEC_SETXID
56847 + bool "Enforce consistent multithreaded privileges"
56848 + default y if GRKERNSEC_CONFIG_AUTO
56849 + depends on (X86 || SPARC64 || PPC || ARM || MIPS)
56850 + help
56851 + If you say Y here, a change from a root uid to a non-root uid
56852 + in a multithreaded application will cause the resulting uids,
56853 + gids, supplementary groups, and capabilities in that thread
56854 + to be propagated to the other threads of the process. In most
56855 + cases this is unnecessary, as glibc will emulate this behavior
56856 + on behalf of the application. Other libcs do not act in the
56857 + same way, allowing the other threads of the process to continue
56858 + running with root privileges. If the sysctl option is enabled,
56859 + a sysctl option with name "consistent_setxid" is created.
56860 +
56861 +config GRKERNSEC_TPE
56862 + bool "Trusted Path Execution (TPE)"
56863 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
56864 + help
56865 + If you say Y here, you will be able to choose a gid to add to the
56866 + supplementary groups of users you want to mark as "untrusted."
56867 + These users will not be able to execute any files that are not in
56868 + root-owned directories writable only by root. If the sysctl option
56869 + is enabled, a sysctl option with name "tpe" is created.
56870 +
56871 +config GRKERNSEC_TPE_ALL
56872 + bool "Partially restrict all non-root users"
56873 + depends on GRKERNSEC_TPE
56874 + help
56875 + If you say Y here, all non-root users will be covered under
56876 + a weaker TPE restriction. This is separate from, and in addition to,
56877 + the main TPE options that you have selected elsewhere. Thus, if a
56878 + "trusted" GID is chosen, this restriction applies to even that GID.
56879 + Under this restriction, all non-root users will only be allowed to
56880 + execute files in directories they own that are not group or
56881 + world-writable, or in directories owned by root and writable only by
56882 + root. If the sysctl option is enabled, a sysctl option with name
56883 + "tpe_restrict_all" is created.
56884 +
56885 +config GRKERNSEC_TPE_INVERT
56886 + bool "Invert GID option"
56887 + depends on GRKERNSEC_TPE
56888 + help
56889 + If you say Y here, the group you specify in the TPE configuration will
56890 + decide what group TPE restrictions will be *disabled* for. This
56891 + option is useful if you want TPE restrictions to be applied to most
56892 + users on the system. If the sysctl option is enabled, a sysctl option
56893 + with name "tpe_invert" is created. Unlike other sysctl options, this
56894 + entry will default to on for backward-compatibility.
56895 +
56896 +config GRKERNSEC_TPE_GID
56897 + int
56898 + default GRKERNSEC_TPE_UNTRUSTED_GID if (GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT)
56899 + default GRKERNSEC_TPE_TRUSTED_GID if (GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT)
56900 +
56901 +config GRKERNSEC_TPE_UNTRUSTED_GID
56902 + int "GID for TPE-untrusted users"
56903 + depends on GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
56904 + default 1005
56905 + help
56906 + Setting this GID determines what group TPE restrictions will be
56907 + *enabled* for. If the sysctl option is enabled, a sysctl option
56908 + with name "tpe_gid" is created.
56909 +
56910 +config GRKERNSEC_TPE_TRUSTED_GID
56911 + int "GID for TPE-trusted users"
56912 + depends on GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
56913 + default 1005
56914 + help
56915 + Setting this GID determines what group TPE restrictions will be
56916 + *disabled* for. If the sysctl option is enabled, a sysctl option
56917 + with name "tpe_gid" is created.
56918 +
56919 +endmenu
56920 +menu "Network Protections"
56921 +depends on GRKERNSEC
56922 +
56923 +config GRKERNSEC_RANDNET
56924 + bool "Larger entropy pools"
56925 + default y if GRKERNSEC_CONFIG_AUTO
56926 + help
56927 + If you say Y here, the entropy pools used for many features of Linux
56928 + and grsecurity will be doubled in size. Since several grsecurity
56929 + features use additional randomness, it is recommended that you say Y
56930 + here. Saying Y here has a similar effect as modifying
56931 + /proc/sys/kernel/random/poolsize.
56932 +
56933 +config GRKERNSEC_BLACKHOLE
56934 + bool "TCP/UDP blackhole and LAST_ACK DoS prevention"
56935 + default y if GRKERNSEC_CONFIG_AUTO
56936 + depends on NET
56937 + help
56938 + If you say Y here, neither TCP resets nor ICMP
56939 + destination-unreachable packets will be sent in response to packets
56940 + sent to ports for which no associated listening process exists.
56941 + This feature supports both IPV4 and IPV6 and exempts the
56942 + loopback interface from blackholing. Enabling this feature
56943 + makes a host more resilient to DoS attacks and reduces network
56944 + visibility against scanners.
56945 +
56946 + The blackhole feature as-implemented is equivalent to the FreeBSD
56947 + blackhole feature, as it prevents RST responses to all packets, not
56948 + just SYNs. Under most application behavior this causes no
56949 + problems, but applications (like haproxy) may not close certain
56950 + connections in a way that cleanly terminates them on the remote
56951 + end, leaving the remote host in LAST_ACK state. Because of this
56952 + side-effect and to prevent intentional LAST_ACK DoSes, this
56953 + feature also adds automatic mitigation against such attacks.
56954 + The mitigation drastically reduces the amount of time a socket
56955 + can spend in LAST_ACK state. If you're using haproxy and not
56956 + all servers it connects to have this option enabled, consider
56957 + disabling this feature on the haproxy host.
56958 +
56959 + If the sysctl option is enabled, two sysctl options with names
56960 + "ip_blackhole" and "lastack_retries" will be created.
56961 + While "ip_blackhole" takes the standard zero/non-zero on/off
56962 + toggle, "lastack_retries" uses the same kinds of values as
56963 + "tcp_retries1" and "tcp_retries2". The default value of 4
56964 + prevents a socket from lasting more than 45 seconds in LAST_ACK
56965 + state.
56966 +
56967 +config GRKERNSEC_NO_SIMULT_CONNECT
56968 + bool "Disable TCP Simultaneous Connect"
56969 + default y if GRKERNSEC_CONFIG_AUTO
56970 + depends on NET
56971 + help
56972 + If you say Y here, a feature by Willy Tarreau will be enabled that
56973 + removes a weakness in Linux's strict implementation of TCP that
56974 + allows two clients to connect to each other without either entering
56975 + a listening state. The weakness allows an attacker to easily prevent
56976 + a client from connecting to a known server provided the source port
56977 + for the connection is guessed correctly.
56978 +
56979 + As the weakness could be used to prevent an antivirus or IPS from
56980 + fetching updates, or prevent an SSL gateway from fetching a CRL,
56981 + it should be eliminated by enabling this option. Though Linux is
56982 + one of few operating systems supporting simultaneous connect, it
56983 + has no legitimate use in practice and is rarely supported by firewalls.
56984 +
56985 +config GRKERNSEC_SOCKET
56986 + bool "Socket restrictions"
56987 + depends on NET
56988 + help
56989 + If you say Y here, you will be able to choose from several options.
56990 + If you assign a GID on your system and add it to the supplementary
56991 + groups of users you want to restrict socket access to, this patch
56992 + will perform up to three things, based on the option(s) you choose.
56993 +
56994 +config GRKERNSEC_SOCKET_ALL
56995 + bool "Deny any sockets to group"
56996 + depends on GRKERNSEC_SOCKET
56997 + help
56998 + If you say Y here, you will be able to choose a GID of whose users will
56999 + be unable to connect to other hosts from your machine or run server
57000 + applications from your machine. If the sysctl option is enabled, a
57001 + sysctl option with name "socket_all" is created.
57002 +
57003 +config GRKERNSEC_SOCKET_ALL_GID
57004 + int "GID to deny all sockets for"
57005 + depends on GRKERNSEC_SOCKET_ALL
57006 + default 1004
57007 + help
57008 + Here you can choose the GID to disable socket access for. Remember to
57009 + add the users you want socket access disabled for to the GID
57010 + specified here. If the sysctl option is enabled, a sysctl option
57011 + with name "socket_all_gid" is created.
57012 +
57013 +config GRKERNSEC_SOCKET_CLIENT
57014 + bool "Deny client sockets to group"
57015 + depends on GRKERNSEC_SOCKET
57016 + help
57017 + If you say Y here, you will be able to choose a GID of whose users will
57018 + be unable to connect to other hosts from your machine, but will be
57019 + able to run servers. If this option is enabled, all users in the group
57020 + you specify will have to use passive mode when initiating ftp transfers
57021 + from the shell on your machine. If the sysctl option is enabled, a
57022 + sysctl option with name "socket_client" is created.
57023 +
57024 +config GRKERNSEC_SOCKET_CLIENT_GID
57025 + int "GID to deny client sockets for"
57026 + depends on GRKERNSEC_SOCKET_CLIENT
57027 + default 1003
57028 + help
57029 + Here you can choose the GID to disable client socket access for.
57030 + Remember to add the users you want client socket access disabled for to
57031 + the GID specified here. If the sysctl option is enabled, a sysctl
57032 + option with name "socket_client_gid" is created.
57033 +
57034 +config GRKERNSEC_SOCKET_SERVER
57035 + bool "Deny server sockets to group"
57036 + depends on GRKERNSEC_SOCKET
57037 + help
57038 + If you say Y here, you will be able to choose a GID of whose users will
57039 + be unable to run server applications from your machine. If the sysctl
57040 + option is enabled, a sysctl option with name "socket_server" is created.
57041 +
57042 +config GRKERNSEC_SOCKET_SERVER_GID
57043 + int "GID to deny server sockets for"
57044 + depends on GRKERNSEC_SOCKET_SERVER
57045 + default 1002
57046 + help
57047 + Here you can choose the GID to disable server socket access for.
57048 + Remember to add the users you want server socket access disabled for to
57049 + the GID specified here. If the sysctl option is enabled, a sysctl
57050 + option with name "socket_server_gid" is created.
57051 +
57052 +endmenu
57053 +menu "Sysctl Support"
57054 +depends on GRKERNSEC && SYSCTL
57055 +
57056 +config GRKERNSEC_SYSCTL
57057 + bool "Sysctl support"
57058 + default y if GRKERNSEC_CONFIG_AUTO
57059 + help
57060 + If you say Y here, you will be able to change the options that
57061 + grsecurity runs with at bootup, without having to recompile your
57062 + kernel. You can echo values to files in /proc/sys/kernel/grsecurity
57063 + to enable (1) or disable (0) various features. All the sysctl entries
57064 + are mutable until the "grsec_lock" entry is set to a non-zero value.
57065 + All features enabled in the kernel configuration are disabled at boot
57066 + if you do not say Y to the "Turn on features by default" option.
57067 + All options should be set at startup, and the grsec_lock entry should
57068 + be set to a non-zero value after all the options are set.
57069 + *THIS IS EXTREMELY IMPORTANT*
57070 +
57071 +config GRKERNSEC_SYSCTL_DISTRO
57072 + bool "Extra sysctl support for distro makers (READ HELP)"
57073 + depends on GRKERNSEC_SYSCTL && GRKERNSEC_IO
57074 + help
57075 + If you say Y here, additional sysctl options will be created
57076 + for features that affect processes running as root. Therefore,
57077 + it is critical when using this option that the grsec_lock entry be
57078 + enabled after boot. Only distros with prebuilt kernel packages
57079 + with this option enabled that can ensure grsec_lock is enabled
57080 + after boot should use this option.
57081 + *Failure to set grsec_lock after boot makes all grsec features
57082 + this option covers useless*
57083 +
57084 + Currently this option creates the following sysctl entries:
57085 + "Disable Privileged I/O": "disable_priv_io"
57086 +
57087 +config GRKERNSEC_SYSCTL_ON
57088 + bool "Turn on features by default"
57089 + default y if GRKERNSEC_CONFIG_AUTO
57090 + depends on GRKERNSEC_SYSCTL
57091 + help
57092 + If you say Y here, instead of having all features enabled in the
57093 + kernel configuration disabled at boot time, the features will be
57094 + enabled at boot time. It is recommended you say Y here unless
57095 + there is some reason you would want all sysctl-tunable features to
57096 + be disabled by default. As mentioned elsewhere, it is important
57097 + to enable the grsec_lock entry once you have finished modifying
57098 + the sysctl entries.
57099 +
57100 +endmenu
57101 +menu "Logging Options"
57102 +depends on GRKERNSEC
57103 +
57104 +config GRKERNSEC_FLOODTIME
57105 + int "Seconds in between log messages (minimum)"
57106 + default 10
57107 + help
57108 + This option allows you to enforce the number of seconds between
57109 + grsecurity log messages. The default should be suitable for most
57110 + people, however, if you choose to change it, choose a value small enough
57111 + to allow informative logs to be produced, but large enough to
57112 + prevent flooding.
57113 +
57114 +config GRKERNSEC_FLOODBURST
57115 + int "Number of messages in a burst (maximum)"
57116 + default 6
57117 + help
57118 + This option allows you to choose the maximum number of messages allowed
57119 + within the flood time interval you chose in a separate option. The
57120 + default should be suitable for most people, however if you find that
57121 + many of your logs are being interpreted as flooding, you may want to
57122 + raise this value.
57123 +
57124 +endmenu
57125 diff --git a/grsecurity/Makefile b/grsecurity/Makefile
57126 new file mode 100644
57127 index 0000000..1b9afa9
57128 --- /dev/null
57129 +++ b/grsecurity/Makefile
57130 @@ -0,0 +1,38 @@
57131 +# grsecurity's ACL system was originally written in 2001 by Michael Dalton
57132 +# during 2001-2009 it has been completely redesigned by Brad Spengler
57133 +# into an RBAC system
57134 +#
57135 +# All code in this directory and various hooks inserted throughout the kernel
57136 +# are copyright Brad Spengler - Open Source Security, Inc., and released
57137 +# under the GPL v2 or higher
57138 +
57139 +KBUILD_CFLAGS += -Werror
57140 +
57141 +obj-y = grsec_chdir.o grsec_chroot.o grsec_exec.o grsec_fifo.o grsec_fork.o \
57142 + grsec_mount.o grsec_sig.o grsec_sysctl.o \
57143 + grsec_time.o grsec_tpe.o grsec_link.o grsec_pax.o grsec_ptrace.o
57144 +
57145 +obj-$(CONFIG_GRKERNSEC) += grsec_init.o grsum.o gracl.o gracl_segv.o \
57146 + gracl_cap.o gracl_alloc.o gracl_shm.o grsec_mem.o gracl_fs.o \
57147 + gracl_learn.o grsec_log.o
57148 +obj-$(CONFIG_GRKERNSEC_RESLOG) += gracl_res.o
57149 +
57150 +ifdef CONFIG_NET
57151 +obj-y += grsec_sock.o
57152 +obj-$(CONFIG_GRKERNSEC) += gracl_ip.o
57153 +endif
57154 +
57155 +ifndef CONFIG_GRKERNSEC
57156 +obj-y += grsec_disabled.o
57157 +endif
57158 +
57159 +ifdef CONFIG_GRKERNSEC_HIDESYM
57160 +extra-y := grsec_hidesym.o
57161 +$(obj)/grsec_hidesym.o:
57162 + @-chmod -f 500 /boot
57163 + @-chmod -f 500 /lib/modules
57164 + @-chmod -f 500 /lib64/modules
57165 + @-chmod -f 500 /lib32/modules
57166 + @-chmod -f 700 .
57167 + @echo ' grsec: protected kernel image paths'
57168 +endif
57169 diff --git a/grsecurity/gracl.c b/grsecurity/gracl.c
57170 new file mode 100644
57171 index 0000000..1248ee0
57172 --- /dev/null
57173 +++ b/grsecurity/gracl.c
57174 @@ -0,0 +1,4073 @@
57175 +#include <linux/kernel.h>
57176 +#include <linux/module.h>
57177 +#include <linux/sched.h>
57178 +#include <linux/mm.h>
57179 +#include <linux/file.h>
57180 +#include <linux/fs.h>
57181 +#include <linux/namei.h>
57182 +#include <linux/mount.h>
57183 +#include <linux/tty.h>
57184 +#include <linux/proc_fs.h>
57185 +#include <linux/lglock.h>
57186 +#include <linux/slab.h>
57187 +#include <linux/vmalloc.h>
57188 +#include <linux/types.h>
57189 +#include <linux/sysctl.h>
57190 +#include <linux/netdevice.h>
57191 +#include <linux/ptrace.h>
57192 +#include <linux/gracl.h>
57193 +#include <linux/gralloc.h>
57194 +#include <linux/security.h>
57195 +#include <linux/grinternal.h>
57196 +#include <linux/pid_namespace.h>
57197 +#include <linux/stop_machine.h>
57198 +#include <linux/fdtable.h>
57199 +#include <linux/percpu.h>
57200 +#include <linux/lglock.h>
57201 +#include <linux/hugetlb.h>
57202 +#include <linux/posix-timers.h>
57203 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
57204 +#include <linux/magic.h>
57205 +#include <linux/pagemap.h>
57206 +#include "../fs/btrfs/async-thread.h"
57207 +#include "../fs/btrfs/ctree.h"
57208 +#include "../fs/btrfs/btrfs_inode.h"
57209 +#endif
57210 +#include "../fs/mount.h"
57211 +
57212 +#include <asm/uaccess.h>
57213 +#include <asm/errno.h>
57214 +#include <asm/mman.h>
57215 +
57216 +extern struct lglock vfsmount_lock;
57217 +
57218 +static struct acl_role_db acl_role_set;
57219 +static struct name_db name_set;
57220 +static struct inodev_db inodev_set;
57221 +
57222 +/* for keeping track of userspace pointers used for subjects, so we
57223 + can share references in the kernel as well
57224 +*/
57225 +
57226 +static struct path real_root;
57227 +
57228 +static struct acl_subj_map_db subj_map_set;
57229 +
57230 +static struct acl_role_label *default_role;
57231 +
57232 +static struct acl_role_label *role_list;
57233 +
57234 +static u16 acl_sp_role_value;
57235 +
57236 +extern char *gr_shared_page[4];
57237 +static DEFINE_MUTEX(gr_dev_mutex);
57238 +DEFINE_RWLOCK(gr_inode_lock);
57239 +
57240 +struct gr_arg *gr_usermode;
57241 +
57242 +static unsigned int gr_status __read_only = GR_STATUS_INIT;
57243 +
57244 +extern int chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum);
57245 +extern void gr_clear_learn_entries(void);
57246 +
57247 +unsigned char *gr_system_salt;
57248 +unsigned char *gr_system_sum;
57249 +
57250 +static struct sprole_pw **acl_special_roles = NULL;
57251 +static __u16 num_sprole_pws = 0;
57252 +
57253 +static struct acl_role_label *kernel_role = NULL;
57254 +
57255 +static unsigned int gr_auth_attempts = 0;
57256 +static unsigned long gr_auth_expires = 0UL;
57257 +
57258 +#ifdef CONFIG_NET
57259 +extern struct vfsmount *sock_mnt;
57260 +#endif
57261 +
57262 +extern struct vfsmount *pipe_mnt;
57263 +extern struct vfsmount *shm_mnt;
57264 +
57265 +#ifdef CONFIG_HUGETLBFS
57266 +extern struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
57267 +#endif
57268 +
57269 +static struct acl_object_label *fakefs_obj_rw;
57270 +static struct acl_object_label *fakefs_obj_rwx;
57271 +
57272 +extern int gr_init_uidset(void);
57273 +extern void gr_free_uidset(void);
57274 +extern void gr_remove_uid(uid_t uid);
57275 +extern int gr_find_uid(uid_t uid);
57276 +
57277 +__inline__ int
57278 +gr_acl_is_enabled(void)
57279 +{
57280 + return (gr_status & GR_READY);
57281 +}
57282 +
57283 +static inline dev_t __get_dev(const struct dentry *dentry)
57284 +{
57285 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
57286 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
57287 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
57288 + else
57289 +#endif
57290 + return dentry->d_sb->s_dev;
57291 +}
57292 +
57293 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
57294 +{
57295 + return __get_dev(dentry);
57296 +}
57297 +
57298 +static char gr_task_roletype_to_char(struct task_struct *task)
57299 +{
57300 + switch (task->role->roletype &
57301 + (GR_ROLE_DEFAULT | GR_ROLE_USER | GR_ROLE_GROUP |
57302 + GR_ROLE_SPECIAL)) {
57303 + case GR_ROLE_DEFAULT:
57304 + return 'D';
57305 + case GR_ROLE_USER:
57306 + return 'U';
57307 + case GR_ROLE_GROUP:
57308 + return 'G';
57309 + case GR_ROLE_SPECIAL:
57310 + return 'S';
57311 + }
57312 +
57313 + return 'X';
57314 +}
57315 +
57316 +char gr_roletype_to_char(void)
57317 +{
57318 + return gr_task_roletype_to_char(current);
57319 +}
57320 +
57321 +__inline__ int
57322 +gr_acl_tpe_check(void)
57323 +{
57324 + if (unlikely(!(gr_status & GR_READY)))
57325 + return 0;
57326 + if (current->role->roletype & GR_ROLE_TPE)
57327 + return 1;
57328 + else
57329 + return 0;
57330 +}
57331 +
57332 +int
57333 +gr_handle_rawio(const struct inode *inode)
57334 +{
57335 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
57336 + if (inode && S_ISBLK(inode->i_mode) &&
57337 + grsec_enable_chroot_caps && proc_is_chrooted(current) &&
57338 + !capable(CAP_SYS_RAWIO))
57339 + return 1;
57340 +#endif
57341 + return 0;
57342 +}
57343 +
57344 +static int
57345 +gr_streq(const char *a, const char *b, const unsigned int lena, const unsigned int lenb)
57346 +{
57347 + if (likely(lena != lenb))
57348 + return 0;
57349 +
57350 + return !memcmp(a, b, lena);
57351 +}
57352 +
57353 +static int prepend(char **buffer, int *buflen, const char *str, int namelen)
57354 +{
57355 + *buflen -= namelen;
57356 + if (*buflen < 0)
57357 + return -ENAMETOOLONG;
57358 + *buffer -= namelen;
57359 + memcpy(*buffer, str, namelen);
57360 + return 0;
57361 +}
57362 +
57363 +static int prepend_name(char **buffer, int *buflen, struct qstr *name)
57364 +{
57365 + return prepend(buffer, buflen, name->name, name->len);
57366 +}
57367 +
57368 +static int prepend_path(const struct path *path, struct path *root,
57369 + char **buffer, int *buflen)
57370 +{
57371 + struct dentry *dentry = path->dentry;
57372 + struct vfsmount *vfsmnt = path->mnt;
57373 + struct mount *mnt = real_mount(vfsmnt);
57374 + bool slash = false;
57375 + int error = 0;
57376 +
57377 + while (dentry != root->dentry || vfsmnt != root->mnt) {
57378 + struct dentry * parent;
57379 +
57380 + if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) {
57381 + /* Global root? */
57382 + if (!mnt_has_parent(mnt)) {
57383 + goto out;
57384 + }
57385 + dentry = mnt->mnt_mountpoint;
57386 + mnt = mnt->mnt_parent;
57387 + vfsmnt = &mnt->mnt;
57388 + continue;
57389 + }
57390 + parent = dentry->d_parent;
57391 + prefetch(parent);
57392 + spin_lock(&dentry->d_lock);
57393 + error = prepend_name(buffer, buflen, &dentry->d_name);
57394 + spin_unlock(&dentry->d_lock);
57395 + if (!error)
57396 + error = prepend(buffer, buflen, "/", 1);
57397 + if (error)
57398 + break;
57399 +
57400 + slash = true;
57401 + dentry = parent;
57402 + }
57403 +
57404 +out:
57405 + if (!error && !slash)
57406 + error = prepend(buffer, buflen, "/", 1);
57407 +
57408 + return error;
57409 +}
57410 +
57411 +/* this must be called with vfsmount_lock and rename_lock held */
57412 +
57413 +static char *__our_d_path(const struct path *path, struct path *root,
57414 + char *buf, int buflen)
57415 +{
57416 + char *res = buf + buflen;
57417 + int error;
57418 +
57419 + prepend(&res, &buflen, "\0", 1);
57420 + error = prepend_path(path, root, &res, &buflen);
57421 + if (error)
57422 + return ERR_PTR(error);
57423 +
57424 + return res;
57425 +}
57426 +
57427 +static char *
57428 +gen_full_path(struct path *path, struct path *root, char *buf, int buflen)
57429 +{
57430 + char *retval;
57431 +
57432 + retval = __our_d_path(path, root, buf, buflen);
57433 + if (unlikely(IS_ERR(retval)))
57434 + retval = strcpy(buf, "<path too long>");
57435 + else if (unlikely(retval[1] == '/' && retval[2] == '\0'))
57436 + retval[1] = '\0';
57437 +
57438 + return retval;
57439 +}
57440 +
57441 +static char *
57442 +__d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
57443 + char *buf, int buflen)
57444 +{
57445 + struct path path;
57446 + char *res;
57447 +
57448 + path.dentry = (struct dentry *)dentry;
57449 + path.mnt = (struct vfsmount *)vfsmnt;
57450 +
57451 + /* we can use real_root.dentry, real_root.mnt, because this is only called
57452 + by the RBAC system */
57453 + res = gen_full_path(&path, &real_root, buf, buflen);
57454 +
57455 + return res;
57456 +}
57457 +
57458 +static char *
57459 +d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
57460 + char *buf, int buflen)
57461 +{
57462 + char *res;
57463 + struct path path;
57464 + struct path root;
57465 + struct task_struct *reaper = init_pid_ns.child_reaper;
57466 +
57467 + path.dentry = (struct dentry *)dentry;
57468 + path.mnt = (struct vfsmount *)vfsmnt;
57469 +
57470 + /* we can't use real_root.dentry, real_root.mnt, because they belong only to the RBAC system */
57471 + get_fs_root(reaper->fs, &root);
57472 +
57473 + br_read_lock(&vfsmount_lock);
57474 + write_seqlock(&rename_lock);
57475 + res = gen_full_path(&path, &root, buf, buflen);
57476 + write_sequnlock(&rename_lock);
57477 + br_read_unlock(&vfsmount_lock);
57478 +
57479 + path_put(&root);
57480 + return res;
57481 +}
57482 +
57483 +static char *
57484 +gr_to_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
57485 +{
57486 + char *ret;
57487 + br_read_lock(&vfsmount_lock);
57488 + write_seqlock(&rename_lock);
57489 + ret = __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
57490 + PAGE_SIZE);
57491 + write_sequnlock(&rename_lock);
57492 + br_read_unlock(&vfsmount_lock);
57493 + return ret;
57494 +}
57495 +
57496 +static char *
57497 +gr_to_proc_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
57498 +{
57499 + char *ret;
57500 + char *buf;
57501 + int buflen;
57502 +
57503 + br_read_lock(&vfsmount_lock);
57504 + write_seqlock(&rename_lock);
57505 + buf = per_cpu_ptr(gr_shared_page[0], smp_processor_id());
57506 + ret = __d_real_path(dentry, mnt, buf, PAGE_SIZE - 6);
57507 + buflen = (int)(ret - buf);
57508 + if (buflen >= 5)
57509 + prepend(&ret, &buflen, "/proc", 5);
57510 + else
57511 + ret = strcpy(buf, "<path too long>");
57512 + write_sequnlock(&rename_lock);
57513 + br_read_unlock(&vfsmount_lock);
57514 + return ret;
57515 +}
57516 +
57517 +char *
57518 +gr_to_filename_nolock(const struct dentry *dentry, const struct vfsmount *mnt)
57519 +{
57520 + return __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
57521 + PAGE_SIZE);
57522 +}
57523 +
57524 +char *
57525 +gr_to_filename(const struct dentry *dentry, const struct vfsmount *mnt)
57526 +{
57527 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
57528 + PAGE_SIZE);
57529 +}
57530 +
57531 +char *
57532 +gr_to_filename1(const struct dentry *dentry, const struct vfsmount *mnt)
57533 +{
57534 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[1], smp_processor_id()),
57535 + PAGE_SIZE);
57536 +}
57537 +
57538 +char *
57539 +gr_to_filename2(const struct dentry *dentry, const struct vfsmount *mnt)
57540 +{
57541 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[2], smp_processor_id()),
57542 + PAGE_SIZE);
57543 +}
57544 +
57545 +char *
57546 +gr_to_filename3(const struct dentry *dentry, const struct vfsmount *mnt)
57547 +{
57548 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[3], smp_processor_id()),
57549 + PAGE_SIZE);
57550 +}
57551 +
57552 +__inline__ __u32
57553 +to_gr_audit(const __u32 reqmode)
57554 +{
57555 + /* masks off auditable permission flags, then shifts them to create
57556 + auditing flags, and adds the special case of append auditing if
57557 + we're requesting write */
57558 + return (((reqmode & ~GR_AUDITS) << 10) | ((reqmode & GR_WRITE) ? GR_AUDIT_APPEND : 0));
57559 +}
57560 +
57561 +struct acl_subject_label *
57562 +lookup_subject_map(const struct acl_subject_label *userp)
57563 +{
57564 + unsigned int index = gr_shash(userp, subj_map_set.s_size);
57565 + struct subject_map *match;
57566 +
57567 + match = subj_map_set.s_hash[index];
57568 +
57569 + while (match && match->user != userp)
57570 + match = match->next;
57571 +
57572 + if (match != NULL)
57573 + return match->kernel;
57574 + else
57575 + return NULL;
57576 +}
57577 +
57578 +static void
57579 +insert_subj_map_entry(struct subject_map *subjmap)
57580 +{
57581 + unsigned int index = gr_shash(subjmap->user, subj_map_set.s_size);
57582 + struct subject_map **curr;
57583 +
57584 + subjmap->prev = NULL;
57585 +
57586 + curr = &subj_map_set.s_hash[index];
57587 + if (*curr != NULL)
57588 + (*curr)->prev = subjmap;
57589 +
57590 + subjmap->next = *curr;
57591 + *curr = subjmap;
57592 +
57593 + return;
57594 +}
57595 +
57596 +static struct acl_role_label *
57597 +lookup_acl_role_label(const struct task_struct *task, const uid_t uid,
57598 + const gid_t gid)
57599 +{
57600 + unsigned int index = gr_rhash(uid, GR_ROLE_USER, acl_role_set.r_size);
57601 + struct acl_role_label *match;
57602 + struct role_allowed_ip *ipp;
57603 + unsigned int x;
57604 + u32 curr_ip = task->signal->curr_ip;
57605 +
57606 + task->signal->saved_ip = curr_ip;
57607 +
57608 + match = acl_role_set.r_hash[index];
57609 +
57610 + while (match) {
57611 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_USER)) == (GR_ROLE_DOMAIN | GR_ROLE_USER)) {
57612 + for (x = 0; x < match->domain_child_num; x++) {
57613 + if (match->domain_children[x] == uid)
57614 + goto found;
57615 + }
57616 + } else if (match->uidgid == uid && match->roletype & GR_ROLE_USER)
57617 + break;
57618 + match = match->next;
57619 + }
57620 +found:
57621 + if (match == NULL) {
57622 + try_group:
57623 + index = gr_rhash(gid, GR_ROLE_GROUP, acl_role_set.r_size);
57624 + match = acl_role_set.r_hash[index];
57625 +
57626 + while (match) {
57627 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) == (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) {
57628 + for (x = 0; x < match->domain_child_num; x++) {
57629 + if (match->domain_children[x] == gid)
57630 + goto found2;
57631 + }
57632 + } else if (match->uidgid == gid && match->roletype & GR_ROLE_GROUP)
57633 + break;
57634 + match = match->next;
57635 + }
57636 +found2:
57637 + if (match == NULL)
57638 + match = default_role;
57639 + if (match->allowed_ips == NULL)
57640 + return match;
57641 + else {
57642 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
57643 + if (likely
57644 + ((ntohl(curr_ip) & ipp->netmask) ==
57645 + (ntohl(ipp->addr) & ipp->netmask)))
57646 + return match;
57647 + }
57648 + match = default_role;
57649 + }
57650 + } else if (match->allowed_ips == NULL) {
57651 + return match;
57652 + } else {
57653 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
57654 + if (likely
57655 + ((ntohl(curr_ip) & ipp->netmask) ==
57656 + (ntohl(ipp->addr) & ipp->netmask)))
57657 + return match;
57658 + }
57659 + goto try_group;
57660 + }
57661 +
57662 + return match;
57663 +}
57664 +
57665 +struct acl_subject_label *
57666 +lookup_acl_subj_label(const ino_t ino, const dev_t dev,
57667 + const struct acl_role_label *role)
57668 +{
57669 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
57670 + struct acl_subject_label *match;
57671 +
57672 + match = role->subj_hash[index];
57673 +
57674 + while (match && (match->inode != ino || match->device != dev ||
57675 + (match->mode & GR_DELETED))) {
57676 + match = match->next;
57677 + }
57678 +
57679 + if (match && !(match->mode & GR_DELETED))
57680 + return match;
57681 + else
57682 + return NULL;
57683 +}
57684 +
57685 +struct acl_subject_label *
57686 +lookup_acl_subj_label_deleted(const ino_t ino, const dev_t dev,
57687 + const struct acl_role_label *role)
57688 +{
57689 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
57690 + struct acl_subject_label *match;
57691 +
57692 + match = role->subj_hash[index];
57693 +
57694 + while (match && (match->inode != ino || match->device != dev ||
57695 + !(match->mode & GR_DELETED))) {
57696 + match = match->next;
57697 + }
57698 +
57699 + if (match && (match->mode & GR_DELETED))
57700 + return match;
57701 + else
57702 + return NULL;
57703 +}
57704 +
57705 +static struct acl_object_label *
57706 +lookup_acl_obj_label(const ino_t ino, const dev_t dev,
57707 + const struct acl_subject_label *subj)
57708 +{
57709 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
57710 + struct acl_object_label *match;
57711 +
57712 + match = subj->obj_hash[index];
57713 +
57714 + while (match && (match->inode != ino || match->device != dev ||
57715 + (match->mode & GR_DELETED))) {
57716 + match = match->next;
57717 + }
57718 +
57719 + if (match && !(match->mode & GR_DELETED))
57720 + return match;
57721 + else
57722 + return NULL;
57723 +}
57724 +
57725 +static struct acl_object_label *
57726 +lookup_acl_obj_label_create(const ino_t ino, const dev_t dev,
57727 + const struct acl_subject_label *subj)
57728 +{
57729 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
57730 + struct acl_object_label *match;
57731 +
57732 + match = subj->obj_hash[index];
57733 +
57734 + while (match && (match->inode != ino || match->device != dev ||
57735 + !(match->mode & GR_DELETED))) {
57736 + match = match->next;
57737 + }
57738 +
57739 + if (match && (match->mode & GR_DELETED))
57740 + return match;
57741 +
57742 + match = subj->obj_hash[index];
57743 +
57744 + while (match && (match->inode != ino || match->device != dev ||
57745 + (match->mode & GR_DELETED))) {
57746 + match = match->next;
57747 + }
57748 +
57749 + if (match && !(match->mode & GR_DELETED))
57750 + return match;
57751 + else
57752 + return NULL;
57753 +}
57754 +
57755 +static struct name_entry *
57756 +lookup_name_entry(const char *name)
57757 +{
57758 + unsigned int len = strlen(name);
57759 + unsigned int key = full_name_hash(name, len);
57760 + unsigned int index = key % name_set.n_size;
57761 + struct name_entry *match;
57762 +
57763 + match = name_set.n_hash[index];
57764 +
57765 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len)))
57766 + match = match->next;
57767 +
57768 + return match;
57769 +}
57770 +
57771 +static struct name_entry *
57772 +lookup_name_entry_create(const char *name)
57773 +{
57774 + unsigned int len = strlen(name);
57775 + unsigned int key = full_name_hash(name, len);
57776 + unsigned int index = key % name_set.n_size;
57777 + struct name_entry *match;
57778 +
57779 + match = name_set.n_hash[index];
57780 +
57781 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
57782 + !match->deleted))
57783 + match = match->next;
57784 +
57785 + if (match && match->deleted)
57786 + return match;
57787 +
57788 + match = name_set.n_hash[index];
57789 +
57790 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
57791 + match->deleted))
57792 + match = match->next;
57793 +
57794 + if (match && !match->deleted)
57795 + return match;
57796 + else
57797 + return NULL;
57798 +}
57799 +
57800 +static struct inodev_entry *
57801 +lookup_inodev_entry(const ino_t ino, const dev_t dev)
57802 +{
57803 + unsigned int index = gr_fhash(ino, dev, inodev_set.i_size);
57804 + struct inodev_entry *match;
57805 +
57806 + match = inodev_set.i_hash[index];
57807 +
57808 + while (match && (match->nentry->inode != ino || match->nentry->device != dev))
57809 + match = match->next;
57810 +
57811 + return match;
57812 +}
57813 +
57814 +static void
57815 +insert_inodev_entry(struct inodev_entry *entry)
57816 +{
57817 + unsigned int index = gr_fhash(entry->nentry->inode, entry->nentry->device,
57818 + inodev_set.i_size);
57819 + struct inodev_entry **curr;
57820 +
57821 + entry->prev = NULL;
57822 +
57823 + curr = &inodev_set.i_hash[index];
57824 + if (*curr != NULL)
57825 + (*curr)->prev = entry;
57826 +
57827 + entry->next = *curr;
57828 + *curr = entry;
57829 +
57830 + return;
57831 +}
57832 +
57833 +static void
57834 +__insert_acl_role_label(struct acl_role_label *role, uid_t uidgid)
57835 +{
57836 + unsigned int index =
57837 + gr_rhash(uidgid, role->roletype & (GR_ROLE_USER | GR_ROLE_GROUP), acl_role_set.r_size);
57838 + struct acl_role_label **curr;
57839 + struct acl_role_label *tmp, *tmp2;
57840 +
57841 + curr = &acl_role_set.r_hash[index];
57842 +
57843 + /* simple case, slot is empty, just set it to our role */
57844 + if (*curr == NULL) {
57845 + *curr = role;
57846 + } else {
57847 + /* example:
57848 + 1 -> 2 -> 3 (adding 2 -> 3 to here)
57849 + 2 -> 3
57850 + */
57851 + /* first check to see if we can already be reached via this slot */
57852 + tmp = *curr;
57853 + while (tmp && tmp != role)
57854 + tmp = tmp->next;
57855 + if (tmp == role) {
57856 + /* we don't need to add ourselves to this slot's chain */
57857 + return;
57858 + }
57859 + /* we need to add ourselves to this chain, two cases */
57860 + if (role->next == NULL) {
57861 + /* simple case, append the current chain to our role */
57862 + role->next = *curr;
57863 + *curr = role;
57864 + } else {
57865 + /* 1 -> 2 -> 3 -> 4
57866 + 2 -> 3 -> 4
57867 + 3 -> 4 (adding 1 -> 2 -> 3 -> 4 to here)
57868 + */
57869 + /* trickier case: walk our role's chain until we find
57870 + the role for the start of the current slot's chain */
57871 + tmp = role;
57872 + tmp2 = *curr;
57873 + while (tmp->next && tmp->next != tmp2)
57874 + tmp = tmp->next;
57875 + if (tmp->next == tmp2) {
57876 + /* from example above, we found 3, so just
57877 + replace this slot's chain with ours */
57878 + *curr = role;
57879 + } else {
57880 + /* we didn't find a subset of our role's chain
57881 + in the current slot's chain, so append their
57882 + chain to ours, and set us as the first role in
57883 + the slot's chain
57884 +
57885 + we could fold this case with the case above,
57886 + but making it explicit for clarity
57887 + */
57888 + tmp->next = tmp2;
57889 + *curr = role;
57890 + }
57891 + }
57892 + }
57893 +
57894 + return;
57895 +}
57896 +
57897 +static void
57898 +insert_acl_role_label(struct acl_role_label *role)
57899 +{
57900 + int i;
57901 +
57902 + if (role_list == NULL) {
57903 + role_list = role;
57904 + role->prev = NULL;
57905 + } else {
57906 + role->prev = role_list;
57907 + role_list = role;
57908 + }
57909 +
57910 + /* used for hash chains */
57911 + role->next = NULL;
57912 +
57913 + if (role->roletype & GR_ROLE_DOMAIN) {
57914 + for (i = 0; i < role->domain_child_num; i++)
57915 + __insert_acl_role_label(role, role->domain_children[i]);
57916 + } else
57917 + __insert_acl_role_label(role, role->uidgid);
57918 +}
57919 +
57920 +static int
57921 +insert_name_entry(char *name, const ino_t inode, const dev_t device, __u8 deleted)
57922 +{
57923 + struct name_entry **curr, *nentry;
57924 + struct inodev_entry *ientry;
57925 + unsigned int len = strlen(name);
57926 + unsigned int key = full_name_hash(name, len);
57927 + unsigned int index = key % name_set.n_size;
57928 +
57929 + curr = &name_set.n_hash[index];
57930 +
57931 + while (*curr && ((*curr)->key != key || !gr_streq((*curr)->name, name, (*curr)->len, len)))
57932 + curr = &((*curr)->next);
57933 +
57934 + if (*curr != NULL)
57935 + return 1;
57936 +
57937 + nentry = acl_alloc(sizeof (struct name_entry));
57938 + if (nentry == NULL)
57939 + return 0;
57940 + ientry = acl_alloc(sizeof (struct inodev_entry));
57941 + if (ientry == NULL)
57942 + return 0;
57943 + ientry->nentry = nentry;
57944 +
57945 + nentry->key = key;
57946 + nentry->name = name;
57947 + nentry->inode = inode;
57948 + nentry->device = device;
57949 + nentry->len = len;
57950 + nentry->deleted = deleted;
57951 +
57952 + nentry->prev = NULL;
57953 + curr = &name_set.n_hash[index];
57954 + if (*curr != NULL)
57955 + (*curr)->prev = nentry;
57956 + nentry->next = *curr;
57957 + *curr = nentry;
57958 +
57959 + /* insert us into the table searchable by inode/dev */
57960 + insert_inodev_entry(ientry);
57961 +
57962 + return 1;
57963 +}
57964 +
57965 +static void
57966 +insert_acl_obj_label(struct acl_object_label *obj,
57967 + struct acl_subject_label *subj)
57968 +{
57969 + unsigned int index =
57970 + gr_fhash(obj->inode, obj->device, subj->obj_hash_size);
57971 + struct acl_object_label **curr;
57972 +
57973 +
57974 + obj->prev = NULL;
57975 +
57976 + curr = &subj->obj_hash[index];
57977 + if (*curr != NULL)
57978 + (*curr)->prev = obj;
57979 +
57980 + obj->next = *curr;
57981 + *curr = obj;
57982 +
57983 + return;
57984 +}
57985 +
57986 +static void
57987 +insert_acl_subj_label(struct acl_subject_label *obj,
57988 + struct acl_role_label *role)
57989 +{
57990 + unsigned int index = gr_fhash(obj->inode, obj->device, role->subj_hash_size);
57991 + struct acl_subject_label **curr;
57992 +
57993 + obj->prev = NULL;
57994 +
57995 + curr = &role->subj_hash[index];
57996 + if (*curr != NULL)
57997 + (*curr)->prev = obj;
57998 +
57999 + obj->next = *curr;
58000 + *curr = obj;
58001 +
58002 + return;
58003 +}
58004 +
58005 +/* allocating chained hash tables, so optimal size is where lambda ~ 1 */
58006 +
58007 +static void *
58008 +create_table(__u32 * len, int elementsize)
58009 +{
58010 + unsigned int table_sizes[] = {
58011 + 7, 13, 31, 61, 127, 251, 509, 1021, 2039, 4093, 8191, 16381,
58012 + 32749, 65521, 131071, 262139, 524287, 1048573, 2097143,
58013 + 4194301, 8388593, 16777213, 33554393, 67108859
58014 + };
58015 + void *newtable = NULL;
58016 + unsigned int pwr = 0;
58017 +
58018 + while ((pwr < ((sizeof (table_sizes) / sizeof (table_sizes[0])) - 1)) &&
58019 + table_sizes[pwr] <= *len)
58020 + pwr++;
58021 +
58022 + if (table_sizes[pwr] <= *len || (table_sizes[pwr] > ULONG_MAX / elementsize))
58023 + return newtable;
58024 +
58025 + if ((table_sizes[pwr] * elementsize) <= PAGE_SIZE)
58026 + newtable =
58027 + kmalloc(table_sizes[pwr] * elementsize, GFP_KERNEL);
58028 + else
58029 + newtable = vmalloc(table_sizes[pwr] * elementsize);
58030 +
58031 + *len = table_sizes[pwr];
58032 +
58033 + return newtable;
58034 +}
58035 +
58036 +static int
58037 +init_variables(const struct gr_arg *arg)
58038 +{
58039 + struct task_struct *reaper = init_pid_ns.child_reaper;
58040 + unsigned int stacksize;
58041 +
58042 + subj_map_set.s_size = arg->role_db.num_subjects;
58043 + acl_role_set.r_size = arg->role_db.num_roles + arg->role_db.num_domain_children;
58044 + name_set.n_size = arg->role_db.num_objects;
58045 + inodev_set.i_size = arg->role_db.num_objects;
58046 +
58047 + if (!subj_map_set.s_size || !acl_role_set.r_size ||
58048 + !name_set.n_size || !inodev_set.i_size)
58049 + return 1;
58050 +
58051 + if (!gr_init_uidset())
58052 + return 1;
58053 +
58054 + /* set up the stack that holds allocation info */
58055 +
58056 + stacksize = arg->role_db.num_pointers + 5;
58057 +
58058 + if (!acl_alloc_stack_init(stacksize))
58059 + return 1;
58060 +
58061 + /* grab reference for the real root dentry and vfsmount */
58062 + get_fs_root(reaper->fs, &real_root);
58063 +
58064 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
58065 + printk(KERN_ALERT "Obtained real root device=%d, inode=%lu\n", __get_dev(real_root.dentry), real_root.dentry->d_inode->i_ino);
58066 +#endif
58067 +
58068 + fakefs_obj_rw = acl_alloc(sizeof(struct acl_object_label));
58069 + if (fakefs_obj_rw == NULL)
58070 + return 1;
58071 + fakefs_obj_rw->mode = GR_FIND | GR_READ | GR_WRITE;
58072 +
58073 + fakefs_obj_rwx = acl_alloc(sizeof(struct acl_object_label));
58074 + if (fakefs_obj_rwx == NULL)
58075 + return 1;
58076 + fakefs_obj_rwx->mode = GR_FIND | GR_READ | GR_WRITE | GR_EXEC;
58077 +
58078 + subj_map_set.s_hash =
58079 + (struct subject_map **) create_table(&subj_map_set.s_size, sizeof(void *));
58080 + acl_role_set.r_hash =
58081 + (struct acl_role_label **) create_table(&acl_role_set.r_size, sizeof(void *));
58082 + name_set.n_hash = (struct name_entry **) create_table(&name_set.n_size, sizeof(void *));
58083 + inodev_set.i_hash =
58084 + (struct inodev_entry **) create_table(&inodev_set.i_size, sizeof(void *));
58085 +
58086 + if (!subj_map_set.s_hash || !acl_role_set.r_hash ||
58087 + !name_set.n_hash || !inodev_set.i_hash)
58088 + return 1;
58089 +
58090 + memset(subj_map_set.s_hash, 0,
58091 + sizeof(struct subject_map *) * subj_map_set.s_size);
58092 + memset(acl_role_set.r_hash, 0,
58093 + sizeof (struct acl_role_label *) * acl_role_set.r_size);
58094 + memset(name_set.n_hash, 0,
58095 + sizeof (struct name_entry *) * name_set.n_size);
58096 + memset(inodev_set.i_hash, 0,
58097 + sizeof (struct inodev_entry *) * inodev_set.i_size);
58098 +
58099 + return 0;
58100 +}
58101 +
58102 +/* free information not needed after startup
58103 + currently contains user->kernel pointer mappings for subjects
58104 +*/
58105 +
58106 +static void
58107 +free_init_variables(void)
58108 +{
58109 + __u32 i;
58110 +
58111 + if (subj_map_set.s_hash) {
58112 + for (i = 0; i < subj_map_set.s_size; i++) {
58113 + if (subj_map_set.s_hash[i]) {
58114 + kfree(subj_map_set.s_hash[i]);
58115 + subj_map_set.s_hash[i] = NULL;
58116 + }
58117 + }
58118 +
58119 + if ((subj_map_set.s_size * sizeof (struct subject_map *)) <=
58120 + PAGE_SIZE)
58121 + kfree(subj_map_set.s_hash);
58122 + else
58123 + vfree(subj_map_set.s_hash);
58124 + }
58125 +
58126 + return;
58127 +}
58128 +
58129 +static void
58130 +free_variables(void)
58131 +{
58132 + struct acl_subject_label *s;
58133 + struct acl_role_label *r;
58134 + struct task_struct *task, *task2;
58135 + unsigned int x;
58136 +
58137 + gr_clear_learn_entries();
58138 +
58139 + read_lock(&tasklist_lock);
58140 + do_each_thread(task2, task) {
58141 + task->acl_sp_role = 0;
58142 + task->acl_role_id = 0;
58143 + task->acl = NULL;
58144 + task->role = NULL;
58145 + } while_each_thread(task2, task);
58146 + read_unlock(&tasklist_lock);
58147 +
58148 + /* release the reference to the real root dentry and vfsmount */
58149 + path_put(&real_root);
58150 + memset(&real_root, 0, sizeof(real_root));
58151 +
58152 + /* free all object hash tables */
58153 +
58154 + FOR_EACH_ROLE_START(r)
58155 + if (r->subj_hash == NULL)
58156 + goto next_role;
58157 + FOR_EACH_SUBJECT_START(r, s, x)
58158 + if (s->obj_hash == NULL)
58159 + break;
58160 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
58161 + kfree(s->obj_hash);
58162 + else
58163 + vfree(s->obj_hash);
58164 + FOR_EACH_SUBJECT_END(s, x)
58165 + FOR_EACH_NESTED_SUBJECT_START(r, s)
58166 + if (s->obj_hash == NULL)
58167 + break;
58168 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
58169 + kfree(s->obj_hash);
58170 + else
58171 + vfree(s->obj_hash);
58172 + FOR_EACH_NESTED_SUBJECT_END(s)
58173 + if ((r->subj_hash_size * sizeof (struct acl_subject_label *)) <= PAGE_SIZE)
58174 + kfree(r->subj_hash);
58175 + else
58176 + vfree(r->subj_hash);
58177 + r->subj_hash = NULL;
58178 +next_role:
58179 + FOR_EACH_ROLE_END(r)
58180 +
58181 + acl_free_all();
58182 +
58183 + if (acl_role_set.r_hash) {
58184 + if ((acl_role_set.r_size * sizeof (struct acl_role_label *)) <=
58185 + PAGE_SIZE)
58186 + kfree(acl_role_set.r_hash);
58187 + else
58188 + vfree(acl_role_set.r_hash);
58189 + }
58190 + if (name_set.n_hash) {
58191 + if ((name_set.n_size * sizeof (struct name_entry *)) <=
58192 + PAGE_SIZE)
58193 + kfree(name_set.n_hash);
58194 + else
58195 + vfree(name_set.n_hash);
58196 + }
58197 +
58198 + if (inodev_set.i_hash) {
58199 + if ((inodev_set.i_size * sizeof (struct inodev_entry *)) <=
58200 + PAGE_SIZE)
58201 + kfree(inodev_set.i_hash);
58202 + else
58203 + vfree(inodev_set.i_hash);
58204 + }
58205 +
58206 + gr_free_uidset();
58207 +
58208 + memset(&name_set, 0, sizeof (struct name_db));
58209 + memset(&inodev_set, 0, sizeof (struct inodev_db));
58210 + memset(&acl_role_set, 0, sizeof (struct acl_role_db));
58211 + memset(&subj_map_set, 0, sizeof (struct acl_subj_map_db));
58212 +
58213 + default_role = NULL;
58214 + kernel_role = NULL;
58215 + role_list = NULL;
58216 +
58217 + return;
58218 +}
58219 +
58220 +static __u32
58221 +count_user_objs(struct acl_object_label *userp)
58222 +{
58223 + struct acl_object_label o_tmp;
58224 + __u32 num = 0;
58225 +
58226 + while (userp) {
58227 + if (copy_from_user(&o_tmp, userp,
58228 + sizeof (struct acl_object_label)))
58229 + break;
58230 +
58231 + userp = o_tmp.prev;
58232 + num++;
58233 + }
58234 +
58235 + return num;
58236 +}
58237 +
58238 +static struct acl_subject_label *
58239 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied);
58240 +
58241 +static int
58242 +copy_user_glob(struct acl_object_label *obj)
58243 +{
58244 + struct acl_object_label *g_tmp, **guser;
58245 + unsigned int len;
58246 + char *tmp;
58247 +
58248 + if (obj->globbed == NULL)
58249 + return 0;
58250 +
58251 + guser = &obj->globbed;
58252 + while (*guser) {
58253 + g_tmp = (struct acl_object_label *)
58254 + acl_alloc(sizeof (struct acl_object_label));
58255 + if (g_tmp == NULL)
58256 + return -ENOMEM;
58257 +
58258 + if (copy_from_user(g_tmp, *guser,
58259 + sizeof (struct acl_object_label)))
58260 + return -EFAULT;
58261 +
58262 + len = strnlen_user(g_tmp->filename, PATH_MAX);
58263 +
58264 + if (!len || len >= PATH_MAX)
58265 + return -EINVAL;
58266 +
58267 + if ((tmp = (char *) acl_alloc(len)) == NULL)
58268 + return -ENOMEM;
58269 +
58270 + if (copy_from_user(tmp, g_tmp->filename, len))
58271 + return -EFAULT;
58272 + tmp[len-1] = '\0';
58273 + g_tmp->filename = tmp;
58274 +
58275 + *guser = g_tmp;
58276 + guser = &(g_tmp->next);
58277 + }
58278 +
58279 + return 0;
58280 +}
58281 +
58282 +static int
58283 +copy_user_objs(struct acl_object_label *userp, struct acl_subject_label *subj,
58284 + struct acl_role_label *role)
58285 +{
58286 + struct acl_object_label *o_tmp;
58287 + unsigned int len;
58288 + int ret;
58289 + char *tmp;
58290 +
58291 + while (userp) {
58292 + if ((o_tmp = (struct acl_object_label *)
58293 + acl_alloc(sizeof (struct acl_object_label))) == NULL)
58294 + return -ENOMEM;
58295 +
58296 + if (copy_from_user(o_tmp, userp,
58297 + sizeof (struct acl_object_label)))
58298 + return -EFAULT;
58299 +
58300 + userp = o_tmp->prev;
58301 +
58302 + len = strnlen_user(o_tmp->filename, PATH_MAX);
58303 +
58304 + if (!len || len >= PATH_MAX)
58305 + return -EINVAL;
58306 +
58307 + if ((tmp = (char *) acl_alloc(len)) == NULL)
58308 + return -ENOMEM;
58309 +
58310 + if (copy_from_user(tmp, o_tmp->filename, len))
58311 + return -EFAULT;
58312 + tmp[len-1] = '\0';
58313 + o_tmp->filename = tmp;
58314 +
58315 + insert_acl_obj_label(o_tmp, subj);
58316 + if (!insert_name_entry(o_tmp->filename, o_tmp->inode,
58317 + o_tmp->device, (o_tmp->mode & GR_DELETED) ? 1 : 0))
58318 + return -ENOMEM;
58319 +
58320 + ret = copy_user_glob(o_tmp);
58321 + if (ret)
58322 + return ret;
58323 +
58324 + if (o_tmp->nested) {
58325 + int already_copied;
58326 +
58327 + o_tmp->nested = do_copy_user_subj(o_tmp->nested, role, &already_copied);
58328 + if (IS_ERR(o_tmp->nested))
58329 + return PTR_ERR(o_tmp->nested);
58330 +
58331 + /* insert into nested subject list if we haven't copied this one yet
58332 + to prevent duplicate entries */
58333 + if (!already_copied) {
58334 + o_tmp->nested->next = role->hash->first;
58335 + role->hash->first = o_tmp->nested;
58336 + }
58337 + }
58338 + }
58339 +
58340 + return 0;
58341 +}
58342 +
58343 +static __u32
58344 +count_user_subjs(struct acl_subject_label *userp)
58345 +{
58346 + struct acl_subject_label s_tmp;
58347 + __u32 num = 0;
58348 +
58349 + while (userp) {
58350 + if (copy_from_user(&s_tmp, userp,
58351 + sizeof (struct acl_subject_label)))
58352 + break;
58353 +
58354 + userp = s_tmp.prev;
58355 + }
58356 +
58357 + return num;
58358 +}
58359 +
58360 +static int
58361 +copy_user_allowedips(struct acl_role_label *rolep)
58362 +{
58363 + struct role_allowed_ip *ruserip, *rtmp = NULL, *rlast;
58364 +
58365 + ruserip = rolep->allowed_ips;
58366 +
58367 + while (ruserip) {
58368 + rlast = rtmp;
58369 +
58370 + if ((rtmp = (struct role_allowed_ip *)
58371 + acl_alloc(sizeof (struct role_allowed_ip))) == NULL)
58372 + return -ENOMEM;
58373 +
58374 + if (copy_from_user(rtmp, ruserip,
58375 + sizeof (struct role_allowed_ip)))
58376 + return -EFAULT;
58377 +
58378 + ruserip = rtmp->prev;
58379 +
58380 + if (!rlast) {
58381 + rtmp->prev = NULL;
58382 + rolep->allowed_ips = rtmp;
58383 + } else {
58384 + rlast->next = rtmp;
58385 + rtmp->prev = rlast;
58386 + }
58387 +
58388 + if (!ruserip)
58389 + rtmp->next = NULL;
58390 + }
58391 +
58392 + return 0;
58393 +}
58394 +
58395 +static int
58396 +copy_user_transitions(struct acl_role_label *rolep)
58397 +{
58398 + struct role_transition *rusertp, *rtmp = NULL, *rlast;
58399 +
58400 + unsigned int len;
58401 + char *tmp;
58402 +
58403 + rusertp = rolep->transitions;
58404 +
58405 + while (rusertp) {
58406 + rlast = rtmp;
58407 +
58408 + if ((rtmp = (struct role_transition *)
58409 + acl_alloc(sizeof (struct role_transition))) == NULL)
58410 + return -ENOMEM;
58411 +
58412 + if (copy_from_user(rtmp, rusertp,
58413 + sizeof (struct role_transition)))
58414 + return -EFAULT;
58415 +
58416 + rusertp = rtmp->prev;
58417 +
58418 + len = strnlen_user(rtmp->rolename, GR_SPROLE_LEN);
58419 +
58420 + if (!len || len >= GR_SPROLE_LEN)
58421 + return -EINVAL;
58422 +
58423 + if ((tmp = (char *) acl_alloc(len)) == NULL)
58424 + return -ENOMEM;
58425 +
58426 + if (copy_from_user(tmp, rtmp->rolename, len))
58427 + return -EFAULT;
58428 + tmp[len-1] = '\0';
58429 + rtmp->rolename = tmp;
58430 +
58431 + if (!rlast) {
58432 + rtmp->prev = NULL;
58433 + rolep->transitions = rtmp;
58434 + } else {
58435 + rlast->next = rtmp;
58436 + rtmp->prev = rlast;
58437 + }
58438 +
58439 + if (!rusertp)
58440 + rtmp->next = NULL;
58441 + }
58442 +
58443 + return 0;
58444 +}
58445 +
58446 +static struct acl_subject_label *
58447 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied)
58448 +{
58449 + struct acl_subject_label *s_tmp = NULL, *s_tmp2;
58450 + unsigned int len;
58451 + char *tmp;
58452 + __u32 num_objs;
58453 + struct acl_ip_label **i_tmp, *i_utmp2;
58454 + struct gr_hash_struct ghash;
58455 + struct subject_map *subjmap;
58456 + unsigned int i_num;
58457 + int err;
58458 +
58459 + if (already_copied != NULL)
58460 + *already_copied = 0;
58461 +
58462 + s_tmp = lookup_subject_map(userp);
58463 +
58464 + /* we've already copied this subject into the kernel, just return
58465 + the reference to it, and don't copy it over again
58466 + */
58467 + if (s_tmp) {
58468 + if (already_copied != NULL)
58469 + *already_copied = 1;
58470 + return(s_tmp);
58471 + }
58472 +
58473 + if ((s_tmp = (struct acl_subject_label *)
58474 + acl_alloc(sizeof (struct acl_subject_label))) == NULL)
58475 + return ERR_PTR(-ENOMEM);
58476 +
58477 + subjmap = (struct subject_map *)kmalloc(sizeof (struct subject_map), GFP_KERNEL);
58478 + if (subjmap == NULL)
58479 + return ERR_PTR(-ENOMEM);
58480 +
58481 + subjmap->user = userp;
58482 + subjmap->kernel = s_tmp;
58483 + insert_subj_map_entry(subjmap);
58484 +
58485 + if (copy_from_user(s_tmp, userp,
58486 + sizeof (struct acl_subject_label)))
58487 + return ERR_PTR(-EFAULT);
58488 +
58489 + len = strnlen_user(s_tmp->filename, PATH_MAX);
58490 +
58491 + if (!len || len >= PATH_MAX)
58492 + return ERR_PTR(-EINVAL);
58493 +
58494 + if ((tmp = (char *) acl_alloc(len)) == NULL)
58495 + return ERR_PTR(-ENOMEM);
58496 +
58497 + if (copy_from_user(tmp, s_tmp->filename, len))
58498 + return ERR_PTR(-EFAULT);
58499 + tmp[len-1] = '\0';
58500 + s_tmp->filename = tmp;
58501 +
58502 + if (!strcmp(s_tmp->filename, "/"))
58503 + role->root_label = s_tmp;
58504 +
58505 + if (copy_from_user(&ghash, s_tmp->hash, sizeof(struct gr_hash_struct)))
58506 + return ERR_PTR(-EFAULT);
58507 +
58508 + /* copy user and group transition tables */
58509 +
58510 + if (s_tmp->user_trans_num) {
58511 + uid_t *uidlist;
58512 +
58513 + uidlist = (uid_t *)acl_alloc_num(s_tmp->user_trans_num, sizeof(uid_t));
58514 + if (uidlist == NULL)
58515 + return ERR_PTR(-ENOMEM);
58516 + if (copy_from_user(uidlist, s_tmp->user_transitions, s_tmp->user_trans_num * sizeof(uid_t)))
58517 + return ERR_PTR(-EFAULT);
58518 +
58519 + s_tmp->user_transitions = uidlist;
58520 + }
58521 +
58522 + if (s_tmp->group_trans_num) {
58523 + gid_t *gidlist;
58524 +
58525 + gidlist = (gid_t *)acl_alloc_num(s_tmp->group_trans_num, sizeof(gid_t));
58526 + if (gidlist == NULL)
58527 + return ERR_PTR(-ENOMEM);
58528 + if (copy_from_user(gidlist, s_tmp->group_transitions, s_tmp->group_trans_num * sizeof(gid_t)))
58529 + return ERR_PTR(-EFAULT);
58530 +
58531 + s_tmp->group_transitions = gidlist;
58532 + }
58533 +
58534 + /* set up object hash table */
58535 + num_objs = count_user_objs(ghash.first);
58536 +
58537 + s_tmp->obj_hash_size = num_objs;
58538 + s_tmp->obj_hash =
58539 + (struct acl_object_label **)
58540 + create_table(&(s_tmp->obj_hash_size), sizeof(void *));
58541 +
58542 + if (!s_tmp->obj_hash)
58543 + return ERR_PTR(-ENOMEM);
58544 +
58545 + memset(s_tmp->obj_hash, 0,
58546 + s_tmp->obj_hash_size *
58547 + sizeof (struct acl_object_label *));
58548 +
58549 + /* add in objects */
58550 + err = copy_user_objs(ghash.first, s_tmp, role);
58551 +
58552 + if (err)
58553 + return ERR_PTR(err);
58554 +
58555 + /* set pointer for parent subject */
58556 + if (s_tmp->parent_subject) {
58557 + s_tmp2 = do_copy_user_subj(s_tmp->parent_subject, role, NULL);
58558 +
58559 + if (IS_ERR(s_tmp2))
58560 + return s_tmp2;
58561 +
58562 + s_tmp->parent_subject = s_tmp2;
58563 + }
58564 +
58565 + /* add in ip acls */
58566 +
58567 + if (!s_tmp->ip_num) {
58568 + s_tmp->ips = NULL;
58569 + goto insert;
58570 + }
58571 +
58572 + i_tmp =
58573 + (struct acl_ip_label **) acl_alloc_num(s_tmp->ip_num,
58574 + sizeof (struct acl_ip_label *));
58575 +
58576 + if (!i_tmp)
58577 + return ERR_PTR(-ENOMEM);
58578 +
58579 + for (i_num = 0; i_num < s_tmp->ip_num; i_num++) {
58580 + *(i_tmp + i_num) =
58581 + (struct acl_ip_label *)
58582 + acl_alloc(sizeof (struct acl_ip_label));
58583 + if (!*(i_tmp + i_num))
58584 + return ERR_PTR(-ENOMEM);
58585 +
58586 + if (copy_from_user
58587 + (&i_utmp2, s_tmp->ips + i_num,
58588 + sizeof (struct acl_ip_label *)))
58589 + return ERR_PTR(-EFAULT);
58590 +
58591 + if (copy_from_user
58592 + (*(i_tmp + i_num), i_utmp2,
58593 + sizeof (struct acl_ip_label)))
58594 + return ERR_PTR(-EFAULT);
58595 +
58596 + if ((*(i_tmp + i_num))->iface == NULL)
58597 + continue;
58598 +
58599 + len = strnlen_user((*(i_tmp + i_num))->iface, IFNAMSIZ);
58600 + if (!len || len >= IFNAMSIZ)
58601 + return ERR_PTR(-EINVAL);
58602 + tmp = acl_alloc(len);
58603 + if (tmp == NULL)
58604 + return ERR_PTR(-ENOMEM);
58605 + if (copy_from_user(tmp, (*(i_tmp + i_num))->iface, len))
58606 + return ERR_PTR(-EFAULT);
58607 + (*(i_tmp + i_num))->iface = tmp;
58608 + }
58609 +
58610 + s_tmp->ips = i_tmp;
58611 +
58612 +insert:
58613 + if (!insert_name_entry(s_tmp->filename, s_tmp->inode,
58614 + s_tmp->device, (s_tmp->mode & GR_DELETED) ? 1 : 0))
58615 + return ERR_PTR(-ENOMEM);
58616 +
58617 + return s_tmp;
58618 +}
58619 +
58620 +static int
58621 +copy_user_subjs(struct acl_subject_label *userp, struct acl_role_label *role)
58622 +{
58623 + struct acl_subject_label s_pre;
58624 + struct acl_subject_label * ret;
58625 + int err;
58626 +
58627 + while (userp) {
58628 + if (copy_from_user(&s_pre, userp,
58629 + sizeof (struct acl_subject_label)))
58630 + return -EFAULT;
58631 +
58632 + ret = do_copy_user_subj(userp, role, NULL);
58633 +
58634 + err = PTR_ERR(ret);
58635 + if (IS_ERR(ret))
58636 + return err;
58637 +
58638 + insert_acl_subj_label(ret, role);
58639 +
58640 + userp = s_pre.prev;
58641 + }
58642 +
58643 + return 0;
58644 +}
58645 +
58646 +static int
58647 +copy_user_acl(struct gr_arg *arg)
58648 +{
58649 + struct acl_role_label *r_tmp = NULL, **r_utmp, *r_utmp2;
58650 + struct acl_subject_label *subj_list;
58651 + struct sprole_pw *sptmp;
58652 + struct gr_hash_struct *ghash;
58653 + uid_t *domainlist;
58654 + unsigned int r_num;
58655 + unsigned int len;
58656 + char *tmp;
58657 + int err = 0;
58658 + __u16 i;
58659 + __u32 num_subjs;
58660 +
58661 + /* we need a default and kernel role */
58662 + if (arg->role_db.num_roles < 2)
58663 + return -EINVAL;
58664 +
58665 + /* copy special role authentication info from userspace */
58666 +
58667 + num_sprole_pws = arg->num_sprole_pws;
58668 + acl_special_roles = (struct sprole_pw **) acl_alloc_num(num_sprole_pws, sizeof(struct sprole_pw *));
58669 +
58670 + if (!acl_special_roles && num_sprole_pws)
58671 + return -ENOMEM;
58672 +
58673 + for (i = 0; i < num_sprole_pws; i++) {
58674 + sptmp = (struct sprole_pw *) acl_alloc(sizeof(struct sprole_pw));
58675 + if (!sptmp)
58676 + return -ENOMEM;
58677 + if (copy_from_user(sptmp, arg->sprole_pws + i,
58678 + sizeof (struct sprole_pw)))
58679 + return -EFAULT;
58680 +
58681 + len = strnlen_user(sptmp->rolename, GR_SPROLE_LEN);
58682 +
58683 + if (!len || len >= GR_SPROLE_LEN)
58684 + return -EINVAL;
58685 +
58686 + if ((tmp = (char *) acl_alloc(len)) == NULL)
58687 + return -ENOMEM;
58688 +
58689 + if (copy_from_user(tmp, sptmp->rolename, len))
58690 + return -EFAULT;
58691 +
58692 + tmp[len-1] = '\0';
58693 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
58694 + printk(KERN_ALERT "Copying special role %s\n", tmp);
58695 +#endif
58696 + sptmp->rolename = tmp;
58697 + acl_special_roles[i] = sptmp;
58698 + }
58699 +
58700 + r_utmp = (struct acl_role_label **) arg->role_db.r_table;
58701 +
58702 + for (r_num = 0; r_num < arg->role_db.num_roles; r_num++) {
58703 + r_tmp = acl_alloc(sizeof (struct acl_role_label));
58704 +
58705 + if (!r_tmp)
58706 + return -ENOMEM;
58707 +
58708 + if (copy_from_user(&r_utmp2, r_utmp + r_num,
58709 + sizeof (struct acl_role_label *)))
58710 + return -EFAULT;
58711 +
58712 + if (copy_from_user(r_tmp, r_utmp2,
58713 + sizeof (struct acl_role_label)))
58714 + return -EFAULT;
58715 +
58716 + len = strnlen_user(r_tmp->rolename, GR_SPROLE_LEN);
58717 +
58718 + if (!len || len >= PATH_MAX)
58719 + return -EINVAL;
58720 +
58721 + if ((tmp = (char *) acl_alloc(len)) == NULL)
58722 + return -ENOMEM;
58723 +
58724 + if (copy_from_user(tmp, r_tmp->rolename, len))
58725 + return -EFAULT;
58726 +
58727 + tmp[len-1] = '\0';
58728 + r_tmp->rolename = tmp;
58729 +
58730 + if (!strcmp(r_tmp->rolename, "default")
58731 + && (r_tmp->roletype & GR_ROLE_DEFAULT)) {
58732 + default_role = r_tmp;
58733 + } else if (!strcmp(r_tmp->rolename, ":::kernel:::")) {
58734 + kernel_role = r_tmp;
58735 + }
58736 +
58737 + if ((ghash = (struct gr_hash_struct *) acl_alloc(sizeof(struct gr_hash_struct))) == NULL)
58738 + return -ENOMEM;
58739 +
58740 + if (copy_from_user(ghash, r_tmp->hash, sizeof(struct gr_hash_struct)))
58741 + return -EFAULT;
58742 +
58743 + r_tmp->hash = ghash;
58744 +
58745 + num_subjs = count_user_subjs(r_tmp->hash->first);
58746 +
58747 + r_tmp->subj_hash_size = num_subjs;
58748 + r_tmp->subj_hash =
58749 + (struct acl_subject_label **)
58750 + create_table(&(r_tmp->subj_hash_size), sizeof(void *));
58751 +
58752 + if (!r_tmp->subj_hash)
58753 + return -ENOMEM;
58754 +
58755 + err = copy_user_allowedips(r_tmp);
58756 + if (err)
58757 + return err;
58758 +
58759 + /* copy domain info */
58760 + if (r_tmp->domain_children != NULL) {
58761 + domainlist = acl_alloc_num(r_tmp->domain_child_num, sizeof(uid_t));
58762 + if (domainlist == NULL)
58763 + return -ENOMEM;
58764 +
58765 + if (copy_from_user(domainlist, r_tmp->domain_children, r_tmp->domain_child_num * sizeof(uid_t)))
58766 + return -EFAULT;
58767 +
58768 + r_tmp->domain_children = domainlist;
58769 + }
58770 +
58771 + err = copy_user_transitions(r_tmp);
58772 + if (err)
58773 + return err;
58774 +
58775 + memset(r_tmp->subj_hash, 0,
58776 + r_tmp->subj_hash_size *
58777 + sizeof (struct acl_subject_label *));
58778 +
58779 + /* acquire the list of subjects, then NULL out
58780 + the list prior to parsing the subjects for this role,
58781 + as during this parsing the list is replaced with a list
58782 + of *nested* subjects for the role
58783 + */
58784 + subj_list = r_tmp->hash->first;
58785 +
58786 + /* set nested subject list to null */
58787 + r_tmp->hash->first = NULL;
58788 +
58789 + err = copy_user_subjs(subj_list, r_tmp);
58790 +
58791 + if (err)
58792 + return err;
58793 +
58794 + insert_acl_role_label(r_tmp);
58795 + }
58796 +
58797 + if (default_role == NULL || kernel_role == NULL)
58798 + return -EINVAL;
58799 +
58800 + return err;
58801 +}
58802 +
58803 +static int
58804 +gracl_init(struct gr_arg *args)
58805 +{
58806 + int error = 0;
58807 +
58808 + memcpy(gr_system_salt, args->salt, GR_SALT_LEN);
58809 + memcpy(gr_system_sum, args->sum, GR_SHA_LEN);
58810 +
58811 + if (init_variables(args)) {
58812 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_INITF_ACL_MSG, GR_VERSION);
58813 + error = -ENOMEM;
58814 + free_variables();
58815 + goto out;
58816 + }
58817 +
58818 + error = copy_user_acl(args);
58819 + free_init_variables();
58820 + if (error) {
58821 + free_variables();
58822 + goto out;
58823 + }
58824 +
58825 + if ((error = gr_set_acls(0))) {
58826 + free_variables();
58827 + goto out;
58828 + }
58829 +
58830 + pax_open_kernel();
58831 + gr_status |= GR_READY;
58832 + pax_close_kernel();
58833 +
58834 + out:
58835 + return error;
58836 +}
58837 +
58838 +/* derived from glibc fnmatch() 0: match, 1: no match*/
58839 +
58840 +static int
58841 +glob_match(const char *p, const char *n)
58842 +{
58843 + char c;
58844 +
58845 + while ((c = *p++) != '\0') {
58846 + switch (c) {
58847 + case '?':
58848 + if (*n == '\0')
58849 + return 1;
58850 + else if (*n == '/')
58851 + return 1;
58852 + break;
58853 + case '\\':
58854 + if (*n != c)
58855 + return 1;
58856 + break;
58857 + case '*':
58858 + for (c = *p++; c == '?' || c == '*'; c = *p++) {
58859 + if (*n == '/')
58860 + return 1;
58861 + else if (c == '?') {
58862 + if (*n == '\0')
58863 + return 1;
58864 + else
58865 + ++n;
58866 + }
58867 + }
58868 + if (c == '\0') {
58869 + return 0;
58870 + } else {
58871 + const char *endp;
58872 +
58873 + if ((endp = strchr(n, '/')) == NULL)
58874 + endp = n + strlen(n);
58875 +
58876 + if (c == '[') {
58877 + for (--p; n < endp; ++n)
58878 + if (!glob_match(p, n))
58879 + return 0;
58880 + } else if (c == '/') {
58881 + while (*n != '\0' && *n != '/')
58882 + ++n;
58883 + if (*n == '/' && !glob_match(p, n + 1))
58884 + return 0;
58885 + } else {
58886 + for (--p; n < endp; ++n)
58887 + if (*n == c && !glob_match(p, n))
58888 + return 0;
58889 + }
58890 +
58891 + return 1;
58892 + }
58893 + case '[':
58894 + {
58895 + int not;
58896 + char cold;
58897 +
58898 + if (*n == '\0' || *n == '/')
58899 + return 1;
58900 +
58901 + not = (*p == '!' || *p == '^');
58902 + if (not)
58903 + ++p;
58904 +
58905 + c = *p++;
58906 + for (;;) {
58907 + unsigned char fn = (unsigned char)*n;
58908 +
58909 + if (c == '\0')
58910 + return 1;
58911 + else {
58912 + if (c == fn)
58913 + goto matched;
58914 + cold = c;
58915 + c = *p++;
58916 +
58917 + if (c == '-' && *p != ']') {
58918 + unsigned char cend = *p++;
58919 +
58920 + if (cend == '\0')
58921 + return 1;
58922 +
58923 + if (cold <= fn && fn <= cend)
58924 + goto matched;
58925 +
58926 + c = *p++;
58927 + }
58928 + }
58929 +
58930 + if (c == ']')
58931 + break;
58932 + }
58933 + if (!not)
58934 + return 1;
58935 + break;
58936 + matched:
58937 + while (c != ']') {
58938 + if (c == '\0')
58939 + return 1;
58940 +
58941 + c = *p++;
58942 + }
58943 + if (not)
58944 + return 1;
58945 + }
58946 + break;
58947 + default:
58948 + if (c != *n)
58949 + return 1;
58950 + }
58951 +
58952 + ++n;
58953 + }
58954 +
58955 + if (*n == '\0')
58956 + return 0;
58957 +
58958 + if (*n == '/')
58959 + return 0;
58960 +
58961 + return 1;
58962 +}
58963 +
58964 +static struct acl_object_label *
58965 +chk_glob_label(struct acl_object_label *globbed,
58966 + const struct dentry *dentry, const struct vfsmount *mnt, char **path)
58967 +{
58968 + struct acl_object_label *tmp;
58969 +
58970 + if (*path == NULL)
58971 + *path = gr_to_filename_nolock(dentry, mnt);
58972 +
58973 + tmp = globbed;
58974 +
58975 + while (tmp) {
58976 + if (!glob_match(tmp->filename, *path))
58977 + return tmp;
58978 + tmp = tmp->next;
58979 + }
58980 +
58981 + return NULL;
58982 +}
58983 +
58984 +static struct acl_object_label *
58985 +__full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
58986 + const ino_t curr_ino, const dev_t curr_dev,
58987 + const struct acl_subject_label *subj, char **path, const int checkglob)
58988 +{
58989 + struct acl_subject_label *tmpsubj;
58990 + struct acl_object_label *retval;
58991 + struct acl_object_label *retval2;
58992 +
58993 + tmpsubj = (struct acl_subject_label *) subj;
58994 + read_lock(&gr_inode_lock);
58995 + do {
58996 + retval = lookup_acl_obj_label(curr_ino, curr_dev, tmpsubj);
58997 + if (retval) {
58998 + if (checkglob && retval->globbed) {
58999 + retval2 = chk_glob_label(retval->globbed, orig_dentry, orig_mnt, path);
59000 + if (retval2)
59001 + retval = retval2;
59002 + }
59003 + break;
59004 + }
59005 + } while ((tmpsubj = tmpsubj->parent_subject));
59006 + read_unlock(&gr_inode_lock);
59007 +
59008 + return retval;
59009 +}
59010 +
59011 +static __inline__ struct acl_object_label *
59012 +full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
59013 + struct dentry *curr_dentry,
59014 + const struct acl_subject_label *subj, char **path, const int checkglob)
59015 +{
59016 + int newglob = checkglob;
59017 + ino_t inode;
59018 + dev_t device;
59019 +
59020 + /* if we aren't checking a subdirectory of the original path yet, don't do glob checking
59021 + as we don't want a / * rule to match instead of the / object
59022 + don't do this for create lookups that call this function though, since they're looking up
59023 + on the parent and thus need globbing checks on all paths
59024 + */
59025 + if (orig_dentry == curr_dentry && newglob != GR_CREATE_GLOB)
59026 + newglob = GR_NO_GLOB;
59027 +
59028 + spin_lock(&curr_dentry->d_lock);
59029 + inode = curr_dentry->d_inode->i_ino;
59030 + device = __get_dev(curr_dentry);
59031 + spin_unlock(&curr_dentry->d_lock);
59032 +
59033 + return __full_lookup(orig_dentry, orig_mnt, inode, device, subj, path, newglob);
59034 +}
59035 +
59036 +#ifdef CONFIG_HUGETLBFS
59037 +static inline bool
59038 +is_hugetlbfs_mnt(const struct vfsmount *mnt)
59039 +{
59040 + int i;
59041 + for (i = 0; i < HUGE_MAX_HSTATE; i++) {
59042 + if (unlikely(hugetlbfs_vfsmount[i] == mnt))
59043 + return true;
59044 + }
59045 +
59046 + return false;
59047 +}
59048 +#endif
59049 +
59050 +static struct acl_object_label *
59051 +__chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
59052 + const struct acl_subject_label *subj, char *path, const int checkglob)
59053 +{
59054 + struct dentry *dentry = (struct dentry *) l_dentry;
59055 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
59056 + struct mount *real_mnt = real_mount(mnt);
59057 + struct acl_object_label *retval;
59058 + struct dentry *parent;
59059 +
59060 + br_read_lock(&vfsmount_lock);
59061 + write_seqlock(&rename_lock);
59062 +
59063 + if (unlikely((mnt == shm_mnt && dentry->d_inode->i_nlink == 0) || mnt == pipe_mnt ||
59064 +#ifdef CONFIG_NET
59065 + mnt == sock_mnt ||
59066 +#endif
59067 +#ifdef CONFIG_HUGETLBFS
59068 + (is_hugetlbfs_mnt(mnt) && dentry->d_inode->i_nlink == 0) ||
59069 +#endif
59070 + /* ignore Eric Biederman */
59071 + IS_PRIVATE(l_dentry->d_inode))) {
59072 + retval = (subj->mode & GR_SHMEXEC) ? fakefs_obj_rwx : fakefs_obj_rw;
59073 + goto out;
59074 + }
59075 +
59076 + for (;;) {
59077 + if (dentry == real_root.dentry && mnt == real_root.mnt)
59078 + break;
59079 +
59080 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
59081 + if (!mnt_has_parent(real_mnt))
59082 + break;
59083 +
59084 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
59085 + if (retval != NULL)
59086 + goto out;
59087 +
59088 + dentry = real_mnt->mnt_mountpoint;
59089 + real_mnt = real_mnt->mnt_parent;
59090 + mnt = &real_mnt->mnt;
59091 + continue;
59092 + }
59093 +
59094 + parent = dentry->d_parent;
59095 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
59096 + if (retval != NULL)
59097 + goto out;
59098 +
59099 + dentry = parent;
59100 + }
59101 +
59102 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
59103 +
59104 + /* real_root is pinned so we don't have to hold a reference */
59105 + if (retval == NULL)
59106 + retval = full_lookup(l_dentry, l_mnt, real_root.dentry, subj, &path, checkglob);
59107 +out:
59108 + write_sequnlock(&rename_lock);
59109 + br_read_unlock(&vfsmount_lock);
59110 +
59111 + BUG_ON(retval == NULL);
59112 +
59113 + return retval;
59114 +}
59115 +
59116 +static __inline__ struct acl_object_label *
59117 +chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
59118 + const struct acl_subject_label *subj)
59119 +{
59120 + char *path = NULL;
59121 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_REG_GLOB);
59122 +}
59123 +
59124 +static __inline__ struct acl_object_label *
59125 +chk_obj_label_noglob(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
59126 + const struct acl_subject_label *subj)
59127 +{
59128 + char *path = NULL;
59129 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_NO_GLOB);
59130 +}
59131 +
59132 +static __inline__ struct acl_object_label *
59133 +chk_obj_create_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
59134 + const struct acl_subject_label *subj, char *path)
59135 +{
59136 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_CREATE_GLOB);
59137 +}
59138 +
59139 +static struct acl_subject_label *
59140 +chk_subj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
59141 + const struct acl_role_label *role)
59142 +{
59143 + struct dentry *dentry = (struct dentry *) l_dentry;
59144 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
59145 + struct mount *real_mnt = real_mount(mnt);
59146 + struct acl_subject_label *retval;
59147 + struct dentry *parent;
59148 +
59149 + br_read_lock(&vfsmount_lock);
59150 + write_seqlock(&rename_lock);
59151 +
59152 + for (;;) {
59153 + if (dentry == real_root.dentry && mnt == real_root.mnt)
59154 + break;
59155 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
59156 + if (!mnt_has_parent(real_mnt))
59157 + break;
59158 +
59159 + spin_lock(&dentry->d_lock);
59160 + read_lock(&gr_inode_lock);
59161 + retval =
59162 + lookup_acl_subj_label(dentry->d_inode->i_ino,
59163 + __get_dev(dentry), role);
59164 + read_unlock(&gr_inode_lock);
59165 + spin_unlock(&dentry->d_lock);
59166 + if (retval != NULL)
59167 + goto out;
59168 +
59169 + dentry = real_mnt->mnt_mountpoint;
59170 + real_mnt = real_mnt->mnt_parent;
59171 + mnt = &real_mnt->mnt;
59172 + continue;
59173 + }
59174 +
59175 + spin_lock(&dentry->d_lock);
59176 + read_lock(&gr_inode_lock);
59177 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
59178 + __get_dev(dentry), role);
59179 + read_unlock(&gr_inode_lock);
59180 + parent = dentry->d_parent;
59181 + spin_unlock(&dentry->d_lock);
59182 +
59183 + if (retval != NULL)
59184 + goto out;
59185 +
59186 + dentry = parent;
59187 + }
59188 +
59189 + spin_lock(&dentry->d_lock);
59190 + read_lock(&gr_inode_lock);
59191 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
59192 + __get_dev(dentry), role);
59193 + read_unlock(&gr_inode_lock);
59194 + spin_unlock(&dentry->d_lock);
59195 +
59196 + if (unlikely(retval == NULL)) {
59197 + /* real_root is pinned, we don't need to hold a reference */
59198 + read_lock(&gr_inode_lock);
59199 + retval = lookup_acl_subj_label(real_root.dentry->d_inode->i_ino,
59200 + __get_dev(real_root.dentry), role);
59201 + read_unlock(&gr_inode_lock);
59202 + }
59203 +out:
59204 + write_sequnlock(&rename_lock);
59205 + br_read_unlock(&vfsmount_lock);
59206 +
59207 + BUG_ON(retval == NULL);
59208 +
59209 + return retval;
59210 +}
59211 +
59212 +static void
59213 +gr_log_learn(const struct dentry *dentry, const struct vfsmount *mnt, const __u32 mode)
59214 +{
59215 + struct task_struct *task = current;
59216 + const struct cred *cred = current_cred();
59217 +
59218 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename, task->role->roletype,
59219 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
59220 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
59221 + 1UL, 1UL, gr_to_filename(dentry, mnt), (unsigned long) mode, &task->signal->saved_ip);
59222 +
59223 + return;
59224 +}
59225 +
59226 +static void
59227 +gr_log_learn_uid_change(const kuid_t real, const kuid_t effective, const kuid_t fs)
59228 +{
59229 + struct task_struct *task = current;
59230 + const struct cred *cred = current_cred();
59231 +
59232 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
59233 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
59234 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
59235 + 'u', GR_GLOBAL_UID(real), GR_GLOBAL_UID(effective), GR_GLOBAL_UID(fs), &task->signal->saved_ip);
59236 +
59237 + return;
59238 +}
59239 +
59240 +static void
59241 +gr_log_learn_gid_change(const kgid_t real, const kgid_t effective, const kgid_t fs)
59242 +{
59243 + struct task_struct *task = current;
59244 + const struct cred *cred = current_cred();
59245 +
59246 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
59247 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
59248 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
59249 + 'g', GR_GLOBAL_GID(real), GR_GLOBAL_GID(effective), GR_GLOBAL_GID(fs), &task->signal->saved_ip);
59250 +
59251 + return;
59252 +}
59253 +
59254 +__u32
59255 +gr_search_file(const struct dentry * dentry, const __u32 mode,
59256 + const struct vfsmount * mnt)
59257 +{
59258 + __u32 retval = mode;
59259 + struct acl_subject_label *curracl;
59260 + struct acl_object_label *currobj;
59261 +
59262 + if (unlikely(!(gr_status & GR_READY)))
59263 + return (mode & ~GR_AUDITS);
59264 +
59265 + curracl = current->acl;
59266 +
59267 + currobj = chk_obj_label(dentry, mnt, curracl);
59268 + retval = currobj->mode & mode;
59269 +
59270 + /* if we're opening a specified transfer file for writing
59271 + (e.g. /dev/initctl), then transfer our role to init
59272 + */
59273 + if (unlikely(currobj->mode & GR_INIT_TRANSFER && retval & GR_WRITE &&
59274 + current->role->roletype & GR_ROLE_PERSIST)) {
59275 + struct task_struct *task = init_pid_ns.child_reaper;
59276 +
59277 + if (task->role != current->role) {
59278 + task->acl_sp_role = 0;
59279 + task->acl_role_id = current->acl_role_id;
59280 + task->role = current->role;
59281 + rcu_read_lock();
59282 + read_lock(&grsec_exec_file_lock);
59283 + gr_apply_subject_to_task(task);
59284 + read_unlock(&grsec_exec_file_lock);
59285 + rcu_read_unlock();
59286 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_INIT_TRANSFER_MSG);
59287 + }
59288 + }
59289 +
59290 + if (unlikely
59291 + ((curracl->mode & (GR_LEARN | GR_INHERITLEARN)) && !(mode & GR_NOPTRACE)
59292 + && (retval != (mode & ~(GR_AUDITS | GR_SUPPRESS))))) {
59293 + __u32 new_mode = mode;
59294 +
59295 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
59296 +
59297 + retval = new_mode;
59298 +
59299 + if (new_mode & GR_EXEC && curracl->mode & GR_INHERITLEARN)
59300 + new_mode |= GR_INHERIT;
59301 +
59302 + if (!(mode & GR_NOLEARN))
59303 + gr_log_learn(dentry, mnt, new_mode);
59304 + }
59305 +
59306 + return retval;
59307 +}
59308 +
59309 +struct acl_object_label *gr_get_create_object(const struct dentry *new_dentry,
59310 + const struct dentry *parent,
59311 + const struct vfsmount *mnt)
59312 +{
59313 + struct name_entry *match;
59314 + struct acl_object_label *matchpo;
59315 + struct acl_subject_label *curracl;
59316 + char *path;
59317 +
59318 + if (unlikely(!(gr_status & GR_READY)))
59319 + return NULL;
59320 +
59321 + preempt_disable();
59322 + path = gr_to_filename_rbac(new_dentry, mnt);
59323 + match = lookup_name_entry_create(path);
59324 +
59325 + curracl = current->acl;
59326 +
59327 + if (match) {
59328 + read_lock(&gr_inode_lock);
59329 + matchpo = lookup_acl_obj_label_create(match->inode, match->device, curracl);
59330 + read_unlock(&gr_inode_lock);
59331 +
59332 + if (matchpo) {
59333 + preempt_enable();
59334 + return matchpo;
59335 + }
59336 + }
59337 +
59338 + // lookup parent
59339 +
59340 + matchpo = chk_obj_create_label(parent, mnt, curracl, path);
59341 +
59342 + preempt_enable();
59343 + return matchpo;
59344 +}
59345 +
59346 +__u32
59347 +gr_check_create(const struct dentry * new_dentry, const struct dentry * parent,
59348 + const struct vfsmount * mnt, const __u32 mode)
59349 +{
59350 + struct acl_object_label *matchpo;
59351 + __u32 retval;
59352 +
59353 + if (unlikely(!(gr_status & GR_READY)))
59354 + return (mode & ~GR_AUDITS);
59355 +
59356 + matchpo = gr_get_create_object(new_dentry, parent, mnt);
59357 +
59358 + retval = matchpo->mode & mode;
59359 +
59360 + if ((retval != (mode & ~(GR_AUDITS | GR_SUPPRESS)))
59361 + && (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
59362 + __u32 new_mode = mode;
59363 +
59364 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
59365 +
59366 + gr_log_learn(new_dentry, mnt, new_mode);
59367 + return new_mode;
59368 + }
59369 +
59370 + return retval;
59371 +}
59372 +
59373 +__u32
59374 +gr_check_link(const struct dentry * new_dentry,
59375 + const struct dentry * parent_dentry,
59376 + const struct vfsmount * parent_mnt,
59377 + const struct dentry * old_dentry, const struct vfsmount * old_mnt)
59378 +{
59379 + struct acl_object_label *obj;
59380 + __u32 oldmode, newmode;
59381 + __u32 needmode;
59382 + __u32 checkmodes = GR_FIND | GR_APPEND | GR_WRITE | GR_EXEC | GR_SETID | GR_READ |
59383 + GR_DELETE | GR_INHERIT;
59384 +
59385 + if (unlikely(!(gr_status & GR_READY)))
59386 + return (GR_CREATE | GR_LINK);
59387 +
59388 + obj = chk_obj_label(old_dentry, old_mnt, current->acl);
59389 + oldmode = obj->mode;
59390 +
59391 + obj = gr_get_create_object(new_dentry, parent_dentry, parent_mnt);
59392 + newmode = obj->mode;
59393 +
59394 + needmode = newmode & checkmodes;
59395 +
59396 + // old name for hardlink must have at least the permissions of the new name
59397 + if ((oldmode & needmode) != needmode)
59398 + goto bad;
59399 +
59400 + // if old name had restrictions/auditing, make sure the new name does as well
59401 + needmode = oldmode & (GR_NOPTRACE | GR_PTRACERD | GR_INHERIT | GR_AUDITS);
59402 +
59403 + // don't allow hardlinking of suid/sgid/fcapped files without permission
59404 + if (is_privileged_binary(old_dentry))
59405 + needmode |= GR_SETID;
59406 +
59407 + if ((newmode & needmode) != needmode)
59408 + goto bad;
59409 +
59410 + // enforce minimum permissions
59411 + if ((newmode & (GR_CREATE | GR_LINK)) == (GR_CREATE | GR_LINK))
59412 + return newmode;
59413 +bad:
59414 + needmode = oldmode;
59415 + if (is_privileged_binary(old_dentry))
59416 + needmode |= GR_SETID;
59417 +
59418 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN)) {
59419 + gr_log_learn(old_dentry, old_mnt, needmode | GR_CREATE | GR_LINK);
59420 + return (GR_CREATE | GR_LINK);
59421 + } else if (newmode & GR_SUPPRESS)
59422 + return GR_SUPPRESS;
59423 + else
59424 + return 0;
59425 +}
59426 +
59427 +int
59428 +gr_check_hidden_task(const struct task_struct *task)
59429 +{
59430 + if (unlikely(!(gr_status & GR_READY)))
59431 + return 0;
59432 +
59433 + if (!(task->acl->mode & GR_PROCFIND) && !(current->acl->mode & GR_VIEW))
59434 + return 1;
59435 +
59436 + return 0;
59437 +}
59438 +
59439 +int
59440 +gr_check_protected_task(const struct task_struct *task)
59441 +{
59442 + if (unlikely(!(gr_status & GR_READY) || !task))
59443 + return 0;
59444 +
59445 + if ((task->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
59446 + task->acl != current->acl)
59447 + return 1;
59448 +
59449 + return 0;
59450 +}
59451 +
59452 +int
59453 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
59454 +{
59455 + struct task_struct *p;
59456 + int ret = 0;
59457 +
59458 + if (unlikely(!(gr_status & GR_READY) || !pid))
59459 + return ret;
59460 +
59461 + read_lock(&tasklist_lock);
59462 + do_each_pid_task(pid, type, p) {
59463 + if ((p->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
59464 + p->acl != current->acl) {
59465 + ret = 1;
59466 + goto out;
59467 + }
59468 + } while_each_pid_task(pid, type, p);
59469 +out:
59470 + read_unlock(&tasklist_lock);
59471 +
59472 + return ret;
59473 +}
59474 +
59475 +void
59476 +gr_copy_label(struct task_struct *tsk)
59477 +{
59478 + tsk->signal->used_accept = 0;
59479 + tsk->acl_sp_role = 0;
59480 + tsk->acl_role_id = current->acl_role_id;
59481 + tsk->acl = current->acl;
59482 + tsk->role = current->role;
59483 + tsk->signal->curr_ip = current->signal->curr_ip;
59484 + tsk->signal->saved_ip = current->signal->saved_ip;
59485 + if (current->exec_file)
59486 + get_file(current->exec_file);
59487 + tsk->exec_file = current->exec_file;
59488 + tsk->is_writable = current->is_writable;
59489 + if (unlikely(current->signal->used_accept)) {
59490 + current->signal->curr_ip = 0;
59491 + current->signal->saved_ip = 0;
59492 + }
59493 +
59494 + return;
59495 +}
59496 +
59497 +static void
59498 +gr_set_proc_res(struct task_struct *task)
59499 +{
59500 + struct acl_subject_label *proc;
59501 + unsigned short i;
59502 +
59503 + proc = task->acl;
59504 +
59505 + if (proc->mode & (GR_LEARN | GR_INHERITLEARN))
59506 + return;
59507 +
59508 + for (i = 0; i < RLIM_NLIMITS; i++) {
59509 + if (!(proc->resmask & (1U << i)))
59510 + continue;
59511 +
59512 + task->signal->rlim[i].rlim_cur = proc->res[i].rlim_cur;
59513 + task->signal->rlim[i].rlim_max = proc->res[i].rlim_max;
59514 +
59515 + if (i == RLIMIT_CPU)
59516 + update_rlimit_cpu(task, proc->res[i].rlim_cur);
59517 + }
59518 +
59519 + return;
59520 +}
59521 +
59522 +extern int __gr_process_user_ban(struct user_struct *user);
59523 +
59524 +int
59525 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
59526 +{
59527 + unsigned int i;
59528 + __u16 num;
59529 + uid_t *uidlist;
59530 + uid_t curuid;
59531 + int realok = 0;
59532 + int effectiveok = 0;
59533 + int fsok = 0;
59534 + uid_t globalreal, globaleffective, globalfs;
59535 +
59536 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
59537 + struct user_struct *user;
59538 +
59539 + if (!uid_valid(real))
59540 + goto skipit;
59541 +
59542 + /* find user based on global namespace */
59543 +
59544 + globalreal = GR_GLOBAL_UID(real);
59545 +
59546 + user = find_user(make_kuid(&init_user_ns, globalreal));
59547 + if (user == NULL)
59548 + goto skipit;
59549 +
59550 + if (__gr_process_user_ban(user)) {
59551 + /* for find_user */
59552 + free_uid(user);
59553 + return 1;
59554 + }
59555 +
59556 + /* for find_user */
59557 + free_uid(user);
59558 +
59559 +skipit:
59560 +#endif
59561 +
59562 + if (unlikely(!(gr_status & GR_READY)))
59563 + return 0;
59564 +
59565 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
59566 + gr_log_learn_uid_change(real, effective, fs);
59567 +
59568 + num = current->acl->user_trans_num;
59569 + uidlist = current->acl->user_transitions;
59570 +
59571 + if (uidlist == NULL)
59572 + return 0;
59573 +
59574 + if (!uid_valid(real)) {
59575 + realok = 1;
59576 + globalreal = (uid_t)-1;
59577 + } else {
59578 + globalreal = GR_GLOBAL_UID(real);
59579 + }
59580 + if (!uid_valid(effective)) {
59581 + effectiveok = 1;
59582 + globaleffective = (uid_t)-1;
59583 + } else {
59584 + globaleffective = GR_GLOBAL_UID(effective);
59585 + }
59586 + if (!uid_valid(fs)) {
59587 + fsok = 1;
59588 + globalfs = (uid_t)-1;
59589 + } else {
59590 + globalfs = GR_GLOBAL_UID(fs);
59591 + }
59592 +
59593 + if (current->acl->user_trans_type & GR_ID_ALLOW) {
59594 + for (i = 0; i < num; i++) {
59595 + curuid = uidlist[i];
59596 + if (globalreal == curuid)
59597 + realok = 1;
59598 + if (globaleffective == curuid)
59599 + effectiveok = 1;
59600 + if (globalfs == curuid)
59601 + fsok = 1;
59602 + }
59603 + } else if (current->acl->user_trans_type & GR_ID_DENY) {
59604 + for (i = 0; i < num; i++) {
59605 + curuid = uidlist[i];
59606 + if (globalreal == curuid)
59607 + break;
59608 + if (globaleffective == curuid)
59609 + break;
59610 + if (globalfs == curuid)
59611 + break;
59612 + }
59613 + /* not in deny list */
59614 + if (i == num) {
59615 + realok = 1;
59616 + effectiveok = 1;
59617 + fsok = 1;
59618 + }
59619 + }
59620 +
59621 + if (realok && effectiveok && fsok)
59622 + return 0;
59623 + else {
59624 + gr_log_int(GR_DONT_AUDIT, GR_USRCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
59625 + return 1;
59626 + }
59627 +}
59628 +
59629 +int
59630 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
59631 +{
59632 + unsigned int i;
59633 + __u16 num;
59634 + gid_t *gidlist;
59635 + gid_t curgid;
59636 + int realok = 0;
59637 + int effectiveok = 0;
59638 + int fsok = 0;
59639 + gid_t globalreal, globaleffective, globalfs;
59640 +
59641 + if (unlikely(!(gr_status & GR_READY)))
59642 + return 0;
59643 +
59644 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
59645 + gr_log_learn_gid_change(real, effective, fs);
59646 +
59647 + num = current->acl->group_trans_num;
59648 + gidlist = current->acl->group_transitions;
59649 +
59650 + if (gidlist == NULL)
59651 + return 0;
59652 +
59653 + if (!gid_valid(real)) {
59654 + realok = 1;
59655 + globalreal = (gid_t)-1;
59656 + } else {
59657 + globalreal = GR_GLOBAL_GID(real);
59658 + }
59659 + if (!gid_valid(effective)) {
59660 + effectiveok = 1;
59661 + globaleffective = (gid_t)-1;
59662 + } else {
59663 + globaleffective = GR_GLOBAL_GID(effective);
59664 + }
59665 + if (!gid_valid(fs)) {
59666 + fsok = 1;
59667 + globalfs = (gid_t)-1;
59668 + } else {
59669 + globalfs = GR_GLOBAL_GID(fs);
59670 + }
59671 +
59672 + if (current->acl->group_trans_type & GR_ID_ALLOW) {
59673 + for (i = 0; i < num; i++) {
59674 + curgid = gidlist[i];
59675 + if (globalreal == curgid)
59676 + realok = 1;
59677 + if (globaleffective == curgid)
59678 + effectiveok = 1;
59679 + if (globalfs == curgid)
59680 + fsok = 1;
59681 + }
59682 + } else if (current->acl->group_trans_type & GR_ID_DENY) {
59683 + for (i = 0; i < num; i++) {
59684 + curgid = gidlist[i];
59685 + if (globalreal == curgid)
59686 + break;
59687 + if (globaleffective == curgid)
59688 + break;
59689 + if (globalfs == curgid)
59690 + break;
59691 + }
59692 + /* not in deny list */
59693 + if (i == num) {
59694 + realok = 1;
59695 + effectiveok = 1;
59696 + fsok = 1;
59697 + }
59698 + }
59699 +
59700 + if (realok && effectiveok && fsok)
59701 + return 0;
59702 + else {
59703 + gr_log_int(GR_DONT_AUDIT, GR_GRPCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
59704 + return 1;
59705 + }
59706 +}
59707 +
59708 +extern int gr_acl_is_capable(const int cap);
59709 +
59710 +void
59711 +gr_set_role_label(struct task_struct *task, const kuid_t kuid, const kgid_t kgid)
59712 +{
59713 + struct acl_role_label *role = task->role;
59714 + struct acl_subject_label *subj = NULL;
59715 + struct acl_object_label *obj;
59716 + struct file *filp;
59717 + uid_t uid;
59718 + gid_t gid;
59719 +
59720 + if (unlikely(!(gr_status & GR_READY)))
59721 + return;
59722 +
59723 + uid = GR_GLOBAL_UID(kuid);
59724 + gid = GR_GLOBAL_GID(kgid);
59725 +
59726 + filp = task->exec_file;
59727 +
59728 + /* kernel process, we'll give them the kernel role */
59729 + if (unlikely(!filp)) {
59730 + task->role = kernel_role;
59731 + task->acl = kernel_role->root_label;
59732 + return;
59733 + } else if (!task->role || !(task->role->roletype & GR_ROLE_SPECIAL))
59734 + role = lookup_acl_role_label(task, uid, gid);
59735 +
59736 + /* don't change the role if we're not a privileged process */
59737 + if (role && task->role != role &&
59738 + (((role->roletype & GR_ROLE_USER) && !gr_acl_is_capable(CAP_SETUID)) ||
59739 + ((role->roletype & GR_ROLE_GROUP) && !gr_acl_is_capable(CAP_SETGID))))
59740 + return;
59741 +
59742 + /* perform subject lookup in possibly new role
59743 + we can use this result below in the case where role == task->role
59744 + */
59745 + subj = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, role);
59746 +
59747 + /* if we changed uid/gid, but result in the same role
59748 + and are using inheritance, don't lose the inherited subject
59749 + if current subject is other than what normal lookup
59750 + would result in, we arrived via inheritance, don't
59751 + lose subject
59752 + */
59753 + if (role != task->role || (!(task->acl->mode & GR_INHERITLEARN) &&
59754 + (subj == task->acl)))
59755 + task->acl = subj;
59756 +
59757 + task->role = role;
59758 +
59759 + task->is_writable = 0;
59760 +
59761 + /* ignore additional mmap checks for processes that are writable
59762 + by the default ACL */
59763 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
59764 + if (unlikely(obj->mode & GR_WRITE))
59765 + task->is_writable = 1;
59766 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
59767 + if (unlikely(obj->mode & GR_WRITE))
59768 + task->is_writable = 1;
59769 +
59770 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
59771 + 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);
59772 +#endif
59773 +
59774 + gr_set_proc_res(task);
59775 +
59776 + return;
59777 +}
59778 +
59779 +int
59780 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
59781 + const int unsafe_flags)
59782 +{
59783 + struct task_struct *task = current;
59784 + struct acl_subject_label *newacl;
59785 + struct acl_object_label *obj;
59786 + __u32 retmode;
59787 +
59788 + if (unlikely(!(gr_status & GR_READY)))
59789 + return 0;
59790 +
59791 + newacl = chk_subj_label(dentry, mnt, task->role);
59792 +
59793 + /* special handling for if we did an strace -f -p <pid> from an admin role, where pid then
59794 + did an exec
59795 + */
59796 + rcu_read_lock();
59797 + read_lock(&tasklist_lock);
59798 + if (task->ptrace && task->parent && ((task->parent->role->roletype & GR_ROLE_GOD) ||
59799 + (task->parent->acl->mode & GR_POVERRIDE))) {
59800 + read_unlock(&tasklist_lock);
59801 + rcu_read_unlock();
59802 + goto skip_check;
59803 + }
59804 + read_unlock(&tasklist_lock);
59805 + rcu_read_unlock();
59806 +
59807 + if (unsafe_flags && !(task->acl->mode & GR_POVERRIDE) && (task->acl != newacl) &&
59808 + !(task->role->roletype & GR_ROLE_GOD) &&
59809 + !gr_search_file(dentry, GR_PTRACERD, mnt) &&
59810 + !(task->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
59811 + if (unsafe_flags & LSM_UNSAFE_SHARE)
59812 + gr_log_fs_generic(GR_DONT_AUDIT, GR_UNSAFESHARE_EXEC_ACL_MSG, dentry, mnt);
59813 + else
59814 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_EXEC_ACL_MSG, dentry, mnt);
59815 + return -EACCES;
59816 + }
59817 +
59818 +skip_check:
59819 +
59820 + obj = chk_obj_label(dentry, mnt, task->acl);
59821 + retmode = obj->mode & (GR_INHERIT | GR_AUDIT_INHERIT);
59822 +
59823 + if (!(task->acl->mode & GR_INHERITLEARN) &&
59824 + ((newacl->mode & GR_LEARN) || !(retmode & GR_INHERIT))) {
59825 + if (obj->nested)
59826 + task->acl = obj->nested;
59827 + else
59828 + task->acl = newacl;
59829 + } else if (retmode & GR_INHERIT && retmode & GR_AUDIT_INHERIT)
59830 + gr_log_str_fs(GR_DO_AUDIT, GR_INHERIT_ACL_MSG, task->acl->filename, dentry, mnt);
59831 +
59832 + task->is_writable = 0;
59833 +
59834 + /* ignore additional mmap checks for processes that are writable
59835 + by the default ACL */
59836 + obj = chk_obj_label(dentry, mnt, default_role->root_label);
59837 + if (unlikely(obj->mode & GR_WRITE))
59838 + task->is_writable = 1;
59839 + obj = chk_obj_label(dentry, mnt, task->role->root_label);
59840 + if (unlikely(obj->mode & GR_WRITE))
59841 + task->is_writable = 1;
59842 +
59843 + gr_set_proc_res(task);
59844 +
59845 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
59846 + 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);
59847 +#endif
59848 + return 0;
59849 +}
59850 +
59851 +/* always called with valid inodev ptr */
59852 +static void
59853 +do_handle_delete(struct inodev_entry *inodev, const ino_t ino, const dev_t dev)
59854 +{
59855 + struct acl_object_label *matchpo;
59856 + struct acl_subject_label *matchps;
59857 + struct acl_subject_label *subj;
59858 + struct acl_role_label *role;
59859 + unsigned int x;
59860 +
59861 + FOR_EACH_ROLE_START(role)
59862 + FOR_EACH_SUBJECT_START(role, subj, x)
59863 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
59864 + matchpo->mode |= GR_DELETED;
59865 + FOR_EACH_SUBJECT_END(subj,x)
59866 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
59867 + /* nested subjects aren't in the role's subj_hash table */
59868 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
59869 + matchpo->mode |= GR_DELETED;
59870 + FOR_EACH_NESTED_SUBJECT_END(subj)
59871 + if ((matchps = lookup_acl_subj_label(ino, dev, role)) != NULL)
59872 + matchps->mode |= GR_DELETED;
59873 + FOR_EACH_ROLE_END(role)
59874 +
59875 + inodev->nentry->deleted = 1;
59876 +
59877 + return;
59878 +}
59879 +
59880 +void
59881 +gr_handle_delete(const ino_t ino, const dev_t dev)
59882 +{
59883 + struct inodev_entry *inodev;
59884 +
59885 + if (unlikely(!(gr_status & GR_READY)))
59886 + return;
59887 +
59888 + write_lock(&gr_inode_lock);
59889 + inodev = lookup_inodev_entry(ino, dev);
59890 + if (inodev != NULL)
59891 + do_handle_delete(inodev, ino, dev);
59892 + write_unlock(&gr_inode_lock);
59893 +
59894 + return;
59895 +}
59896 +
59897 +static void
59898 +update_acl_obj_label(const ino_t oldinode, const dev_t olddevice,
59899 + const ino_t newinode, const dev_t newdevice,
59900 + struct acl_subject_label *subj)
59901 +{
59902 + unsigned int index = gr_fhash(oldinode, olddevice, subj->obj_hash_size);
59903 + struct acl_object_label *match;
59904 +
59905 + match = subj->obj_hash[index];
59906 +
59907 + while (match && (match->inode != oldinode ||
59908 + match->device != olddevice ||
59909 + !(match->mode & GR_DELETED)))
59910 + match = match->next;
59911 +
59912 + if (match && (match->inode == oldinode)
59913 + && (match->device == olddevice)
59914 + && (match->mode & GR_DELETED)) {
59915 + if (match->prev == NULL) {
59916 + subj->obj_hash[index] = match->next;
59917 + if (match->next != NULL)
59918 + match->next->prev = NULL;
59919 + } else {
59920 + match->prev->next = match->next;
59921 + if (match->next != NULL)
59922 + match->next->prev = match->prev;
59923 + }
59924 + match->prev = NULL;
59925 + match->next = NULL;
59926 + match->inode = newinode;
59927 + match->device = newdevice;
59928 + match->mode &= ~GR_DELETED;
59929 +
59930 + insert_acl_obj_label(match, subj);
59931 + }
59932 +
59933 + return;
59934 +}
59935 +
59936 +static void
59937 +update_acl_subj_label(const ino_t oldinode, const dev_t olddevice,
59938 + const ino_t newinode, const dev_t newdevice,
59939 + struct acl_role_label *role)
59940 +{
59941 + unsigned int index = gr_fhash(oldinode, olddevice, role->subj_hash_size);
59942 + struct acl_subject_label *match;
59943 +
59944 + match = role->subj_hash[index];
59945 +
59946 + while (match && (match->inode != oldinode ||
59947 + match->device != olddevice ||
59948 + !(match->mode & GR_DELETED)))
59949 + match = match->next;
59950 +
59951 + if (match && (match->inode == oldinode)
59952 + && (match->device == olddevice)
59953 + && (match->mode & GR_DELETED)) {
59954 + if (match->prev == NULL) {
59955 + role->subj_hash[index] = match->next;
59956 + if (match->next != NULL)
59957 + match->next->prev = NULL;
59958 + } else {
59959 + match->prev->next = match->next;
59960 + if (match->next != NULL)
59961 + match->next->prev = match->prev;
59962 + }
59963 + match->prev = NULL;
59964 + match->next = NULL;
59965 + match->inode = newinode;
59966 + match->device = newdevice;
59967 + match->mode &= ~GR_DELETED;
59968 +
59969 + insert_acl_subj_label(match, role);
59970 + }
59971 +
59972 + return;
59973 +}
59974 +
59975 +static void
59976 +update_inodev_entry(const ino_t oldinode, const dev_t olddevice,
59977 + const ino_t newinode, const dev_t newdevice)
59978 +{
59979 + unsigned int index = gr_fhash(oldinode, olddevice, inodev_set.i_size);
59980 + struct inodev_entry *match;
59981 +
59982 + match = inodev_set.i_hash[index];
59983 +
59984 + while (match && (match->nentry->inode != oldinode ||
59985 + match->nentry->device != olddevice || !match->nentry->deleted))
59986 + match = match->next;
59987 +
59988 + if (match && (match->nentry->inode == oldinode)
59989 + && (match->nentry->device == olddevice) &&
59990 + match->nentry->deleted) {
59991 + if (match->prev == NULL) {
59992 + inodev_set.i_hash[index] = match->next;
59993 + if (match->next != NULL)
59994 + match->next->prev = NULL;
59995 + } else {
59996 + match->prev->next = match->next;
59997 + if (match->next != NULL)
59998 + match->next->prev = match->prev;
59999 + }
60000 + match->prev = NULL;
60001 + match->next = NULL;
60002 + match->nentry->inode = newinode;
60003 + match->nentry->device = newdevice;
60004 + match->nentry->deleted = 0;
60005 +
60006 + insert_inodev_entry(match);
60007 + }
60008 +
60009 + return;
60010 +}
60011 +
60012 +static void
60013 +__do_handle_create(const struct name_entry *matchn, ino_t ino, dev_t dev)
60014 +{
60015 + struct acl_subject_label *subj;
60016 + struct acl_role_label *role;
60017 + unsigned int x;
60018 +
60019 + FOR_EACH_ROLE_START(role)
60020 + update_acl_subj_label(matchn->inode, matchn->device, ino, dev, role);
60021 +
60022 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
60023 + if ((subj->inode == ino) && (subj->device == dev)) {
60024 + subj->inode = ino;
60025 + subj->device = dev;
60026 + }
60027 + /* nested subjects aren't in the role's subj_hash table */
60028 + update_acl_obj_label(matchn->inode, matchn->device,
60029 + ino, dev, subj);
60030 + FOR_EACH_NESTED_SUBJECT_END(subj)
60031 + FOR_EACH_SUBJECT_START(role, subj, x)
60032 + update_acl_obj_label(matchn->inode, matchn->device,
60033 + ino, dev, subj);
60034 + FOR_EACH_SUBJECT_END(subj,x)
60035 + FOR_EACH_ROLE_END(role)
60036 +
60037 + update_inodev_entry(matchn->inode, matchn->device, ino, dev);
60038 +
60039 + return;
60040 +}
60041 +
60042 +static void
60043 +do_handle_create(const struct name_entry *matchn, const struct dentry *dentry,
60044 + const struct vfsmount *mnt)
60045 +{
60046 + ino_t ino = dentry->d_inode->i_ino;
60047 + dev_t dev = __get_dev(dentry);
60048 +
60049 + __do_handle_create(matchn, ino, dev);
60050 +
60051 + return;
60052 +}
60053 +
60054 +void
60055 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
60056 +{
60057 + struct name_entry *matchn;
60058 +
60059 + if (unlikely(!(gr_status & GR_READY)))
60060 + return;
60061 +
60062 + preempt_disable();
60063 + matchn = lookup_name_entry(gr_to_filename_rbac(dentry, mnt));
60064 +
60065 + if (unlikely((unsigned long)matchn)) {
60066 + write_lock(&gr_inode_lock);
60067 + do_handle_create(matchn, dentry, mnt);
60068 + write_unlock(&gr_inode_lock);
60069 + }
60070 + preempt_enable();
60071 +
60072 + return;
60073 +}
60074 +
60075 +void
60076 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
60077 +{
60078 + struct name_entry *matchn;
60079 +
60080 + if (unlikely(!(gr_status & GR_READY)))
60081 + return;
60082 +
60083 + preempt_disable();
60084 + matchn = lookup_name_entry(gr_to_proc_filename_rbac(dentry, init_pid_ns.proc_mnt));
60085 +
60086 + if (unlikely((unsigned long)matchn)) {
60087 + write_lock(&gr_inode_lock);
60088 + __do_handle_create(matchn, inode->i_ino, inode->i_sb->s_dev);
60089 + write_unlock(&gr_inode_lock);
60090 + }
60091 + preempt_enable();
60092 +
60093 + return;
60094 +}
60095 +
60096 +void
60097 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
60098 + struct dentry *old_dentry,
60099 + struct dentry *new_dentry,
60100 + struct vfsmount *mnt, const __u8 replace)
60101 +{
60102 + struct name_entry *matchn;
60103 + struct inodev_entry *inodev;
60104 + struct inode *inode = new_dentry->d_inode;
60105 + ino_t old_ino = old_dentry->d_inode->i_ino;
60106 + dev_t old_dev = __get_dev(old_dentry);
60107 +
60108 + /* vfs_rename swaps the name and parent link for old_dentry and
60109 + new_dentry
60110 + at this point, old_dentry has the new name, parent link, and inode
60111 + for the renamed file
60112 + if a file is being replaced by a rename, new_dentry has the inode
60113 + and name for the replaced file
60114 + */
60115 +
60116 + if (unlikely(!(gr_status & GR_READY)))
60117 + return;
60118 +
60119 + preempt_disable();
60120 + matchn = lookup_name_entry(gr_to_filename_rbac(old_dentry, mnt));
60121 +
60122 + /* we wouldn't have to check d_inode if it weren't for
60123 + NFS silly-renaming
60124 + */
60125 +
60126 + write_lock(&gr_inode_lock);
60127 + if (unlikely(replace && inode)) {
60128 + ino_t new_ino = inode->i_ino;
60129 + dev_t new_dev = __get_dev(new_dentry);
60130 +
60131 + inodev = lookup_inodev_entry(new_ino, new_dev);
60132 + if (inodev != NULL && ((inode->i_nlink <= 1) || S_ISDIR(inode->i_mode)))
60133 + do_handle_delete(inodev, new_ino, new_dev);
60134 + }
60135 +
60136 + inodev = lookup_inodev_entry(old_ino, old_dev);
60137 + if (inodev != NULL && ((old_dentry->d_inode->i_nlink <= 1) || S_ISDIR(old_dentry->d_inode->i_mode)))
60138 + do_handle_delete(inodev, old_ino, old_dev);
60139 +
60140 + if (unlikely((unsigned long)matchn))
60141 + do_handle_create(matchn, old_dentry, mnt);
60142 +
60143 + write_unlock(&gr_inode_lock);
60144 + preempt_enable();
60145 +
60146 + return;
60147 +}
60148 +
60149 +static int
60150 +lookup_special_role_auth(__u16 mode, const char *rolename, unsigned char **salt,
60151 + unsigned char **sum)
60152 +{
60153 + struct acl_role_label *r;
60154 + struct role_allowed_ip *ipp;
60155 + struct role_transition *trans;
60156 + unsigned int i;
60157 + int found = 0;
60158 + u32 curr_ip = current->signal->curr_ip;
60159 +
60160 + current->signal->saved_ip = curr_ip;
60161 +
60162 + /* check transition table */
60163 +
60164 + for (trans = current->role->transitions; trans; trans = trans->next) {
60165 + if (!strcmp(rolename, trans->rolename)) {
60166 + found = 1;
60167 + break;
60168 + }
60169 + }
60170 +
60171 + if (!found)
60172 + return 0;
60173 +
60174 + /* handle special roles that do not require authentication
60175 + and check ip */
60176 +
60177 + FOR_EACH_ROLE_START(r)
60178 + if (!strcmp(rolename, r->rolename) &&
60179 + (r->roletype & GR_ROLE_SPECIAL)) {
60180 + found = 0;
60181 + if (r->allowed_ips != NULL) {
60182 + for (ipp = r->allowed_ips; ipp; ipp = ipp->next) {
60183 + if ((ntohl(curr_ip) & ipp->netmask) ==
60184 + (ntohl(ipp->addr) & ipp->netmask))
60185 + found = 1;
60186 + }
60187 + } else
60188 + found = 2;
60189 + if (!found)
60190 + return 0;
60191 +
60192 + if (((mode == GR_SPROLE) && (r->roletype & GR_ROLE_NOPW)) ||
60193 + ((mode == GR_SPROLEPAM) && (r->roletype & GR_ROLE_PAM))) {
60194 + *salt = NULL;
60195 + *sum = NULL;
60196 + return 1;
60197 + }
60198 + }
60199 + FOR_EACH_ROLE_END(r)
60200 +
60201 + for (i = 0; i < num_sprole_pws; i++) {
60202 + if (!strcmp(rolename, acl_special_roles[i]->rolename)) {
60203 + *salt = acl_special_roles[i]->salt;
60204 + *sum = acl_special_roles[i]->sum;
60205 + return 1;
60206 + }
60207 + }
60208 +
60209 + return 0;
60210 +}
60211 +
60212 +static void
60213 +assign_special_role(char *rolename)
60214 +{
60215 + struct acl_object_label *obj;
60216 + struct acl_role_label *r;
60217 + struct acl_role_label *assigned = NULL;
60218 + struct task_struct *tsk;
60219 + struct file *filp;
60220 +
60221 + FOR_EACH_ROLE_START(r)
60222 + if (!strcmp(rolename, r->rolename) &&
60223 + (r->roletype & GR_ROLE_SPECIAL)) {
60224 + assigned = r;
60225 + break;
60226 + }
60227 + FOR_EACH_ROLE_END(r)
60228 +
60229 + if (!assigned)
60230 + return;
60231 +
60232 + read_lock(&tasklist_lock);
60233 + read_lock(&grsec_exec_file_lock);
60234 +
60235 + tsk = current->real_parent;
60236 + if (tsk == NULL)
60237 + goto out_unlock;
60238 +
60239 + filp = tsk->exec_file;
60240 + if (filp == NULL)
60241 + goto out_unlock;
60242 +
60243 + tsk->is_writable = 0;
60244 +
60245 + tsk->acl_sp_role = 1;
60246 + tsk->acl_role_id = ++acl_sp_role_value;
60247 + tsk->role = assigned;
60248 + tsk->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role);
60249 +
60250 + /* ignore additional mmap checks for processes that are writable
60251 + by the default ACL */
60252 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
60253 + if (unlikely(obj->mode & GR_WRITE))
60254 + tsk->is_writable = 1;
60255 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role->root_label);
60256 + if (unlikely(obj->mode & GR_WRITE))
60257 + tsk->is_writable = 1;
60258 +
60259 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
60260 + 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));
60261 +#endif
60262 +
60263 +out_unlock:
60264 + read_unlock(&grsec_exec_file_lock);
60265 + read_unlock(&tasklist_lock);
60266 + return;
60267 +}
60268 +
60269 +int gr_check_secure_terminal(struct task_struct *task)
60270 +{
60271 + struct task_struct *p, *p2, *p3;
60272 + struct files_struct *files;
60273 + struct fdtable *fdt;
60274 + struct file *our_file = NULL, *file;
60275 + int i;
60276 +
60277 + if (task->signal->tty == NULL)
60278 + return 1;
60279 +
60280 + files = get_files_struct(task);
60281 + if (files != NULL) {
60282 + rcu_read_lock();
60283 + fdt = files_fdtable(files);
60284 + for (i=0; i < fdt->max_fds; i++) {
60285 + file = fcheck_files(files, i);
60286 + if (file && (our_file == NULL) && (file->private_data == task->signal->tty)) {
60287 + get_file(file);
60288 + our_file = file;
60289 + }
60290 + }
60291 + rcu_read_unlock();
60292 + put_files_struct(files);
60293 + }
60294 +
60295 + if (our_file == NULL)
60296 + return 1;
60297 +
60298 + read_lock(&tasklist_lock);
60299 + do_each_thread(p2, p) {
60300 + files = get_files_struct(p);
60301 + if (files == NULL ||
60302 + (p->signal && p->signal->tty == task->signal->tty)) {
60303 + if (files != NULL)
60304 + put_files_struct(files);
60305 + continue;
60306 + }
60307 + rcu_read_lock();
60308 + fdt = files_fdtable(files);
60309 + for (i=0; i < fdt->max_fds; i++) {
60310 + file = fcheck_files(files, i);
60311 + if (file && S_ISCHR(file->f_path.dentry->d_inode->i_mode) &&
60312 + file->f_path.dentry->d_inode->i_rdev == our_file->f_path.dentry->d_inode->i_rdev) {
60313 + p3 = task;
60314 + while (task_pid_nr(p3) > 0) {
60315 + if (p3 == p)
60316 + break;
60317 + p3 = p3->real_parent;
60318 + }
60319 + if (p3 == p)
60320 + break;
60321 + gr_log_ttysniff(GR_DONT_AUDIT_GOOD, GR_TTYSNIFF_ACL_MSG, p);
60322 + gr_handle_alertkill(p);
60323 + rcu_read_unlock();
60324 + put_files_struct(files);
60325 + read_unlock(&tasklist_lock);
60326 + fput(our_file);
60327 + return 0;
60328 + }
60329 + }
60330 + rcu_read_unlock();
60331 + put_files_struct(files);
60332 + } while_each_thread(p2, p);
60333 + read_unlock(&tasklist_lock);
60334 +
60335 + fput(our_file);
60336 + return 1;
60337 +}
60338 +
60339 +static int gr_rbac_disable(void *unused)
60340 +{
60341 + pax_open_kernel();
60342 + gr_status &= ~GR_READY;
60343 + pax_close_kernel();
60344 +
60345 + return 0;
60346 +}
60347 +
60348 +ssize_t
60349 +write_grsec_handler(struct file *file, const char * buf, size_t count, loff_t *ppos)
60350 +{
60351 + struct gr_arg_wrapper uwrap;
60352 + unsigned char *sprole_salt = NULL;
60353 + unsigned char *sprole_sum = NULL;
60354 + int error = sizeof (struct gr_arg_wrapper);
60355 + int error2 = 0;
60356 +
60357 + mutex_lock(&gr_dev_mutex);
60358 +
60359 + if ((gr_status & GR_READY) && !(current->acl->mode & GR_KERNELAUTH)) {
60360 + error = -EPERM;
60361 + goto out;
60362 + }
60363 +
60364 + if (count != sizeof (struct gr_arg_wrapper)) {
60365 + gr_log_int_int(GR_DONT_AUDIT_GOOD, GR_DEV_ACL_MSG, (int)count, (int)sizeof(struct gr_arg_wrapper));
60366 + error = -EINVAL;
60367 + goto out;
60368 + }
60369 +
60370 +
60371 + if (gr_auth_expires && time_after_eq(get_seconds(), gr_auth_expires)) {
60372 + gr_auth_expires = 0;
60373 + gr_auth_attempts = 0;
60374 + }
60375 +
60376 + if (copy_from_user(&uwrap, buf, sizeof (struct gr_arg_wrapper))) {
60377 + error = -EFAULT;
60378 + goto out;
60379 + }
60380 +
60381 + if ((uwrap.version != GRSECURITY_VERSION) || (uwrap.size != sizeof(struct gr_arg))) {
60382 + error = -EINVAL;
60383 + goto out;
60384 + }
60385 +
60386 + if (copy_from_user(gr_usermode, uwrap.arg, sizeof (struct gr_arg))) {
60387 + error = -EFAULT;
60388 + goto out;
60389 + }
60390 +
60391 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_SPROLEPAM &&
60392 + gr_auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
60393 + time_after(gr_auth_expires, get_seconds())) {
60394 + error = -EBUSY;
60395 + goto out;
60396 + }
60397 +
60398 + /* if non-root trying to do anything other than use a special role,
60399 + do not attempt authentication, do not count towards authentication
60400 + locking
60401 + */
60402 +
60403 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_STATUS &&
60404 + gr_usermode->mode != GR_UNSPROLE && gr_usermode->mode != GR_SPROLEPAM &&
60405 + gr_is_global_nonroot(current_uid())) {
60406 + error = -EPERM;
60407 + goto out;
60408 + }
60409 +
60410 + /* ensure pw and special role name are null terminated */
60411 +
60412 + gr_usermode->pw[GR_PW_LEN - 1] = '\0';
60413 + gr_usermode->sp_role[GR_SPROLE_LEN - 1] = '\0';
60414 +
60415 + /* Okay.
60416 + * We have our enough of the argument structure..(we have yet
60417 + * to copy_from_user the tables themselves) . Copy the tables
60418 + * only if we need them, i.e. for loading operations. */
60419 +
60420 + switch (gr_usermode->mode) {
60421 + case GR_STATUS:
60422 + if (gr_status & GR_READY) {
60423 + error = 1;
60424 + if (!gr_check_secure_terminal(current))
60425 + error = 3;
60426 + } else
60427 + error = 2;
60428 + goto out;
60429 + case GR_SHUTDOWN:
60430 + if ((gr_status & GR_READY)
60431 + && !(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
60432 + stop_machine(gr_rbac_disable, NULL, NULL);
60433 + free_variables();
60434 + memset(gr_usermode, 0, sizeof (struct gr_arg));
60435 + memset(gr_system_salt, 0, GR_SALT_LEN);
60436 + memset(gr_system_sum, 0, GR_SHA_LEN);
60437 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTS_ACL_MSG);
60438 + } else if (gr_status & GR_READY) {
60439 + gr_log_noargs(GR_DONT_AUDIT, GR_SHUTF_ACL_MSG);
60440 + error = -EPERM;
60441 + } else {
60442 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTI_ACL_MSG);
60443 + error = -EAGAIN;
60444 + }
60445 + break;
60446 + case GR_ENABLE:
60447 + if (!(gr_status & GR_READY) && !(error2 = gracl_init(gr_usermode)))
60448 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_ENABLE_ACL_MSG, GR_VERSION);
60449 + else {
60450 + if (gr_status & GR_READY)
60451 + error = -EAGAIN;
60452 + else
60453 + error = error2;
60454 + gr_log_str(GR_DONT_AUDIT, GR_ENABLEF_ACL_MSG, GR_VERSION);
60455 + }
60456 + break;
60457 + case GR_RELOAD:
60458 + if (!(gr_status & GR_READY)) {
60459 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOADI_ACL_MSG, GR_VERSION);
60460 + error = -EAGAIN;
60461 + } else if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
60462 + stop_machine(gr_rbac_disable, NULL, NULL);
60463 + free_variables();
60464 + error2 = gracl_init(gr_usermode);
60465 + if (!error2)
60466 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOAD_ACL_MSG, GR_VERSION);
60467 + else {
60468 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
60469 + error = error2;
60470 + }
60471 + } else {
60472 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
60473 + error = -EPERM;
60474 + }
60475 + break;
60476 + case GR_SEGVMOD:
60477 + if (unlikely(!(gr_status & GR_READY))) {
60478 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODI_ACL_MSG);
60479 + error = -EAGAIN;
60480 + break;
60481 + }
60482 +
60483 + if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
60484 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODS_ACL_MSG);
60485 + if (gr_usermode->segv_device && gr_usermode->segv_inode) {
60486 + struct acl_subject_label *segvacl;
60487 + segvacl =
60488 + lookup_acl_subj_label(gr_usermode->segv_inode,
60489 + gr_usermode->segv_device,
60490 + current->role);
60491 + if (segvacl) {
60492 + segvacl->crashes = 0;
60493 + segvacl->expires = 0;
60494 + }
60495 + } else if (gr_find_uid(gr_usermode->segv_uid) >= 0) {
60496 + gr_remove_uid(gr_usermode->segv_uid);
60497 + }
60498 + } else {
60499 + gr_log_noargs(GR_DONT_AUDIT, GR_SEGVMODF_ACL_MSG);
60500 + error = -EPERM;
60501 + }
60502 + break;
60503 + case GR_SPROLE:
60504 + case GR_SPROLEPAM:
60505 + if (unlikely(!(gr_status & GR_READY))) {
60506 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SPROLEI_ACL_MSG);
60507 + error = -EAGAIN;
60508 + break;
60509 + }
60510 +
60511 + if (current->role->expires && time_after_eq(get_seconds(), current->role->expires)) {
60512 + current->role->expires = 0;
60513 + current->role->auth_attempts = 0;
60514 + }
60515 +
60516 + if (current->role->auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
60517 + time_after(current->role->expires, get_seconds())) {
60518 + error = -EBUSY;
60519 + goto out;
60520 + }
60521 +
60522 + if (lookup_special_role_auth
60523 + (gr_usermode->mode, gr_usermode->sp_role, &sprole_salt, &sprole_sum)
60524 + && ((!sprole_salt && !sprole_sum)
60525 + || !(chkpw(gr_usermode, sprole_salt, sprole_sum)))) {
60526 + char *p = "";
60527 + assign_special_role(gr_usermode->sp_role);
60528 + read_lock(&tasklist_lock);
60529 + if (current->real_parent)
60530 + p = current->real_parent->role->rolename;
60531 + read_unlock(&tasklist_lock);
60532 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLES_ACL_MSG,
60533 + p, acl_sp_role_value);
60534 + } else {
60535 + gr_log_str(GR_DONT_AUDIT, GR_SPROLEF_ACL_MSG, gr_usermode->sp_role);
60536 + error = -EPERM;
60537 + if(!(current->role->auth_attempts++))
60538 + current->role->expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
60539 +
60540 + goto out;
60541 + }
60542 + break;
60543 + case GR_UNSPROLE:
60544 + if (unlikely(!(gr_status & GR_READY))) {
60545 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_UNSPROLEI_ACL_MSG);
60546 + error = -EAGAIN;
60547 + break;
60548 + }
60549 +
60550 + if (current->role->roletype & GR_ROLE_SPECIAL) {
60551 + char *p = "";
60552 + int i = 0;
60553 +
60554 + read_lock(&tasklist_lock);
60555 + if (current->real_parent) {
60556 + p = current->real_parent->role->rolename;
60557 + i = current->real_parent->acl_role_id;
60558 + }
60559 + read_unlock(&tasklist_lock);
60560 +
60561 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_UNSPROLES_ACL_MSG, p, i);
60562 + gr_set_acls(1);
60563 + } else {
60564 + error = -EPERM;
60565 + goto out;
60566 + }
60567 + break;
60568 + default:
60569 + gr_log_int(GR_DONT_AUDIT, GR_INVMODE_ACL_MSG, gr_usermode->mode);
60570 + error = -EINVAL;
60571 + break;
60572 + }
60573 +
60574 + if (error != -EPERM)
60575 + goto out;
60576 +
60577 + if(!(gr_auth_attempts++))
60578 + gr_auth_expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
60579 +
60580 + out:
60581 + mutex_unlock(&gr_dev_mutex);
60582 + return error;
60583 +}
60584 +
60585 +/* must be called with
60586 + rcu_read_lock();
60587 + read_lock(&tasklist_lock);
60588 + read_lock(&grsec_exec_file_lock);
60589 +*/
60590 +int gr_apply_subject_to_task(struct task_struct *task)
60591 +{
60592 + struct acl_object_label *obj;
60593 + char *tmpname;
60594 + struct acl_subject_label *tmpsubj;
60595 + struct file *filp;
60596 + struct name_entry *nmatch;
60597 +
60598 + filp = task->exec_file;
60599 + if (filp == NULL)
60600 + return 0;
60601 +
60602 + /* the following is to apply the correct subject
60603 + on binaries running when the RBAC system
60604 + is enabled, when the binaries have been
60605 + replaced or deleted since their execution
60606 + -----
60607 + when the RBAC system starts, the inode/dev
60608 + from exec_file will be one the RBAC system
60609 + is unaware of. It only knows the inode/dev
60610 + of the present file on disk, or the absence
60611 + of it.
60612 + */
60613 + preempt_disable();
60614 + tmpname = gr_to_filename_rbac(filp->f_path.dentry, filp->f_path.mnt);
60615 +
60616 + nmatch = lookup_name_entry(tmpname);
60617 + preempt_enable();
60618 + tmpsubj = NULL;
60619 + if (nmatch) {
60620 + if (nmatch->deleted)
60621 + tmpsubj = lookup_acl_subj_label_deleted(nmatch->inode, nmatch->device, task->role);
60622 + else
60623 + tmpsubj = lookup_acl_subj_label(nmatch->inode, nmatch->device, task->role);
60624 + if (tmpsubj != NULL)
60625 + task->acl = tmpsubj;
60626 + }
60627 + if (tmpsubj == NULL)
60628 + task->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt,
60629 + task->role);
60630 + if (task->acl) {
60631 + task->is_writable = 0;
60632 + /* ignore additional mmap checks for processes that are writable
60633 + by the default ACL */
60634 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
60635 + if (unlikely(obj->mode & GR_WRITE))
60636 + task->is_writable = 1;
60637 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
60638 + if (unlikely(obj->mode & GR_WRITE))
60639 + task->is_writable = 1;
60640 +
60641 + gr_set_proc_res(task);
60642 +
60643 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
60644 + 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);
60645 +#endif
60646 + } else {
60647 + return 1;
60648 + }
60649 +
60650 + return 0;
60651 +}
60652 +
60653 +int
60654 +gr_set_acls(const int type)
60655 +{
60656 + struct task_struct *task, *task2;
60657 + struct acl_role_label *role = current->role;
60658 + __u16 acl_role_id = current->acl_role_id;
60659 + const struct cred *cred;
60660 + int ret;
60661 +
60662 + rcu_read_lock();
60663 + read_lock(&tasklist_lock);
60664 + read_lock(&grsec_exec_file_lock);
60665 + do_each_thread(task2, task) {
60666 + /* check to see if we're called from the exit handler,
60667 + if so, only replace ACLs that have inherited the admin
60668 + ACL */
60669 +
60670 + if (type && (task->role != role ||
60671 + task->acl_role_id != acl_role_id))
60672 + continue;
60673 +
60674 + task->acl_role_id = 0;
60675 + task->acl_sp_role = 0;
60676 +
60677 + if (task->exec_file) {
60678 + cred = __task_cred(task);
60679 + task->role = lookup_acl_role_label(task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
60680 + ret = gr_apply_subject_to_task(task);
60681 + if (ret) {
60682 + read_unlock(&grsec_exec_file_lock);
60683 + read_unlock(&tasklist_lock);
60684 + rcu_read_unlock();
60685 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_DEFACL_MSG, task->comm, task_pid_nr(task));
60686 + return ret;
60687 + }
60688 + } else {
60689 + // it's a kernel process
60690 + task->role = kernel_role;
60691 + task->acl = kernel_role->root_label;
60692 +#ifdef CONFIG_GRKERNSEC_ACL_HIDEKERN
60693 + task->acl->mode &= ~GR_PROCFIND;
60694 +#endif
60695 + }
60696 + } while_each_thread(task2, task);
60697 + read_unlock(&grsec_exec_file_lock);
60698 + read_unlock(&tasklist_lock);
60699 + rcu_read_unlock();
60700 +
60701 + return 0;
60702 +}
60703 +
60704 +#if defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC)
60705 +static const unsigned long res_learn_bumps[GR_NLIMITS] = {
60706 + [RLIMIT_CPU] = GR_RLIM_CPU_BUMP,
60707 + [RLIMIT_FSIZE] = GR_RLIM_FSIZE_BUMP,
60708 + [RLIMIT_DATA] = GR_RLIM_DATA_BUMP,
60709 + [RLIMIT_STACK] = GR_RLIM_STACK_BUMP,
60710 + [RLIMIT_CORE] = GR_RLIM_CORE_BUMP,
60711 + [RLIMIT_RSS] = GR_RLIM_RSS_BUMP,
60712 + [RLIMIT_NPROC] = GR_RLIM_NPROC_BUMP,
60713 + [RLIMIT_NOFILE] = GR_RLIM_NOFILE_BUMP,
60714 + [RLIMIT_MEMLOCK] = GR_RLIM_MEMLOCK_BUMP,
60715 + [RLIMIT_AS] = GR_RLIM_AS_BUMP,
60716 + [RLIMIT_LOCKS] = GR_RLIM_LOCKS_BUMP,
60717 + [RLIMIT_SIGPENDING] = GR_RLIM_SIGPENDING_BUMP,
60718 + [RLIMIT_MSGQUEUE] = GR_RLIM_MSGQUEUE_BUMP,
60719 + [RLIMIT_NICE] = GR_RLIM_NICE_BUMP,
60720 + [RLIMIT_RTPRIO] = GR_RLIM_RTPRIO_BUMP,
60721 + [RLIMIT_RTTIME] = GR_RLIM_RTTIME_BUMP
60722 +};
60723 +
60724 +void
60725 +gr_learn_resource(const struct task_struct *task,
60726 + const int res, const unsigned long wanted, const int gt)
60727 +{
60728 + struct acl_subject_label *acl;
60729 + const struct cred *cred;
60730 +
60731 + if (unlikely((gr_status & GR_READY) &&
60732 + task->acl && (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))))
60733 + goto skip_reslog;
60734 +
60735 + gr_log_resource(task, res, wanted, gt);
60736 +skip_reslog:
60737 +
60738 + if (unlikely(!(gr_status & GR_READY) || !wanted || res >= GR_NLIMITS))
60739 + return;
60740 +
60741 + acl = task->acl;
60742 +
60743 + if (likely(!acl || !(acl->mode & (GR_LEARN | GR_INHERITLEARN)) ||
60744 + !(acl->resmask & (1U << (unsigned short) res))))
60745 + return;
60746 +
60747 + if (wanted >= acl->res[res].rlim_cur) {
60748 + unsigned long res_add;
60749 +
60750 + res_add = wanted + res_learn_bumps[res];
60751 +
60752 + acl->res[res].rlim_cur = res_add;
60753 +
60754 + if (wanted > acl->res[res].rlim_max)
60755 + acl->res[res].rlim_max = res_add;
60756 +
60757 + /* only log the subject filename, since resource logging is supported for
60758 + single-subject learning only */
60759 + rcu_read_lock();
60760 + cred = __task_cred(task);
60761 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
60762 + task->role->roletype, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), acl->filename,
60763 + acl->filename, acl->res[res].rlim_cur, acl->res[res].rlim_max,
60764 + "", (unsigned long) res, &task->signal->saved_ip);
60765 + rcu_read_unlock();
60766 + }
60767 +
60768 + return;
60769 +}
60770 +EXPORT_SYMBOL(gr_learn_resource);
60771 +#endif
60772 +
60773 +#if defined(CONFIG_PAX_HAVE_ACL_FLAGS) && (defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR))
60774 +void
60775 +pax_set_initial_flags(struct linux_binprm *bprm)
60776 +{
60777 + struct task_struct *task = current;
60778 + struct acl_subject_label *proc;
60779 + unsigned long flags;
60780 +
60781 + if (unlikely(!(gr_status & GR_READY)))
60782 + return;
60783 +
60784 + flags = pax_get_flags(task);
60785 +
60786 + proc = task->acl;
60787 +
60788 + if (proc->pax_flags & GR_PAX_DISABLE_PAGEEXEC)
60789 + flags &= ~MF_PAX_PAGEEXEC;
60790 + if (proc->pax_flags & GR_PAX_DISABLE_SEGMEXEC)
60791 + flags &= ~MF_PAX_SEGMEXEC;
60792 + if (proc->pax_flags & GR_PAX_DISABLE_RANDMMAP)
60793 + flags &= ~MF_PAX_RANDMMAP;
60794 + if (proc->pax_flags & GR_PAX_DISABLE_EMUTRAMP)
60795 + flags &= ~MF_PAX_EMUTRAMP;
60796 + if (proc->pax_flags & GR_PAX_DISABLE_MPROTECT)
60797 + flags &= ~MF_PAX_MPROTECT;
60798 +
60799 + if (proc->pax_flags & GR_PAX_ENABLE_PAGEEXEC)
60800 + flags |= MF_PAX_PAGEEXEC;
60801 + if (proc->pax_flags & GR_PAX_ENABLE_SEGMEXEC)
60802 + flags |= MF_PAX_SEGMEXEC;
60803 + if (proc->pax_flags & GR_PAX_ENABLE_RANDMMAP)
60804 + flags |= MF_PAX_RANDMMAP;
60805 + if (proc->pax_flags & GR_PAX_ENABLE_EMUTRAMP)
60806 + flags |= MF_PAX_EMUTRAMP;
60807 + if (proc->pax_flags & GR_PAX_ENABLE_MPROTECT)
60808 + flags |= MF_PAX_MPROTECT;
60809 +
60810 + pax_set_flags(task, flags);
60811 +
60812 + return;
60813 +}
60814 +#endif
60815 +
60816 +int
60817 +gr_handle_proc_ptrace(struct task_struct *task)
60818 +{
60819 + struct file *filp;
60820 + struct task_struct *tmp = task;
60821 + struct task_struct *curtemp = current;
60822 + __u32 retmode;
60823 +
60824 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
60825 + if (unlikely(!(gr_status & GR_READY)))
60826 + return 0;
60827 +#endif
60828 +
60829 + read_lock(&tasklist_lock);
60830 + read_lock(&grsec_exec_file_lock);
60831 + filp = task->exec_file;
60832 +
60833 + while (task_pid_nr(tmp) > 0) {
60834 + if (tmp == curtemp)
60835 + break;
60836 + tmp = tmp->real_parent;
60837 + }
60838 +
60839 + if (!filp || (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
60840 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE))))) {
60841 + read_unlock(&grsec_exec_file_lock);
60842 + read_unlock(&tasklist_lock);
60843 + return 1;
60844 + }
60845 +
60846 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
60847 + if (!(gr_status & GR_READY)) {
60848 + read_unlock(&grsec_exec_file_lock);
60849 + read_unlock(&tasklist_lock);
60850 + return 0;
60851 + }
60852 +#endif
60853 +
60854 + retmode = gr_search_file(filp->f_path.dentry, GR_NOPTRACE, filp->f_path.mnt);
60855 + read_unlock(&grsec_exec_file_lock);
60856 + read_unlock(&tasklist_lock);
60857 +
60858 + if (retmode & GR_NOPTRACE)
60859 + return 1;
60860 +
60861 + if (!(current->acl->mode & GR_POVERRIDE) && !(current->role->roletype & GR_ROLE_GOD)
60862 + && (current->acl != task->acl || (current->acl != current->role->root_label
60863 + && task_pid_nr(current) != task_pid_nr(task))))
60864 + return 1;
60865 +
60866 + return 0;
60867 +}
60868 +
60869 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p)
60870 +{
60871 + if (unlikely(!(gr_status & GR_READY)))
60872 + return;
60873 +
60874 + if (!(current->role->roletype & GR_ROLE_GOD))
60875 + return;
60876 +
60877 + seq_printf(m, "RBAC:\t%.64s:%c:%.950s\n",
60878 + p->role->rolename, gr_task_roletype_to_char(p),
60879 + p->acl->filename);
60880 +}
60881 +
60882 +int
60883 +gr_handle_ptrace(struct task_struct *task, const long request)
60884 +{
60885 + struct task_struct *tmp = task;
60886 + struct task_struct *curtemp = current;
60887 + __u32 retmode;
60888 +
60889 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
60890 + if (unlikely(!(gr_status & GR_READY)))
60891 + return 0;
60892 +#endif
60893 + if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
60894 + read_lock(&tasklist_lock);
60895 + while (task_pid_nr(tmp) > 0) {
60896 + if (tmp == curtemp)
60897 + break;
60898 + tmp = tmp->real_parent;
60899 + }
60900 +
60901 + if (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
60902 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE)))) {
60903 + read_unlock(&tasklist_lock);
60904 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
60905 + return 1;
60906 + }
60907 + read_unlock(&tasklist_lock);
60908 + }
60909 +
60910 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
60911 + if (!(gr_status & GR_READY))
60912 + return 0;
60913 +#endif
60914 +
60915 + read_lock(&grsec_exec_file_lock);
60916 + if (unlikely(!task->exec_file)) {
60917 + read_unlock(&grsec_exec_file_lock);
60918 + return 0;
60919 + }
60920 +
60921 + retmode = gr_search_file(task->exec_file->f_path.dentry, GR_PTRACERD | GR_NOPTRACE, task->exec_file->f_path.mnt);
60922 + read_unlock(&grsec_exec_file_lock);
60923 +
60924 + if (retmode & GR_NOPTRACE) {
60925 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
60926 + return 1;
60927 + }
60928 +
60929 + if (retmode & GR_PTRACERD) {
60930 + switch (request) {
60931 + case PTRACE_SEIZE:
60932 + case PTRACE_POKETEXT:
60933 + case PTRACE_POKEDATA:
60934 + case PTRACE_POKEUSR:
60935 +#if !defined(CONFIG_PPC32) && !defined(CONFIG_PPC64) && !defined(CONFIG_PARISC) && !defined(CONFIG_ALPHA) && !defined(CONFIG_IA64)
60936 + case PTRACE_SETREGS:
60937 + case PTRACE_SETFPREGS:
60938 +#endif
60939 +#ifdef CONFIG_X86
60940 + case PTRACE_SETFPXREGS:
60941 +#endif
60942 +#ifdef CONFIG_ALTIVEC
60943 + case PTRACE_SETVRREGS:
60944 +#endif
60945 + return 1;
60946 + default:
60947 + return 0;
60948 + }
60949 + } else if (!(current->acl->mode & GR_POVERRIDE) &&
60950 + !(current->role->roletype & GR_ROLE_GOD) &&
60951 + (current->acl != task->acl)) {
60952 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
60953 + return 1;
60954 + }
60955 +
60956 + return 0;
60957 +}
60958 +
60959 +static int is_writable_mmap(const struct file *filp)
60960 +{
60961 + struct task_struct *task = current;
60962 + struct acl_object_label *obj, *obj2;
60963 +
60964 + if (gr_status & GR_READY && !(task->acl->mode & GR_OVERRIDE) &&
60965 + !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))) {
60966 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
60967 + obj2 = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt,
60968 + task->role->root_label);
60969 + if (unlikely((obj->mode & GR_WRITE) || (obj2->mode & GR_WRITE))) {
60970 + gr_log_fs_generic(GR_DONT_AUDIT, GR_WRITLIB_ACL_MSG, filp->f_path.dentry, filp->f_path.mnt);
60971 + return 1;
60972 + }
60973 + }
60974 + return 0;
60975 +}
60976 +
60977 +int
60978 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot)
60979 +{
60980 + __u32 mode;
60981 +
60982 + if (unlikely(!file || !(prot & PROT_EXEC)))
60983 + return 1;
60984 +
60985 + if (is_writable_mmap(file))
60986 + return 0;
60987 +
60988 + mode =
60989 + gr_search_file(file->f_path.dentry,
60990 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
60991 + file->f_path.mnt);
60992 +
60993 + if (!gr_tpe_allow(file))
60994 + return 0;
60995 +
60996 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
60997 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
60998 + return 0;
60999 + } else if (unlikely(!(mode & GR_EXEC))) {
61000 + return 0;
61001 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
61002 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
61003 + return 1;
61004 + }
61005 +
61006 + return 1;
61007 +}
61008 +
61009 +int
61010 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
61011 +{
61012 + __u32 mode;
61013 +
61014 + if (unlikely(!file || !(prot & PROT_EXEC)))
61015 + return 1;
61016 +
61017 + if (is_writable_mmap(file))
61018 + return 0;
61019 +
61020 + mode =
61021 + gr_search_file(file->f_path.dentry,
61022 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
61023 + file->f_path.mnt);
61024 +
61025 + if (!gr_tpe_allow(file))
61026 + return 0;
61027 +
61028 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
61029 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
61030 + return 0;
61031 + } else if (unlikely(!(mode & GR_EXEC))) {
61032 + return 0;
61033 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
61034 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
61035 + return 1;
61036 + }
61037 +
61038 + return 1;
61039 +}
61040 +
61041 +void
61042 +gr_acl_handle_psacct(struct task_struct *task, const long code)
61043 +{
61044 + unsigned long runtime;
61045 + unsigned long cputime;
61046 + unsigned int wday, cday;
61047 + __u8 whr, chr;
61048 + __u8 wmin, cmin;
61049 + __u8 wsec, csec;
61050 + struct timespec timeval;
61051 +
61052 + if (unlikely(!(gr_status & GR_READY) || !task->acl ||
61053 + !(task->acl->mode & GR_PROCACCT)))
61054 + return;
61055 +
61056 + do_posix_clock_monotonic_gettime(&timeval);
61057 + runtime = timeval.tv_sec - task->start_time.tv_sec;
61058 + wday = runtime / (3600 * 24);
61059 + runtime -= wday * (3600 * 24);
61060 + whr = runtime / 3600;
61061 + runtime -= whr * 3600;
61062 + wmin = runtime / 60;
61063 + runtime -= wmin * 60;
61064 + wsec = runtime;
61065 +
61066 + cputime = (task->utime + task->stime) / HZ;
61067 + cday = cputime / (3600 * 24);
61068 + cputime -= cday * (3600 * 24);
61069 + chr = cputime / 3600;
61070 + cputime -= chr * 3600;
61071 + cmin = cputime / 60;
61072 + cputime -= cmin * 60;
61073 + csec = cputime;
61074 +
61075 + gr_log_procacct(GR_DO_AUDIT, GR_ACL_PROCACCT_MSG, task, wday, whr, wmin, wsec, cday, chr, cmin, csec, code);
61076 +
61077 + return;
61078 +}
61079 +
61080 +void gr_set_kernel_label(struct task_struct *task)
61081 +{
61082 + if (gr_status & GR_READY) {
61083 + task->role = kernel_role;
61084 + task->acl = kernel_role->root_label;
61085 + }
61086 + return;
61087 +}
61088 +
61089 +#ifdef CONFIG_TASKSTATS
61090 +int gr_is_taskstats_denied(int pid)
61091 +{
61092 + struct task_struct *task;
61093 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
61094 + const struct cred *cred;
61095 +#endif
61096 + int ret = 0;
61097 +
61098 + /* restrict taskstats viewing to un-chrooted root users
61099 + who have the 'view' subject flag if the RBAC system is enabled
61100 + */
61101 +
61102 + rcu_read_lock();
61103 + read_lock(&tasklist_lock);
61104 + task = find_task_by_vpid(pid);
61105 + if (task) {
61106 +#ifdef CONFIG_GRKERNSEC_CHROOT
61107 + if (proc_is_chrooted(task))
61108 + ret = -EACCES;
61109 +#endif
61110 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
61111 + cred = __task_cred(task);
61112 +#ifdef CONFIG_GRKERNSEC_PROC_USER
61113 + if (gr_is_global_nonroot(cred->uid))
61114 + ret = -EACCES;
61115 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
61116 + if (gr_is_global_nonroot(cred->uid) && !groups_search(cred->group_info, grsec_proc_gid))
61117 + ret = -EACCES;
61118 +#endif
61119 +#endif
61120 + if (gr_status & GR_READY) {
61121 + if (!(task->acl->mode & GR_VIEW))
61122 + ret = -EACCES;
61123 + }
61124 + } else
61125 + ret = -ENOENT;
61126 +
61127 + read_unlock(&tasklist_lock);
61128 + rcu_read_unlock();
61129 +
61130 + return ret;
61131 +}
61132 +#endif
61133 +
61134 +/* AUXV entries are filled via a descendant of search_binary_handler
61135 + after we've already applied the subject for the target
61136 +*/
61137 +int gr_acl_enable_at_secure(void)
61138 +{
61139 + if (unlikely(!(gr_status & GR_READY)))
61140 + return 0;
61141 +
61142 + if (current->acl->mode & GR_ATSECURE)
61143 + return 1;
61144 +
61145 + return 0;
61146 +}
61147 +
61148 +int gr_acl_handle_filldir(const struct file *file, const char *name, const unsigned int namelen, const ino_t ino)
61149 +{
61150 + struct task_struct *task = current;
61151 + struct dentry *dentry = file->f_path.dentry;
61152 + struct vfsmount *mnt = file->f_path.mnt;
61153 + struct acl_object_label *obj, *tmp;
61154 + struct acl_subject_label *subj;
61155 + unsigned int bufsize;
61156 + int is_not_root;
61157 + char *path;
61158 + dev_t dev = __get_dev(dentry);
61159 +
61160 + if (unlikely(!(gr_status & GR_READY)))
61161 + return 1;
61162 +
61163 + if (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))
61164 + return 1;
61165 +
61166 + /* ignore Eric Biederman */
61167 + if (IS_PRIVATE(dentry->d_inode))
61168 + return 1;
61169 +
61170 + subj = task->acl;
61171 + read_lock(&gr_inode_lock);
61172 + do {
61173 + obj = lookup_acl_obj_label(ino, dev, subj);
61174 + if (obj != NULL) {
61175 + read_unlock(&gr_inode_lock);
61176 + return (obj->mode & GR_FIND) ? 1 : 0;
61177 + }
61178 + } while ((subj = subj->parent_subject));
61179 + read_unlock(&gr_inode_lock);
61180 +
61181 + /* this is purely an optimization since we're looking for an object
61182 + for the directory we're doing a readdir on
61183 + if it's possible for any globbed object to match the entry we're
61184 + filling into the directory, then the object we find here will be
61185 + an anchor point with attached globbed objects
61186 + */
61187 + obj = chk_obj_label_noglob(dentry, mnt, task->acl);
61188 + if (obj->globbed == NULL)
61189 + return (obj->mode & GR_FIND) ? 1 : 0;
61190 +
61191 + is_not_root = ((obj->filename[0] == '/') &&
61192 + (obj->filename[1] == '\0')) ? 0 : 1;
61193 + bufsize = PAGE_SIZE - namelen - is_not_root;
61194 +
61195 + /* check bufsize > PAGE_SIZE || bufsize == 0 */
61196 + if (unlikely((bufsize - 1) > (PAGE_SIZE - 1)))
61197 + return 1;
61198 +
61199 + preempt_disable();
61200 + path = d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
61201 + bufsize);
61202 +
61203 + bufsize = strlen(path);
61204 +
61205 + /* if base is "/", don't append an additional slash */
61206 + if (is_not_root)
61207 + *(path + bufsize) = '/';
61208 + memcpy(path + bufsize + is_not_root, name, namelen);
61209 + *(path + bufsize + namelen + is_not_root) = '\0';
61210 +
61211 + tmp = obj->globbed;
61212 + while (tmp) {
61213 + if (!glob_match(tmp->filename, path)) {
61214 + preempt_enable();
61215 + return (tmp->mode & GR_FIND) ? 1 : 0;
61216 + }
61217 + tmp = tmp->next;
61218 + }
61219 + preempt_enable();
61220 + return (obj->mode & GR_FIND) ? 1 : 0;
61221 +}
61222 +
61223 +void gr_put_exec_file(struct task_struct *task)
61224 +{
61225 + struct file *filp;
61226 +
61227 + write_lock(&grsec_exec_file_lock);
61228 + filp = task->exec_file;
61229 + task->exec_file = NULL;
61230 + write_unlock(&grsec_exec_file_lock);
61231 +
61232 + if (filp)
61233 + fput(filp);
61234 +
61235 + return;
61236 +}
61237 +
61238 +
61239 +#ifdef CONFIG_NETFILTER_XT_MATCH_GRADM_MODULE
61240 +EXPORT_SYMBOL(gr_acl_is_enabled);
61241 +#endif
61242 +EXPORT_SYMBOL(gr_set_kernel_label);
61243 +#ifdef CONFIG_SECURITY
61244 +EXPORT_SYMBOL(gr_check_user_change);
61245 +EXPORT_SYMBOL(gr_check_group_change);
61246 +#endif
61247 +
61248 diff --git a/grsecurity/gracl_alloc.c b/grsecurity/gracl_alloc.c
61249 new file mode 100644
61250 index 0000000..34fefda
61251 --- /dev/null
61252 +++ b/grsecurity/gracl_alloc.c
61253 @@ -0,0 +1,105 @@
61254 +#include <linux/kernel.h>
61255 +#include <linux/mm.h>
61256 +#include <linux/slab.h>
61257 +#include <linux/vmalloc.h>
61258 +#include <linux/gracl.h>
61259 +#include <linux/grsecurity.h>
61260 +
61261 +static unsigned long alloc_stack_next = 1;
61262 +static unsigned long alloc_stack_size = 1;
61263 +static void **alloc_stack;
61264 +
61265 +static __inline__ int
61266 +alloc_pop(void)
61267 +{
61268 + if (alloc_stack_next == 1)
61269 + return 0;
61270 +
61271 + kfree(alloc_stack[alloc_stack_next - 2]);
61272 +
61273 + alloc_stack_next--;
61274 +
61275 + return 1;
61276 +}
61277 +
61278 +static __inline__ int
61279 +alloc_push(void *buf)
61280 +{
61281 + if (alloc_stack_next >= alloc_stack_size)
61282 + return 1;
61283 +
61284 + alloc_stack[alloc_stack_next - 1] = buf;
61285 +
61286 + alloc_stack_next++;
61287 +
61288 + return 0;
61289 +}
61290 +
61291 +void *
61292 +acl_alloc(unsigned long len)
61293 +{
61294 + void *ret = NULL;
61295 +
61296 + if (!len || len > PAGE_SIZE)
61297 + goto out;
61298 +
61299 + ret = kmalloc(len, GFP_KERNEL);
61300 +
61301 + if (ret) {
61302 + if (alloc_push(ret)) {
61303 + kfree(ret);
61304 + ret = NULL;
61305 + }
61306 + }
61307 +
61308 +out:
61309 + return ret;
61310 +}
61311 +
61312 +void *
61313 +acl_alloc_num(unsigned long num, unsigned long len)
61314 +{
61315 + if (!len || (num > (PAGE_SIZE / len)))
61316 + return NULL;
61317 +
61318 + return acl_alloc(num * len);
61319 +}
61320 +
61321 +void
61322 +acl_free_all(void)
61323 +{
61324 + if (gr_acl_is_enabled() || !alloc_stack)
61325 + return;
61326 +
61327 + while (alloc_pop()) ;
61328 +
61329 + if (alloc_stack) {
61330 + if ((alloc_stack_size * sizeof (void *)) <= PAGE_SIZE)
61331 + kfree(alloc_stack);
61332 + else
61333 + vfree(alloc_stack);
61334 + }
61335 +
61336 + alloc_stack = NULL;
61337 + alloc_stack_size = 1;
61338 + alloc_stack_next = 1;
61339 +
61340 + return;
61341 +}
61342 +
61343 +int
61344 +acl_alloc_stack_init(unsigned long size)
61345 +{
61346 + if ((size * sizeof (void *)) <= PAGE_SIZE)
61347 + alloc_stack =
61348 + (void **) kmalloc(size * sizeof (void *), GFP_KERNEL);
61349 + else
61350 + alloc_stack = (void **) vmalloc(size * sizeof (void *));
61351 +
61352 + alloc_stack_size = size;
61353 +
61354 + if (!alloc_stack)
61355 + return 0;
61356 + else
61357 + return 1;
61358 +}
61359 diff --git a/grsecurity/gracl_cap.c b/grsecurity/gracl_cap.c
61360 new file mode 100644
61361 index 0000000..bdd51ea
61362 --- /dev/null
61363 +++ b/grsecurity/gracl_cap.c
61364 @@ -0,0 +1,110 @@
61365 +#include <linux/kernel.h>
61366 +#include <linux/module.h>
61367 +#include <linux/sched.h>
61368 +#include <linux/gracl.h>
61369 +#include <linux/grsecurity.h>
61370 +#include <linux/grinternal.h>
61371 +
61372 +extern const char *captab_log[];
61373 +extern int captab_log_entries;
61374 +
61375 +int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
61376 +{
61377 + struct acl_subject_label *curracl;
61378 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
61379 + kernel_cap_t cap_audit = __cap_empty_set;
61380 +
61381 + if (!gr_acl_is_enabled())
61382 + return 1;
61383 +
61384 + curracl = task->acl;
61385 +
61386 + cap_drop = curracl->cap_lower;
61387 + cap_mask = curracl->cap_mask;
61388 + cap_audit = curracl->cap_invert_audit;
61389 +
61390 + while ((curracl = curracl->parent_subject)) {
61391 + /* if the cap isn't specified in the current computed mask but is specified in the
61392 + current level subject, and is lowered in the current level subject, then add
61393 + it to the set of dropped capabilities
61394 + otherwise, add the current level subject's mask to the current computed mask
61395 + */
61396 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
61397 + cap_raise(cap_mask, cap);
61398 + if (cap_raised(curracl->cap_lower, cap))
61399 + cap_raise(cap_drop, cap);
61400 + if (cap_raised(curracl->cap_invert_audit, cap))
61401 + cap_raise(cap_audit, cap);
61402 + }
61403 + }
61404 +
61405 + if (!cap_raised(cap_drop, cap)) {
61406 + if (cap_raised(cap_audit, cap))
61407 + gr_log_cap(GR_DO_AUDIT, GR_CAP_ACL_MSG2, task, captab_log[cap]);
61408 + return 1;
61409 + }
61410 +
61411 + curracl = task->acl;
61412 +
61413 + if ((curracl->mode & (GR_LEARN | GR_INHERITLEARN))
61414 + && cap_raised(cred->cap_effective, cap)) {
61415 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
61416 + task->role->roletype, GR_GLOBAL_UID(cred->uid),
61417 + GR_GLOBAL_GID(cred->gid), task->exec_file ?
61418 + gr_to_filename(task->exec_file->f_path.dentry,
61419 + task->exec_file->f_path.mnt) : curracl->filename,
61420 + curracl->filename, 0UL,
61421 + 0UL, "", (unsigned long) cap, &task->signal->saved_ip);
61422 + return 1;
61423 + }
61424 +
61425 + if ((cap >= 0) && (cap < captab_log_entries) && cap_raised(cred->cap_effective, cap) && !cap_raised(cap_audit, cap))
61426 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_ACL_MSG, task, captab_log[cap]);
61427 +
61428 + return 0;
61429 +}
61430 +
61431 +int
61432 +gr_acl_is_capable(const int cap)
61433 +{
61434 + return gr_task_acl_is_capable(current, current_cred(), cap);
61435 +}
61436 +
61437 +int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap)
61438 +{
61439 + struct acl_subject_label *curracl;
61440 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
61441 +
61442 + if (!gr_acl_is_enabled())
61443 + return 1;
61444 +
61445 + curracl = task->acl;
61446 +
61447 + cap_drop = curracl->cap_lower;
61448 + cap_mask = curracl->cap_mask;
61449 +
61450 + while ((curracl = curracl->parent_subject)) {
61451 + /* if the cap isn't specified in the current computed mask but is specified in the
61452 + current level subject, and is lowered in the current level subject, then add
61453 + it to the set of dropped capabilities
61454 + otherwise, add the current level subject's mask to the current computed mask
61455 + */
61456 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
61457 + cap_raise(cap_mask, cap);
61458 + if (cap_raised(curracl->cap_lower, cap))
61459 + cap_raise(cap_drop, cap);
61460 + }
61461 + }
61462 +
61463 + if (!cap_raised(cap_drop, cap))
61464 + return 1;
61465 +
61466 + return 0;
61467 +}
61468 +
61469 +int
61470 +gr_acl_is_capable_nolog(const int cap)
61471 +{
61472 + return gr_task_acl_is_capable_nolog(current, cap);
61473 +}
61474 +
61475 diff --git a/grsecurity/gracl_fs.c b/grsecurity/gracl_fs.c
61476 new file mode 100644
61477 index 0000000..a340c17
61478 --- /dev/null
61479 +++ b/grsecurity/gracl_fs.c
61480 @@ -0,0 +1,431 @@
61481 +#include <linux/kernel.h>
61482 +#include <linux/sched.h>
61483 +#include <linux/types.h>
61484 +#include <linux/fs.h>
61485 +#include <linux/file.h>
61486 +#include <linux/stat.h>
61487 +#include <linux/grsecurity.h>
61488 +#include <linux/grinternal.h>
61489 +#include <linux/gracl.h>
61490 +
61491 +umode_t
61492 +gr_acl_umask(void)
61493 +{
61494 + if (unlikely(!gr_acl_is_enabled()))
61495 + return 0;
61496 +
61497 + return current->role->umask;
61498 +}
61499 +
61500 +__u32
61501 +gr_acl_handle_hidden_file(const struct dentry * dentry,
61502 + const struct vfsmount * mnt)
61503 +{
61504 + __u32 mode;
61505 +
61506 + if (unlikely(!dentry->d_inode))
61507 + return GR_FIND;
61508 +
61509 + mode =
61510 + gr_search_file(dentry, GR_FIND | GR_AUDIT_FIND | GR_SUPPRESS, mnt);
61511 +
61512 + if (unlikely(mode & GR_FIND && mode & GR_AUDIT_FIND)) {
61513 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
61514 + return mode;
61515 + } else if (unlikely(!(mode & GR_FIND) && !(mode & GR_SUPPRESS))) {
61516 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
61517 + return 0;
61518 + } else if (unlikely(!(mode & GR_FIND)))
61519 + return 0;
61520 +
61521 + return GR_FIND;
61522 +}
61523 +
61524 +__u32
61525 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
61526 + int acc_mode)
61527 +{
61528 + __u32 reqmode = GR_FIND;
61529 + __u32 mode;
61530 +
61531 + if (unlikely(!dentry->d_inode))
61532 + return reqmode;
61533 +
61534 + if (acc_mode & MAY_APPEND)
61535 + reqmode |= GR_APPEND;
61536 + else if (acc_mode & MAY_WRITE)
61537 + reqmode |= GR_WRITE;
61538 + if ((acc_mode & MAY_READ) && !S_ISDIR(dentry->d_inode->i_mode))
61539 + reqmode |= GR_READ;
61540 +
61541 + mode =
61542 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
61543 + mnt);
61544 +
61545 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
61546 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
61547 + reqmode & GR_READ ? " reading" : "",
61548 + reqmode & GR_WRITE ? " writing" : reqmode &
61549 + GR_APPEND ? " appending" : "");
61550 + return reqmode;
61551 + } else
61552 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
61553 + {
61554 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
61555 + reqmode & GR_READ ? " reading" : "",
61556 + reqmode & GR_WRITE ? " writing" : reqmode &
61557 + GR_APPEND ? " appending" : "");
61558 + return 0;
61559 + } else if (unlikely((mode & reqmode) != reqmode))
61560 + return 0;
61561 +
61562 + return reqmode;
61563 +}
61564 +
61565 +__u32
61566 +gr_acl_handle_creat(const struct dentry * dentry,
61567 + const struct dentry * p_dentry,
61568 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
61569 + const int imode)
61570 +{
61571 + __u32 reqmode = GR_WRITE | GR_CREATE;
61572 + __u32 mode;
61573 +
61574 + if (acc_mode & MAY_APPEND)
61575 + reqmode |= GR_APPEND;
61576 + // if a directory was required or the directory already exists, then
61577 + // don't count this open as a read
61578 + if ((acc_mode & MAY_READ) &&
61579 + !((open_flags & O_DIRECTORY) || (dentry->d_inode && S_ISDIR(dentry->d_inode->i_mode))))
61580 + reqmode |= GR_READ;
61581 + if ((open_flags & O_CREAT) &&
61582 + ((imode & S_ISUID) || ((imode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
61583 + reqmode |= GR_SETID;
61584 +
61585 + mode =
61586 + gr_check_create(dentry, p_dentry, p_mnt,
61587 + reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
61588 +
61589 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
61590 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
61591 + reqmode & GR_READ ? " reading" : "",
61592 + reqmode & GR_WRITE ? " writing" : reqmode &
61593 + GR_APPEND ? " appending" : "");
61594 + return reqmode;
61595 + } else
61596 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
61597 + {
61598 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
61599 + reqmode & GR_READ ? " reading" : "",
61600 + reqmode & GR_WRITE ? " writing" : reqmode &
61601 + GR_APPEND ? " appending" : "");
61602 + return 0;
61603 + } else if (unlikely((mode & reqmode) != reqmode))
61604 + return 0;
61605 +
61606 + return reqmode;
61607 +}
61608 +
61609 +__u32
61610 +gr_acl_handle_access(const struct dentry * dentry, const struct vfsmount * mnt,
61611 + const int fmode)
61612 +{
61613 + __u32 mode, reqmode = GR_FIND;
61614 +
61615 + if ((fmode & S_IXOTH) && !S_ISDIR(dentry->d_inode->i_mode))
61616 + reqmode |= GR_EXEC;
61617 + if (fmode & S_IWOTH)
61618 + reqmode |= GR_WRITE;
61619 + if (fmode & S_IROTH)
61620 + reqmode |= GR_READ;
61621 +
61622 + mode =
61623 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
61624 + mnt);
61625 +
61626 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
61627 + gr_log_fs_rbac_mode3(GR_DO_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
61628 + reqmode & GR_READ ? " reading" : "",
61629 + reqmode & GR_WRITE ? " writing" : "",
61630 + reqmode & GR_EXEC ? " executing" : "");
61631 + return reqmode;
61632 + } else
61633 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
61634 + {
61635 + gr_log_fs_rbac_mode3(GR_DONT_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
61636 + reqmode & GR_READ ? " reading" : "",
61637 + reqmode & GR_WRITE ? " writing" : "",
61638 + reqmode & GR_EXEC ? " executing" : "");
61639 + return 0;
61640 + } else if (unlikely((mode & reqmode) != reqmode))
61641 + return 0;
61642 +
61643 + return reqmode;
61644 +}
61645 +
61646 +static __u32 generic_fs_handler(const struct dentry *dentry, const struct vfsmount *mnt, __u32 reqmode, const char *fmt)
61647 +{
61648 + __u32 mode;
61649 +
61650 + mode = gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS, mnt);
61651 +
61652 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
61653 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, dentry, mnt);
61654 + return mode;
61655 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
61656 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, dentry, mnt);
61657 + return 0;
61658 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
61659 + return 0;
61660 +
61661 + return (reqmode);
61662 +}
61663 +
61664 +__u32
61665 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
61666 +{
61667 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_RMDIR_ACL_MSG);
61668 +}
61669 +
61670 +__u32
61671 +gr_acl_handle_unlink(const struct dentry *dentry, const struct vfsmount *mnt)
61672 +{
61673 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_UNLINK_ACL_MSG);
61674 +}
61675 +
61676 +__u32
61677 +gr_acl_handle_truncate(const struct dentry *dentry, const struct vfsmount *mnt)
61678 +{
61679 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_TRUNCATE_ACL_MSG);
61680 +}
61681 +
61682 +__u32
61683 +gr_acl_handle_utime(const struct dentry *dentry, const struct vfsmount *mnt)
61684 +{
61685 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_ATIME_ACL_MSG);
61686 +}
61687 +
61688 +__u32
61689 +gr_acl_handle_chmod(const struct dentry *dentry, const struct vfsmount *mnt,
61690 + umode_t *modeptr)
61691 +{
61692 + umode_t mode;
61693 +
61694 + *modeptr &= ~gr_acl_umask();
61695 + mode = *modeptr;
61696 +
61697 + if (unlikely(dentry->d_inode && S_ISSOCK(dentry->d_inode->i_mode)))
61698 + return 1;
61699 +
61700 + if (unlikely(dentry->d_inode && !S_ISDIR(dentry->d_inode->i_mode) &&
61701 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))) {
61702 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_SETID,
61703 + GR_CHMOD_ACL_MSG);
61704 + } else {
61705 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHMOD_ACL_MSG);
61706 + }
61707 +}
61708 +
61709 +__u32
61710 +gr_acl_handle_chown(const struct dentry *dentry, const struct vfsmount *mnt)
61711 +{
61712 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHOWN_ACL_MSG);
61713 +}
61714 +
61715 +__u32
61716 +gr_acl_handle_setxattr(const struct dentry *dentry, const struct vfsmount *mnt)
61717 +{
61718 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_SETXATTR_ACL_MSG);
61719 +}
61720 +
61721 +__u32
61722 +gr_acl_handle_execve(const struct dentry *dentry, const struct vfsmount *mnt)
61723 +{
61724 + return generic_fs_handler(dentry, mnt, GR_EXEC, GR_EXEC_ACL_MSG);
61725 +}
61726 +
61727 +__u32
61728 +gr_acl_handle_unix(const struct dentry *dentry, const struct vfsmount *mnt)
61729 +{
61730 + return generic_fs_handler(dentry, mnt, GR_READ | GR_WRITE,
61731 + GR_UNIXCONNECT_ACL_MSG);
61732 +}
61733 +
61734 +/* hardlinks require at minimum create and link permission,
61735 + any additional privilege required is based on the
61736 + privilege of the file being linked to
61737 +*/
61738 +__u32
61739 +gr_acl_handle_link(const struct dentry * new_dentry,
61740 + const struct dentry * parent_dentry,
61741 + const struct vfsmount * parent_mnt,
61742 + const struct dentry * old_dentry,
61743 + const struct vfsmount * old_mnt, const struct filename *to)
61744 +{
61745 + __u32 mode;
61746 + __u32 needmode = GR_CREATE | GR_LINK;
61747 + __u32 needaudit = GR_AUDIT_CREATE | GR_AUDIT_LINK;
61748 +
61749 + mode =
61750 + gr_check_link(new_dentry, parent_dentry, parent_mnt, old_dentry,
61751 + old_mnt);
61752 +
61753 + if (unlikely(((mode & needmode) == needmode) && (mode & needaudit))) {
61754 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
61755 + return mode;
61756 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
61757 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
61758 + return 0;
61759 + } else if (unlikely((mode & needmode) != needmode))
61760 + return 0;
61761 +
61762 + return 1;
61763 +}
61764 +
61765 +__u32
61766 +gr_acl_handle_symlink(const struct dentry * new_dentry,
61767 + const struct dentry * parent_dentry,
61768 + const struct vfsmount * parent_mnt, const struct filename *from)
61769 +{
61770 + __u32 needmode = GR_WRITE | GR_CREATE;
61771 + __u32 mode;
61772 +
61773 + mode =
61774 + gr_check_create(new_dentry, parent_dentry, parent_mnt,
61775 + GR_CREATE | GR_AUDIT_CREATE |
61776 + GR_WRITE | GR_AUDIT_WRITE | GR_SUPPRESS);
61777 +
61778 + if (unlikely(mode & GR_WRITE && mode & GR_AUDITS)) {
61779 + gr_log_fs_str_rbac(GR_DO_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
61780 + return mode;
61781 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
61782 + gr_log_fs_str_rbac(GR_DONT_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
61783 + return 0;
61784 + } else if (unlikely((mode & needmode) != needmode))
61785 + return 0;
61786 +
61787 + return (GR_WRITE | GR_CREATE);
61788 +}
61789 +
61790 +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)
61791 +{
61792 + __u32 mode;
61793 +
61794 + mode = gr_check_create(new_dentry, parent_dentry, parent_mnt, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
61795 +
61796 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
61797 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, new_dentry, parent_mnt);
61798 + return mode;
61799 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
61800 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, new_dentry, parent_mnt);
61801 + return 0;
61802 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
61803 + return 0;
61804 +
61805 + return (reqmode);
61806 +}
61807 +
61808 +__u32
61809 +gr_acl_handle_mknod(const struct dentry * new_dentry,
61810 + const struct dentry * parent_dentry,
61811 + const struct vfsmount * parent_mnt,
61812 + const int mode)
61813 +{
61814 + __u32 reqmode = GR_WRITE | GR_CREATE;
61815 + if (unlikely((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
61816 + reqmode |= GR_SETID;
61817 +
61818 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
61819 + reqmode, GR_MKNOD_ACL_MSG);
61820 +}
61821 +
61822 +__u32
61823 +gr_acl_handle_mkdir(const struct dentry *new_dentry,
61824 + const struct dentry *parent_dentry,
61825 + const struct vfsmount *parent_mnt)
61826 +{
61827 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
61828 + GR_WRITE | GR_CREATE, GR_MKDIR_ACL_MSG);
61829 +}
61830 +
61831 +#define RENAME_CHECK_SUCCESS(old, new) \
61832 + (((old & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)) && \
61833 + ((new & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)))
61834 +
61835 +int
61836 +gr_acl_handle_rename(struct dentry *new_dentry,
61837 + struct dentry *parent_dentry,
61838 + const struct vfsmount *parent_mnt,
61839 + struct dentry *old_dentry,
61840 + struct inode *old_parent_inode,
61841 + struct vfsmount *old_mnt, const struct filename *newname)
61842 +{
61843 + __u32 comp1, comp2;
61844 + int error = 0;
61845 +
61846 + if (unlikely(!gr_acl_is_enabled()))
61847 + return 0;
61848 +
61849 + if (!new_dentry->d_inode) {
61850 + comp1 = gr_check_create(new_dentry, parent_dentry, parent_mnt,
61851 + GR_READ | GR_WRITE | GR_CREATE | GR_AUDIT_READ |
61852 + GR_AUDIT_WRITE | GR_AUDIT_CREATE | GR_SUPPRESS);
61853 + comp2 = gr_search_file(old_dentry, GR_READ | GR_WRITE |
61854 + GR_DELETE | GR_AUDIT_DELETE |
61855 + GR_AUDIT_READ | GR_AUDIT_WRITE |
61856 + GR_SUPPRESS, old_mnt);
61857 + } else {
61858 + comp1 = gr_search_file(new_dentry, GR_READ | GR_WRITE |
61859 + GR_CREATE | GR_DELETE |
61860 + GR_AUDIT_CREATE | GR_AUDIT_DELETE |
61861 + GR_AUDIT_READ | GR_AUDIT_WRITE |
61862 + GR_SUPPRESS, parent_mnt);
61863 + comp2 =
61864 + gr_search_file(old_dentry,
61865 + GR_READ | GR_WRITE | GR_AUDIT_READ |
61866 + GR_DELETE | GR_AUDIT_DELETE |
61867 + GR_AUDIT_WRITE | GR_SUPPRESS, old_mnt);
61868 + }
61869 +
61870 + if (RENAME_CHECK_SUCCESS(comp1, comp2) &&
61871 + ((comp1 & GR_AUDITS) || (comp2 & GR_AUDITS)))
61872 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
61873 + else if (!RENAME_CHECK_SUCCESS(comp1, comp2) && !(comp1 & GR_SUPPRESS)
61874 + && !(comp2 & GR_SUPPRESS)) {
61875 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
61876 + error = -EACCES;
61877 + } else if (unlikely(!RENAME_CHECK_SUCCESS(comp1, comp2)))
61878 + error = -EACCES;
61879 +
61880 + return error;
61881 +}
61882 +
61883 +void
61884 +gr_acl_handle_exit(void)
61885 +{
61886 + u16 id;
61887 + char *rolename;
61888 +
61889 + if (unlikely(current->acl_sp_role && gr_acl_is_enabled() &&
61890 + !(current->role->roletype & GR_ROLE_PERSIST))) {
61891 + id = current->acl_role_id;
61892 + rolename = current->role->rolename;
61893 + gr_set_acls(1);
61894 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLEL_ACL_MSG, rolename, id);
61895 + }
61896 +
61897 + gr_put_exec_file(current);
61898 + return;
61899 +}
61900 +
61901 +int
61902 +gr_acl_handle_procpidmem(const struct task_struct *task)
61903 +{
61904 + if (unlikely(!gr_acl_is_enabled()))
61905 + return 0;
61906 +
61907 + if (task != current && task->acl->mode & GR_PROTPROCFD)
61908 + return -EACCES;
61909 +
61910 + return 0;
61911 +}
61912 diff --git a/grsecurity/gracl_ip.c b/grsecurity/gracl_ip.c
61913 new file mode 100644
61914 index 0000000..8132048
61915 --- /dev/null
61916 +++ b/grsecurity/gracl_ip.c
61917 @@ -0,0 +1,387 @@
61918 +#include <linux/kernel.h>
61919 +#include <asm/uaccess.h>
61920 +#include <asm/errno.h>
61921 +#include <net/sock.h>
61922 +#include <linux/file.h>
61923 +#include <linux/fs.h>
61924 +#include <linux/net.h>
61925 +#include <linux/in.h>
61926 +#include <linux/skbuff.h>
61927 +#include <linux/ip.h>
61928 +#include <linux/udp.h>
61929 +#include <linux/types.h>
61930 +#include <linux/sched.h>
61931 +#include <linux/netdevice.h>
61932 +#include <linux/inetdevice.h>
61933 +#include <linux/gracl.h>
61934 +#include <linux/grsecurity.h>
61935 +#include <linux/grinternal.h>
61936 +
61937 +#define GR_BIND 0x01
61938 +#define GR_CONNECT 0x02
61939 +#define GR_INVERT 0x04
61940 +#define GR_BINDOVERRIDE 0x08
61941 +#define GR_CONNECTOVERRIDE 0x10
61942 +#define GR_SOCK_FAMILY 0x20
61943 +
61944 +static const char * gr_protocols[IPPROTO_MAX] = {
61945 + "ip", "icmp", "igmp", "ggp", "ipencap", "st", "tcp", "cbt",
61946 + "egp", "igp", "bbn-rcc", "nvp", "pup", "argus", "emcon", "xnet",
61947 + "chaos", "udp", "mux", "dcn", "hmp", "prm", "xns-idp", "trunk-1",
61948 + "trunk-2", "leaf-1", "leaf-2", "rdp", "irtp", "iso-tp4", "netblt", "mfe-nsp",
61949 + "merit-inp", "sep", "3pc", "idpr", "xtp", "ddp", "idpr-cmtp", "tp++",
61950 + "il", "ipv6", "sdrp", "ipv6-route", "ipv6-frag", "idrp", "rsvp", "gre",
61951 + "mhrp", "bna", "ipv6-crypt", "ipv6-auth", "i-nlsp", "swipe", "narp", "mobile",
61952 + "tlsp", "skip", "ipv6-icmp", "ipv6-nonxt", "ipv6-opts", "unknown:61", "cftp", "unknown:63",
61953 + "sat-expak", "kryptolan", "rvd", "ippc", "unknown:68", "sat-mon", "visa", "ipcv",
61954 + "cpnx", "cphb", "wsn", "pvp", "br-sat-mon", "sun-nd", "wb-mon", "wb-expak",
61955 + "iso-ip", "vmtp", "secure-vmtp", "vines", "ttp", "nfsnet-igp", "dgp", "tcf",
61956 + "eigrp", "ospf", "sprite-rpc", "larp", "mtp", "ax.25", "ipip", "micp",
61957 + "scc-sp", "etherip", "encap", "unknown:99", "gmtp", "ifmp", "pnni", "pim",
61958 + "aris", "scps", "qnx", "a/n", "ipcomp", "snp", "compaq-peer", "ipx-in-ip",
61959 + "vrrp", "pgm", "unknown:114", "l2tp", "ddx", "iatp", "stp", "srp",
61960 + "uti", "smp", "sm", "ptp", "isis", "fire", "crtp", "crdup",
61961 + "sscopmce", "iplt", "sps", "pipe", "sctp", "fc", "unkown:134", "unknown:135",
61962 + "unknown:136", "unknown:137", "unknown:138", "unknown:139", "unknown:140", "unknown:141", "unknown:142", "unknown:143",
61963 + "unknown:144", "unknown:145", "unknown:146", "unknown:147", "unknown:148", "unknown:149", "unknown:150", "unknown:151",
61964 + "unknown:152", "unknown:153", "unknown:154", "unknown:155", "unknown:156", "unknown:157", "unknown:158", "unknown:159",
61965 + "unknown:160", "unknown:161", "unknown:162", "unknown:163", "unknown:164", "unknown:165", "unknown:166", "unknown:167",
61966 + "unknown:168", "unknown:169", "unknown:170", "unknown:171", "unknown:172", "unknown:173", "unknown:174", "unknown:175",
61967 + "unknown:176", "unknown:177", "unknown:178", "unknown:179", "unknown:180", "unknown:181", "unknown:182", "unknown:183",
61968 + "unknown:184", "unknown:185", "unknown:186", "unknown:187", "unknown:188", "unknown:189", "unknown:190", "unknown:191",
61969 + "unknown:192", "unknown:193", "unknown:194", "unknown:195", "unknown:196", "unknown:197", "unknown:198", "unknown:199",
61970 + "unknown:200", "unknown:201", "unknown:202", "unknown:203", "unknown:204", "unknown:205", "unknown:206", "unknown:207",
61971 + "unknown:208", "unknown:209", "unknown:210", "unknown:211", "unknown:212", "unknown:213", "unknown:214", "unknown:215",
61972 + "unknown:216", "unknown:217", "unknown:218", "unknown:219", "unknown:220", "unknown:221", "unknown:222", "unknown:223",
61973 + "unknown:224", "unknown:225", "unknown:226", "unknown:227", "unknown:228", "unknown:229", "unknown:230", "unknown:231",
61974 + "unknown:232", "unknown:233", "unknown:234", "unknown:235", "unknown:236", "unknown:237", "unknown:238", "unknown:239",
61975 + "unknown:240", "unknown:241", "unknown:242", "unknown:243", "unknown:244", "unknown:245", "unknown:246", "unknown:247",
61976 + "unknown:248", "unknown:249", "unknown:250", "unknown:251", "unknown:252", "unknown:253", "unknown:254", "unknown:255",
61977 + };
61978 +
61979 +static const char * gr_socktypes[SOCK_MAX] = {
61980 + "unknown:0", "stream", "dgram", "raw", "rdm", "seqpacket", "unknown:6",
61981 + "unknown:7", "unknown:8", "unknown:9", "packet"
61982 + };
61983 +
61984 +static const char * gr_sockfamilies[AF_MAX+1] = {
61985 + "unspec", "unix", "inet", "ax25", "ipx", "appletalk", "netrom", "bridge", "atmpvc", "x25",
61986 + "inet6", "rose", "decnet", "netbeui", "security", "key", "netlink", "packet", "ash",
61987 + "econet", "atmsvc", "rds", "sna", "irda", "ppox", "wanpipe", "llc", "fam_27", "fam_28",
61988 + "tipc", "bluetooth", "iucv", "rxrpc", "isdn", "phonet", "ieee802154", "ciaf"
61989 + };
61990 +
61991 +const char *
61992 +gr_proto_to_name(unsigned char proto)
61993 +{
61994 + return gr_protocols[proto];
61995 +}
61996 +
61997 +const char *
61998 +gr_socktype_to_name(unsigned char type)
61999 +{
62000 + return gr_socktypes[type];
62001 +}
62002 +
62003 +const char *
62004 +gr_sockfamily_to_name(unsigned char family)
62005 +{
62006 + return gr_sockfamilies[family];
62007 +}
62008 +
62009 +int
62010 +gr_search_socket(const int domain, const int type, const int protocol)
62011 +{
62012 + struct acl_subject_label *curr;
62013 + const struct cred *cred = current_cred();
62014 +
62015 + if (unlikely(!gr_acl_is_enabled()))
62016 + goto exit;
62017 +
62018 + if ((domain < 0) || (type < 0) || (protocol < 0) ||
62019 + (domain >= AF_MAX) || (type >= SOCK_MAX) || (protocol >= IPPROTO_MAX))
62020 + goto exit; // let the kernel handle it
62021 +
62022 + curr = current->acl;
62023 +
62024 + if (curr->sock_families[domain / 32] & (1U << (domain % 32))) {
62025 + /* the family is allowed, if this is PF_INET allow it only if
62026 + the extra sock type/protocol checks pass */
62027 + if (domain == PF_INET)
62028 + goto inet_check;
62029 + goto exit;
62030 + } else {
62031 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
62032 + __u32 fakeip = 0;
62033 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
62034 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
62035 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
62036 + gr_to_filename(current->exec_file->f_path.dentry,
62037 + current->exec_file->f_path.mnt) :
62038 + curr->filename, curr->filename,
62039 + &fakeip, domain, 0, 0, GR_SOCK_FAMILY,
62040 + &current->signal->saved_ip);
62041 + goto exit;
62042 + }
62043 + goto exit_fail;
62044 + }
62045 +
62046 +inet_check:
62047 + /* the rest of this checking is for IPv4 only */
62048 + if (!curr->ips)
62049 + goto exit;
62050 +
62051 + if ((curr->ip_type & (1U << type)) &&
62052 + (curr->ip_proto[protocol / 32] & (1U << (protocol % 32))))
62053 + goto exit;
62054 +
62055 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
62056 + /* we don't place acls on raw sockets , and sometimes
62057 + dgram/ip sockets are opened for ioctl and not
62058 + bind/connect, so we'll fake a bind learn log */
62059 + if (type == SOCK_RAW || type == SOCK_PACKET) {
62060 + __u32 fakeip = 0;
62061 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
62062 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
62063 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
62064 + gr_to_filename(current->exec_file->f_path.dentry,
62065 + current->exec_file->f_path.mnt) :
62066 + curr->filename, curr->filename,
62067 + &fakeip, 0, type,
62068 + protocol, GR_CONNECT, &current->signal->saved_ip);
62069 + } else if ((type == SOCK_DGRAM) && (protocol == IPPROTO_IP)) {
62070 + __u32 fakeip = 0;
62071 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
62072 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
62073 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
62074 + gr_to_filename(current->exec_file->f_path.dentry,
62075 + current->exec_file->f_path.mnt) :
62076 + curr->filename, curr->filename,
62077 + &fakeip, 0, type,
62078 + protocol, GR_BIND, &current->signal->saved_ip);
62079 + }
62080 + /* we'll log when they use connect or bind */
62081 + goto exit;
62082 + }
62083 +
62084 +exit_fail:
62085 + if (domain == PF_INET)
62086 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(domain),
62087 + gr_socktype_to_name(type), gr_proto_to_name(protocol));
62088 + else
62089 +#ifndef CONFIG_IPV6
62090 + if (domain != PF_INET6)
62091 +#endif
62092 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(domain),
62093 + gr_socktype_to_name(type), protocol);
62094 +
62095 + return 0;
62096 +exit:
62097 + return 1;
62098 +}
62099 +
62100 +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)
62101 +{
62102 + if ((ip->mode & mode) &&
62103 + (ip_port >= ip->low) &&
62104 + (ip_port <= ip->high) &&
62105 + ((ntohl(ip_addr) & our_netmask) ==
62106 + (ntohl(our_addr) & our_netmask))
62107 + && (ip->proto[protocol / 32] & (1U << (protocol % 32)))
62108 + && (ip->type & (1U << type))) {
62109 + if (ip->mode & GR_INVERT)
62110 + return 2; // specifically denied
62111 + else
62112 + return 1; // allowed
62113 + }
62114 +
62115 + return 0; // not specifically allowed, may continue parsing
62116 +}
62117 +
62118 +static int
62119 +gr_search_connectbind(const int full_mode, struct sock *sk,
62120 + struct sockaddr_in *addr, const int type)
62121 +{
62122 + char iface[IFNAMSIZ] = {0};
62123 + struct acl_subject_label *curr;
62124 + struct acl_ip_label *ip;
62125 + struct inet_sock *isk;
62126 + struct net_device *dev;
62127 + struct in_device *idev;
62128 + unsigned long i;
62129 + int ret;
62130 + int mode = full_mode & (GR_BIND | GR_CONNECT);
62131 + __u32 ip_addr = 0;
62132 + __u32 our_addr;
62133 + __u32 our_netmask;
62134 + char *p;
62135 + __u16 ip_port = 0;
62136 + const struct cred *cred = current_cred();
62137 +
62138 + if (unlikely(!gr_acl_is_enabled() || sk->sk_family != PF_INET))
62139 + return 0;
62140 +
62141 + curr = current->acl;
62142 + isk = inet_sk(sk);
62143 +
62144 + /* INADDR_ANY overriding for binds, inaddr_any_override is already in network order */
62145 + if ((full_mode & GR_BINDOVERRIDE) && addr->sin_addr.s_addr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0)
62146 + addr->sin_addr.s_addr = curr->inaddr_any_override;
62147 + if ((full_mode & GR_CONNECT) && isk->inet_saddr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0) {
62148 + struct sockaddr_in saddr;
62149 + int err;
62150 +
62151 + saddr.sin_family = AF_INET;
62152 + saddr.sin_addr.s_addr = curr->inaddr_any_override;
62153 + saddr.sin_port = isk->inet_sport;
62154 +
62155 + err = security_socket_bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
62156 + if (err)
62157 + return err;
62158 +
62159 + err = sk->sk_socket->ops->bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
62160 + if (err)
62161 + return err;
62162 + }
62163 +
62164 + if (!curr->ips)
62165 + return 0;
62166 +
62167 + ip_addr = addr->sin_addr.s_addr;
62168 + ip_port = ntohs(addr->sin_port);
62169 +
62170 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
62171 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
62172 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
62173 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
62174 + gr_to_filename(current->exec_file->f_path.dentry,
62175 + current->exec_file->f_path.mnt) :
62176 + curr->filename, curr->filename,
62177 + &ip_addr, ip_port, type,
62178 + sk->sk_protocol, mode, &current->signal->saved_ip);
62179 + return 0;
62180 + }
62181 +
62182 + for (i = 0; i < curr->ip_num; i++) {
62183 + ip = *(curr->ips + i);
62184 + if (ip->iface != NULL) {
62185 + strncpy(iface, ip->iface, IFNAMSIZ - 1);
62186 + p = strchr(iface, ':');
62187 + if (p != NULL)
62188 + *p = '\0';
62189 + dev = dev_get_by_name(sock_net(sk), iface);
62190 + if (dev == NULL)
62191 + continue;
62192 + idev = in_dev_get(dev);
62193 + if (idev == NULL) {
62194 + dev_put(dev);
62195 + continue;
62196 + }
62197 + rcu_read_lock();
62198 + for_ifa(idev) {
62199 + if (!strcmp(ip->iface, ifa->ifa_label)) {
62200 + our_addr = ifa->ifa_address;
62201 + our_netmask = 0xffffffff;
62202 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
62203 + if (ret == 1) {
62204 + rcu_read_unlock();
62205 + in_dev_put(idev);
62206 + dev_put(dev);
62207 + return 0;
62208 + } else if (ret == 2) {
62209 + rcu_read_unlock();
62210 + in_dev_put(idev);
62211 + dev_put(dev);
62212 + goto denied;
62213 + }
62214 + }
62215 + } endfor_ifa(idev);
62216 + rcu_read_unlock();
62217 + in_dev_put(idev);
62218 + dev_put(dev);
62219 + } else {
62220 + our_addr = ip->addr;
62221 + our_netmask = ip->netmask;
62222 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
62223 + if (ret == 1)
62224 + return 0;
62225 + else if (ret == 2)
62226 + goto denied;
62227 + }
62228 + }
62229 +
62230 +denied:
62231 + if (mode == GR_BIND)
62232 + 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));
62233 + else if (mode == GR_CONNECT)
62234 + 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));
62235 +
62236 + return -EACCES;
62237 +}
62238 +
62239 +int
62240 +gr_search_connect(struct socket *sock, struct sockaddr_in *addr)
62241 +{
62242 + /* always allow disconnection of dgram sockets with connect */
62243 + if (addr->sin_family == AF_UNSPEC)
62244 + return 0;
62245 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sock->sk, addr, sock->type);
62246 +}
62247 +
62248 +int
62249 +gr_search_bind(struct socket *sock, struct sockaddr_in *addr)
62250 +{
62251 + return gr_search_connectbind(GR_BIND | GR_BINDOVERRIDE, sock->sk, addr, sock->type);
62252 +}
62253 +
62254 +int gr_search_listen(struct socket *sock)
62255 +{
62256 + struct sock *sk = sock->sk;
62257 + struct sockaddr_in addr;
62258 +
62259 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
62260 + addr.sin_port = inet_sk(sk)->inet_sport;
62261 +
62262 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
62263 +}
62264 +
62265 +int gr_search_accept(struct socket *sock)
62266 +{
62267 + struct sock *sk = sock->sk;
62268 + struct sockaddr_in addr;
62269 +
62270 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
62271 + addr.sin_port = inet_sk(sk)->inet_sport;
62272 +
62273 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
62274 +}
62275 +
62276 +int
62277 +gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr)
62278 +{
62279 + if (addr)
62280 + return gr_search_connectbind(GR_CONNECT, sk, addr, SOCK_DGRAM);
62281 + else {
62282 + struct sockaddr_in sin;
62283 + const struct inet_sock *inet = inet_sk(sk);
62284 +
62285 + sin.sin_addr.s_addr = inet->inet_daddr;
62286 + sin.sin_port = inet->inet_dport;
62287 +
62288 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
62289 + }
62290 +}
62291 +
62292 +int
62293 +gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb)
62294 +{
62295 + struct sockaddr_in sin;
62296 +
62297 + if (unlikely(skb->len < sizeof (struct udphdr)))
62298 + return 0; // skip this packet
62299 +
62300 + sin.sin_addr.s_addr = ip_hdr(skb)->saddr;
62301 + sin.sin_port = udp_hdr(skb)->source;
62302 +
62303 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
62304 +}
62305 diff --git a/grsecurity/gracl_learn.c b/grsecurity/gracl_learn.c
62306 new file mode 100644
62307 index 0000000..25f54ef
62308 --- /dev/null
62309 +++ b/grsecurity/gracl_learn.c
62310 @@ -0,0 +1,207 @@
62311 +#include <linux/kernel.h>
62312 +#include <linux/mm.h>
62313 +#include <linux/sched.h>
62314 +#include <linux/poll.h>
62315 +#include <linux/string.h>
62316 +#include <linux/file.h>
62317 +#include <linux/types.h>
62318 +#include <linux/vmalloc.h>
62319 +#include <linux/grinternal.h>
62320 +
62321 +extern ssize_t write_grsec_handler(struct file * file, const char __user * buf,
62322 + size_t count, loff_t *ppos);
62323 +extern int gr_acl_is_enabled(void);
62324 +
62325 +static DECLARE_WAIT_QUEUE_HEAD(learn_wait);
62326 +static int gr_learn_attached;
62327 +
62328 +/* use a 512k buffer */
62329 +#define LEARN_BUFFER_SIZE (512 * 1024)
62330 +
62331 +static DEFINE_SPINLOCK(gr_learn_lock);
62332 +static DEFINE_MUTEX(gr_learn_user_mutex);
62333 +
62334 +/* we need to maintain two buffers, so that the kernel context of grlearn
62335 + uses a semaphore around the userspace copying, and the other kernel contexts
62336 + use a spinlock when copying into the buffer, since they cannot sleep
62337 +*/
62338 +static char *learn_buffer;
62339 +static char *learn_buffer_user;
62340 +static int learn_buffer_len;
62341 +static int learn_buffer_user_len;
62342 +
62343 +static ssize_t
62344 +read_learn(struct file *file, char __user * buf, size_t count, loff_t * ppos)
62345 +{
62346 + DECLARE_WAITQUEUE(wait, current);
62347 + ssize_t retval = 0;
62348 +
62349 + add_wait_queue(&learn_wait, &wait);
62350 + set_current_state(TASK_INTERRUPTIBLE);
62351 + do {
62352 + mutex_lock(&gr_learn_user_mutex);
62353 + spin_lock(&gr_learn_lock);
62354 + if (learn_buffer_len)
62355 + break;
62356 + spin_unlock(&gr_learn_lock);
62357 + mutex_unlock(&gr_learn_user_mutex);
62358 + if (file->f_flags & O_NONBLOCK) {
62359 + retval = -EAGAIN;
62360 + goto out;
62361 + }
62362 + if (signal_pending(current)) {
62363 + retval = -ERESTARTSYS;
62364 + goto out;
62365 + }
62366 +
62367 + schedule();
62368 + } while (1);
62369 +
62370 + memcpy(learn_buffer_user, learn_buffer, learn_buffer_len);
62371 + learn_buffer_user_len = learn_buffer_len;
62372 + retval = learn_buffer_len;
62373 + learn_buffer_len = 0;
62374 +
62375 + spin_unlock(&gr_learn_lock);
62376 +
62377 + if (copy_to_user(buf, learn_buffer_user, learn_buffer_user_len))
62378 + retval = -EFAULT;
62379 +
62380 + mutex_unlock(&gr_learn_user_mutex);
62381 +out:
62382 + set_current_state(TASK_RUNNING);
62383 + remove_wait_queue(&learn_wait, &wait);
62384 + return retval;
62385 +}
62386 +
62387 +static unsigned int
62388 +poll_learn(struct file * file, poll_table * wait)
62389 +{
62390 + poll_wait(file, &learn_wait, wait);
62391 +
62392 + if (learn_buffer_len)
62393 + return (POLLIN | POLLRDNORM);
62394 +
62395 + return 0;
62396 +}
62397 +
62398 +void
62399 +gr_clear_learn_entries(void)
62400 +{
62401 + char *tmp;
62402 +
62403 + mutex_lock(&gr_learn_user_mutex);
62404 + spin_lock(&gr_learn_lock);
62405 + tmp = learn_buffer;
62406 + learn_buffer = NULL;
62407 + spin_unlock(&gr_learn_lock);
62408 + if (tmp)
62409 + vfree(tmp);
62410 + if (learn_buffer_user != NULL) {
62411 + vfree(learn_buffer_user);
62412 + learn_buffer_user = NULL;
62413 + }
62414 + learn_buffer_len = 0;
62415 + mutex_unlock(&gr_learn_user_mutex);
62416 +
62417 + return;
62418 +}
62419 +
62420 +void
62421 +gr_add_learn_entry(const char *fmt, ...)
62422 +{
62423 + va_list args;
62424 + unsigned int len;
62425 +
62426 + if (!gr_learn_attached)
62427 + return;
62428 +
62429 + spin_lock(&gr_learn_lock);
62430 +
62431 + /* leave a gap at the end so we know when it's "full" but don't have to
62432 + compute the exact length of the string we're trying to append
62433 + */
62434 + if (learn_buffer_len > LEARN_BUFFER_SIZE - 16384) {
62435 + spin_unlock(&gr_learn_lock);
62436 + wake_up_interruptible(&learn_wait);
62437 + return;
62438 + }
62439 + if (learn_buffer == NULL) {
62440 + spin_unlock(&gr_learn_lock);
62441 + return;
62442 + }
62443 +
62444 + va_start(args, fmt);
62445 + len = vsnprintf(learn_buffer + learn_buffer_len, LEARN_BUFFER_SIZE - learn_buffer_len, fmt, args);
62446 + va_end(args);
62447 +
62448 + learn_buffer_len += len + 1;
62449 +
62450 + spin_unlock(&gr_learn_lock);
62451 + wake_up_interruptible(&learn_wait);
62452 +
62453 + return;
62454 +}
62455 +
62456 +static int
62457 +open_learn(struct inode *inode, struct file *file)
62458 +{
62459 + if (file->f_mode & FMODE_READ && gr_learn_attached)
62460 + return -EBUSY;
62461 + if (file->f_mode & FMODE_READ) {
62462 + int retval = 0;
62463 + mutex_lock(&gr_learn_user_mutex);
62464 + if (learn_buffer == NULL)
62465 + learn_buffer = vmalloc(LEARN_BUFFER_SIZE);
62466 + if (learn_buffer_user == NULL)
62467 + learn_buffer_user = vmalloc(LEARN_BUFFER_SIZE);
62468 + if (learn_buffer == NULL) {
62469 + retval = -ENOMEM;
62470 + goto out_error;
62471 + }
62472 + if (learn_buffer_user == NULL) {
62473 + retval = -ENOMEM;
62474 + goto out_error;
62475 + }
62476 + learn_buffer_len = 0;
62477 + learn_buffer_user_len = 0;
62478 + gr_learn_attached = 1;
62479 +out_error:
62480 + mutex_unlock(&gr_learn_user_mutex);
62481 + return retval;
62482 + }
62483 + return 0;
62484 +}
62485 +
62486 +static int
62487 +close_learn(struct inode *inode, struct file *file)
62488 +{
62489 + if (file->f_mode & FMODE_READ) {
62490 + char *tmp = NULL;
62491 + mutex_lock(&gr_learn_user_mutex);
62492 + spin_lock(&gr_learn_lock);
62493 + tmp = learn_buffer;
62494 + learn_buffer = NULL;
62495 + spin_unlock(&gr_learn_lock);
62496 + if (tmp)
62497 + vfree(tmp);
62498 + if (learn_buffer_user != NULL) {
62499 + vfree(learn_buffer_user);
62500 + learn_buffer_user = NULL;
62501 + }
62502 + learn_buffer_len = 0;
62503 + learn_buffer_user_len = 0;
62504 + gr_learn_attached = 0;
62505 + mutex_unlock(&gr_learn_user_mutex);
62506 + }
62507 +
62508 + return 0;
62509 +}
62510 +
62511 +const struct file_operations grsec_fops = {
62512 + .read = read_learn,
62513 + .write = write_grsec_handler,
62514 + .open = open_learn,
62515 + .release = close_learn,
62516 + .poll = poll_learn,
62517 +};
62518 diff --git a/grsecurity/gracl_res.c b/grsecurity/gracl_res.c
62519 new file mode 100644
62520 index 0000000..39645c9
62521 --- /dev/null
62522 +++ b/grsecurity/gracl_res.c
62523 @@ -0,0 +1,68 @@
62524 +#include <linux/kernel.h>
62525 +#include <linux/sched.h>
62526 +#include <linux/gracl.h>
62527 +#include <linux/grinternal.h>
62528 +
62529 +static const char *restab_log[] = {
62530 + [RLIMIT_CPU] = "RLIMIT_CPU",
62531 + [RLIMIT_FSIZE] = "RLIMIT_FSIZE",
62532 + [RLIMIT_DATA] = "RLIMIT_DATA",
62533 + [RLIMIT_STACK] = "RLIMIT_STACK",
62534 + [RLIMIT_CORE] = "RLIMIT_CORE",
62535 + [RLIMIT_RSS] = "RLIMIT_RSS",
62536 + [RLIMIT_NPROC] = "RLIMIT_NPROC",
62537 + [RLIMIT_NOFILE] = "RLIMIT_NOFILE",
62538 + [RLIMIT_MEMLOCK] = "RLIMIT_MEMLOCK",
62539 + [RLIMIT_AS] = "RLIMIT_AS",
62540 + [RLIMIT_LOCKS] = "RLIMIT_LOCKS",
62541 + [RLIMIT_SIGPENDING] = "RLIMIT_SIGPENDING",
62542 + [RLIMIT_MSGQUEUE] = "RLIMIT_MSGQUEUE",
62543 + [RLIMIT_NICE] = "RLIMIT_NICE",
62544 + [RLIMIT_RTPRIO] = "RLIMIT_RTPRIO",
62545 + [RLIMIT_RTTIME] = "RLIMIT_RTTIME",
62546 + [GR_CRASH_RES] = "RLIMIT_CRASH"
62547 +};
62548 +
62549 +void
62550 +gr_log_resource(const struct task_struct *task,
62551 + const int res, const unsigned long wanted, const int gt)
62552 +{
62553 + const struct cred *cred;
62554 + unsigned long rlim;
62555 +
62556 + if (!gr_acl_is_enabled() && !grsec_resource_logging)
62557 + return;
62558 +
62559 + // not yet supported resource
62560 + if (unlikely(!restab_log[res]))
62561 + return;
62562 +
62563 + if (res == RLIMIT_CPU || res == RLIMIT_RTTIME)
62564 + rlim = task_rlimit_max(task, res);
62565 + else
62566 + rlim = task_rlimit(task, res);
62567 +
62568 + if (likely((rlim == RLIM_INFINITY) || (gt && wanted <= rlim) || (!gt && wanted < rlim)))
62569 + return;
62570 +
62571 + rcu_read_lock();
62572 + cred = __task_cred(task);
62573 +
62574 + if (res == RLIMIT_NPROC &&
62575 + (cap_raised(cred->cap_effective, CAP_SYS_ADMIN) ||
62576 + cap_raised(cred->cap_effective, CAP_SYS_RESOURCE)))
62577 + goto out_rcu_unlock;
62578 + else if (res == RLIMIT_MEMLOCK &&
62579 + cap_raised(cred->cap_effective, CAP_IPC_LOCK))
62580 + goto out_rcu_unlock;
62581 + else if (res == RLIMIT_NICE && cap_raised(cred->cap_effective, CAP_SYS_NICE))
62582 + goto out_rcu_unlock;
62583 + rcu_read_unlock();
62584 +
62585 + gr_log_res_ulong2_str(GR_DONT_AUDIT, GR_RESOURCE_MSG, task, wanted, restab_log[res], rlim);
62586 +
62587 + return;
62588 +out_rcu_unlock:
62589 + rcu_read_unlock();
62590 + return;
62591 +}
62592 diff --git a/grsecurity/gracl_segv.c b/grsecurity/gracl_segv.c
62593 new file mode 100644
62594 index 0000000..4dcc92a
62595 --- /dev/null
62596 +++ b/grsecurity/gracl_segv.c
62597 @@ -0,0 +1,305 @@
62598 +#include <linux/kernel.h>
62599 +#include <linux/mm.h>
62600 +#include <asm/uaccess.h>
62601 +#include <asm/errno.h>
62602 +#include <asm/mman.h>
62603 +#include <net/sock.h>
62604 +#include <linux/file.h>
62605 +#include <linux/fs.h>
62606 +#include <linux/net.h>
62607 +#include <linux/in.h>
62608 +#include <linux/slab.h>
62609 +#include <linux/types.h>
62610 +#include <linux/sched.h>
62611 +#include <linux/timer.h>
62612 +#include <linux/gracl.h>
62613 +#include <linux/grsecurity.h>
62614 +#include <linux/grinternal.h>
62615 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
62616 +#include <linux/magic.h>
62617 +#include <linux/pagemap.h>
62618 +#include "../fs/btrfs/async-thread.h"
62619 +#include "../fs/btrfs/ctree.h"
62620 +#include "../fs/btrfs/btrfs_inode.h"
62621 +#endif
62622 +
62623 +static struct crash_uid *uid_set;
62624 +static unsigned short uid_used;
62625 +static DEFINE_SPINLOCK(gr_uid_lock);
62626 +extern rwlock_t gr_inode_lock;
62627 +extern struct acl_subject_label *
62628 + lookup_acl_subj_label(const ino_t inode, const dev_t dev,
62629 + struct acl_role_label *role);
62630 +
62631 +static inline dev_t __get_dev(const struct dentry *dentry)
62632 +{
62633 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
62634 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
62635 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
62636 + else
62637 +#endif
62638 + return dentry->d_sb->s_dev;
62639 +}
62640 +
62641 +int
62642 +gr_init_uidset(void)
62643 +{
62644 + uid_set =
62645 + kmalloc(GR_UIDTABLE_MAX * sizeof (struct crash_uid), GFP_KERNEL);
62646 + uid_used = 0;
62647 +
62648 + return uid_set ? 1 : 0;
62649 +}
62650 +
62651 +void
62652 +gr_free_uidset(void)
62653 +{
62654 + if (uid_set)
62655 + kfree(uid_set);
62656 +
62657 + return;
62658 +}
62659 +
62660 +int
62661 +gr_find_uid(const uid_t uid)
62662 +{
62663 + struct crash_uid *tmp = uid_set;
62664 + uid_t buid;
62665 + int low = 0, high = uid_used - 1, mid;
62666 +
62667 + while (high >= low) {
62668 + mid = (low + high) >> 1;
62669 + buid = tmp[mid].uid;
62670 + if (buid == uid)
62671 + return mid;
62672 + if (buid > uid)
62673 + high = mid - 1;
62674 + if (buid < uid)
62675 + low = mid + 1;
62676 + }
62677 +
62678 + return -1;
62679 +}
62680 +
62681 +static __inline__ void
62682 +gr_insertsort(void)
62683 +{
62684 + unsigned short i, j;
62685 + struct crash_uid index;
62686 +
62687 + for (i = 1; i < uid_used; i++) {
62688 + index = uid_set[i];
62689 + j = i;
62690 + while ((j > 0) && uid_set[j - 1].uid > index.uid) {
62691 + uid_set[j] = uid_set[j - 1];
62692 + j--;
62693 + }
62694 + uid_set[j] = index;
62695 + }
62696 +
62697 + return;
62698 +}
62699 +
62700 +static __inline__ void
62701 +gr_insert_uid(const kuid_t kuid, const unsigned long expires)
62702 +{
62703 + int loc;
62704 + uid_t uid = GR_GLOBAL_UID(kuid);
62705 +
62706 + if (uid_used == GR_UIDTABLE_MAX)
62707 + return;
62708 +
62709 + loc = gr_find_uid(uid);
62710 +
62711 + if (loc >= 0) {
62712 + uid_set[loc].expires = expires;
62713 + return;
62714 + }
62715 +
62716 + uid_set[uid_used].uid = uid;
62717 + uid_set[uid_used].expires = expires;
62718 + uid_used++;
62719 +
62720 + gr_insertsort();
62721 +
62722 + return;
62723 +}
62724 +
62725 +void
62726 +gr_remove_uid(const unsigned short loc)
62727 +{
62728 + unsigned short i;
62729 +
62730 + for (i = loc + 1; i < uid_used; i++)
62731 + uid_set[i - 1] = uid_set[i];
62732 +
62733 + uid_used--;
62734 +
62735 + return;
62736 +}
62737 +
62738 +int
62739 +gr_check_crash_uid(const kuid_t kuid)
62740 +{
62741 + int loc;
62742 + int ret = 0;
62743 + uid_t uid;
62744 +
62745 + if (unlikely(!gr_acl_is_enabled()))
62746 + return 0;
62747 +
62748 + uid = GR_GLOBAL_UID(kuid);
62749 +
62750 + spin_lock(&gr_uid_lock);
62751 + loc = gr_find_uid(uid);
62752 +
62753 + if (loc < 0)
62754 + goto out_unlock;
62755 +
62756 + if (time_before_eq(uid_set[loc].expires, get_seconds()))
62757 + gr_remove_uid(loc);
62758 + else
62759 + ret = 1;
62760 +
62761 +out_unlock:
62762 + spin_unlock(&gr_uid_lock);
62763 + return ret;
62764 +}
62765 +
62766 +static __inline__ int
62767 +proc_is_setxid(const struct cred *cred)
62768 +{
62769 + if (!uid_eq(cred->uid, cred->euid) || !uid_eq(cred->uid, cred->suid) ||
62770 + !uid_eq(cred->uid, cred->fsuid))
62771 + return 1;
62772 + if (!gid_eq(cred->gid, cred->egid) || !gid_eq(cred->gid, cred->sgid) ||
62773 + !gid_eq(cred->gid, cred->fsgid))
62774 + return 1;
62775 +
62776 + return 0;
62777 +}
62778 +
62779 +extern int gr_fake_force_sig(int sig, struct task_struct *t);
62780 +
62781 +void
62782 +gr_handle_crash(struct task_struct *task, const int sig)
62783 +{
62784 + struct acl_subject_label *curr;
62785 + struct task_struct *tsk, *tsk2;
62786 + const struct cred *cred;
62787 + const struct cred *cred2;
62788 +
62789 + if (sig != SIGSEGV && sig != SIGKILL && sig != SIGBUS && sig != SIGILL)
62790 + return;
62791 +
62792 + if (unlikely(!gr_acl_is_enabled()))
62793 + return;
62794 +
62795 + curr = task->acl;
62796 +
62797 + if (!(curr->resmask & (1U << GR_CRASH_RES)))
62798 + return;
62799 +
62800 + if (time_before_eq(curr->expires, get_seconds())) {
62801 + curr->expires = 0;
62802 + curr->crashes = 0;
62803 + }
62804 +
62805 + curr->crashes++;
62806 +
62807 + if (!curr->expires)
62808 + curr->expires = get_seconds() + curr->res[GR_CRASH_RES].rlim_max;
62809 +
62810 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
62811 + time_after(curr->expires, get_seconds())) {
62812 + rcu_read_lock();
62813 + cred = __task_cred(task);
62814 + if (gr_is_global_nonroot(cred->uid) && proc_is_setxid(cred)) {
62815 + gr_log_crash1(GR_DONT_AUDIT, GR_SEGVSTART_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
62816 + spin_lock(&gr_uid_lock);
62817 + gr_insert_uid(cred->uid, curr->expires);
62818 + spin_unlock(&gr_uid_lock);
62819 + curr->expires = 0;
62820 + curr->crashes = 0;
62821 + read_lock(&tasklist_lock);
62822 + do_each_thread(tsk2, tsk) {
62823 + cred2 = __task_cred(tsk);
62824 + if (tsk != task && uid_eq(cred2->uid, cred->uid))
62825 + gr_fake_force_sig(SIGKILL, tsk);
62826 + } while_each_thread(tsk2, tsk);
62827 + read_unlock(&tasklist_lock);
62828 + } else {
62829 + gr_log_crash2(GR_DONT_AUDIT, GR_SEGVNOSUID_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
62830 + read_lock(&tasklist_lock);
62831 + read_lock(&grsec_exec_file_lock);
62832 + do_each_thread(tsk2, tsk) {
62833 + if (likely(tsk != task)) {
62834 + // if this thread has the same subject as the one that triggered
62835 + // RES_CRASH and it's the same binary, kill it
62836 + if (tsk->acl == task->acl && tsk->exec_file == task->exec_file)
62837 + gr_fake_force_sig(SIGKILL, tsk);
62838 + }
62839 + } while_each_thread(tsk2, tsk);
62840 + read_unlock(&grsec_exec_file_lock);
62841 + read_unlock(&tasklist_lock);
62842 + }
62843 + rcu_read_unlock();
62844 + }
62845 +
62846 + return;
62847 +}
62848 +
62849 +int
62850 +gr_check_crash_exec(const struct file *filp)
62851 +{
62852 + struct acl_subject_label *curr;
62853 +
62854 + if (unlikely(!gr_acl_is_enabled()))
62855 + return 0;
62856 +
62857 + read_lock(&gr_inode_lock);
62858 + curr = lookup_acl_subj_label(filp->f_path.dentry->d_inode->i_ino,
62859 + __get_dev(filp->f_path.dentry),
62860 + current->role);
62861 + read_unlock(&gr_inode_lock);
62862 +
62863 + if (!curr || !(curr->resmask & (1U << GR_CRASH_RES)) ||
62864 + (!curr->crashes && !curr->expires))
62865 + return 0;
62866 +
62867 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
62868 + time_after(curr->expires, get_seconds()))
62869 + return 1;
62870 + else if (time_before_eq(curr->expires, get_seconds())) {
62871 + curr->crashes = 0;
62872 + curr->expires = 0;
62873 + }
62874 +
62875 + return 0;
62876 +}
62877 +
62878 +void
62879 +gr_handle_alertkill(struct task_struct *task)
62880 +{
62881 + struct acl_subject_label *curracl;
62882 + __u32 curr_ip;
62883 + struct task_struct *p, *p2;
62884 +
62885 + if (unlikely(!gr_acl_is_enabled()))
62886 + return;
62887 +
62888 + curracl = task->acl;
62889 + curr_ip = task->signal->curr_ip;
62890 +
62891 + if ((curracl->mode & GR_KILLIPPROC) && curr_ip) {
62892 + read_lock(&tasklist_lock);
62893 + do_each_thread(p2, p) {
62894 + if (p->signal->curr_ip == curr_ip)
62895 + gr_fake_force_sig(SIGKILL, p);
62896 + } while_each_thread(p2, p);
62897 + read_unlock(&tasklist_lock);
62898 + } else if (curracl->mode & GR_KILLPROC)
62899 + gr_fake_force_sig(SIGKILL, task);
62900 +
62901 + return;
62902 +}
62903 diff --git a/grsecurity/gracl_shm.c b/grsecurity/gracl_shm.c
62904 new file mode 100644
62905 index 0000000..98011b0
62906 --- /dev/null
62907 +++ b/grsecurity/gracl_shm.c
62908 @@ -0,0 +1,40 @@
62909 +#include <linux/kernel.h>
62910 +#include <linux/mm.h>
62911 +#include <linux/sched.h>
62912 +#include <linux/file.h>
62913 +#include <linux/ipc.h>
62914 +#include <linux/gracl.h>
62915 +#include <linux/grsecurity.h>
62916 +#include <linux/grinternal.h>
62917 +
62918 +int
62919 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
62920 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
62921 +{
62922 + struct task_struct *task;
62923 +
62924 + if (!gr_acl_is_enabled())
62925 + return 1;
62926 +
62927 + rcu_read_lock();
62928 + read_lock(&tasklist_lock);
62929 +
62930 + task = find_task_by_vpid(shm_cprid);
62931 +
62932 + if (unlikely(!task))
62933 + task = find_task_by_vpid(shm_lapid);
62934 +
62935 + if (unlikely(task && (time_before_eq((unsigned long)task->start_time.tv_sec, (unsigned long)shm_createtime) ||
62936 + (task_pid_nr(task) == shm_lapid)) &&
62937 + (task->acl->mode & GR_PROTSHM) &&
62938 + (task->acl != current->acl))) {
62939 + read_unlock(&tasklist_lock);
62940 + rcu_read_unlock();
62941 + gr_log_int3(GR_DONT_AUDIT, GR_SHMAT_ACL_MSG, GR_GLOBAL_UID(cuid), shm_cprid, shmid);
62942 + return 0;
62943 + }
62944 + read_unlock(&tasklist_lock);
62945 + rcu_read_unlock();
62946 +
62947 + return 1;
62948 +}
62949 diff --git a/grsecurity/grsec_chdir.c b/grsecurity/grsec_chdir.c
62950 new file mode 100644
62951 index 0000000..bc0be01
62952 --- /dev/null
62953 +++ b/grsecurity/grsec_chdir.c
62954 @@ -0,0 +1,19 @@
62955 +#include <linux/kernel.h>
62956 +#include <linux/sched.h>
62957 +#include <linux/fs.h>
62958 +#include <linux/file.h>
62959 +#include <linux/grsecurity.h>
62960 +#include <linux/grinternal.h>
62961 +
62962 +void
62963 +gr_log_chdir(const struct dentry *dentry, const struct vfsmount *mnt)
62964 +{
62965 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
62966 + if ((grsec_enable_chdir && grsec_enable_group &&
62967 + in_group_p(grsec_audit_gid)) || (grsec_enable_chdir &&
62968 + !grsec_enable_group)) {
62969 + gr_log_fs_generic(GR_DO_AUDIT, GR_CHDIR_AUDIT_MSG, dentry, mnt);
62970 + }
62971 +#endif
62972 + return;
62973 +}
62974 diff --git a/grsecurity/grsec_chroot.c b/grsecurity/grsec_chroot.c
62975 new file mode 100644
62976 index 0000000..bd6e105
62977 --- /dev/null
62978 +++ b/grsecurity/grsec_chroot.c
62979 @@ -0,0 +1,370 @@
62980 +#include <linux/kernel.h>
62981 +#include <linux/module.h>
62982 +#include <linux/sched.h>
62983 +#include <linux/file.h>
62984 +#include <linux/fs.h>
62985 +#include <linux/mount.h>
62986 +#include <linux/types.h>
62987 +#include "../fs/mount.h"
62988 +#include <linux/grsecurity.h>
62989 +#include <linux/grinternal.h>
62990 +
62991 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
62992 +static int gr_init_ran;
62993 +#endif
62994 +
62995 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path)
62996 +{
62997 +#ifdef CONFIG_GRKERNSEC
62998 + if (task_pid_nr(task) > 1 && path->dentry != init_task.fs->root.dentry &&
62999 + path->dentry != task->nsproxy->mnt_ns->root->mnt.mnt_root
63000 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
63001 + && gr_init_ran
63002 +#endif
63003 + )
63004 + task->gr_is_chrooted = 1;
63005 + else {
63006 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
63007 + if (task_pid_nr(task) == 1 && !gr_init_ran)
63008 + gr_init_ran = 1;
63009 +#endif
63010 + task->gr_is_chrooted = 0;
63011 + }
63012 +
63013 + task->gr_chroot_dentry = path->dentry;
63014 +#endif
63015 + return;
63016 +}
63017 +
63018 +void gr_clear_chroot_entries(struct task_struct *task)
63019 +{
63020 +#ifdef CONFIG_GRKERNSEC
63021 + task->gr_is_chrooted = 0;
63022 + task->gr_chroot_dentry = NULL;
63023 +#endif
63024 + return;
63025 +}
63026 +
63027 +int
63028 +gr_handle_chroot_unix(const pid_t pid)
63029 +{
63030 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
63031 + struct task_struct *p;
63032 +
63033 + if (unlikely(!grsec_enable_chroot_unix))
63034 + return 1;
63035 +
63036 + if (likely(!proc_is_chrooted(current)))
63037 + return 1;
63038 +
63039 + rcu_read_lock();
63040 + read_lock(&tasklist_lock);
63041 + p = find_task_by_vpid_unrestricted(pid);
63042 + if (unlikely(p && !have_same_root(current, p))) {
63043 + read_unlock(&tasklist_lock);
63044 + rcu_read_unlock();
63045 + gr_log_noargs(GR_DONT_AUDIT, GR_UNIX_CHROOT_MSG);
63046 + return 0;
63047 + }
63048 + read_unlock(&tasklist_lock);
63049 + rcu_read_unlock();
63050 +#endif
63051 + return 1;
63052 +}
63053 +
63054 +int
63055 +gr_handle_chroot_nice(void)
63056 +{
63057 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
63058 + if (grsec_enable_chroot_nice && proc_is_chrooted(current)) {
63059 + gr_log_noargs(GR_DONT_AUDIT, GR_NICE_CHROOT_MSG);
63060 + return -EPERM;
63061 + }
63062 +#endif
63063 + return 0;
63064 +}
63065 +
63066 +int
63067 +gr_handle_chroot_setpriority(struct task_struct *p, const int niceval)
63068 +{
63069 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
63070 + if (grsec_enable_chroot_nice && (niceval < task_nice(p))
63071 + && proc_is_chrooted(current)) {
63072 + gr_log_str_int(GR_DONT_AUDIT, GR_PRIORITY_CHROOT_MSG, p->comm, task_pid_nr(p));
63073 + return -EACCES;
63074 + }
63075 +#endif
63076 + return 0;
63077 +}
63078 +
63079 +int
63080 +gr_handle_chroot_fowner(struct pid *pid, enum pid_type type)
63081 +{
63082 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
63083 + struct task_struct *p;
63084 + int ret = 0;
63085 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || !pid)
63086 + return ret;
63087 +
63088 + read_lock(&tasklist_lock);
63089 + do_each_pid_task(pid, type, p) {
63090 + if (!have_same_root(current, p)) {
63091 + ret = 1;
63092 + goto out;
63093 + }
63094 + } while_each_pid_task(pid, type, p);
63095 +out:
63096 + read_unlock(&tasklist_lock);
63097 + return ret;
63098 +#endif
63099 + return 0;
63100 +}
63101 +
63102 +int
63103 +gr_pid_is_chrooted(struct task_struct *p)
63104 +{
63105 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
63106 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || p == NULL)
63107 + return 0;
63108 +
63109 + if ((p->exit_state & (EXIT_ZOMBIE | EXIT_DEAD)) ||
63110 + !have_same_root(current, p)) {
63111 + return 1;
63112 + }
63113 +#endif
63114 + return 0;
63115 +}
63116 +
63117 +EXPORT_SYMBOL(gr_pid_is_chrooted);
63118 +
63119 +#if defined(CONFIG_GRKERNSEC_CHROOT_DOUBLE) || defined(CONFIG_GRKERNSEC_CHROOT_FCHDIR)
63120 +int gr_is_outside_chroot(const struct dentry *u_dentry, const struct vfsmount *u_mnt)
63121 +{
63122 + struct path path, currentroot;
63123 + int ret = 0;
63124 +
63125 + path.dentry = (struct dentry *)u_dentry;
63126 + path.mnt = (struct vfsmount *)u_mnt;
63127 + get_fs_root(current->fs, &currentroot);
63128 + if (path_is_under(&path, &currentroot))
63129 + ret = 1;
63130 + path_put(&currentroot);
63131 +
63132 + return ret;
63133 +}
63134 +#endif
63135 +
63136 +int
63137 +gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt)
63138 +{
63139 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
63140 + if (!grsec_enable_chroot_fchdir)
63141 + return 1;
63142 +
63143 + if (!proc_is_chrooted(current))
63144 + return 1;
63145 + else if (!gr_is_outside_chroot(u_dentry, u_mnt)) {
63146 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_FCHDIR_MSG, u_dentry, u_mnt);
63147 + return 0;
63148 + }
63149 +#endif
63150 + return 1;
63151 +}
63152 +
63153 +int
63154 +gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
63155 + const time_t shm_createtime)
63156 +{
63157 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
63158 + struct task_struct *p;
63159 + time_t starttime;
63160 +
63161 + if (unlikely(!grsec_enable_chroot_shmat))
63162 + return 1;
63163 +
63164 + if (likely(!proc_is_chrooted(current)))
63165 + return 1;
63166 +
63167 + rcu_read_lock();
63168 + read_lock(&tasklist_lock);
63169 +
63170 + if ((p = find_task_by_vpid_unrestricted(shm_cprid))) {
63171 + starttime = p->start_time.tv_sec;
63172 + if (time_before_eq((unsigned long)starttime, (unsigned long)shm_createtime)) {
63173 + if (have_same_root(current, p)) {
63174 + goto allow;
63175 + } else {
63176 + read_unlock(&tasklist_lock);
63177 + rcu_read_unlock();
63178 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
63179 + return 0;
63180 + }
63181 + }
63182 + /* creator exited, pid reuse, fall through to next check */
63183 + }
63184 + if ((p = find_task_by_vpid_unrestricted(shm_lapid))) {
63185 + if (unlikely(!have_same_root(current, p))) {
63186 + read_unlock(&tasklist_lock);
63187 + rcu_read_unlock();
63188 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
63189 + return 0;
63190 + }
63191 + }
63192 +
63193 +allow:
63194 + read_unlock(&tasklist_lock);
63195 + rcu_read_unlock();
63196 +#endif
63197 + return 1;
63198 +}
63199 +
63200 +void
63201 +gr_log_chroot_exec(const struct dentry *dentry, const struct vfsmount *mnt)
63202 +{
63203 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
63204 + if (grsec_enable_chroot_execlog && proc_is_chrooted(current))
63205 + gr_log_fs_generic(GR_DO_AUDIT, GR_EXEC_CHROOT_MSG, dentry, mnt);
63206 +#endif
63207 + return;
63208 +}
63209 +
63210 +int
63211 +gr_handle_chroot_mknod(const struct dentry *dentry,
63212 + const struct vfsmount *mnt, const int mode)
63213 +{
63214 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
63215 + if (grsec_enable_chroot_mknod && !S_ISFIFO(mode) && !S_ISREG(mode) &&
63216 + proc_is_chrooted(current)) {
63217 + gr_log_fs_generic(GR_DONT_AUDIT, GR_MKNOD_CHROOT_MSG, dentry, mnt);
63218 + return -EPERM;
63219 + }
63220 +#endif
63221 + return 0;
63222 +}
63223 +
63224 +int
63225 +gr_handle_chroot_mount(const struct dentry *dentry,
63226 + const struct vfsmount *mnt, const char *dev_name)
63227 +{
63228 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
63229 + if (grsec_enable_chroot_mount && proc_is_chrooted(current)) {
63230 + gr_log_str_fs(GR_DONT_AUDIT, GR_MOUNT_CHROOT_MSG, dev_name ? dev_name : "none", dentry, mnt);
63231 + return -EPERM;
63232 + }
63233 +#endif
63234 + return 0;
63235 +}
63236 +
63237 +int
63238 +gr_handle_chroot_pivot(void)
63239 +{
63240 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
63241 + if (grsec_enable_chroot_pivot && proc_is_chrooted(current)) {
63242 + gr_log_noargs(GR_DONT_AUDIT, GR_PIVOT_CHROOT_MSG);
63243 + return -EPERM;
63244 + }
63245 +#endif
63246 + return 0;
63247 +}
63248 +
63249 +int
63250 +gr_handle_chroot_chroot(const struct dentry *dentry, const struct vfsmount *mnt)
63251 +{
63252 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
63253 + if (grsec_enable_chroot_double && proc_is_chrooted(current) &&
63254 + !gr_is_outside_chroot(dentry, mnt)) {
63255 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_CHROOT_MSG, dentry, mnt);
63256 + return -EPERM;
63257 + }
63258 +#endif
63259 + return 0;
63260 +}
63261 +
63262 +extern const char *captab_log[];
63263 +extern int captab_log_entries;
63264 +
63265 +int
63266 +gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
63267 +{
63268 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
63269 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
63270 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
63271 + if (cap_raised(chroot_caps, cap)) {
63272 + if (cap_raised(cred->cap_effective, cap) && cap < captab_log_entries) {
63273 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_CHROOT_MSG, task, captab_log[cap]);
63274 + }
63275 + return 0;
63276 + }
63277 + }
63278 +#endif
63279 + return 1;
63280 +}
63281 +
63282 +int
63283 +gr_chroot_is_capable(const int cap)
63284 +{
63285 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
63286 + return gr_task_chroot_is_capable(current, current_cred(), cap);
63287 +#endif
63288 + return 1;
63289 +}
63290 +
63291 +int
63292 +gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap)
63293 +{
63294 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
63295 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
63296 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
63297 + if (cap_raised(chroot_caps, cap)) {
63298 + return 0;
63299 + }
63300 + }
63301 +#endif
63302 + return 1;
63303 +}
63304 +
63305 +int
63306 +gr_chroot_is_capable_nolog(const int cap)
63307 +{
63308 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
63309 + return gr_task_chroot_is_capable_nolog(current, cap);
63310 +#endif
63311 + return 1;
63312 +}
63313 +
63314 +int
63315 +gr_handle_chroot_sysctl(const int op)
63316 +{
63317 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
63318 + if (grsec_enable_chroot_sysctl && (op & MAY_WRITE) &&
63319 + proc_is_chrooted(current))
63320 + return -EACCES;
63321 +#endif
63322 + return 0;
63323 +}
63324 +
63325 +void
63326 +gr_handle_chroot_chdir(const struct path *path)
63327 +{
63328 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
63329 + if (grsec_enable_chroot_chdir)
63330 + set_fs_pwd(current->fs, path);
63331 +#endif
63332 + return;
63333 +}
63334 +
63335 +int
63336 +gr_handle_chroot_chmod(const struct dentry *dentry,
63337 + const struct vfsmount *mnt, const int mode)
63338 +{
63339 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
63340 + /* allow chmod +s on directories, but not files */
63341 + if (grsec_enable_chroot_chmod && !S_ISDIR(dentry->d_inode->i_mode) &&
63342 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))) &&
63343 + proc_is_chrooted(current)) {
63344 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHMOD_CHROOT_MSG, dentry, mnt);
63345 + return -EPERM;
63346 + }
63347 +#endif
63348 + return 0;
63349 +}
63350 diff --git a/grsecurity/grsec_disabled.c b/grsecurity/grsec_disabled.c
63351 new file mode 100644
63352 index 0000000..ce65ceb
63353 --- /dev/null
63354 +++ b/grsecurity/grsec_disabled.c
63355 @@ -0,0 +1,434 @@
63356 +#include <linux/kernel.h>
63357 +#include <linux/module.h>
63358 +#include <linux/sched.h>
63359 +#include <linux/file.h>
63360 +#include <linux/fs.h>
63361 +#include <linux/kdev_t.h>
63362 +#include <linux/net.h>
63363 +#include <linux/in.h>
63364 +#include <linux/ip.h>
63365 +#include <linux/skbuff.h>
63366 +#include <linux/sysctl.h>
63367 +
63368 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
63369 +void
63370 +pax_set_initial_flags(struct linux_binprm *bprm)
63371 +{
63372 + return;
63373 +}
63374 +#endif
63375 +
63376 +#ifdef CONFIG_SYSCTL
63377 +__u32
63378 +gr_handle_sysctl(const struct ctl_table * table, const int op)
63379 +{
63380 + return 0;
63381 +}
63382 +#endif
63383 +
63384 +#ifdef CONFIG_TASKSTATS
63385 +int gr_is_taskstats_denied(int pid)
63386 +{
63387 + return 0;
63388 +}
63389 +#endif
63390 +
63391 +int
63392 +gr_acl_is_enabled(void)
63393 +{
63394 + return 0;
63395 +}
63396 +
63397 +void
63398 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
63399 +{
63400 + return;
63401 +}
63402 +
63403 +int
63404 +gr_handle_rawio(const struct inode *inode)
63405 +{
63406 + return 0;
63407 +}
63408 +
63409 +void
63410 +gr_acl_handle_psacct(struct task_struct *task, const long code)
63411 +{
63412 + return;
63413 +}
63414 +
63415 +int
63416 +gr_handle_ptrace(struct task_struct *task, const long request)
63417 +{
63418 + return 0;
63419 +}
63420 +
63421 +int
63422 +gr_handle_proc_ptrace(struct task_struct *task)
63423 +{
63424 + return 0;
63425 +}
63426 +
63427 +int
63428 +gr_set_acls(const int type)
63429 +{
63430 + return 0;
63431 +}
63432 +
63433 +int
63434 +gr_check_hidden_task(const struct task_struct *tsk)
63435 +{
63436 + return 0;
63437 +}
63438 +
63439 +int
63440 +gr_check_protected_task(const struct task_struct *task)
63441 +{
63442 + return 0;
63443 +}
63444 +
63445 +int
63446 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
63447 +{
63448 + return 0;
63449 +}
63450 +
63451 +void
63452 +gr_copy_label(struct task_struct *tsk)
63453 +{
63454 + return;
63455 +}
63456 +
63457 +void
63458 +gr_set_pax_flags(struct task_struct *task)
63459 +{
63460 + return;
63461 +}
63462 +
63463 +int
63464 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
63465 + const int unsafe_share)
63466 +{
63467 + return 0;
63468 +}
63469 +
63470 +void
63471 +gr_handle_delete(const ino_t ino, const dev_t dev)
63472 +{
63473 + return;
63474 +}
63475 +
63476 +void
63477 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
63478 +{
63479 + return;
63480 +}
63481 +
63482 +void
63483 +gr_handle_crash(struct task_struct *task, const int sig)
63484 +{
63485 + return;
63486 +}
63487 +
63488 +int
63489 +gr_check_crash_exec(const struct file *filp)
63490 +{
63491 + return 0;
63492 +}
63493 +
63494 +int
63495 +gr_check_crash_uid(const kuid_t uid)
63496 +{
63497 + return 0;
63498 +}
63499 +
63500 +void
63501 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
63502 + struct dentry *old_dentry,
63503 + struct dentry *new_dentry,
63504 + struct vfsmount *mnt, const __u8 replace)
63505 +{
63506 + return;
63507 +}
63508 +
63509 +int
63510 +gr_search_socket(const int family, const int type, const int protocol)
63511 +{
63512 + return 1;
63513 +}
63514 +
63515 +int
63516 +gr_search_connectbind(const int mode, const struct socket *sock,
63517 + const struct sockaddr_in *addr)
63518 +{
63519 + return 0;
63520 +}
63521 +
63522 +void
63523 +gr_handle_alertkill(struct task_struct *task)
63524 +{
63525 + return;
63526 +}
63527 +
63528 +__u32
63529 +gr_acl_handle_execve(const struct dentry * dentry, const struct vfsmount * mnt)
63530 +{
63531 + return 1;
63532 +}
63533 +
63534 +__u32
63535 +gr_acl_handle_hidden_file(const struct dentry * dentry,
63536 + const struct vfsmount * mnt)
63537 +{
63538 + return 1;
63539 +}
63540 +
63541 +__u32
63542 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
63543 + int acc_mode)
63544 +{
63545 + return 1;
63546 +}
63547 +
63548 +__u32
63549 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
63550 +{
63551 + return 1;
63552 +}
63553 +
63554 +__u32
63555 +gr_acl_handle_unlink(const struct dentry * dentry, const struct vfsmount * mnt)
63556 +{
63557 + return 1;
63558 +}
63559 +
63560 +int
63561 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot,
63562 + unsigned int *vm_flags)
63563 +{
63564 + return 1;
63565 +}
63566 +
63567 +__u32
63568 +gr_acl_handle_truncate(const struct dentry * dentry,
63569 + const struct vfsmount * mnt)
63570 +{
63571 + return 1;
63572 +}
63573 +
63574 +__u32
63575 +gr_acl_handle_utime(const struct dentry * dentry, const struct vfsmount * mnt)
63576 +{
63577 + return 1;
63578 +}
63579 +
63580 +__u32
63581 +gr_acl_handle_access(const struct dentry * dentry,
63582 + const struct vfsmount * mnt, const int fmode)
63583 +{
63584 + return 1;
63585 +}
63586 +
63587 +__u32
63588 +gr_acl_handle_chmod(const struct dentry * dentry, const struct vfsmount * mnt,
63589 + umode_t *mode)
63590 +{
63591 + return 1;
63592 +}
63593 +
63594 +__u32
63595 +gr_acl_handle_chown(const struct dentry * dentry, const struct vfsmount * mnt)
63596 +{
63597 + return 1;
63598 +}
63599 +
63600 +__u32
63601 +gr_acl_handle_setxattr(const struct dentry * dentry, const struct vfsmount * mnt)
63602 +{
63603 + return 1;
63604 +}
63605 +
63606 +void
63607 +grsecurity_init(void)
63608 +{
63609 + return;
63610 +}
63611 +
63612 +umode_t gr_acl_umask(void)
63613 +{
63614 + return 0;
63615 +}
63616 +
63617 +__u32
63618 +gr_acl_handle_mknod(const struct dentry * new_dentry,
63619 + const struct dentry * parent_dentry,
63620 + const struct vfsmount * parent_mnt,
63621 + const int mode)
63622 +{
63623 + return 1;
63624 +}
63625 +
63626 +__u32
63627 +gr_acl_handle_mkdir(const struct dentry * new_dentry,
63628 + const struct dentry * parent_dentry,
63629 + const struct vfsmount * parent_mnt)
63630 +{
63631 + return 1;
63632 +}
63633 +
63634 +__u32
63635 +gr_acl_handle_symlink(const struct dentry * new_dentry,
63636 + const struct dentry * parent_dentry,
63637 + const struct vfsmount * parent_mnt, const struct filename *from)
63638 +{
63639 + return 1;
63640 +}
63641 +
63642 +__u32
63643 +gr_acl_handle_link(const struct dentry * new_dentry,
63644 + const struct dentry * parent_dentry,
63645 + const struct vfsmount * parent_mnt,
63646 + const struct dentry * old_dentry,
63647 + const struct vfsmount * old_mnt, const struct filename *to)
63648 +{
63649 + return 1;
63650 +}
63651 +
63652 +int
63653 +gr_acl_handle_rename(const struct dentry *new_dentry,
63654 + const struct dentry *parent_dentry,
63655 + const struct vfsmount *parent_mnt,
63656 + const struct dentry *old_dentry,
63657 + const struct inode *old_parent_inode,
63658 + const struct vfsmount *old_mnt, const struct filename *newname)
63659 +{
63660 + return 0;
63661 +}
63662 +
63663 +int
63664 +gr_acl_handle_filldir(const struct file *file, const char *name,
63665 + const int namelen, const ino_t ino)
63666 +{
63667 + return 1;
63668 +}
63669 +
63670 +int
63671 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
63672 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
63673 +{
63674 + return 1;
63675 +}
63676 +
63677 +int
63678 +gr_search_bind(const struct socket *sock, const struct sockaddr_in *addr)
63679 +{
63680 + return 0;
63681 +}
63682 +
63683 +int
63684 +gr_search_accept(const struct socket *sock)
63685 +{
63686 + return 0;
63687 +}
63688 +
63689 +int
63690 +gr_search_listen(const struct socket *sock)
63691 +{
63692 + return 0;
63693 +}
63694 +
63695 +int
63696 +gr_search_connect(const struct socket *sock, const struct sockaddr_in *addr)
63697 +{
63698 + return 0;
63699 +}
63700 +
63701 +__u32
63702 +gr_acl_handle_unix(const struct dentry * dentry, const struct vfsmount * mnt)
63703 +{
63704 + return 1;
63705 +}
63706 +
63707 +__u32
63708 +gr_acl_handle_creat(const struct dentry * dentry,
63709 + const struct dentry * p_dentry,
63710 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
63711 + const int imode)
63712 +{
63713 + return 1;
63714 +}
63715 +
63716 +void
63717 +gr_acl_handle_exit(void)
63718 +{
63719 + return;
63720 +}
63721 +
63722 +int
63723 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
63724 +{
63725 + return 1;
63726 +}
63727 +
63728 +void
63729 +gr_set_role_label(const kuid_t uid, const kgid_t gid)
63730 +{
63731 + return;
63732 +}
63733 +
63734 +int
63735 +gr_acl_handle_procpidmem(const struct task_struct *task)
63736 +{
63737 + return 0;
63738 +}
63739 +
63740 +int
63741 +gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb)
63742 +{
63743 + return 0;
63744 +}
63745 +
63746 +int
63747 +gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr)
63748 +{
63749 + return 0;
63750 +}
63751 +
63752 +void
63753 +gr_set_kernel_label(struct task_struct *task)
63754 +{
63755 + return;
63756 +}
63757 +
63758 +int
63759 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
63760 +{
63761 + return 0;
63762 +}
63763 +
63764 +int
63765 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
63766 +{
63767 + return 0;
63768 +}
63769 +
63770 +int gr_acl_enable_at_secure(void)
63771 +{
63772 + return 0;
63773 +}
63774 +
63775 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
63776 +{
63777 + return dentry->d_sb->s_dev;
63778 +}
63779 +
63780 +void gr_put_exec_file(struct task_struct *task)
63781 +{
63782 + return;
63783 +}
63784 +
63785 +EXPORT_SYMBOL(gr_set_kernel_label);
63786 +#ifdef CONFIG_SECURITY
63787 +EXPORT_SYMBOL(gr_check_user_change);
63788 +EXPORT_SYMBOL(gr_check_group_change);
63789 +#endif
63790 diff --git a/grsecurity/grsec_exec.c b/grsecurity/grsec_exec.c
63791 new file mode 100644
63792 index 0000000..387032b
63793 --- /dev/null
63794 +++ b/grsecurity/grsec_exec.c
63795 @@ -0,0 +1,187 @@
63796 +#include <linux/kernel.h>
63797 +#include <linux/sched.h>
63798 +#include <linux/file.h>
63799 +#include <linux/binfmts.h>
63800 +#include <linux/fs.h>
63801 +#include <linux/types.h>
63802 +#include <linux/grdefs.h>
63803 +#include <linux/grsecurity.h>
63804 +#include <linux/grinternal.h>
63805 +#include <linux/capability.h>
63806 +#include <linux/module.h>
63807 +#include <linux/compat.h>
63808 +
63809 +#include <asm/uaccess.h>
63810 +
63811 +#ifdef CONFIG_GRKERNSEC_EXECLOG
63812 +static char gr_exec_arg_buf[132];
63813 +static DEFINE_MUTEX(gr_exec_arg_mutex);
63814 +#endif
63815 +
63816 +struct user_arg_ptr {
63817 +#ifdef CONFIG_COMPAT
63818 + bool is_compat;
63819 +#endif
63820 + union {
63821 + const char __user *const __user *native;
63822 +#ifdef CONFIG_COMPAT
63823 + const compat_uptr_t __user *compat;
63824 +#endif
63825 + } ptr;
63826 +};
63827 +
63828 +extern const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr);
63829 +
63830 +void
63831 +gr_handle_exec_args(struct linux_binprm *bprm, struct user_arg_ptr argv)
63832 +{
63833 +#ifdef CONFIG_GRKERNSEC_EXECLOG
63834 + char *grarg = gr_exec_arg_buf;
63835 + unsigned int i, x, execlen = 0;
63836 + char c;
63837 +
63838 + if (!((grsec_enable_execlog && grsec_enable_group &&
63839 + in_group_p(grsec_audit_gid))
63840 + || (grsec_enable_execlog && !grsec_enable_group)))
63841 + return;
63842 +
63843 + mutex_lock(&gr_exec_arg_mutex);
63844 + memset(grarg, 0, sizeof(gr_exec_arg_buf));
63845 +
63846 + for (i = 0; i < bprm->argc && execlen < 128; i++) {
63847 + const char __user *p;
63848 + unsigned int len;
63849 +
63850 + p = get_user_arg_ptr(argv, i);
63851 + if (IS_ERR(p))
63852 + goto log;
63853 +
63854 + len = strnlen_user(p, 128 - execlen);
63855 + if (len > 128 - execlen)
63856 + len = 128 - execlen;
63857 + else if (len > 0)
63858 + len--;
63859 + if (copy_from_user(grarg + execlen, p, len))
63860 + goto log;
63861 +
63862 + /* rewrite unprintable characters */
63863 + for (x = 0; x < len; x++) {
63864 + c = *(grarg + execlen + x);
63865 + if (c < 32 || c > 126)
63866 + *(grarg + execlen + x) = ' ';
63867 + }
63868 +
63869 + execlen += len;
63870 + *(grarg + execlen) = ' ';
63871 + *(grarg + execlen + 1) = '\0';
63872 + execlen++;
63873 + }
63874 +
63875 + log:
63876 + gr_log_fs_str(GR_DO_AUDIT, GR_EXEC_AUDIT_MSG, bprm->file->f_path.dentry,
63877 + bprm->file->f_path.mnt, grarg);
63878 + mutex_unlock(&gr_exec_arg_mutex);
63879 +#endif
63880 + return;
63881 +}
63882 +
63883 +#ifdef CONFIG_GRKERNSEC
63884 +extern int gr_acl_is_capable(const int cap);
63885 +extern int gr_acl_is_capable_nolog(const int cap);
63886 +extern int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
63887 +extern int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap);
63888 +extern int gr_chroot_is_capable(const int cap);
63889 +extern int gr_chroot_is_capable_nolog(const int cap);
63890 +extern int gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
63891 +extern int gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap);
63892 +#endif
63893 +
63894 +const char *captab_log[] = {
63895 + "CAP_CHOWN",
63896 + "CAP_DAC_OVERRIDE",
63897 + "CAP_DAC_READ_SEARCH",
63898 + "CAP_FOWNER",
63899 + "CAP_FSETID",
63900 + "CAP_KILL",
63901 + "CAP_SETGID",
63902 + "CAP_SETUID",
63903 + "CAP_SETPCAP",
63904 + "CAP_LINUX_IMMUTABLE",
63905 + "CAP_NET_BIND_SERVICE",
63906 + "CAP_NET_BROADCAST",
63907 + "CAP_NET_ADMIN",
63908 + "CAP_NET_RAW",
63909 + "CAP_IPC_LOCK",
63910 + "CAP_IPC_OWNER",
63911 + "CAP_SYS_MODULE",
63912 + "CAP_SYS_RAWIO",
63913 + "CAP_SYS_CHROOT",
63914 + "CAP_SYS_PTRACE",
63915 + "CAP_SYS_PACCT",
63916 + "CAP_SYS_ADMIN",
63917 + "CAP_SYS_BOOT",
63918 + "CAP_SYS_NICE",
63919 + "CAP_SYS_RESOURCE",
63920 + "CAP_SYS_TIME",
63921 + "CAP_SYS_TTY_CONFIG",
63922 + "CAP_MKNOD",
63923 + "CAP_LEASE",
63924 + "CAP_AUDIT_WRITE",
63925 + "CAP_AUDIT_CONTROL",
63926 + "CAP_SETFCAP",
63927 + "CAP_MAC_OVERRIDE",
63928 + "CAP_MAC_ADMIN",
63929 + "CAP_SYSLOG",
63930 + "CAP_WAKE_ALARM"
63931 +};
63932 +
63933 +int captab_log_entries = sizeof(captab_log)/sizeof(captab_log[0]);
63934 +
63935 +int gr_is_capable(const int cap)
63936 +{
63937 +#ifdef CONFIG_GRKERNSEC
63938 + if (gr_acl_is_capable(cap) && gr_chroot_is_capable(cap))
63939 + return 1;
63940 + return 0;
63941 +#else
63942 + return 1;
63943 +#endif
63944 +}
63945 +
63946 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
63947 +{
63948 +#ifdef CONFIG_GRKERNSEC
63949 + if (gr_task_acl_is_capable(task, cred, cap) && gr_task_chroot_is_capable(task, cred, cap))
63950 + return 1;
63951 + return 0;
63952 +#else
63953 + return 1;
63954 +#endif
63955 +}
63956 +
63957 +int gr_is_capable_nolog(const int cap)
63958 +{
63959 +#ifdef CONFIG_GRKERNSEC
63960 + if (gr_acl_is_capable_nolog(cap) && gr_chroot_is_capable_nolog(cap))
63961 + return 1;
63962 + return 0;
63963 +#else
63964 + return 1;
63965 +#endif
63966 +}
63967 +
63968 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap)
63969 +{
63970 +#ifdef CONFIG_GRKERNSEC
63971 + if (gr_task_acl_is_capable_nolog(task, cap) && gr_task_chroot_is_capable_nolog(task, cap))
63972 + return 1;
63973 + return 0;
63974 +#else
63975 + return 1;
63976 +#endif
63977 +}
63978 +
63979 +EXPORT_SYMBOL(gr_is_capable);
63980 +EXPORT_SYMBOL(gr_is_capable_nolog);
63981 +EXPORT_SYMBOL(gr_task_is_capable);
63982 +EXPORT_SYMBOL(gr_task_is_capable_nolog);
63983 diff --git a/grsecurity/grsec_fifo.c b/grsecurity/grsec_fifo.c
63984 new file mode 100644
63985 index 0000000..06cc6ea
63986 --- /dev/null
63987 +++ b/grsecurity/grsec_fifo.c
63988 @@ -0,0 +1,24 @@
63989 +#include <linux/kernel.h>
63990 +#include <linux/sched.h>
63991 +#include <linux/fs.h>
63992 +#include <linux/file.h>
63993 +#include <linux/grinternal.h>
63994 +
63995 +int
63996 +gr_handle_fifo(const struct dentry *dentry, const struct vfsmount *mnt,
63997 + const struct dentry *dir, const int flag, const int acc_mode)
63998 +{
63999 +#ifdef CONFIG_GRKERNSEC_FIFO
64000 + const struct cred *cred = current_cred();
64001 +
64002 + if (grsec_enable_fifo && S_ISFIFO(dentry->d_inode->i_mode) &&
64003 + !(flag & O_EXCL) && (dir->d_inode->i_mode & S_ISVTX) &&
64004 + !uid_eq(dentry->d_inode->i_uid, dir->d_inode->i_uid) &&
64005 + !uid_eq(cred->fsuid, dentry->d_inode->i_uid)) {
64006 + if (!inode_permission(dentry->d_inode, acc_mode))
64007 + 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));
64008 + return -EACCES;
64009 + }
64010 +#endif
64011 + return 0;
64012 +}
64013 diff --git a/grsecurity/grsec_fork.c b/grsecurity/grsec_fork.c
64014 new file mode 100644
64015 index 0000000..8ca18bf
64016 --- /dev/null
64017 +++ b/grsecurity/grsec_fork.c
64018 @@ -0,0 +1,23 @@
64019 +#include <linux/kernel.h>
64020 +#include <linux/sched.h>
64021 +#include <linux/grsecurity.h>
64022 +#include <linux/grinternal.h>
64023 +#include <linux/errno.h>
64024 +
64025 +void
64026 +gr_log_forkfail(const int retval)
64027 +{
64028 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
64029 + if (grsec_enable_forkfail && (retval == -EAGAIN || retval == -ENOMEM)) {
64030 + switch (retval) {
64031 + case -EAGAIN:
64032 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "EAGAIN");
64033 + break;
64034 + case -ENOMEM:
64035 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "ENOMEM");
64036 + break;
64037 + }
64038 + }
64039 +#endif
64040 + return;
64041 +}
64042 diff --git a/grsecurity/grsec_init.c b/grsecurity/grsec_init.c
64043 new file mode 100644
64044 index 0000000..a862e9f
64045 --- /dev/null
64046 +++ b/grsecurity/grsec_init.c
64047 @@ -0,0 +1,283 @@
64048 +#include <linux/kernel.h>
64049 +#include <linux/sched.h>
64050 +#include <linux/mm.h>
64051 +#include <linux/gracl.h>
64052 +#include <linux/slab.h>
64053 +#include <linux/vmalloc.h>
64054 +#include <linux/percpu.h>
64055 +#include <linux/module.h>
64056 +
64057 +int grsec_enable_ptrace_readexec;
64058 +int grsec_enable_setxid;
64059 +int grsec_enable_symlinkown;
64060 +kgid_t grsec_symlinkown_gid;
64061 +int grsec_enable_brute;
64062 +int grsec_enable_link;
64063 +int grsec_enable_dmesg;
64064 +int grsec_enable_harden_ptrace;
64065 +int grsec_enable_fifo;
64066 +int grsec_enable_execlog;
64067 +int grsec_enable_signal;
64068 +int grsec_enable_forkfail;
64069 +int grsec_enable_audit_ptrace;
64070 +int grsec_enable_time;
64071 +int grsec_enable_audit_textrel;
64072 +int grsec_enable_group;
64073 +kgid_t grsec_audit_gid;
64074 +int grsec_enable_chdir;
64075 +int grsec_enable_mount;
64076 +int grsec_enable_rofs;
64077 +int grsec_enable_chroot_findtask;
64078 +int grsec_enable_chroot_mount;
64079 +int grsec_enable_chroot_shmat;
64080 +int grsec_enable_chroot_fchdir;
64081 +int grsec_enable_chroot_double;
64082 +int grsec_enable_chroot_pivot;
64083 +int grsec_enable_chroot_chdir;
64084 +int grsec_enable_chroot_chmod;
64085 +int grsec_enable_chroot_mknod;
64086 +int grsec_enable_chroot_nice;
64087 +int grsec_enable_chroot_execlog;
64088 +int grsec_enable_chroot_caps;
64089 +int grsec_enable_chroot_sysctl;
64090 +int grsec_enable_chroot_unix;
64091 +int grsec_enable_tpe;
64092 +kgid_t grsec_tpe_gid;
64093 +int grsec_enable_blackhole;
64094 +#ifdef CONFIG_IPV6_MODULE
64095 +EXPORT_SYMBOL(grsec_enable_blackhole);
64096 +#endif
64097 +int grsec_lastack_retries;
64098 +int grsec_enable_tpe_all;
64099 +int grsec_enable_tpe_invert;
64100 +int grsec_enable_socket_all;
64101 +kgid_t grsec_socket_all_gid;
64102 +int grsec_enable_socket_client;
64103 +kgid_t grsec_socket_client_gid;
64104 +int grsec_enable_socket_server;
64105 +kgid_t grsec_socket_server_gid;
64106 +int grsec_resource_logging;
64107 +int grsec_disable_privio;
64108 +int grsec_enable_log_rwxmaps;
64109 +int grsec_lock;
64110 +
64111 +DEFINE_SPINLOCK(grsec_alert_lock);
64112 +unsigned long grsec_alert_wtime = 0;
64113 +unsigned long grsec_alert_fyet = 0;
64114 +
64115 +DEFINE_SPINLOCK(grsec_audit_lock);
64116 +
64117 +DEFINE_RWLOCK(grsec_exec_file_lock);
64118 +
64119 +char *gr_shared_page[4];
64120 +
64121 +char *gr_alert_log_fmt;
64122 +char *gr_audit_log_fmt;
64123 +char *gr_alert_log_buf;
64124 +char *gr_audit_log_buf;
64125 +
64126 +extern struct gr_arg *gr_usermode;
64127 +extern unsigned char *gr_system_salt;
64128 +extern unsigned char *gr_system_sum;
64129 +
64130 +void __init
64131 +grsecurity_init(void)
64132 +{
64133 + int j;
64134 + /* create the per-cpu shared pages */
64135 +
64136 +#ifdef CONFIG_X86
64137 + memset((char *)(0x41a + PAGE_OFFSET), 0, 36);
64138 +#endif
64139 +
64140 + for (j = 0; j < 4; j++) {
64141 + gr_shared_page[j] = (char *)__alloc_percpu(PAGE_SIZE, __alignof__(unsigned long long));
64142 + if (gr_shared_page[j] == NULL) {
64143 + panic("Unable to allocate grsecurity shared page");
64144 + return;
64145 + }
64146 + }
64147 +
64148 + /* allocate log buffers */
64149 + gr_alert_log_fmt = kmalloc(512, GFP_KERNEL);
64150 + if (!gr_alert_log_fmt) {
64151 + panic("Unable to allocate grsecurity alert log format buffer");
64152 + return;
64153 + }
64154 + gr_audit_log_fmt = kmalloc(512, GFP_KERNEL);
64155 + if (!gr_audit_log_fmt) {
64156 + panic("Unable to allocate grsecurity audit log format buffer");
64157 + return;
64158 + }
64159 + gr_alert_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
64160 + if (!gr_alert_log_buf) {
64161 + panic("Unable to allocate grsecurity alert log buffer");
64162 + return;
64163 + }
64164 + gr_audit_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
64165 + if (!gr_audit_log_buf) {
64166 + panic("Unable to allocate grsecurity audit log buffer");
64167 + return;
64168 + }
64169 +
64170 + /* allocate memory for authentication structure */
64171 + gr_usermode = kmalloc(sizeof(struct gr_arg), GFP_KERNEL);
64172 + gr_system_salt = kmalloc(GR_SALT_LEN, GFP_KERNEL);
64173 + gr_system_sum = kmalloc(GR_SHA_LEN, GFP_KERNEL);
64174 +
64175 + if (!gr_usermode || !gr_system_salt || !gr_system_sum) {
64176 + panic("Unable to allocate grsecurity authentication structure");
64177 + return;
64178 + }
64179 +
64180 +
64181 +#ifdef CONFIG_GRKERNSEC_IO
64182 +#if !defined(CONFIG_GRKERNSEC_SYSCTL_DISTRO)
64183 + grsec_disable_privio = 1;
64184 +#elif defined(CONFIG_GRKERNSEC_SYSCTL_ON)
64185 + grsec_disable_privio = 1;
64186 +#else
64187 + grsec_disable_privio = 0;
64188 +#endif
64189 +#endif
64190 +
64191 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
64192 + /* for backward compatibility, tpe_invert always defaults to on if
64193 + enabled in the kernel
64194 + */
64195 + grsec_enable_tpe_invert = 1;
64196 +#endif
64197 +
64198 +#if !defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_SYSCTL_ON)
64199 +#ifndef CONFIG_GRKERNSEC_SYSCTL
64200 + grsec_lock = 1;
64201 +#endif
64202 +
64203 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
64204 + grsec_enable_audit_textrel = 1;
64205 +#endif
64206 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
64207 + grsec_enable_log_rwxmaps = 1;
64208 +#endif
64209 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
64210 + grsec_enable_group = 1;
64211 + grsec_audit_gid = KGIDT_INIT(CONFIG_GRKERNSEC_AUDIT_GID);
64212 +#endif
64213 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
64214 + grsec_enable_ptrace_readexec = 1;
64215 +#endif
64216 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
64217 + grsec_enable_chdir = 1;
64218 +#endif
64219 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
64220 + grsec_enable_harden_ptrace = 1;
64221 +#endif
64222 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
64223 + grsec_enable_mount = 1;
64224 +#endif
64225 +#ifdef CONFIG_GRKERNSEC_LINK
64226 + grsec_enable_link = 1;
64227 +#endif
64228 +#ifdef CONFIG_GRKERNSEC_BRUTE
64229 + grsec_enable_brute = 1;
64230 +#endif
64231 +#ifdef CONFIG_GRKERNSEC_DMESG
64232 + grsec_enable_dmesg = 1;
64233 +#endif
64234 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
64235 + grsec_enable_blackhole = 1;
64236 + grsec_lastack_retries = 4;
64237 +#endif
64238 +#ifdef CONFIG_GRKERNSEC_FIFO
64239 + grsec_enable_fifo = 1;
64240 +#endif
64241 +#ifdef CONFIG_GRKERNSEC_EXECLOG
64242 + grsec_enable_execlog = 1;
64243 +#endif
64244 +#ifdef CONFIG_GRKERNSEC_SETXID
64245 + grsec_enable_setxid = 1;
64246 +#endif
64247 +#ifdef CONFIG_GRKERNSEC_SIGNAL
64248 + grsec_enable_signal = 1;
64249 +#endif
64250 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
64251 + grsec_enable_forkfail = 1;
64252 +#endif
64253 +#ifdef CONFIG_GRKERNSEC_TIME
64254 + grsec_enable_time = 1;
64255 +#endif
64256 +#ifdef CONFIG_GRKERNSEC_RESLOG
64257 + grsec_resource_logging = 1;
64258 +#endif
64259 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
64260 + grsec_enable_chroot_findtask = 1;
64261 +#endif
64262 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
64263 + grsec_enable_chroot_unix = 1;
64264 +#endif
64265 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
64266 + grsec_enable_chroot_mount = 1;
64267 +#endif
64268 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
64269 + grsec_enable_chroot_fchdir = 1;
64270 +#endif
64271 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
64272 + grsec_enable_chroot_shmat = 1;
64273 +#endif
64274 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
64275 + grsec_enable_audit_ptrace = 1;
64276 +#endif
64277 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
64278 + grsec_enable_chroot_double = 1;
64279 +#endif
64280 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
64281 + grsec_enable_chroot_pivot = 1;
64282 +#endif
64283 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
64284 + grsec_enable_chroot_chdir = 1;
64285 +#endif
64286 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
64287 + grsec_enable_chroot_chmod = 1;
64288 +#endif
64289 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
64290 + grsec_enable_chroot_mknod = 1;
64291 +#endif
64292 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
64293 + grsec_enable_chroot_nice = 1;
64294 +#endif
64295 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
64296 + grsec_enable_chroot_execlog = 1;
64297 +#endif
64298 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
64299 + grsec_enable_chroot_caps = 1;
64300 +#endif
64301 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
64302 + grsec_enable_chroot_sysctl = 1;
64303 +#endif
64304 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
64305 + grsec_enable_symlinkown = 1;
64306 + grsec_symlinkown_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SYMLINKOWN_GID);
64307 +#endif
64308 +#ifdef CONFIG_GRKERNSEC_TPE
64309 + grsec_enable_tpe = 1;
64310 + grsec_tpe_gid = KGIDT_INIT(CONFIG_GRKERNSEC_TPE_GID);
64311 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
64312 + grsec_enable_tpe_all = 1;
64313 +#endif
64314 +#endif
64315 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
64316 + grsec_enable_socket_all = 1;
64317 + grsec_socket_all_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_ALL_GID);
64318 +#endif
64319 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
64320 + grsec_enable_socket_client = 1;
64321 + grsec_socket_client_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_CLIENT_GID);
64322 +#endif
64323 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
64324 + grsec_enable_socket_server = 1;
64325 + grsec_socket_server_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_SERVER_GID);
64326 +#endif
64327 +#endif
64328 +
64329 + return;
64330 +}
64331 diff --git a/grsecurity/grsec_link.c b/grsecurity/grsec_link.c
64332 new file mode 100644
64333 index 0000000..5e05e20
64334 --- /dev/null
64335 +++ b/grsecurity/grsec_link.c
64336 @@ -0,0 +1,58 @@
64337 +#include <linux/kernel.h>
64338 +#include <linux/sched.h>
64339 +#include <linux/fs.h>
64340 +#include <linux/file.h>
64341 +#include <linux/grinternal.h>
64342 +
64343 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target)
64344 +{
64345 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
64346 + const struct inode *link_inode = link->dentry->d_inode;
64347 +
64348 + if (grsec_enable_symlinkown && in_group_p(grsec_symlinkown_gid) &&
64349 + /* ignore root-owned links, e.g. /proc/self */
64350 + gr_is_global_nonroot(link_inode->i_uid) && target &&
64351 + !uid_eq(link_inode->i_uid, target->i_uid)) {
64352 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINKOWNER_MSG, link->dentry, link->mnt, link_inode->i_uid, target->i_uid);
64353 + return 1;
64354 + }
64355 +#endif
64356 + return 0;
64357 +}
64358 +
64359 +int
64360 +gr_handle_follow_link(const struct inode *parent,
64361 + const struct inode *inode,
64362 + const struct dentry *dentry, const struct vfsmount *mnt)
64363 +{
64364 +#ifdef CONFIG_GRKERNSEC_LINK
64365 + const struct cred *cred = current_cred();
64366 +
64367 + if (grsec_enable_link && S_ISLNK(inode->i_mode) &&
64368 + (parent->i_mode & S_ISVTX) && !uid_eq(parent->i_uid, inode->i_uid) &&
64369 + (parent->i_mode & S_IWOTH) && !uid_eq(cred->fsuid, inode->i_uid)) {
64370 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid);
64371 + return -EACCES;
64372 + }
64373 +#endif
64374 + return 0;
64375 +}
64376 +
64377 +int
64378 +gr_handle_hardlink(const struct dentry *dentry,
64379 + const struct vfsmount *mnt,
64380 + struct inode *inode, const int mode, const struct filename *to)
64381 +{
64382 +#ifdef CONFIG_GRKERNSEC_LINK
64383 + const struct cred *cred = current_cred();
64384 +
64385 + if (grsec_enable_link && !uid_eq(cred->fsuid, inode->i_uid) &&
64386 + (!S_ISREG(mode) || is_privileged_binary(dentry) ||
64387 + (inode_permission(inode, MAY_READ | MAY_WRITE))) &&
64388 + !capable(CAP_FOWNER) && gr_is_global_nonroot(cred->uid)) {
64389 + gr_log_fs_int2_str(GR_DONT_AUDIT, GR_HARDLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid, to->name);
64390 + return -EPERM;
64391 + }
64392 +#endif
64393 + return 0;
64394 +}
64395 diff --git a/grsecurity/grsec_log.c b/grsecurity/grsec_log.c
64396 new file mode 100644
64397 index 0000000..7c06085
64398 --- /dev/null
64399 +++ b/grsecurity/grsec_log.c
64400 @@ -0,0 +1,326 @@
64401 +#include <linux/kernel.h>
64402 +#include <linux/sched.h>
64403 +#include <linux/file.h>
64404 +#include <linux/tty.h>
64405 +#include <linux/fs.h>
64406 +#include <linux/grinternal.h>
64407 +
64408 +#ifdef CONFIG_TREE_PREEMPT_RCU
64409 +#define DISABLE_PREEMPT() preempt_disable()
64410 +#define ENABLE_PREEMPT() preempt_enable()
64411 +#else
64412 +#define DISABLE_PREEMPT()
64413 +#define ENABLE_PREEMPT()
64414 +#endif
64415 +
64416 +#define BEGIN_LOCKS(x) \
64417 + DISABLE_PREEMPT(); \
64418 + rcu_read_lock(); \
64419 + read_lock(&tasklist_lock); \
64420 + read_lock(&grsec_exec_file_lock); \
64421 + if (x != GR_DO_AUDIT) \
64422 + spin_lock(&grsec_alert_lock); \
64423 + else \
64424 + spin_lock(&grsec_audit_lock)
64425 +
64426 +#define END_LOCKS(x) \
64427 + if (x != GR_DO_AUDIT) \
64428 + spin_unlock(&grsec_alert_lock); \
64429 + else \
64430 + spin_unlock(&grsec_audit_lock); \
64431 + read_unlock(&grsec_exec_file_lock); \
64432 + read_unlock(&tasklist_lock); \
64433 + rcu_read_unlock(); \
64434 + ENABLE_PREEMPT(); \
64435 + if (x == GR_DONT_AUDIT) \
64436 + gr_handle_alertkill(current)
64437 +
64438 +enum {
64439 + FLOODING,
64440 + NO_FLOODING
64441 +};
64442 +
64443 +extern char *gr_alert_log_fmt;
64444 +extern char *gr_audit_log_fmt;
64445 +extern char *gr_alert_log_buf;
64446 +extern char *gr_audit_log_buf;
64447 +
64448 +static int gr_log_start(int audit)
64449 +{
64450 + char *loglevel = (audit == GR_DO_AUDIT) ? KERN_INFO : KERN_ALERT;
64451 + char *fmt = (audit == GR_DO_AUDIT) ? gr_audit_log_fmt : gr_alert_log_fmt;
64452 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
64453 +#if (CONFIG_GRKERNSEC_FLOODTIME > 0 && CONFIG_GRKERNSEC_FLOODBURST > 0)
64454 + unsigned long curr_secs = get_seconds();
64455 +
64456 + if (audit == GR_DO_AUDIT)
64457 + goto set_fmt;
64458 +
64459 + if (!grsec_alert_wtime || time_after(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)) {
64460 + grsec_alert_wtime = curr_secs;
64461 + grsec_alert_fyet = 0;
64462 + } else if (time_before_eq(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)
64463 + && (grsec_alert_fyet < CONFIG_GRKERNSEC_FLOODBURST)) {
64464 + grsec_alert_fyet++;
64465 + } else if (grsec_alert_fyet == CONFIG_GRKERNSEC_FLOODBURST) {
64466 + grsec_alert_wtime = curr_secs;
64467 + grsec_alert_fyet++;
64468 + printk(KERN_ALERT "grsec: more alerts, logging disabled for %d seconds\n", CONFIG_GRKERNSEC_FLOODTIME);
64469 + return FLOODING;
64470 + }
64471 + else return FLOODING;
64472 +
64473 +set_fmt:
64474 +#endif
64475 + memset(buf, 0, PAGE_SIZE);
64476 + if (current->signal->curr_ip && gr_acl_is_enabled()) {
64477 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: (%.64s:%c:%.950s) ");
64478 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
64479 + } else if (current->signal->curr_ip) {
64480 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: ");
64481 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip);
64482 + } else if (gr_acl_is_enabled()) {
64483 + sprintf(fmt, "%s%s", loglevel, "grsec: (%.64s:%c:%.950s) ");
64484 + snprintf(buf, PAGE_SIZE - 1, fmt, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
64485 + } else {
64486 + sprintf(fmt, "%s%s", loglevel, "grsec: ");
64487 + strcpy(buf, fmt);
64488 + }
64489 +
64490 + return NO_FLOODING;
64491 +}
64492 +
64493 +static void gr_log_middle(int audit, const char *msg, va_list ap)
64494 + __attribute__ ((format (printf, 2, 0)));
64495 +
64496 +static void gr_log_middle(int audit, const char *msg, va_list ap)
64497 +{
64498 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
64499 + unsigned int len = strlen(buf);
64500 +
64501 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
64502 +
64503 + return;
64504 +}
64505 +
64506 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
64507 + __attribute__ ((format (printf, 2, 3)));
64508 +
64509 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
64510 +{
64511 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
64512 + unsigned int len = strlen(buf);
64513 + va_list ap;
64514 +
64515 + va_start(ap, msg);
64516 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
64517 + va_end(ap);
64518 +
64519 + return;
64520 +}
64521 +
64522 +static void gr_log_end(int audit, int append_default)
64523 +{
64524 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
64525 + if (append_default) {
64526 + struct task_struct *task = current;
64527 + struct task_struct *parent = task->real_parent;
64528 + const struct cred *cred = __task_cred(task);
64529 + const struct cred *pcred = __task_cred(parent);
64530 + unsigned int len = strlen(buf);
64531 +
64532 + 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));
64533 + }
64534 +
64535 + printk("%s\n", buf);
64536 +
64537 + return;
64538 +}
64539 +
64540 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...)
64541 +{
64542 + int logtype;
64543 + char *result = (audit == GR_DO_AUDIT) ? "successful" : "denied";
64544 + char *str1 = NULL, *str2 = NULL, *str3 = NULL;
64545 + void *voidptr = NULL;
64546 + int num1 = 0, num2 = 0;
64547 + unsigned long ulong1 = 0, ulong2 = 0;
64548 + struct dentry *dentry = NULL;
64549 + struct vfsmount *mnt = NULL;
64550 + struct file *file = NULL;
64551 + struct task_struct *task = NULL;
64552 + const struct cred *cred, *pcred;
64553 + va_list ap;
64554 +
64555 + BEGIN_LOCKS(audit);
64556 + logtype = gr_log_start(audit);
64557 + if (logtype == FLOODING) {
64558 + END_LOCKS(audit);
64559 + return;
64560 + }
64561 + va_start(ap, argtypes);
64562 + switch (argtypes) {
64563 + case GR_TTYSNIFF:
64564 + task = va_arg(ap, struct task_struct *);
64565 + 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));
64566 + break;
64567 + case GR_SYSCTL_HIDDEN:
64568 + str1 = va_arg(ap, char *);
64569 + gr_log_middle_varargs(audit, msg, result, str1);
64570 + break;
64571 + case GR_RBAC:
64572 + dentry = va_arg(ap, struct dentry *);
64573 + mnt = va_arg(ap, struct vfsmount *);
64574 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt));
64575 + break;
64576 + case GR_RBAC_STR:
64577 + dentry = va_arg(ap, struct dentry *);
64578 + mnt = va_arg(ap, struct vfsmount *);
64579 + str1 = va_arg(ap, char *);
64580 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1);
64581 + break;
64582 + case GR_STR_RBAC:
64583 + str1 = va_arg(ap, char *);
64584 + dentry = va_arg(ap, struct dentry *);
64585 + mnt = va_arg(ap, struct vfsmount *);
64586 + gr_log_middle_varargs(audit, msg, result, str1, gr_to_filename(dentry, mnt));
64587 + break;
64588 + case GR_RBAC_MODE2:
64589 + dentry = va_arg(ap, struct dentry *);
64590 + mnt = va_arg(ap, struct vfsmount *);
64591 + str1 = va_arg(ap, char *);
64592 + str2 = va_arg(ap, char *);
64593 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2);
64594 + break;
64595 + case GR_RBAC_MODE3:
64596 + dentry = va_arg(ap, struct dentry *);
64597 + mnt = va_arg(ap, struct vfsmount *);
64598 + str1 = va_arg(ap, char *);
64599 + str2 = va_arg(ap, char *);
64600 + str3 = va_arg(ap, char *);
64601 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2, str3);
64602 + break;
64603 + case GR_FILENAME:
64604 + dentry = va_arg(ap, struct dentry *);
64605 + mnt = va_arg(ap, struct vfsmount *);
64606 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt));
64607 + break;
64608 + case GR_STR_FILENAME:
64609 + str1 = va_arg(ap, char *);
64610 + dentry = va_arg(ap, struct dentry *);
64611 + mnt = va_arg(ap, struct vfsmount *);
64612 + gr_log_middle_varargs(audit, msg, str1, gr_to_filename(dentry, mnt));
64613 + break;
64614 + case GR_FILENAME_STR:
64615 + dentry = va_arg(ap, struct dentry *);
64616 + mnt = va_arg(ap, struct vfsmount *);
64617 + str1 = va_arg(ap, char *);
64618 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), str1);
64619 + break;
64620 + case GR_FILENAME_TWO_INT:
64621 + dentry = va_arg(ap, struct dentry *);
64622 + mnt = va_arg(ap, struct vfsmount *);
64623 + num1 = va_arg(ap, int);
64624 + num2 = va_arg(ap, int);
64625 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2);
64626 + break;
64627 + case GR_FILENAME_TWO_INT_STR:
64628 + dentry = va_arg(ap, struct dentry *);
64629 + mnt = va_arg(ap, struct vfsmount *);
64630 + num1 = va_arg(ap, int);
64631 + num2 = va_arg(ap, int);
64632 + str1 = va_arg(ap, char *);
64633 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2, str1);
64634 + break;
64635 + case GR_TEXTREL:
64636 + file = va_arg(ap, struct file *);
64637 + ulong1 = va_arg(ap, unsigned long);
64638 + ulong2 = va_arg(ap, unsigned long);
64639 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>", ulong1, ulong2);
64640 + break;
64641 + case GR_PTRACE:
64642 + task = va_arg(ap, struct task_struct *);
64643 + 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));
64644 + break;
64645 + case GR_RESOURCE:
64646 + task = va_arg(ap, struct task_struct *);
64647 + cred = __task_cred(task);
64648 + pcred = __task_cred(task->real_parent);
64649 + ulong1 = va_arg(ap, unsigned long);
64650 + str1 = va_arg(ap, char *);
64651 + ulong2 = va_arg(ap, unsigned long);
64652 + 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));
64653 + break;
64654 + case GR_CAP:
64655 + task = va_arg(ap, struct task_struct *);
64656 + cred = __task_cred(task);
64657 + pcred = __task_cred(task->real_parent);
64658 + str1 = va_arg(ap, char *);
64659 + 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));
64660 + break;
64661 + case GR_SIG:
64662 + str1 = va_arg(ap, char *);
64663 + voidptr = va_arg(ap, void *);
64664 + gr_log_middle_varargs(audit, msg, str1, voidptr);
64665 + break;
64666 + case GR_SIG2:
64667 + task = va_arg(ap, struct task_struct *);
64668 + cred = __task_cred(task);
64669 + pcred = __task_cred(task->real_parent);
64670 + num1 = va_arg(ap, int);
64671 + 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));
64672 + break;
64673 + case GR_CRASH1:
64674 + task = va_arg(ap, struct task_struct *);
64675 + cred = __task_cred(task);
64676 + pcred = __task_cred(task->real_parent);
64677 + ulong1 = va_arg(ap, unsigned long);
64678 + 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);
64679 + break;
64680 + case GR_CRASH2:
64681 + task = va_arg(ap, struct task_struct *);
64682 + cred = __task_cred(task);
64683 + pcred = __task_cred(task->real_parent);
64684 + ulong1 = va_arg(ap, unsigned long);
64685 + 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);
64686 + break;
64687 + case GR_RWXMAP:
64688 + file = va_arg(ap, struct file *);
64689 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>");
64690 + break;
64691 + case GR_PSACCT:
64692 + {
64693 + unsigned int wday, cday;
64694 + __u8 whr, chr;
64695 + __u8 wmin, cmin;
64696 + __u8 wsec, csec;
64697 + char cur_tty[64] = { 0 };
64698 + char parent_tty[64] = { 0 };
64699 +
64700 + task = va_arg(ap, struct task_struct *);
64701 + wday = va_arg(ap, unsigned int);
64702 + cday = va_arg(ap, unsigned int);
64703 + whr = va_arg(ap, int);
64704 + chr = va_arg(ap, int);
64705 + wmin = va_arg(ap, int);
64706 + cmin = va_arg(ap, int);
64707 + wsec = va_arg(ap, int);
64708 + csec = va_arg(ap, int);
64709 + ulong1 = va_arg(ap, unsigned long);
64710 + cred = __task_cred(task);
64711 + pcred = __task_cred(task->real_parent);
64712 +
64713 + 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));
64714 + }
64715 + break;
64716 + default:
64717 + gr_log_middle(audit, msg, ap);
64718 + }
64719 + va_end(ap);
64720 + // these don't need DEFAULTSECARGS printed on the end
64721 + if (argtypes == GR_CRASH1 || argtypes == GR_CRASH2)
64722 + gr_log_end(audit, 0);
64723 + else
64724 + gr_log_end(audit, 1);
64725 + END_LOCKS(audit);
64726 +}
64727 diff --git a/grsecurity/grsec_mem.c b/grsecurity/grsec_mem.c
64728 new file mode 100644
64729 index 0000000..f536303
64730 --- /dev/null
64731 +++ b/grsecurity/grsec_mem.c
64732 @@ -0,0 +1,40 @@
64733 +#include <linux/kernel.h>
64734 +#include <linux/sched.h>
64735 +#include <linux/mm.h>
64736 +#include <linux/mman.h>
64737 +#include <linux/grinternal.h>
64738 +
64739 +void
64740 +gr_handle_ioperm(void)
64741 +{
64742 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPERM_MSG);
64743 + return;
64744 +}
64745 +
64746 +void
64747 +gr_handle_iopl(void)
64748 +{
64749 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPL_MSG);
64750 + return;
64751 +}
64752 +
64753 +void
64754 +gr_handle_mem_readwrite(u64 from, u64 to)
64755 +{
64756 + gr_log_two_u64(GR_DONT_AUDIT, GR_MEM_READWRITE_MSG, from, to);
64757 + return;
64758 +}
64759 +
64760 +void
64761 +gr_handle_vm86(void)
64762 +{
64763 + gr_log_noargs(GR_DONT_AUDIT, GR_VM86_MSG);
64764 + return;
64765 +}
64766 +
64767 +void
64768 +gr_log_badprocpid(const char *entry)
64769 +{
64770 + gr_log_str(GR_DONT_AUDIT, GR_BADPROCPID_MSG, entry);
64771 + return;
64772 +}
64773 diff --git a/grsecurity/grsec_mount.c b/grsecurity/grsec_mount.c
64774 new file mode 100644
64775 index 0000000..2131422
64776 --- /dev/null
64777 +++ b/grsecurity/grsec_mount.c
64778 @@ -0,0 +1,62 @@
64779 +#include <linux/kernel.h>
64780 +#include <linux/sched.h>
64781 +#include <linux/mount.h>
64782 +#include <linux/grsecurity.h>
64783 +#include <linux/grinternal.h>
64784 +
64785 +void
64786 +gr_log_remount(const char *devname, const int retval)
64787 +{
64788 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
64789 + if (grsec_enable_mount && (retval >= 0))
64790 + gr_log_str(GR_DO_AUDIT, GR_REMOUNT_AUDIT_MSG, devname ? devname : "none");
64791 +#endif
64792 + return;
64793 +}
64794 +
64795 +void
64796 +gr_log_unmount(const char *devname, const int retval)
64797 +{
64798 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
64799 + if (grsec_enable_mount && (retval >= 0))
64800 + gr_log_str(GR_DO_AUDIT, GR_UNMOUNT_AUDIT_MSG, devname ? devname : "none");
64801 +#endif
64802 + return;
64803 +}
64804 +
64805 +void
64806 +gr_log_mount(const char *from, const char *to, const int retval)
64807 +{
64808 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
64809 + if (grsec_enable_mount && (retval >= 0))
64810 + gr_log_str_str(GR_DO_AUDIT, GR_MOUNT_AUDIT_MSG, from ? from : "none", to);
64811 +#endif
64812 + return;
64813 +}
64814 +
64815 +int
64816 +gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags)
64817 +{
64818 +#ifdef CONFIG_GRKERNSEC_ROFS
64819 + if (grsec_enable_rofs && !(mnt_flags & MNT_READONLY)) {
64820 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_MOUNT_MSG, dentry, mnt);
64821 + return -EPERM;
64822 + } else
64823 + return 0;
64824 +#endif
64825 + return 0;
64826 +}
64827 +
64828 +int
64829 +gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode)
64830 +{
64831 +#ifdef CONFIG_GRKERNSEC_ROFS
64832 + if (grsec_enable_rofs && (acc_mode & MAY_WRITE) &&
64833 + dentry->d_inode && S_ISBLK(dentry->d_inode->i_mode)) {
64834 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_BLOCKWRITE_MSG, dentry, mnt);
64835 + return -EPERM;
64836 + } else
64837 + return 0;
64838 +#endif
64839 + return 0;
64840 +}
64841 diff --git a/grsecurity/grsec_pax.c b/grsecurity/grsec_pax.c
64842 new file mode 100644
64843 index 0000000..a3b12a0
64844 --- /dev/null
64845 +++ b/grsecurity/grsec_pax.c
64846 @@ -0,0 +1,36 @@
64847 +#include <linux/kernel.h>
64848 +#include <linux/sched.h>
64849 +#include <linux/mm.h>
64850 +#include <linux/file.h>
64851 +#include <linux/grinternal.h>
64852 +#include <linux/grsecurity.h>
64853 +
64854 +void
64855 +gr_log_textrel(struct vm_area_struct * vma)
64856 +{
64857 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
64858 + if (grsec_enable_audit_textrel)
64859 + gr_log_textrel_ulong_ulong(GR_DO_AUDIT, GR_TEXTREL_AUDIT_MSG, vma->vm_file, vma->vm_start, vma->vm_pgoff);
64860 +#endif
64861 + return;
64862 +}
64863 +
64864 +void
64865 +gr_log_rwxmmap(struct file *file)
64866 +{
64867 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
64868 + if (grsec_enable_log_rwxmaps)
64869 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMMAP_MSG, file);
64870 +#endif
64871 + return;
64872 +}
64873 +
64874 +void
64875 +gr_log_rwxmprotect(struct file *file)
64876 +{
64877 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
64878 + if (grsec_enable_log_rwxmaps)
64879 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMPROTECT_MSG, file);
64880 +#endif
64881 + return;
64882 +}
64883 diff --git a/grsecurity/grsec_ptrace.c b/grsecurity/grsec_ptrace.c
64884 new file mode 100644
64885 index 0000000..f7f29aa
64886 --- /dev/null
64887 +++ b/grsecurity/grsec_ptrace.c
64888 @@ -0,0 +1,30 @@
64889 +#include <linux/kernel.h>
64890 +#include <linux/sched.h>
64891 +#include <linux/grinternal.h>
64892 +#include <linux/security.h>
64893 +
64894 +void
64895 +gr_audit_ptrace(struct task_struct *task)
64896 +{
64897 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
64898 + if (grsec_enable_audit_ptrace)
64899 + gr_log_ptrace(GR_DO_AUDIT, GR_PTRACE_AUDIT_MSG, task);
64900 +#endif
64901 + return;
64902 +}
64903 +
64904 +int
64905 +gr_ptrace_readexec(struct file *file, int unsafe_flags)
64906 +{
64907 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
64908 + const struct dentry *dentry = file->f_path.dentry;
64909 + const struct vfsmount *mnt = file->f_path.mnt;
64910 +
64911 + if (grsec_enable_ptrace_readexec && (unsafe_flags & LSM_UNSAFE_PTRACE) &&
64912 + (inode_permission(dentry->d_inode, MAY_READ) || !gr_acl_handle_open(dentry, mnt, MAY_READ))) {
64913 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_READEXEC_MSG, dentry, mnt);
64914 + return -EACCES;
64915 + }
64916 +#endif
64917 + return 0;
64918 +}
64919 diff --git a/grsecurity/grsec_sig.c b/grsecurity/grsec_sig.c
64920 new file mode 100644
64921 index 0000000..e09715a
64922 --- /dev/null
64923 +++ b/grsecurity/grsec_sig.c
64924 @@ -0,0 +1,222 @@
64925 +#include <linux/kernel.h>
64926 +#include <linux/sched.h>
64927 +#include <linux/delay.h>
64928 +#include <linux/grsecurity.h>
64929 +#include <linux/grinternal.h>
64930 +#include <linux/hardirq.h>
64931 +
64932 +char *signames[] = {
64933 + [SIGSEGV] = "Segmentation fault",
64934 + [SIGILL] = "Illegal instruction",
64935 + [SIGABRT] = "Abort",
64936 + [SIGBUS] = "Invalid alignment/Bus error"
64937 +};
64938 +
64939 +void
64940 +gr_log_signal(const int sig, const void *addr, const struct task_struct *t)
64941 +{
64942 +#ifdef CONFIG_GRKERNSEC_SIGNAL
64943 + if (grsec_enable_signal && ((sig == SIGSEGV) || (sig == SIGILL) ||
64944 + (sig == SIGABRT) || (sig == SIGBUS))) {
64945 + if (task_pid_nr(t) == task_pid_nr(current)) {
64946 + gr_log_sig_addr(GR_DONT_AUDIT_GOOD, GR_UNISIGLOG_MSG, signames[sig], addr);
64947 + } else {
64948 + gr_log_sig_task(GR_DONT_AUDIT_GOOD, GR_DUALSIGLOG_MSG, t, sig);
64949 + }
64950 + }
64951 +#endif
64952 + return;
64953 +}
64954 +
64955 +int
64956 +gr_handle_signal(const struct task_struct *p, const int sig)
64957 +{
64958 +#ifdef CONFIG_GRKERNSEC
64959 + /* ignore the 0 signal for protected task checks */
64960 + if (task_pid_nr(current) > 1 && sig && gr_check_protected_task(p)) {
64961 + gr_log_sig_task(GR_DONT_AUDIT, GR_SIG_ACL_MSG, p, sig);
64962 + return -EPERM;
64963 + } else if (gr_pid_is_chrooted((struct task_struct *)p)) {
64964 + return -EPERM;
64965 + }
64966 +#endif
64967 + return 0;
64968 +}
64969 +
64970 +#ifdef CONFIG_GRKERNSEC
64971 +extern int specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t);
64972 +
64973 +int gr_fake_force_sig(int sig, struct task_struct *t)
64974 +{
64975 + unsigned long int flags;
64976 + int ret, blocked, ignored;
64977 + struct k_sigaction *action;
64978 +
64979 + spin_lock_irqsave(&t->sighand->siglock, flags);
64980 + action = &t->sighand->action[sig-1];
64981 + ignored = action->sa.sa_handler == SIG_IGN;
64982 + blocked = sigismember(&t->blocked, sig);
64983 + if (blocked || ignored) {
64984 + action->sa.sa_handler = SIG_DFL;
64985 + if (blocked) {
64986 + sigdelset(&t->blocked, sig);
64987 + recalc_sigpending_and_wake(t);
64988 + }
64989 + }
64990 + if (action->sa.sa_handler == SIG_DFL)
64991 + t->signal->flags &= ~SIGNAL_UNKILLABLE;
64992 + ret = specific_send_sig_info(sig, SEND_SIG_PRIV, t);
64993 +
64994 + spin_unlock_irqrestore(&t->sighand->siglock, flags);
64995 +
64996 + return ret;
64997 +}
64998 +#endif
64999 +
65000 +#ifdef CONFIG_GRKERNSEC_BRUTE
65001 +#define GR_USER_BAN_TIME (15 * 60)
65002 +#define GR_DAEMON_BRUTE_TIME (30 * 60)
65003 +
65004 +static int __get_dumpable(unsigned long mm_flags)
65005 +{
65006 + int ret;
65007 +
65008 + ret = mm_flags & MMF_DUMPABLE_MASK;
65009 + return (ret >= 2) ? 2 : ret;
65010 +}
65011 +#endif
65012 +
65013 +void gr_handle_brute_attach(unsigned long mm_flags)
65014 +{
65015 +#ifdef CONFIG_GRKERNSEC_BRUTE
65016 + struct task_struct *p = current;
65017 + kuid_t uid = GLOBAL_ROOT_UID;
65018 + int daemon = 0;
65019 +
65020 + if (!grsec_enable_brute)
65021 + return;
65022 +
65023 + rcu_read_lock();
65024 + read_lock(&tasklist_lock);
65025 + read_lock(&grsec_exec_file_lock);
65026 + if (p->real_parent && p->real_parent->exec_file == p->exec_file) {
65027 + p->real_parent->brute_expires = get_seconds() + GR_DAEMON_BRUTE_TIME;
65028 + p->real_parent->brute = 1;
65029 + daemon = 1;
65030 + } else {
65031 + const struct cred *cred = __task_cred(p), *cred2;
65032 + struct task_struct *tsk, *tsk2;
65033 +
65034 + if (!__get_dumpable(mm_flags) && gr_is_global_nonroot(cred->uid)) {
65035 + struct user_struct *user;
65036 +
65037 + uid = cred->uid;
65038 +
65039 + /* this is put upon execution past expiration */
65040 + user = find_user(uid);
65041 + if (user == NULL)
65042 + goto unlock;
65043 + user->banned = 1;
65044 + user->ban_expires = get_seconds() + GR_USER_BAN_TIME;
65045 + if (user->ban_expires == ~0UL)
65046 + user->ban_expires--;
65047 +
65048 + do_each_thread(tsk2, tsk) {
65049 + cred2 = __task_cred(tsk);
65050 + if (tsk != p && uid_eq(cred2->uid, uid))
65051 + gr_fake_force_sig(SIGKILL, tsk);
65052 + } while_each_thread(tsk2, tsk);
65053 + }
65054 + }
65055 +unlock:
65056 + read_unlock(&grsec_exec_file_lock);
65057 + read_unlock(&tasklist_lock);
65058 + rcu_read_unlock();
65059 +
65060 + if (gr_is_global_nonroot(uid))
65061 + printk(KERN_ALERT "grsec: bruteforce prevention initiated against uid %u, banning for %d minutes\n",
65062 + GR_GLOBAL_UID(uid), GR_USER_BAN_TIME / 60);
65063 + else if (daemon)
65064 + gr_log_noargs(GR_DONT_AUDIT, GR_BRUTE_DAEMON_MSG);
65065 +
65066 +#endif
65067 + return;
65068 +}
65069 +
65070 +void gr_handle_brute_check(void)
65071 +{
65072 +#ifdef CONFIG_GRKERNSEC_BRUTE
65073 + struct task_struct *p = current;
65074 +
65075 + if (unlikely(p->brute)) {
65076 + if (!grsec_enable_brute)
65077 + p->brute = 0;
65078 + else if (time_before(get_seconds(), p->brute_expires))
65079 + msleep(30 * 1000);
65080 + }
65081 +#endif
65082 + return;
65083 +}
65084 +
65085 +void gr_handle_kernel_exploit(void)
65086 +{
65087 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
65088 + const struct cred *cred;
65089 + struct task_struct *tsk, *tsk2;
65090 + struct user_struct *user;
65091 + kuid_t uid;
65092 +
65093 + if (in_irq() || in_serving_softirq() || in_nmi())
65094 + panic("grsec: halting the system due to suspicious kernel crash caused in interrupt context");
65095 +
65096 + uid = current_uid();
65097 +
65098 + if (gr_is_global_root(uid))
65099 + panic("grsec: halting the system due to suspicious kernel crash caused by root");
65100 + else {
65101 + /* kill all the processes of this user, hold a reference
65102 + to their creds struct, and prevent them from creating
65103 + another process until system reset
65104 + */
65105 + printk(KERN_ALERT "grsec: banning user with uid %u until system restart for suspicious kernel crash\n",
65106 + GR_GLOBAL_UID(uid));
65107 + /* we intentionally leak this ref */
65108 + user = get_uid(current->cred->user);
65109 + if (user) {
65110 + user->banned = 1;
65111 + user->ban_expires = ~0UL;
65112 + }
65113 +
65114 + read_lock(&tasklist_lock);
65115 + do_each_thread(tsk2, tsk) {
65116 + cred = __task_cred(tsk);
65117 + if (uid_eq(cred->uid, uid))
65118 + gr_fake_force_sig(SIGKILL, tsk);
65119 + } while_each_thread(tsk2, tsk);
65120 + read_unlock(&tasklist_lock);
65121 + }
65122 +#endif
65123 +}
65124 +
65125 +int __gr_process_user_ban(struct user_struct *user)
65126 +{
65127 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
65128 + if (unlikely(user->banned)) {
65129 + if (user->ban_expires != ~0UL && time_after_eq(get_seconds(), user->ban_expires)) {
65130 + user->banned = 0;
65131 + user->ban_expires = 0;
65132 + free_uid(user);
65133 + } else
65134 + return -EPERM;
65135 + }
65136 +#endif
65137 + return 0;
65138 +}
65139 +
65140 +int gr_process_user_ban(void)
65141 +{
65142 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
65143 + return __gr_process_user_ban(current->cred->user);
65144 +#endif
65145 + return 0;
65146 +}
65147 diff --git a/grsecurity/grsec_sock.c b/grsecurity/grsec_sock.c
65148 new file mode 100644
65149 index 0000000..4030d57
65150 --- /dev/null
65151 +++ b/grsecurity/grsec_sock.c
65152 @@ -0,0 +1,244 @@
65153 +#include <linux/kernel.h>
65154 +#include <linux/module.h>
65155 +#include <linux/sched.h>
65156 +#include <linux/file.h>
65157 +#include <linux/net.h>
65158 +#include <linux/in.h>
65159 +#include <linux/ip.h>
65160 +#include <net/sock.h>
65161 +#include <net/inet_sock.h>
65162 +#include <linux/grsecurity.h>
65163 +#include <linux/grinternal.h>
65164 +#include <linux/gracl.h>
65165 +
65166 +extern int gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb);
65167 +extern int gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr);
65168 +
65169 +EXPORT_SYMBOL(gr_search_udp_recvmsg);
65170 +EXPORT_SYMBOL(gr_search_udp_sendmsg);
65171 +
65172 +#ifdef CONFIG_UNIX_MODULE
65173 +EXPORT_SYMBOL(gr_acl_handle_unix);
65174 +EXPORT_SYMBOL(gr_acl_handle_mknod);
65175 +EXPORT_SYMBOL(gr_handle_chroot_unix);
65176 +EXPORT_SYMBOL(gr_handle_create);
65177 +#endif
65178 +
65179 +#ifdef CONFIG_GRKERNSEC
65180 +#define gr_conn_table_size 32749
65181 +struct conn_table_entry {
65182 + struct conn_table_entry *next;
65183 + struct signal_struct *sig;
65184 +};
65185 +
65186 +struct conn_table_entry *gr_conn_table[gr_conn_table_size];
65187 +DEFINE_SPINLOCK(gr_conn_table_lock);
65188 +
65189 +extern const char * gr_socktype_to_name(unsigned char type);
65190 +extern const char * gr_proto_to_name(unsigned char proto);
65191 +extern const char * gr_sockfamily_to_name(unsigned char family);
65192 +
65193 +static __inline__ int
65194 +conn_hash(__u32 saddr, __u32 daddr, __u16 sport, __u16 dport, unsigned int size)
65195 +{
65196 + return ((daddr + saddr + (sport << 8) + (dport << 16)) % size);
65197 +}
65198 +
65199 +static __inline__ int
65200 +conn_match(const struct signal_struct *sig, __u32 saddr, __u32 daddr,
65201 + __u16 sport, __u16 dport)
65202 +{
65203 + if (unlikely(sig->gr_saddr == saddr && sig->gr_daddr == daddr &&
65204 + sig->gr_sport == sport && sig->gr_dport == dport))
65205 + return 1;
65206 + else
65207 + return 0;
65208 +}
65209 +
65210 +static void gr_add_to_task_ip_table_nolock(struct signal_struct *sig, struct conn_table_entry *newent)
65211 +{
65212 + struct conn_table_entry **match;
65213 + unsigned int index;
65214 +
65215 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
65216 + sig->gr_sport, sig->gr_dport,
65217 + gr_conn_table_size);
65218 +
65219 + newent->sig = sig;
65220 +
65221 + match = &gr_conn_table[index];
65222 + newent->next = *match;
65223 + *match = newent;
65224 +
65225 + return;
65226 +}
65227 +
65228 +static void gr_del_task_from_ip_table_nolock(struct signal_struct *sig)
65229 +{
65230 + struct conn_table_entry *match, *last = NULL;
65231 + unsigned int index;
65232 +
65233 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
65234 + sig->gr_sport, sig->gr_dport,
65235 + gr_conn_table_size);
65236 +
65237 + match = gr_conn_table[index];
65238 + while (match && !conn_match(match->sig,
65239 + sig->gr_saddr, sig->gr_daddr, sig->gr_sport,
65240 + sig->gr_dport)) {
65241 + last = match;
65242 + match = match->next;
65243 + }
65244 +
65245 + if (match) {
65246 + if (last)
65247 + last->next = match->next;
65248 + else
65249 + gr_conn_table[index] = NULL;
65250 + kfree(match);
65251 + }
65252 +
65253 + return;
65254 +}
65255 +
65256 +static struct signal_struct * gr_lookup_task_ip_table(__u32 saddr, __u32 daddr,
65257 + __u16 sport, __u16 dport)
65258 +{
65259 + struct conn_table_entry *match;
65260 + unsigned int index;
65261 +
65262 + index = conn_hash(saddr, daddr, sport, dport, gr_conn_table_size);
65263 +
65264 + match = gr_conn_table[index];
65265 + while (match && !conn_match(match->sig, saddr, daddr, sport, dport))
65266 + match = match->next;
65267 +
65268 + if (match)
65269 + return match->sig;
65270 + else
65271 + return NULL;
65272 +}
65273 +
65274 +#endif
65275 +
65276 +void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet)
65277 +{
65278 +#ifdef CONFIG_GRKERNSEC
65279 + struct signal_struct *sig = task->signal;
65280 + struct conn_table_entry *newent;
65281 +
65282 + newent = kmalloc(sizeof(struct conn_table_entry), GFP_ATOMIC);
65283 + if (newent == NULL)
65284 + return;
65285 + /* no bh lock needed since we are called with bh disabled */
65286 + spin_lock(&gr_conn_table_lock);
65287 + gr_del_task_from_ip_table_nolock(sig);
65288 + sig->gr_saddr = inet->inet_rcv_saddr;
65289 + sig->gr_daddr = inet->inet_daddr;
65290 + sig->gr_sport = inet->inet_sport;
65291 + sig->gr_dport = inet->inet_dport;
65292 + gr_add_to_task_ip_table_nolock(sig, newent);
65293 + spin_unlock(&gr_conn_table_lock);
65294 +#endif
65295 + return;
65296 +}
65297 +
65298 +void gr_del_task_from_ip_table(struct task_struct *task)
65299 +{
65300 +#ifdef CONFIG_GRKERNSEC
65301 + spin_lock_bh(&gr_conn_table_lock);
65302 + gr_del_task_from_ip_table_nolock(task->signal);
65303 + spin_unlock_bh(&gr_conn_table_lock);
65304 +#endif
65305 + return;
65306 +}
65307 +
65308 +void
65309 +gr_attach_curr_ip(const struct sock *sk)
65310 +{
65311 +#ifdef CONFIG_GRKERNSEC
65312 + struct signal_struct *p, *set;
65313 + const struct inet_sock *inet = inet_sk(sk);
65314 +
65315 + if (unlikely(sk->sk_protocol != IPPROTO_TCP))
65316 + return;
65317 +
65318 + set = current->signal;
65319 +
65320 + spin_lock_bh(&gr_conn_table_lock);
65321 + p = gr_lookup_task_ip_table(inet->inet_daddr, inet->inet_rcv_saddr,
65322 + inet->inet_dport, inet->inet_sport);
65323 + if (unlikely(p != NULL)) {
65324 + set->curr_ip = p->curr_ip;
65325 + set->used_accept = 1;
65326 + gr_del_task_from_ip_table_nolock(p);
65327 + spin_unlock_bh(&gr_conn_table_lock);
65328 + return;
65329 + }
65330 + spin_unlock_bh(&gr_conn_table_lock);
65331 +
65332 + set->curr_ip = inet->inet_daddr;
65333 + set->used_accept = 1;
65334 +#endif
65335 + return;
65336 +}
65337 +
65338 +int
65339 +gr_handle_sock_all(const int family, const int type, const int protocol)
65340 +{
65341 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
65342 + if (grsec_enable_socket_all && in_group_p(grsec_socket_all_gid) &&
65343 + (family != AF_UNIX)) {
65344 + if (family == AF_INET)
65345 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), gr_proto_to_name(protocol));
65346 + else
65347 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), protocol);
65348 + return -EACCES;
65349 + }
65350 +#endif
65351 + return 0;
65352 +}
65353 +
65354 +int
65355 +gr_handle_sock_server(const struct sockaddr *sck)
65356 +{
65357 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
65358 + if (grsec_enable_socket_server &&
65359 + in_group_p(grsec_socket_server_gid) &&
65360 + sck && (sck->sa_family != AF_UNIX) &&
65361 + (sck->sa_family != AF_LOCAL)) {
65362 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
65363 + return -EACCES;
65364 + }
65365 +#endif
65366 + return 0;
65367 +}
65368 +
65369 +int
65370 +gr_handle_sock_server_other(const struct sock *sck)
65371 +{
65372 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
65373 + if (grsec_enable_socket_server &&
65374 + in_group_p(grsec_socket_server_gid) &&
65375 + sck && (sck->sk_family != AF_UNIX) &&
65376 + (sck->sk_family != AF_LOCAL)) {
65377 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
65378 + return -EACCES;
65379 + }
65380 +#endif
65381 + return 0;
65382 +}
65383 +
65384 +int
65385 +gr_handle_sock_client(const struct sockaddr *sck)
65386 +{
65387 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
65388 + if (grsec_enable_socket_client && in_group_p(grsec_socket_client_gid) &&
65389 + sck && (sck->sa_family != AF_UNIX) &&
65390 + (sck->sa_family != AF_LOCAL)) {
65391 + gr_log_noargs(GR_DONT_AUDIT, GR_CONNECT_MSG);
65392 + return -EACCES;
65393 + }
65394 +#endif
65395 + return 0;
65396 +}
65397 diff --git a/grsecurity/grsec_sysctl.c b/grsecurity/grsec_sysctl.c
65398 new file mode 100644
65399 index 0000000..f55ef0f
65400 --- /dev/null
65401 +++ b/grsecurity/grsec_sysctl.c
65402 @@ -0,0 +1,469 @@
65403 +#include <linux/kernel.h>
65404 +#include <linux/sched.h>
65405 +#include <linux/sysctl.h>
65406 +#include <linux/grsecurity.h>
65407 +#include <linux/grinternal.h>
65408 +
65409 +int
65410 +gr_handle_sysctl_mod(const char *dirname, const char *name, const int op)
65411 +{
65412 +#ifdef CONFIG_GRKERNSEC_SYSCTL
65413 + if (dirname == NULL || name == NULL)
65414 + return 0;
65415 + if (!strcmp(dirname, "grsecurity") && grsec_lock && (op & MAY_WRITE)) {
65416 + gr_log_str(GR_DONT_AUDIT, GR_SYSCTL_MSG, name);
65417 + return -EACCES;
65418 + }
65419 +#endif
65420 + return 0;
65421 +}
65422 +
65423 +#ifdef CONFIG_GRKERNSEC_ROFS
65424 +static int __maybe_unused one = 1;
65425 +#endif
65426 +
65427 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
65428 +struct ctl_table grsecurity_table[] = {
65429 +#ifdef CONFIG_GRKERNSEC_SYSCTL
65430 +#ifdef CONFIG_GRKERNSEC_SYSCTL_DISTRO
65431 +#ifdef CONFIG_GRKERNSEC_IO
65432 + {
65433 + .procname = "disable_priv_io",
65434 + .data = &grsec_disable_privio,
65435 + .maxlen = sizeof(int),
65436 + .mode = 0600,
65437 + .proc_handler = &proc_dointvec,
65438 + },
65439 +#endif
65440 +#endif
65441 +#ifdef CONFIG_GRKERNSEC_LINK
65442 + {
65443 + .procname = "linking_restrictions",
65444 + .data = &grsec_enable_link,
65445 + .maxlen = sizeof(int),
65446 + .mode = 0600,
65447 + .proc_handler = &proc_dointvec,
65448 + },
65449 +#endif
65450 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
65451 + {
65452 + .procname = "enforce_symlinksifowner",
65453 + .data = &grsec_enable_symlinkown,
65454 + .maxlen = sizeof(int),
65455 + .mode = 0600,
65456 + .proc_handler = &proc_dointvec,
65457 + },
65458 + {
65459 + .procname = "symlinkown_gid",
65460 + .data = &grsec_symlinkown_gid,
65461 + .maxlen = sizeof(int),
65462 + .mode = 0600,
65463 + .proc_handler = &proc_dointvec,
65464 + },
65465 +#endif
65466 +#ifdef CONFIG_GRKERNSEC_BRUTE
65467 + {
65468 + .procname = "deter_bruteforce",
65469 + .data = &grsec_enable_brute,
65470 + .maxlen = sizeof(int),
65471 + .mode = 0600,
65472 + .proc_handler = &proc_dointvec,
65473 + },
65474 +#endif
65475 +#ifdef CONFIG_GRKERNSEC_FIFO
65476 + {
65477 + .procname = "fifo_restrictions",
65478 + .data = &grsec_enable_fifo,
65479 + .maxlen = sizeof(int),
65480 + .mode = 0600,
65481 + .proc_handler = &proc_dointvec,
65482 + },
65483 +#endif
65484 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
65485 + {
65486 + .procname = "ptrace_readexec",
65487 + .data = &grsec_enable_ptrace_readexec,
65488 + .maxlen = sizeof(int),
65489 + .mode = 0600,
65490 + .proc_handler = &proc_dointvec,
65491 + },
65492 +#endif
65493 +#ifdef CONFIG_GRKERNSEC_SETXID
65494 + {
65495 + .procname = "consistent_setxid",
65496 + .data = &grsec_enable_setxid,
65497 + .maxlen = sizeof(int),
65498 + .mode = 0600,
65499 + .proc_handler = &proc_dointvec,
65500 + },
65501 +#endif
65502 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
65503 + {
65504 + .procname = "ip_blackhole",
65505 + .data = &grsec_enable_blackhole,
65506 + .maxlen = sizeof(int),
65507 + .mode = 0600,
65508 + .proc_handler = &proc_dointvec,
65509 + },
65510 + {
65511 + .procname = "lastack_retries",
65512 + .data = &grsec_lastack_retries,
65513 + .maxlen = sizeof(int),
65514 + .mode = 0600,
65515 + .proc_handler = &proc_dointvec,
65516 + },
65517 +#endif
65518 +#ifdef CONFIG_GRKERNSEC_EXECLOG
65519 + {
65520 + .procname = "exec_logging",
65521 + .data = &grsec_enable_execlog,
65522 + .maxlen = sizeof(int),
65523 + .mode = 0600,
65524 + .proc_handler = &proc_dointvec,
65525 + },
65526 +#endif
65527 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
65528 + {
65529 + .procname = "rwxmap_logging",
65530 + .data = &grsec_enable_log_rwxmaps,
65531 + .maxlen = sizeof(int),
65532 + .mode = 0600,
65533 + .proc_handler = &proc_dointvec,
65534 + },
65535 +#endif
65536 +#ifdef CONFIG_GRKERNSEC_SIGNAL
65537 + {
65538 + .procname = "signal_logging",
65539 + .data = &grsec_enable_signal,
65540 + .maxlen = sizeof(int),
65541 + .mode = 0600,
65542 + .proc_handler = &proc_dointvec,
65543 + },
65544 +#endif
65545 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
65546 + {
65547 + .procname = "forkfail_logging",
65548 + .data = &grsec_enable_forkfail,
65549 + .maxlen = sizeof(int),
65550 + .mode = 0600,
65551 + .proc_handler = &proc_dointvec,
65552 + },
65553 +#endif
65554 +#ifdef CONFIG_GRKERNSEC_TIME
65555 + {
65556 + .procname = "timechange_logging",
65557 + .data = &grsec_enable_time,
65558 + .maxlen = sizeof(int),
65559 + .mode = 0600,
65560 + .proc_handler = &proc_dointvec,
65561 + },
65562 +#endif
65563 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
65564 + {
65565 + .procname = "chroot_deny_shmat",
65566 + .data = &grsec_enable_chroot_shmat,
65567 + .maxlen = sizeof(int),
65568 + .mode = 0600,
65569 + .proc_handler = &proc_dointvec,
65570 + },
65571 +#endif
65572 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
65573 + {
65574 + .procname = "chroot_deny_unix",
65575 + .data = &grsec_enable_chroot_unix,
65576 + .maxlen = sizeof(int),
65577 + .mode = 0600,
65578 + .proc_handler = &proc_dointvec,
65579 + },
65580 +#endif
65581 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
65582 + {
65583 + .procname = "chroot_deny_mount",
65584 + .data = &grsec_enable_chroot_mount,
65585 + .maxlen = sizeof(int),
65586 + .mode = 0600,
65587 + .proc_handler = &proc_dointvec,
65588 + },
65589 +#endif
65590 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
65591 + {
65592 + .procname = "chroot_deny_fchdir",
65593 + .data = &grsec_enable_chroot_fchdir,
65594 + .maxlen = sizeof(int),
65595 + .mode = 0600,
65596 + .proc_handler = &proc_dointvec,
65597 + },
65598 +#endif
65599 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
65600 + {
65601 + .procname = "chroot_deny_chroot",
65602 + .data = &grsec_enable_chroot_double,
65603 + .maxlen = sizeof(int),
65604 + .mode = 0600,
65605 + .proc_handler = &proc_dointvec,
65606 + },
65607 +#endif
65608 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
65609 + {
65610 + .procname = "chroot_deny_pivot",
65611 + .data = &grsec_enable_chroot_pivot,
65612 + .maxlen = sizeof(int),
65613 + .mode = 0600,
65614 + .proc_handler = &proc_dointvec,
65615 + },
65616 +#endif
65617 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
65618 + {
65619 + .procname = "chroot_enforce_chdir",
65620 + .data = &grsec_enable_chroot_chdir,
65621 + .maxlen = sizeof(int),
65622 + .mode = 0600,
65623 + .proc_handler = &proc_dointvec,
65624 + },
65625 +#endif
65626 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
65627 + {
65628 + .procname = "chroot_deny_chmod",
65629 + .data = &grsec_enable_chroot_chmod,
65630 + .maxlen = sizeof(int),
65631 + .mode = 0600,
65632 + .proc_handler = &proc_dointvec,
65633 + },
65634 +#endif
65635 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
65636 + {
65637 + .procname = "chroot_deny_mknod",
65638 + .data = &grsec_enable_chroot_mknod,
65639 + .maxlen = sizeof(int),
65640 + .mode = 0600,
65641 + .proc_handler = &proc_dointvec,
65642 + },
65643 +#endif
65644 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
65645 + {
65646 + .procname = "chroot_restrict_nice",
65647 + .data = &grsec_enable_chroot_nice,
65648 + .maxlen = sizeof(int),
65649 + .mode = 0600,
65650 + .proc_handler = &proc_dointvec,
65651 + },
65652 +#endif
65653 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
65654 + {
65655 + .procname = "chroot_execlog",
65656 + .data = &grsec_enable_chroot_execlog,
65657 + .maxlen = sizeof(int),
65658 + .mode = 0600,
65659 + .proc_handler = &proc_dointvec,
65660 + },
65661 +#endif
65662 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
65663 + {
65664 + .procname = "chroot_caps",
65665 + .data = &grsec_enable_chroot_caps,
65666 + .maxlen = sizeof(int),
65667 + .mode = 0600,
65668 + .proc_handler = &proc_dointvec,
65669 + },
65670 +#endif
65671 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
65672 + {
65673 + .procname = "chroot_deny_sysctl",
65674 + .data = &grsec_enable_chroot_sysctl,
65675 + .maxlen = sizeof(int),
65676 + .mode = 0600,
65677 + .proc_handler = &proc_dointvec,
65678 + },
65679 +#endif
65680 +#ifdef CONFIG_GRKERNSEC_TPE
65681 + {
65682 + .procname = "tpe",
65683 + .data = &grsec_enable_tpe,
65684 + .maxlen = sizeof(int),
65685 + .mode = 0600,
65686 + .proc_handler = &proc_dointvec,
65687 + },
65688 + {
65689 + .procname = "tpe_gid",
65690 + .data = &grsec_tpe_gid,
65691 + .maxlen = sizeof(int),
65692 + .mode = 0600,
65693 + .proc_handler = &proc_dointvec,
65694 + },
65695 +#endif
65696 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
65697 + {
65698 + .procname = "tpe_invert",
65699 + .data = &grsec_enable_tpe_invert,
65700 + .maxlen = sizeof(int),
65701 + .mode = 0600,
65702 + .proc_handler = &proc_dointvec,
65703 + },
65704 +#endif
65705 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
65706 + {
65707 + .procname = "tpe_restrict_all",
65708 + .data = &grsec_enable_tpe_all,
65709 + .maxlen = sizeof(int),
65710 + .mode = 0600,
65711 + .proc_handler = &proc_dointvec,
65712 + },
65713 +#endif
65714 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
65715 + {
65716 + .procname = "socket_all",
65717 + .data = &grsec_enable_socket_all,
65718 + .maxlen = sizeof(int),
65719 + .mode = 0600,
65720 + .proc_handler = &proc_dointvec,
65721 + },
65722 + {
65723 + .procname = "socket_all_gid",
65724 + .data = &grsec_socket_all_gid,
65725 + .maxlen = sizeof(int),
65726 + .mode = 0600,
65727 + .proc_handler = &proc_dointvec,
65728 + },
65729 +#endif
65730 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
65731 + {
65732 + .procname = "socket_client",
65733 + .data = &grsec_enable_socket_client,
65734 + .maxlen = sizeof(int),
65735 + .mode = 0600,
65736 + .proc_handler = &proc_dointvec,
65737 + },
65738 + {
65739 + .procname = "socket_client_gid",
65740 + .data = &grsec_socket_client_gid,
65741 + .maxlen = sizeof(int),
65742 + .mode = 0600,
65743 + .proc_handler = &proc_dointvec,
65744 + },
65745 +#endif
65746 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
65747 + {
65748 + .procname = "socket_server",
65749 + .data = &grsec_enable_socket_server,
65750 + .maxlen = sizeof(int),
65751 + .mode = 0600,
65752 + .proc_handler = &proc_dointvec,
65753 + },
65754 + {
65755 + .procname = "socket_server_gid",
65756 + .data = &grsec_socket_server_gid,
65757 + .maxlen = sizeof(int),
65758 + .mode = 0600,
65759 + .proc_handler = &proc_dointvec,
65760 + },
65761 +#endif
65762 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
65763 + {
65764 + .procname = "audit_group",
65765 + .data = &grsec_enable_group,
65766 + .maxlen = sizeof(int),
65767 + .mode = 0600,
65768 + .proc_handler = &proc_dointvec,
65769 + },
65770 + {
65771 + .procname = "audit_gid",
65772 + .data = &grsec_audit_gid,
65773 + .maxlen = sizeof(int),
65774 + .mode = 0600,
65775 + .proc_handler = &proc_dointvec,
65776 + },
65777 +#endif
65778 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
65779 + {
65780 + .procname = "audit_chdir",
65781 + .data = &grsec_enable_chdir,
65782 + .maxlen = sizeof(int),
65783 + .mode = 0600,
65784 + .proc_handler = &proc_dointvec,
65785 + },
65786 +#endif
65787 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65788 + {
65789 + .procname = "audit_mount",
65790 + .data = &grsec_enable_mount,
65791 + .maxlen = sizeof(int),
65792 + .mode = 0600,
65793 + .proc_handler = &proc_dointvec,
65794 + },
65795 +#endif
65796 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
65797 + {
65798 + .procname = "audit_textrel",
65799 + .data = &grsec_enable_audit_textrel,
65800 + .maxlen = sizeof(int),
65801 + .mode = 0600,
65802 + .proc_handler = &proc_dointvec,
65803 + },
65804 +#endif
65805 +#ifdef CONFIG_GRKERNSEC_DMESG
65806 + {
65807 + .procname = "dmesg",
65808 + .data = &grsec_enable_dmesg,
65809 + .maxlen = sizeof(int),
65810 + .mode = 0600,
65811 + .proc_handler = &proc_dointvec,
65812 + },
65813 +#endif
65814 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
65815 + {
65816 + .procname = "chroot_findtask",
65817 + .data = &grsec_enable_chroot_findtask,
65818 + .maxlen = sizeof(int),
65819 + .mode = 0600,
65820 + .proc_handler = &proc_dointvec,
65821 + },
65822 +#endif
65823 +#ifdef CONFIG_GRKERNSEC_RESLOG
65824 + {
65825 + .procname = "resource_logging",
65826 + .data = &grsec_resource_logging,
65827 + .maxlen = sizeof(int),
65828 + .mode = 0600,
65829 + .proc_handler = &proc_dointvec,
65830 + },
65831 +#endif
65832 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
65833 + {
65834 + .procname = "audit_ptrace",
65835 + .data = &grsec_enable_audit_ptrace,
65836 + .maxlen = sizeof(int),
65837 + .mode = 0600,
65838 + .proc_handler = &proc_dointvec,
65839 + },
65840 +#endif
65841 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
65842 + {
65843 + .procname = "harden_ptrace",
65844 + .data = &grsec_enable_harden_ptrace,
65845 + .maxlen = sizeof(int),
65846 + .mode = 0600,
65847 + .proc_handler = &proc_dointvec,
65848 + },
65849 +#endif
65850 + {
65851 + .procname = "grsec_lock",
65852 + .data = &grsec_lock,
65853 + .maxlen = sizeof(int),
65854 + .mode = 0600,
65855 + .proc_handler = &proc_dointvec,
65856 + },
65857 +#endif
65858 +#ifdef CONFIG_GRKERNSEC_ROFS
65859 + {
65860 + .procname = "romount_protect",
65861 + .data = &grsec_enable_rofs,
65862 + .maxlen = sizeof(int),
65863 + .mode = 0600,
65864 + .proc_handler = &proc_dointvec_minmax,
65865 + .extra1 = &one,
65866 + .extra2 = &one,
65867 + },
65868 +#endif
65869 + { }
65870 +};
65871 +#endif
65872 diff --git a/grsecurity/grsec_time.c b/grsecurity/grsec_time.c
65873 new file mode 100644
65874 index 0000000..0dc13c3
65875 --- /dev/null
65876 +++ b/grsecurity/grsec_time.c
65877 @@ -0,0 +1,16 @@
65878 +#include <linux/kernel.h>
65879 +#include <linux/sched.h>
65880 +#include <linux/grinternal.h>
65881 +#include <linux/module.h>
65882 +
65883 +void
65884 +gr_log_timechange(void)
65885 +{
65886 +#ifdef CONFIG_GRKERNSEC_TIME
65887 + if (grsec_enable_time)
65888 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_TIME_MSG);
65889 +#endif
65890 + return;
65891 +}
65892 +
65893 +EXPORT_SYMBOL(gr_log_timechange);
65894 diff --git a/grsecurity/grsec_tpe.c b/grsecurity/grsec_tpe.c
65895 new file mode 100644
65896 index 0000000..ee57dcf
65897 --- /dev/null
65898 +++ b/grsecurity/grsec_tpe.c
65899 @@ -0,0 +1,73 @@
65900 +#include <linux/kernel.h>
65901 +#include <linux/sched.h>
65902 +#include <linux/file.h>
65903 +#include <linux/fs.h>
65904 +#include <linux/grinternal.h>
65905 +
65906 +extern int gr_acl_tpe_check(void);
65907 +
65908 +int
65909 +gr_tpe_allow(const struct file *file)
65910 +{
65911 +#ifdef CONFIG_GRKERNSEC
65912 + struct inode *inode = file->f_path.dentry->d_parent->d_inode;
65913 + const struct cred *cred = current_cred();
65914 + char *msg = NULL;
65915 + char *msg2 = NULL;
65916 +
65917 + // never restrict root
65918 + if (gr_is_global_root(cred->uid))
65919 + return 1;
65920 +
65921 + if (grsec_enable_tpe) {
65922 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
65923 + if (grsec_enable_tpe_invert && !in_group_p(grsec_tpe_gid))
65924 + msg = "not being in trusted group";
65925 + else if (!grsec_enable_tpe_invert && in_group_p(grsec_tpe_gid))
65926 + msg = "being in untrusted group";
65927 +#else
65928 + if (in_group_p(grsec_tpe_gid))
65929 + msg = "being in untrusted group";
65930 +#endif
65931 + }
65932 + if (!msg && gr_acl_tpe_check())
65933 + msg = "being in untrusted role";
65934 +
65935 + // not in any affected group/role
65936 + if (!msg)
65937 + goto next_check;
65938 +
65939 + if (gr_is_global_nonroot(inode->i_uid))
65940 + msg2 = "file in non-root-owned directory";
65941 + else if (inode->i_mode & S_IWOTH)
65942 + msg2 = "file in world-writable directory";
65943 + else if (inode->i_mode & S_IWGRP)
65944 + msg2 = "file in group-writable directory";
65945 +
65946 + if (msg && msg2) {
65947 + char fullmsg[70] = {0};
65948 + snprintf(fullmsg, sizeof(fullmsg)-1, "%s and %s", msg, msg2);
65949 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, fullmsg, file->f_path.dentry, file->f_path.mnt);
65950 + return 0;
65951 + }
65952 + msg = NULL;
65953 +next_check:
65954 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
65955 + if (!grsec_enable_tpe || !grsec_enable_tpe_all)
65956 + return 1;
65957 +
65958 + if (gr_is_global_nonroot(inode->i_uid) && !uid_eq(inode->i_uid, cred->uid))
65959 + msg = "directory not owned by user";
65960 + else if (inode->i_mode & S_IWOTH)
65961 + msg = "file in world-writable directory";
65962 + else if (inode->i_mode & S_IWGRP)
65963 + msg = "file in group-writable directory";
65964 +
65965 + if (msg) {
65966 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, msg, file->f_path.dentry, file->f_path.mnt);
65967 + return 0;
65968 + }
65969 +#endif
65970 +#endif
65971 + return 1;
65972 +}
65973 diff --git a/grsecurity/grsum.c b/grsecurity/grsum.c
65974 new file mode 100644
65975 index 0000000..9f7b1ac
65976 --- /dev/null
65977 +++ b/grsecurity/grsum.c
65978 @@ -0,0 +1,61 @@
65979 +#include <linux/err.h>
65980 +#include <linux/kernel.h>
65981 +#include <linux/sched.h>
65982 +#include <linux/mm.h>
65983 +#include <linux/scatterlist.h>
65984 +#include <linux/crypto.h>
65985 +#include <linux/gracl.h>
65986 +
65987 +
65988 +#if !defined(CONFIG_CRYPTO) || defined(CONFIG_CRYPTO_MODULE) || !defined(CONFIG_CRYPTO_SHA256) || defined(CONFIG_CRYPTO_SHA256_MODULE)
65989 +#error "crypto and sha256 must be built into the kernel"
65990 +#endif
65991 +
65992 +int
65993 +chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum)
65994 +{
65995 + char *p;
65996 + struct crypto_hash *tfm;
65997 + struct hash_desc desc;
65998 + struct scatterlist sg;
65999 + unsigned char temp_sum[GR_SHA_LEN];
66000 + volatile int retval = 0;
66001 + volatile int dummy = 0;
66002 + unsigned int i;
66003 +
66004 + sg_init_table(&sg, 1);
66005 +
66006 + tfm = crypto_alloc_hash("sha256", 0, CRYPTO_ALG_ASYNC);
66007 + if (IS_ERR(tfm)) {
66008 + /* should never happen, since sha256 should be built in */
66009 + return 1;
66010 + }
66011 +
66012 + desc.tfm = tfm;
66013 + desc.flags = 0;
66014 +
66015 + crypto_hash_init(&desc);
66016 +
66017 + p = salt;
66018 + sg_set_buf(&sg, p, GR_SALT_LEN);
66019 + crypto_hash_update(&desc, &sg, sg.length);
66020 +
66021 + p = entry->pw;
66022 + sg_set_buf(&sg, p, strlen(p));
66023 +
66024 + crypto_hash_update(&desc, &sg, sg.length);
66025 +
66026 + crypto_hash_final(&desc, temp_sum);
66027 +
66028 + memset(entry->pw, 0, GR_PW_LEN);
66029 +
66030 + for (i = 0; i < GR_SHA_LEN; i++)
66031 + if (sum[i] != temp_sum[i])
66032 + retval = 1;
66033 + else
66034 + dummy = 1; // waste a cycle
66035 +
66036 + crypto_free_hash(tfm);
66037 +
66038 + return retval;
66039 +}
66040 diff --git a/include/asm-generic/4level-fixup.h b/include/asm-generic/4level-fixup.h
66041 index 77ff547..181834f 100644
66042 --- a/include/asm-generic/4level-fixup.h
66043 +++ b/include/asm-generic/4level-fixup.h
66044 @@ -13,8 +13,10 @@
66045 #define pmd_alloc(mm, pud, address) \
66046 ((unlikely(pgd_none(*(pud))) && __pmd_alloc(mm, pud, address))? \
66047 NULL: pmd_offset(pud, address))
66048 +#define pmd_alloc_kernel(mm, pud, address) pmd_alloc((mm), (pud), (address))
66049
66050 #define pud_alloc(mm, pgd, address) (pgd)
66051 +#define pud_alloc_kernel(mm, pgd, address) pud_alloc((mm), (pgd), (address))
66052 #define pud_offset(pgd, start) (pgd)
66053 #define pud_none(pud) 0
66054 #define pud_bad(pud) 0
66055 diff --git a/include/asm-generic/atomic-long.h b/include/asm-generic/atomic-long.h
66056 index b7babf0..04ad282 100644
66057 --- a/include/asm-generic/atomic-long.h
66058 +++ b/include/asm-generic/atomic-long.h
66059 @@ -22,6 +22,12 @@
66060
66061 typedef atomic64_t atomic_long_t;
66062
66063 +#ifdef CONFIG_PAX_REFCOUNT
66064 +typedef atomic64_unchecked_t atomic_long_unchecked_t;
66065 +#else
66066 +typedef atomic64_t atomic_long_unchecked_t;
66067 +#endif
66068 +
66069 #define ATOMIC_LONG_INIT(i) ATOMIC64_INIT(i)
66070
66071 static inline long atomic_long_read(atomic_long_t *l)
66072 @@ -31,6 +37,15 @@ static inline long atomic_long_read(atomic_long_t *l)
66073 return (long)atomic64_read(v);
66074 }
66075
66076 +#ifdef CONFIG_PAX_REFCOUNT
66077 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
66078 +{
66079 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66080 +
66081 + return (long)atomic64_read_unchecked(v);
66082 +}
66083 +#endif
66084 +
66085 static inline void atomic_long_set(atomic_long_t *l, long i)
66086 {
66087 atomic64_t *v = (atomic64_t *)l;
66088 @@ -38,6 +53,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
66089 atomic64_set(v, i);
66090 }
66091
66092 +#ifdef CONFIG_PAX_REFCOUNT
66093 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
66094 +{
66095 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66096 +
66097 + atomic64_set_unchecked(v, i);
66098 +}
66099 +#endif
66100 +
66101 static inline void atomic_long_inc(atomic_long_t *l)
66102 {
66103 atomic64_t *v = (atomic64_t *)l;
66104 @@ -45,6 +69,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
66105 atomic64_inc(v);
66106 }
66107
66108 +#ifdef CONFIG_PAX_REFCOUNT
66109 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
66110 +{
66111 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66112 +
66113 + atomic64_inc_unchecked(v);
66114 +}
66115 +#endif
66116 +
66117 static inline void atomic_long_dec(atomic_long_t *l)
66118 {
66119 atomic64_t *v = (atomic64_t *)l;
66120 @@ -52,6 +85,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
66121 atomic64_dec(v);
66122 }
66123
66124 +#ifdef CONFIG_PAX_REFCOUNT
66125 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
66126 +{
66127 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66128 +
66129 + atomic64_dec_unchecked(v);
66130 +}
66131 +#endif
66132 +
66133 static inline void atomic_long_add(long i, atomic_long_t *l)
66134 {
66135 atomic64_t *v = (atomic64_t *)l;
66136 @@ -59,6 +101,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
66137 atomic64_add(i, v);
66138 }
66139
66140 +#ifdef CONFIG_PAX_REFCOUNT
66141 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
66142 +{
66143 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66144 +
66145 + atomic64_add_unchecked(i, v);
66146 +}
66147 +#endif
66148 +
66149 static inline void atomic_long_sub(long i, atomic_long_t *l)
66150 {
66151 atomic64_t *v = (atomic64_t *)l;
66152 @@ -66,6 +117,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
66153 atomic64_sub(i, v);
66154 }
66155
66156 +#ifdef CONFIG_PAX_REFCOUNT
66157 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
66158 +{
66159 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66160 +
66161 + atomic64_sub_unchecked(i, v);
66162 +}
66163 +#endif
66164 +
66165 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
66166 {
66167 atomic64_t *v = (atomic64_t *)l;
66168 @@ -101,6 +161,15 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
66169 return (long)atomic64_add_return(i, v);
66170 }
66171
66172 +#ifdef CONFIG_PAX_REFCOUNT
66173 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
66174 +{
66175 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66176 +
66177 + return (long)atomic64_add_return_unchecked(i, v);
66178 +}
66179 +#endif
66180 +
66181 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
66182 {
66183 atomic64_t *v = (atomic64_t *)l;
66184 @@ -115,6 +184,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
66185 return (long)atomic64_inc_return(v);
66186 }
66187
66188 +#ifdef CONFIG_PAX_REFCOUNT
66189 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
66190 +{
66191 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66192 +
66193 + return (long)atomic64_inc_return_unchecked(v);
66194 +}
66195 +#endif
66196 +
66197 static inline long atomic_long_dec_return(atomic_long_t *l)
66198 {
66199 atomic64_t *v = (atomic64_t *)l;
66200 @@ -140,6 +218,12 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
66201
66202 typedef atomic_t atomic_long_t;
66203
66204 +#ifdef CONFIG_PAX_REFCOUNT
66205 +typedef atomic_unchecked_t atomic_long_unchecked_t;
66206 +#else
66207 +typedef atomic_t atomic_long_unchecked_t;
66208 +#endif
66209 +
66210 #define ATOMIC_LONG_INIT(i) ATOMIC_INIT(i)
66211 static inline long atomic_long_read(atomic_long_t *l)
66212 {
66213 @@ -148,6 +232,15 @@ static inline long atomic_long_read(atomic_long_t *l)
66214 return (long)atomic_read(v);
66215 }
66216
66217 +#ifdef CONFIG_PAX_REFCOUNT
66218 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
66219 +{
66220 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66221 +
66222 + return (long)atomic_read_unchecked(v);
66223 +}
66224 +#endif
66225 +
66226 static inline void atomic_long_set(atomic_long_t *l, long i)
66227 {
66228 atomic_t *v = (atomic_t *)l;
66229 @@ -155,6 +248,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
66230 atomic_set(v, i);
66231 }
66232
66233 +#ifdef CONFIG_PAX_REFCOUNT
66234 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
66235 +{
66236 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66237 +
66238 + atomic_set_unchecked(v, i);
66239 +}
66240 +#endif
66241 +
66242 static inline void atomic_long_inc(atomic_long_t *l)
66243 {
66244 atomic_t *v = (atomic_t *)l;
66245 @@ -162,6 +264,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
66246 atomic_inc(v);
66247 }
66248
66249 +#ifdef CONFIG_PAX_REFCOUNT
66250 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
66251 +{
66252 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66253 +
66254 + atomic_inc_unchecked(v);
66255 +}
66256 +#endif
66257 +
66258 static inline void atomic_long_dec(atomic_long_t *l)
66259 {
66260 atomic_t *v = (atomic_t *)l;
66261 @@ -169,6 +280,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
66262 atomic_dec(v);
66263 }
66264
66265 +#ifdef CONFIG_PAX_REFCOUNT
66266 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
66267 +{
66268 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66269 +
66270 + atomic_dec_unchecked(v);
66271 +}
66272 +#endif
66273 +
66274 static inline void atomic_long_add(long i, atomic_long_t *l)
66275 {
66276 atomic_t *v = (atomic_t *)l;
66277 @@ -176,6 +296,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
66278 atomic_add(i, v);
66279 }
66280
66281 +#ifdef CONFIG_PAX_REFCOUNT
66282 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
66283 +{
66284 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66285 +
66286 + atomic_add_unchecked(i, v);
66287 +}
66288 +#endif
66289 +
66290 static inline void atomic_long_sub(long i, atomic_long_t *l)
66291 {
66292 atomic_t *v = (atomic_t *)l;
66293 @@ -183,6 +312,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
66294 atomic_sub(i, v);
66295 }
66296
66297 +#ifdef CONFIG_PAX_REFCOUNT
66298 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
66299 +{
66300 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66301 +
66302 + atomic_sub_unchecked(i, v);
66303 +}
66304 +#endif
66305 +
66306 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
66307 {
66308 atomic_t *v = (atomic_t *)l;
66309 @@ -218,6 +356,16 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
66310 return (long)atomic_add_return(i, v);
66311 }
66312
66313 +#ifdef CONFIG_PAX_REFCOUNT
66314 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
66315 +{
66316 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66317 +
66318 + return (long)atomic_add_return_unchecked(i, v);
66319 +}
66320 +
66321 +#endif
66322 +
66323 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
66324 {
66325 atomic_t *v = (atomic_t *)l;
66326 @@ -232,6 +380,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
66327 return (long)atomic_inc_return(v);
66328 }
66329
66330 +#ifdef CONFIG_PAX_REFCOUNT
66331 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
66332 +{
66333 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66334 +
66335 + return (long)atomic_inc_return_unchecked(v);
66336 +}
66337 +#endif
66338 +
66339 static inline long atomic_long_dec_return(atomic_long_t *l)
66340 {
66341 atomic_t *v = (atomic_t *)l;
66342 @@ -255,4 +412,57 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
66343
66344 #endif /* BITS_PER_LONG == 64 */
66345
66346 +#ifdef CONFIG_PAX_REFCOUNT
66347 +static inline void pax_refcount_needs_these_functions(void)
66348 +{
66349 + atomic_read_unchecked((atomic_unchecked_t *)NULL);
66350 + atomic_set_unchecked((atomic_unchecked_t *)NULL, 0);
66351 + atomic_add_unchecked(0, (atomic_unchecked_t *)NULL);
66352 + atomic_sub_unchecked(0, (atomic_unchecked_t *)NULL);
66353 + atomic_inc_unchecked((atomic_unchecked_t *)NULL);
66354 + (void)atomic_inc_and_test_unchecked((atomic_unchecked_t *)NULL);
66355 + atomic_inc_return_unchecked((atomic_unchecked_t *)NULL);
66356 + atomic_add_return_unchecked(0, (atomic_unchecked_t *)NULL);
66357 + atomic_dec_unchecked((atomic_unchecked_t *)NULL);
66358 + atomic_cmpxchg_unchecked((atomic_unchecked_t *)NULL, 0, 0);
66359 + (void)atomic_xchg_unchecked((atomic_unchecked_t *)NULL, 0);
66360 +#ifdef CONFIG_X86
66361 + atomic_clear_mask_unchecked(0, NULL);
66362 + atomic_set_mask_unchecked(0, NULL);
66363 +#endif
66364 +
66365 + atomic_long_read_unchecked((atomic_long_unchecked_t *)NULL);
66366 + atomic_long_set_unchecked((atomic_long_unchecked_t *)NULL, 0);
66367 + atomic_long_add_unchecked(0, (atomic_long_unchecked_t *)NULL);
66368 + atomic_long_sub_unchecked(0, (atomic_long_unchecked_t *)NULL);
66369 + atomic_long_inc_unchecked((atomic_long_unchecked_t *)NULL);
66370 + atomic_long_add_return_unchecked(0, (atomic_long_unchecked_t *)NULL);
66371 + atomic_long_inc_return_unchecked((atomic_long_unchecked_t *)NULL);
66372 + atomic_long_dec_unchecked((atomic_long_unchecked_t *)NULL);
66373 +}
66374 +#else
66375 +#define atomic_read_unchecked(v) atomic_read(v)
66376 +#define atomic_set_unchecked(v, i) atomic_set((v), (i))
66377 +#define atomic_add_unchecked(i, v) atomic_add((i), (v))
66378 +#define atomic_sub_unchecked(i, v) atomic_sub((i), (v))
66379 +#define atomic_inc_unchecked(v) atomic_inc(v)
66380 +#define atomic_inc_and_test_unchecked(v) atomic_inc_and_test(v)
66381 +#define atomic_inc_return_unchecked(v) atomic_inc_return(v)
66382 +#define atomic_add_return_unchecked(i, v) atomic_add_return((i), (v))
66383 +#define atomic_dec_unchecked(v) atomic_dec(v)
66384 +#define atomic_cmpxchg_unchecked(v, o, n) atomic_cmpxchg((v), (o), (n))
66385 +#define atomic_xchg_unchecked(v, i) atomic_xchg((v), (i))
66386 +#define atomic_clear_mask_unchecked(mask, v) atomic_clear_mask((mask), (v))
66387 +#define atomic_set_mask_unchecked(mask, v) atomic_set_mask((mask), (v))
66388 +
66389 +#define atomic_long_read_unchecked(v) atomic_long_read(v)
66390 +#define atomic_long_set_unchecked(v, i) atomic_long_set((v), (i))
66391 +#define atomic_long_add_unchecked(i, v) atomic_long_add((i), (v))
66392 +#define atomic_long_sub_unchecked(i, v) atomic_long_sub((i), (v))
66393 +#define atomic_long_inc_unchecked(v) atomic_long_inc(v)
66394 +#define atomic_long_add_return_unchecked(i, v) atomic_long_add_return((i), (v))
66395 +#define atomic_long_inc_return_unchecked(v) atomic_long_inc_return(v)
66396 +#define atomic_long_dec_unchecked(v) atomic_long_dec(v)
66397 +#endif
66398 +
66399 #endif /* _ASM_GENERIC_ATOMIC_LONG_H */
66400 diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h
66401 index 33bd2de..f31bff97 100644
66402 --- a/include/asm-generic/atomic.h
66403 +++ b/include/asm-generic/atomic.h
66404 @@ -153,7 +153,7 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
66405 * Atomically clears the bits set in @mask from @v
66406 */
66407 #ifndef atomic_clear_mask
66408 -static inline void atomic_clear_mask(unsigned long mask, atomic_t *v)
66409 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
66410 {
66411 unsigned long flags;
66412
66413 diff --git a/include/asm-generic/atomic64.h b/include/asm-generic/atomic64.h
66414 index b18ce4f..2ee2843 100644
66415 --- a/include/asm-generic/atomic64.h
66416 +++ b/include/asm-generic/atomic64.h
66417 @@ -16,6 +16,8 @@ typedef struct {
66418 long long counter;
66419 } atomic64_t;
66420
66421 +typedef atomic64_t atomic64_unchecked_t;
66422 +
66423 #define ATOMIC64_INIT(i) { (i) }
66424
66425 extern long long atomic64_read(const atomic64_t *v);
66426 @@ -39,4 +41,14 @@ extern int atomic64_add_unless(atomic64_t *v, long long a, long long u);
66427 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
66428 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
66429
66430 +#define atomic64_read_unchecked(v) atomic64_read(v)
66431 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
66432 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
66433 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
66434 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
66435 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
66436 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
66437 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
66438 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
66439 +
66440 #endif /* _ASM_GENERIC_ATOMIC64_H */
66441 diff --git a/include/asm-generic/cache.h b/include/asm-generic/cache.h
66442 index 1bfcfe5..e04c5c9 100644
66443 --- a/include/asm-generic/cache.h
66444 +++ b/include/asm-generic/cache.h
66445 @@ -6,7 +6,7 @@
66446 * cache lines need to provide their own cache.h.
66447 */
66448
66449 -#define L1_CACHE_SHIFT 5
66450 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
66451 +#define L1_CACHE_SHIFT 5UL
66452 +#define L1_CACHE_BYTES (1UL << L1_CACHE_SHIFT)
66453
66454 #endif /* __ASM_GENERIC_CACHE_H */
66455 diff --git a/include/asm-generic/emergency-restart.h b/include/asm-generic/emergency-restart.h
66456 index 0d68a1e..b74a761 100644
66457 --- a/include/asm-generic/emergency-restart.h
66458 +++ b/include/asm-generic/emergency-restart.h
66459 @@ -1,7 +1,7 @@
66460 #ifndef _ASM_GENERIC_EMERGENCY_RESTART_H
66461 #define _ASM_GENERIC_EMERGENCY_RESTART_H
66462
66463 -static inline void machine_emergency_restart(void)
66464 +static inline __noreturn void machine_emergency_restart(void)
66465 {
66466 machine_restart(NULL);
66467 }
66468 diff --git a/include/asm-generic/kmap_types.h b/include/asm-generic/kmap_types.h
66469 index 90f99c7..00ce236 100644
66470 --- a/include/asm-generic/kmap_types.h
66471 +++ b/include/asm-generic/kmap_types.h
66472 @@ -2,9 +2,9 @@
66473 #define _ASM_GENERIC_KMAP_TYPES_H
66474
66475 #ifdef __WITH_KM_FENCE
66476 -# define KM_TYPE_NR 41
66477 +# define KM_TYPE_NR 42
66478 #else
66479 -# define KM_TYPE_NR 20
66480 +# define KM_TYPE_NR 21
66481 #endif
66482
66483 #endif
66484 diff --git a/include/asm-generic/local.h b/include/asm-generic/local.h
66485 index 9ceb03b..62b0b8f 100644
66486 --- a/include/asm-generic/local.h
66487 +++ b/include/asm-generic/local.h
66488 @@ -23,24 +23,37 @@ typedef struct
66489 atomic_long_t a;
66490 } local_t;
66491
66492 +typedef struct {
66493 + atomic_long_unchecked_t a;
66494 +} local_unchecked_t;
66495 +
66496 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
66497
66498 #define local_read(l) atomic_long_read(&(l)->a)
66499 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
66500 #define local_set(l,i) atomic_long_set((&(l)->a),(i))
66501 +#define local_set_unchecked(l,i) atomic_long_set_unchecked((&(l)->a),(i))
66502 #define local_inc(l) atomic_long_inc(&(l)->a)
66503 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
66504 #define local_dec(l) atomic_long_dec(&(l)->a)
66505 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
66506 #define local_add(i,l) atomic_long_add((i),(&(l)->a))
66507 +#define local_add_unchecked(i,l) atomic_long_add_unchecked((i),(&(l)->a))
66508 #define local_sub(i,l) atomic_long_sub((i),(&(l)->a))
66509 +#define local_sub_unchecked(i,l) atomic_long_sub_unchecked((i),(&(l)->a))
66510
66511 #define local_sub_and_test(i, l) atomic_long_sub_and_test((i), (&(l)->a))
66512 #define local_dec_and_test(l) atomic_long_dec_and_test(&(l)->a)
66513 #define local_inc_and_test(l) atomic_long_inc_and_test(&(l)->a)
66514 #define local_add_negative(i, l) atomic_long_add_negative((i), (&(l)->a))
66515 #define local_add_return(i, l) atomic_long_add_return((i), (&(l)->a))
66516 +#define local_add_return_unchecked(i, l) atomic_long_add_return_unchecked((i), (&(l)->a))
66517 #define local_sub_return(i, l) atomic_long_sub_return((i), (&(l)->a))
66518 #define local_inc_return(l) atomic_long_inc_return(&(l)->a)
66519 +#define local_dec_return(l) atomic_long_dec_return(&(l)->a)
66520
66521 #define local_cmpxchg(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
66522 +#define local_cmpxchg_unchecked(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
66523 #define local_xchg(l, n) atomic_long_xchg((&(l)->a), (n))
66524 #define local_add_unless(l, _a, u) atomic_long_add_unless((&(l)->a), (_a), (u))
66525 #define local_inc_not_zero(l) atomic_long_inc_not_zero(&(l)->a)
66526 diff --git a/include/asm-generic/pgtable-nopmd.h b/include/asm-generic/pgtable-nopmd.h
66527 index 725612b..9cc513a 100644
66528 --- a/include/asm-generic/pgtable-nopmd.h
66529 +++ b/include/asm-generic/pgtable-nopmd.h
66530 @@ -1,14 +1,19 @@
66531 #ifndef _PGTABLE_NOPMD_H
66532 #define _PGTABLE_NOPMD_H
66533
66534 -#ifndef __ASSEMBLY__
66535 -
66536 #include <asm-generic/pgtable-nopud.h>
66537
66538 -struct mm_struct;
66539 -
66540 #define __PAGETABLE_PMD_FOLDED
66541
66542 +#define PMD_SHIFT PUD_SHIFT
66543 +#define PTRS_PER_PMD 1
66544 +#define PMD_SIZE (_AC(1,UL) << PMD_SHIFT)
66545 +#define PMD_MASK (~(PMD_SIZE-1))
66546 +
66547 +#ifndef __ASSEMBLY__
66548 +
66549 +struct mm_struct;
66550 +
66551 /*
66552 * Having the pmd type consist of a pud gets the size right, and allows
66553 * us to conceptually access the pud entry that this pmd is folded into
66554 @@ -16,11 +21,6 @@ struct mm_struct;
66555 */
66556 typedef struct { pud_t pud; } pmd_t;
66557
66558 -#define PMD_SHIFT PUD_SHIFT
66559 -#define PTRS_PER_PMD 1
66560 -#define PMD_SIZE (1UL << PMD_SHIFT)
66561 -#define PMD_MASK (~(PMD_SIZE-1))
66562 -
66563 /*
66564 * The "pud_xxx()" functions here are trivial for a folded two-level
66565 * setup: the pmd is never bad, and a pmd always exists (as it's folded
66566 diff --git a/include/asm-generic/pgtable-nopud.h b/include/asm-generic/pgtable-nopud.h
66567 index 810431d..0ec4804f 100644
66568 --- a/include/asm-generic/pgtable-nopud.h
66569 +++ b/include/asm-generic/pgtable-nopud.h
66570 @@ -1,10 +1,15 @@
66571 #ifndef _PGTABLE_NOPUD_H
66572 #define _PGTABLE_NOPUD_H
66573
66574 -#ifndef __ASSEMBLY__
66575 -
66576 #define __PAGETABLE_PUD_FOLDED
66577
66578 +#define PUD_SHIFT PGDIR_SHIFT
66579 +#define PTRS_PER_PUD 1
66580 +#define PUD_SIZE (_AC(1,UL) << PUD_SHIFT)
66581 +#define PUD_MASK (~(PUD_SIZE-1))
66582 +
66583 +#ifndef __ASSEMBLY__
66584 +
66585 /*
66586 * Having the pud type consist of a pgd gets the size right, and allows
66587 * us to conceptually access the pgd entry that this pud is folded into
66588 @@ -12,11 +17,6 @@
66589 */
66590 typedef struct { pgd_t pgd; } pud_t;
66591
66592 -#define PUD_SHIFT PGDIR_SHIFT
66593 -#define PTRS_PER_PUD 1
66594 -#define PUD_SIZE (1UL << PUD_SHIFT)
66595 -#define PUD_MASK (~(PUD_SIZE-1))
66596 -
66597 /*
66598 * The "pgd_xxx()" functions here are trivial for a folded two-level
66599 * setup: the pud is never bad, and a pud always exists (as it's folded
66600 @@ -29,6 +29,7 @@ static inline void pgd_clear(pgd_t *pgd) { }
66601 #define pud_ERROR(pud) (pgd_ERROR((pud).pgd))
66602
66603 #define pgd_populate(mm, pgd, pud) do { } while (0)
66604 +#define pgd_populate_kernel(mm, pgd, pud) do { } while (0)
66605 /*
66606 * (puds are folded into pgds so this doesn't get actually called,
66607 * but the define is needed for a generic inline function.)
66608 diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
66609 index a59ff51..2594a70 100644
66610 --- a/include/asm-generic/pgtable.h
66611 +++ b/include/asm-generic/pgtable.h
66612 @@ -688,6 +688,14 @@ static inline pmd_t pmd_mknuma(pmd_t pmd)
66613 }
66614 #endif /* CONFIG_NUMA_BALANCING */
66615
66616 +#ifndef __HAVE_ARCH_PAX_OPEN_KERNEL
66617 +static inline unsigned long pax_open_kernel(void) { return 0; }
66618 +#endif
66619 +
66620 +#ifndef __HAVE_ARCH_PAX_CLOSE_KERNEL
66621 +static inline unsigned long pax_close_kernel(void) { return 0; }
66622 +#endif
66623 +
66624 #endif /* CONFIG_MMU */
66625
66626 #endif /* !__ASSEMBLY__ */
66627 diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
66628 index afa12c7..99d4da0 100644
66629 --- a/include/asm-generic/vmlinux.lds.h
66630 +++ b/include/asm-generic/vmlinux.lds.h
66631 @@ -245,6 +245,7 @@
66632 .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
66633 VMLINUX_SYMBOL(__start_rodata) = .; \
66634 *(.rodata) *(.rodata.*) \
66635 + *(.data..read_only) \
66636 *(__vermagic) /* Kernel version magic */ \
66637 . = ALIGN(8); \
66638 VMLINUX_SYMBOL(__start___tracepoints_ptrs) = .; \
66639 @@ -755,17 +756,18 @@
66640 * section in the linker script will go there too. @phdr should have
66641 * a leading colon.
66642 *
66643 - * Note that this macros defines __per_cpu_load as an absolute symbol.
66644 + * Note that this macros defines per_cpu_load as an absolute symbol.
66645 * If there is no need to put the percpu section at a predetermined
66646 * address, use PERCPU_SECTION.
66647 */
66648 #define PERCPU_VADDR(cacheline, vaddr, phdr) \
66649 - VMLINUX_SYMBOL(__per_cpu_load) = .; \
66650 - .data..percpu vaddr : AT(VMLINUX_SYMBOL(__per_cpu_load) \
66651 + per_cpu_load = .; \
66652 + .data..percpu vaddr : AT(VMLINUX_SYMBOL(per_cpu_load) \
66653 - LOAD_OFFSET) { \
66654 + VMLINUX_SYMBOL(__per_cpu_load) = . + per_cpu_load; \
66655 PERCPU_INPUT(cacheline) \
66656 } phdr \
66657 - . = VMLINUX_SYMBOL(__per_cpu_load) + SIZEOF(.data..percpu);
66658 + . = VMLINUX_SYMBOL(per_cpu_load) + SIZEOF(.data..percpu);
66659
66660 /**
66661 * PERCPU_SECTION - define output section for percpu area, simple version
66662 diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
66663 index 418d270..bfd2794 100644
66664 --- a/include/crypto/algapi.h
66665 +++ b/include/crypto/algapi.h
66666 @@ -34,7 +34,7 @@ struct crypto_type {
66667 unsigned int maskclear;
66668 unsigned int maskset;
66669 unsigned int tfmsize;
66670 -};
66671 +} __do_const;
66672
66673 struct crypto_instance {
66674 struct crypto_alg alg;
66675 diff --git a/include/drm/drmP.h b/include/drm/drmP.h
66676 index f1ce786..086a7a5 100644
66677 --- a/include/drm/drmP.h
66678 +++ b/include/drm/drmP.h
66679 @@ -72,6 +72,7 @@
66680 #include <linux/workqueue.h>
66681 #include <linux/poll.h>
66682 #include <asm/pgalloc.h>
66683 +#include <asm/local.h>
66684 #include <drm/drm.h>
66685 #include <drm/drm_sarea.h>
66686
66687 @@ -296,10 +297,12 @@ do { \
66688 * \param cmd command.
66689 * \param arg argument.
66690 */
66691 -typedef int drm_ioctl_t(struct drm_device *dev, void *data,
66692 +typedef int (* const drm_ioctl_t)(struct drm_device *dev, void *data,
66693 + struct drm_file *file_priv);
66694 +typedef int (* drm_ioctl_no_const_t)(struct drm_device *dev, void *data,
66695 struct drm_file *file_priv);
66696
66697 -typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
66698 +typedef int (* const drm_ioctl_compat_t)(struct file *filp, unsigned int cmd,
66699 unsigned long arg);
66700
66701 #define DRM_IOCTL_NR(n) _IOC_NR(n)
66702 @@ -314,9 +317,9 @@ typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
66703 struct drm_ioctl_desc {
66704 unsigned int cmd;
66705 int flags;
66706 - drm_ioctl_t *func;
66707 + drm_ioctl_t func;
66708 unsigned int cmd_drv;
66709 -};
66710 +} __do_const;
66711
66712 /**
66713 * Creates a driver or general drm_ioctl_desc array entry for the given
66714 @@ -1014,7 +1017,7 @@ struct drm_info_list {
66715 int (*show)(struct seq_file*, void*); /** show callback */
66716 u32 driver_features; /**< Required driver features for this entry */
66717 void *data;
66718 -};
66719 +} __do_const;
66720
66721 /**
66722 * debugfs node structure. This structure represents a debugfs file.
66723 @@ -1087,7 +1090,7 @@ struct drm_device {
66724
66725 /** \name Usage Counters */
66726 /*@{ */
66727 - int open_count; /**< Outstanding files open */
66728 + local_t open_count; /**< Outstanding files open */
66729 atomic_t ioctl_count; /**< Outstanding IOCTLs pending */
66730 atomic_t vma_count; /**< Outstanding vma areas open */
66731 int buf_use; /**< Buffers in use -- cannot alloc */
66732 @@ -1098,7 +1101,7 @@ struct drm_device {
66733 /*@{ */
66734 unsigned long counters;
66735 enum drm_stat_type types[15];
66736 - atomic_t counts[15];
66737 + atomic_unchecked_t counts[15];
66738 /*@} */
66739
66740 struct list_head filelist;
66741 diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
66742 index f43d556..94d9343 100644
66743 --- a/include/drm/drm_crtc_helper.h
66744 +++ b/include/drm/drm_crtc_helper.h
66745 @@ -109,7 +109,7 @@ struct drm_encoder_helper_funcs {
66746 struct drm_connector *connector);
66747 /* disable encoder when not in use - more explicit than dpms off */
66748 void (*disable)(struct drm_encoder *encoder);
66749 -};
66750 +} __no_const;
66751
66752 /**
66753 * drm_connector_helper_funcs - helper operations for connectors
66754 diff --git a/include/drm/ttm/ttm_memory.h b/include/drm/ttm/ttm_memory.h
66755 index 72dcbe8..8db58d7 100644
66756 --- a/include/drm/ttm/ttm_memory.h
66757 +++ b/include/drm/ttm/ttm_memory.h
66758 @@ -48,7 +48,7 @@
66759
66760 struct ttm_mem_shrink {
66761 int (*do_shrink) (struct ttm_mem_shrink *);
66762 -};
66763 +} __no_const;
66764
66765 /**
66766 * struct ttm_mem_global - Global memory accounting structure.
66767 diff --git a/include/keys/asymmetric-subtype.h b/include/keys/asymmetric-subtype.h
66768 index 4b840e8..155d235 100644
66769 --- a/include/keys/asymmetric-subtype.h
66770 +++ b/include/keys/asymmetric-subtype.h
66771 @@ -37,7 +37,7 @@ struct asymmetric_key_subtype {
66772 /* Verify the signature on a key of this subtype (optional) */
66773 int (*verify_signature)(const struct key *key,
66774 const struct public_key_signature *sig);
66775 -};
66776 +} __do_const;
66777
66778 /**
66779 * asymmetric_key_subtype - Get the subtype from an asymmetric key
66780 diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h
66781 index c1da539..1dcec55 100644
66782 --- a/include/linux/atmdev.h
66783 +++ b/include/linux/atmdev.h
66784 @@ -28,7 +28,7 @@ struct compat_atm_iobuf {
66785 #endif
66786
66787 struct k_atm_aal_stats {
66788 -#define __HANDLE_ITEM(i) atomic_t i
66789 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
66790 __AAL_STAT_ITEMS
66791 #undef __HANDLE_ITEM
66792 };
66793 @@ -200,7 +200,7 @@ struct atmdev_ops { /* only send is required */
66794 int (*change_qos)(struct atm_vcc *vcc,struct atm_qos *qos,int flags);
66795 int (*proc_read)(struct atm_dev *dev,loff_t *pos,char *page);
66796 struct module *owner;
66797 -};
66798 +} __do_const ;
66799
66800 struct atmphy_ops {
66801 int (*start)(struct atm_dev *dev);
66802 diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
66803 index c3a0914..ec5d48a 100644
66804 --- a/include/linux/binfmts.h
66805 +++ b/include/linux/binfmts.h
66806 @@ -73,8 +73,9 @@ struct linux_binfmt {
66807 int (*load_binary)(struct linux_binprm *);
66808 int (*load_shlib)(struct file *);
66809 int (*core_dump)(struct coredump_params *cprm);
66810 + void (*handle_mprotect)(struct vm_area_struct *vma, unsigned long newflags);
66811 unsigned long min_coredump; /* minimal dump size */
66812 -};
66813 +} __do_const;
66814
66815 extern void __register_binfmt(struct linux_binfmt *fmt, int insert);
66816
66817 diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
66818 index 33f358f..7f2c27f 100644
66819 --- a/include/linux/blkdev.h
66820 +++ b/include/linux/blkdev.h
66821 @@ -1499,7 +1499,7 @@ struct block_device_operations {
66822 /* this callback is with swap_lock and sometimes page table lock held */
66823 void (*swap_slot_free_notify) (struct block_device *, unsigned long);
66824 struct module *owner;
66825 -};
66826 +} __do_const;
66827
66828 extern int __blkdev_driver_ioctl(struct block_device *, fmode_t, unsigned int,
66829 unsigned long);
66830 diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
66831 index 7c2e030..b72475d 100644
66832 --- a/include/linux/blktrace_api.h
66833 +++ b/include/linux/blktrace_api.h
66834 @@ -23,7 +23,7 @@ struct blk_trace {
66835 struct dentry *dir;
66836 struct dentry *dropped_file;
66837 struct dentry *msg_file;
66838 - atomic_t dropped;
66839 + atomic_unchecked_t dropped;
66840 };
66841
66842 extern int blk_trace_ioctl(struct block_device *, unsigned, char __user *);
66843 diff --git a/include/linux/cache.h b/include/linux/cache.h
66844 index 4c57065..4307975 100644
66845 --- a/include/linux/cache.h
66846 +++ b/include/linux/cache.h
66847 @@ -16,6 +16,10 @@
66848 #define __read_mostly
66849 #endif
66850
66851 +#ifndef __read_only
66852 +#define __read_only __read_mostly
66853 +#endif
66854 +
66855 #ifndef ____cacheline_aligned
66856 #define ____cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES)))
66857 #endif
66858 diff --git a/include/linux/capability.h b/include/linux/capability.h
66859 index d9a4f7f4..19f77d6 100644
66860 --- a/include/linux/capability.h
66861 +++ b/include/linux/capability.h
66862 @@ -213,8 +213,13 @@ extern bool ns_capable(struct user_namespace *ns, int cap);
66863 extern bool nsown_capable(int cap);
66864 extern bool inode_capable(const struct inode *inode, int cap);
66865 extern bool file_ns_capable(const struct file *file, struct user_namespace *ns, int cap);
66866 +extern bool capable_nolog(int cap);
66867 +extern bool ns_capable_nolog(struct user_namespace *ns, int cap);
66868 +extern bool inode_capable_nolog(const struct inode *inode, int cap);
66869
66870 /* audit system wants to get cap info from files as well */
66871 extern int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data *cpu_caps);
66872
66873 +extern int is_privileged_binary(const struct dentry *dentry);
66874 +
66875 #endif /* !_LINUX_CAPABILITY_H */
66876 diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h
66877 index 8609d57..86e4d79 100644
66878 --- a/include/linux/cdrom.h
66879 +++ b/include/linux/cdrom.h
66880 @@ -87,7 +87,6 @@ struct cdrom_device_ops {
66881
66882 /* driver specifications */
66883 const int capability; /* capability flags */
66884 - int n_minors; /* number of active minor devices */
66885 /* handle uniform packets for scsi type devices (scsi,atapi) */
66886 int (*generic_packet) (struct cdrom_device_info *,
66887 struct packet_command *);
66888 diff --git a/include/linux/cleancache.h b/include/linux/cleancache.h
66889 index 42e55de..1cd0e66 100644
66890 --- a/include/linux/cleancache.h
66891 +++ b/include/linux/cleancache.h
66892 @@ -31,7 +31,7 @@ struct cleancache_ops {
66893 void (*invalidate_page)(int, struct cleancache_filekey, pgoff_t);
66894 void (*invalidate_inode)(int, struct cleancache_filekey);
66895 void (*invalidate_fs)(int);
66896 -};
66897 +} __no_const;
66898
66899 extern struct cleancache_ops
66900 cleancache_register_ops(struct cleancache_ops *ops);
66901 diff --git a/include/linux/compat.h b/include/linux/compat.h
66902 index 377cd8c..2479845 100644
66903 --- a/include/linux/compat.h
66904 +++ b/include/linux/compat.h
66905 @@ -332,14 +332,14 @@ long compat_sys_msgsnd(int first, int second, int third, void __user *uptr);
66906 long compat_sys_msgrcv(int first, int second, int msgtyp, int third,
66907 int version, void __user *uptr);
66908 long compat_sys_shmat(int first, int second, compat_uptr_t third, int version,
66909 - void __user *uptr);
66910 + void __user *uptr) __intentional_overflow(0);
66911 #else
66912 long compat_sys_semctl(int semid, int semnum, int cmd, int arg);
66913 long compat_sys_msgsnd(int msqid, struct compat_msgbuf __user *msgp,
66914 compat_ssize_t msgsz, int msgflg);
66915 long compat_sys_msgrcv(int msqid, struct compat_msgbuf __user *msgp,
66916 compat_ssize_t msgsz, long msgtyp, int msgflg);
66917 -long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg);
66918 +long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg) __intentional_overflow(0);
66919 #endif
66920 long compat_sys_msgctl(int first, int second, void __user *uptr);
66921 long compat_sys_shmctl(int first, int second, void __user *uptr);
66922 @@ -442,7 +442,7 @@ extern int compat_ptrace_request(struct task_struct *child,
66923 extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
66924 compat_ulong_t addr, compat_ulong_t data);
66925 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
66926 - compat_long_t addr, compat_long_t data);
66927 + compat_ulong_t addr, compat_ulong_t data);
66928
66929 /*
66930 * epoll (fs/eventpoll.c) compat bits follow ...
66931 diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
66932 index 68b162d..660f5f0 100644
66933 --- a/include/linux/compiler-gcc4.h
66934 +++ b/include/linux/compiler-gcc4.h
66935 @@ -39,9 +39,29 @@
66936 # define __compiletime_warning(message) __attribute__((warning(message)))
66937 # define __compiletime_error(message) __attribute__((error(message)))
66938 #endif /* __CHECKER__ */
66939 +
66940 +#define __alloc_size(...) __attribute((alloc_size(__VA_ARGS__)))
66941 +#define __bos(ptr, arg) __builtin_object_size((ptr), (arg))
66942 +#define __bos0(ptr) __bos((ptr), 0)
66943 +#define __bos1(ptr) __bos((ptr), 1)
66944 #endif /* GCC_VERSION >= 40300 */
66945
66946 #if GCC_VERSION >= 40500
66947 +
66948 +#ifdef CONSTIFY_PLUGIN
66949 +#define __no_const __attribute__((no_const))
66950 +#define __do_const __attribute__((do_const))
66951 +#endif
66952 +
66953 +#ifdef SIZE_OVERFLOW_PLUGIN
66954 +#define __size_overflow(...) __attribute__((size_overflow(__VA_ARGS__)))
66955 +#define __intentional_overflow(...) __attribute__((intentional_overflow(__VA_ARGS__)))
66956 +#endif
66957 +
66958 +#ifdef LATENT_ENTROPY_PLUGIN
66959 +#define __latent_entropy __attribute__((latent_entropy))
66960 +#endif
66961 +
66962 /*
66963 * Mark a position in code as unreachable. This can be used to
66964 * suppress control flow warnings after asm blocks that transfer
66965 diff --git a/include/linux/compiler.h b/include/linux/compiler.h
66966 index 10b8f23..5e0b083 100644
66967 --- a/include/linux/compiler.h
66968 +++ b/include/linux/compiler.h
66969 @@ -5,11 +5,14 @@
66970
66971 #ifdef __CHECKER__
66972 # define __user __attribute__((noderef, address_space(1)))
66973 +# define __force_user __force __user
66974 # define __kernel __attribute__((address_space(0)))
66975 +# define __force_kernel __force __kernel
66976 # define __safe __attribute__((safe))
66977 # define __force __attribute__((force))
66978 # define __nocast __attribute__((nocast))
66979 # define __iomem __attribute__((noderef, address_space(2)))
66980 +# define __force_iomem __force __iomem
66981 # define __must_hold(x) __attribute__((context(x,1,1)))
66982 # define __acquires(x) __attribute__((context(x,0,1)))
66983 # define __releases(x) __attribute__((context(x,1,0)))
66984 @@ -17,20 +20,37 @@
66985 # define __release(x) __context__(x,-1)
66986 # define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0)
66987 # define __percpu __attribute__((noderef, address_space(3)))
66988 +# define __force_percpu __force __percpu
66989 #ifdef CONFIG_SPARSE_RCU_POINTER
66990 # define __rcu __attribute__((noderef, address_space(4)))
66991 +# define __force_rcu __force __rcu
66992 #else
66993 # define __rcu
66994 +# define __force_rcu
66995 #endif
66996 extern void __chk_user_ptr(const volatile void __user *);
66997 extern void __chk_io_ptr(const volatile void __iomem *);
66998 #else
66999 -# define __user
67000 -# define __kernel
67001 +# ifdef CHECKER_PLUGIN
67002 +//# define __user
67003 +//# define __force_user
67004 +//# define __kernel
67005 +//# define __force_kernel
67006 +# else
67007 +# ifdef STRUCTLEAK_PLUGIN
67008 +# define __user __attribute__((user))
67009 +# else
67010 +# define __user
67011 +# endif
67012 +# define __force_user
67013 +# define __kernel
67014 +# define __force_kernel
67015 +# endif
67016 # define __safe
67017 # define __force
67018 # define __nocast
67019 # define __iomem
67020 +# define __force_iomem
67021 # define __chk_user_ptr(x) (void)0
67022 # define __chk_io_ptr(x) (void)0
67023 # define __builtin_warning(x, y...) (1)
67024 @@ -41,7 +61,9 @@ extern void __chk_io_ptr(const volatile void __iomem *);
67025 # define __release(x) (void)0
67026 # define __cond_lock(x,c) (c)
67027 # define __percpu
67028 +# define __force_percpu
67029 # define __rcu
67030 +# define __force_rcu
67031 #endif
67032
67033 /* Indirect macros required for expanded argument pasting, eg. __LINE__. */
67034 @@ -275,6 +297,26 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
67035 # define __attribute_const__ /* unimplemented */
67036 #endif
67037
67038 +#ifndef __no_const
67039 +# define __no_const
67040 +#endif
67041 +
67042 +#ifndef __do_const
67043 +# define __do_const
67044 +#endif
67045 +
67046 +#ifndef __size_overflow
67047 +# define __size_overflow(...)
67048 +#endif
67049 +
67050 +#ifndef __intentional_overflow
67051 +# define __intentional_overflow(...)
67052 +#endif
67053 +
67054 +#ifndef __latent_entropy
67055 +# define __latent_entropy
67056 +#endif
67057 +
67058 /*
67059 * Tell gcc if a function is cold. The compiler will assume any path
67060 * directly leading to the call is unlikely.
67061 @@ -284,6 +326,22 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
67062 #define __cold
67063 #endif
67064
67065 +#ifndef __alloc_size
67066 +#define __alloc_size(...)
67067 +#endif
67068 +
67069 +#ifndef __bos
67070 +#define __bos(ptr, arg)
67071 +#endif
67072 +
67073 +#ifndef __bos0
67074 +#define __bos0(ptr)
67075 +#endif
67076 +
67077 +#ifndef __bos1
67078 +#define __bos1(ptr)
67079 +#endif
67080 +
67081 /* Simple shorthand for a section definition */
67082 #ifndef __section
67083 # define __section(S) __attribute__ ((__section__(#S)))
67084 @@ -349,6 +407,7 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
67085 * use is to mediate communication between process-level code and irq/NMI
67086 * handlers, all running on the same CPU.
67087 */
67088 -#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
67089 +#define ACCESS_ONCE(x) (*(volatile const typeof(x) *)&(x))
67090 +#define ACCESS_ONCE_RW(x) (*(volatile typeof(x) *)&(x))
67091
67092 #endif /* __LINUX_COMPILER_H */
67093 diff --git a/include/linux/completion.h b/include/linux/completion.h
67094 index 33f0280..35c6568 100644
67095 --- a/include/linux/completion.h
67096 +++ b/include/linux/completion.h
67097 @@ -79,15 +79,15 @@ static inline void init_completion(struct completion *x)
67098 extern void wait_for_completion(struct completion *);
67099 extern void wait_for_completion_io(struct completion *);
67100 extern int wait_for_completion_interruptible(struct completion *x);
67101 -extern int wait_for_completion_killable(struct completion *x);
67102 +extern int wait_for_completion_killable(struct completion *x) __intentional_overflow(-1);
67103 extern unsigned long wait_for_completion_timeout(struct completion *x,
67104 unsigned long timeout);
67105 extern unsigned long wait_for_completion_io_timeout(struct completion *x,
67106 unsigned long timeout);
67107 extern long wait_for_completion_interruptible_timeout(
67108 - struct completion *x, unsigned long timeout);
67109 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
67110 extern long wait_for_completion_killable_timeout(
67111 - struct completion *x, unsigned long timeout);
67112 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
67113 extern bool try_wait_for_completion(struct completion *x);
67114 extern bool completion_done(struct completion *x);
67115
67116 diff --git a/include/linux/configfs.h b/include/linux/configfs.h
67117 index 34025df..d94bbbc 100644
67118 --- a/include/linux/configfs.h
67119 +++ b/include/linux/configfs.h
67120 @@ -125,7 +125,7 @@ struct configfs_attribute {
67121 const char *ca_name;
67122 struct module *ca_owner;
67123 umode_t ca_mode;
67124 -};
67125 +} __do_const;
67126
67127 /*
67128 * Users often need to create attribute structures for their configurable
67129 diff --git a/include/linux/cpu.h b/include/linux/cpu.h
67130 index ce7a074..01ab8ac 100644
67131 --- a/include/linux/cpu.h
67132 +++ b/include/linux/cpu.h
67133 @@ -115,7 +115,7 @@ enum {
67134 /* Need to know about CPUs going up/down? */
67135 #if defined(CONFIG_HOTPLUG_CPU) || !defined(MODULE)
67136 #define cpu_notifier(fn, pri) { \
67137 - static struct notifier_block fn##_nb __cpuinitdata = \
67138 + static struct notifier_block fn##_nb = \
67139 { .notifier_call = fn, .priority = pri }; \
67140 register_cpu_notifier(&fn##_nb); \
67141 }
67142 diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
67143 index a22944c..4e695fe 100644
67144 --- a/include/linux/cpufreq.h
67145 +++ b/include/linux/cpufreq.h
67146 @@ -252,7 +252,7 @@ struct cpufreq_driver {
67147 int (*suspend) (struct cpufreq_policy *policy);
67148 int (*resume) (struct cpufreq_policy *policy);
67149 struct freq_attr **attr;
67150 -};
67151 +} __do_const;
67152
67153 /* flags */
67154
67155 @@ -311,6 +311,7 @@ struct global_attr {
67156 ssize_t (*store)(struct kobject *a, struct attribute *b,
67157 const char *c, size_t count);
67158 };
67159 +typedef struct global_attr __no_const global_attr_no_const;
67160
67161 #define define_one_global_ro(_name) \
67162 static struct global_attr _name = \
67163 diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
67164 index 480c14d..552896f 100644
67165 --- a/include/linux/cpuidle.h
67166 +++ b/include/linux/cpuidle.h
67167 @@ -52,7 +52,8 @@ struct cpuidle_state {
67168 int index);
67169
67170 int (*enter_dead) (struct cpuidle_device *dev, int index);
67171 -};
67172 +} __do_const;
67173 +typedef struct cpuidle_state __no_const cpuidle_state_no_const;
67174
67175 /* Idle State Flags */
67176 #define CPUIDLE_FLAG_TIME_VALID (0x01) /* is residency time measurable? */
67177 @@ -194,7 +195,7 @@ struct cpuidle_governor {
67178 void (*reflect) (struct cpuidle_device *dev, int index);
67179
67180 struct module *owner;
67181 -};
67182 +} __do_const;
67183
67184 #ifdef CONFIG_CPU_IDLE
67185
67186 diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
67187 index 0325602..5e9feff 100644
67188 --- a/include/linux/cpumask.h
67189 +++ b/include/linux/cpumask.h
67190 @@ -118,17 +118,17 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
67191 }
67192
67193 /* Valid inputs for n are -1 and 0. */
67194 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
67195 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
67196 {
67197 return n+1;
67198 }
67199
67200 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
67201 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
67202 {
67203 return n+1;
67204 }
67205
67206 -static inline unsigned int cpumask_next_and(int n,
67207 +static inline unsigned int __intentional_overflow(-1) cpumask_next_and(int n,
67208 const struct cpumask *srcp,
67209 const struct cpumask *andp)
67210 {
67211 @@ -167,7 +167,7 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
67212 *
67213 * Returns >= nr_cpu_ids if no further cpus set.
67214 */
67215 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
67216 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
67217 {
67218 /* -1 is a legal arg here. */
67219 if (n != -1)
67220 @@ -182,7 +182,7 @@ static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
67221 *
67222 * Returns >= nr_cpu_ids if no further cpus unset.
67223 */
67224 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
67225 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
67226 {
67227 /* -1 is a legal arg here. */
67228 if (n != -1)
67229 @@ -190,7 +190,7 @@ static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
67230 return find_next_zero_bit(cpumask_bits(srcp), nr_cpumask_bits, n+1);
67231 }
67232
67233 -int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *);
67234 +int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *) __intentional_overflow(-1);
67235 int cpumask_any_but(const struct cpumask *mask, unsigned int cpu);
67236
67237 /**
67238 diff --git a/include/linux/cred.h b/include/linux/cred.h
67239 index 04421e8..6bce4ef 100644
67240 --- a/include/linux/cred.h
67241 +++ b/include/linux/cred.h
67242 @@ -194,6 +194,9 @@ static inline void validate_creds_for_do_exit(struct task_struct *tsk)
67243 static inline void validate_process_creds(void)
67244 {
67245 }
67246 +static inline void validate_task_creds(struct task_struct *task)
67247 +{
67248 +}
67249 #endif
67250
67251 /**
67252 diff --git a/include/linux/crypto.h b/include/linux/crypto.h
67253 index b92eadf..b4ecdc1 100644
67254 --- a/include/linux/crypto.h
67255 +++ b/include/linux/crypto.h
67256 @@ -373,7 +373,7 @@ struct cipher_tfm {
67257 const u8 *key, unsigned int keylen);
67258 void (*cit_encrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
67259 void (*cit_decrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
67260 -};
67261 +} __no_const;
67262
67263 struct hash_tfm {
67264 int (*init)(struct hash_desc *desc);
67265 @@ -394,13 +394,13 @@ struct compress_tfm {
67266 int (*cot_decompress)(struct crypto_tfm *tfm,
67267 const u8 *src, unsigned int slen,
67268 u8 *dst, unsigned int *dlen);
67269 -};
67270 +} __no_const;
67271
67272 struct rng_tfm {
67273 int (*rng_gen_random)(struct crypto_rng *tfm, u8 *rdata,
67274 unsigned int dlen);
67275 int (*rng_reset)(struct crypto_rng *tfm, u8 *seed, unsigned int slen);
67276 -};
67277 +} __no_const;
67278
67279 #define crt_ablkcipher crt_u.ablkcipher
67280 #define crt_aead crt_u.aead
67281 diff --git a/include/linux/ctype.h b/include/linux/ctype.h
67282 index 8acfe31..6ffccd63 100644
67283 --- a/include/linux/ctype.h
67284 +++ b/include/linux/ctype.h
67285 @@ -56,7 +56,7 @@ static inline unsigned char __toupper(unsigned char c)
67286 * Fast implementation of tolower() for internal usage. Do not use in your
67287 * code.
67288 */
67289 -static inline char _tolower(const char c)
67290 +static inline unsigned char _tolower(const unsigned char c)
67291 {
67292 return c | 0x20;
67293 }
67294 diff --git a/include/linux/decompress/mm.h b/include/linux/decompress/mm.h
67295 index 7925bf0..d5143d2 100644
67296 --- a/include/linux/decompress/mm.h
67297 +++ b/include/linux/decompress/mm.h
67298 @@ -77,7 +77,7 @@ static void free(void *where)
67299 * warnings when not needed (indeed large_malloc / large_free are not
67300 * needed by inflate */
67301
67302 -#define malloc(a) kmalloc(a, GFP_KERNEL)
67303 +#define malloc(a) kmalloc((a), GFP_KERNEL)
67304 #define free(a) kfree(a)
67305
67306 #define large_malloc(a) vmalloc(a)
67307 diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
67308 index fe8c447..bdc1f33 100644
67309 --- a/include/linux/devfreq.h
67310 +++ b/include/linux/devfreq.h
67311 @@ -114,7 +114,7 @@ struct devfreq_governor {
67312 int (*get_target_freq)(struct devfreq *this, unsigned long *freq);
67313 int (*event_handler)(struct devfreq *devfreq,
67314 unsigned int event, void *data);
67315 -};
67316 +} __do_const;
67317
67318 /**
67319 * struct devfreq - Device devfreq structure
67320 diff --git a/include/linux/device.h b/include/linux/device.h
67321 index 9d6464e..8a5cc92 100644
67322 --- a/include/linux/device.h
67323 +++ b/include/linux/device.h
67324 @@ -295,7 +295,7 @@ struct subsys_interface {
67325 struct list_head node;
67326 int (*add_dev)(struct device *dev, struct subsys_interface *sif);
67327 int (*remove_dev)(struct device *dev, struct subsys_interface *sif);
67328 -};
67329 +} __do_const;
67330
67331 int subsys_interface_register(struct subsys_interface *sif);
67332 void subsys_interface_unregister(struct subsys_interface *sif);
67333 @@ -475,7 +475,7 @@ struct device_type {
67334 void (*release)(struct device *dev);
67335
67336 const struct dev_pm_ops *pm;
67337 -};
67338 +} __do_const;
67339
67340 /* interface for exporting device attributes */
67341 struct device_attribute {
67342 @@ -485,11 +485,12 @@ struct device_attribute {
67343 ssize_t (*store)(struct device *dev, struct device_attribute *attr,
67344 const char *buf, size_t count);
67345 };
67346 +typedef struct device_attribute __no_const device_attribute_no_const;
67347
67348 struct dev_ext_attribute {
67349 struct device_attribute attr;
67350 void *var;
67351 -};
67352 +} __do_const;
67353
67354 ssize_t device_show_ulong(struct device *dev, struct device_attribute *attr,
67355 char *buf);
67356 diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
67357 index 94af418..b1ca7a2 100644
67358 --- a/include/linux/dma-mapping.h
67359 +++ b/include/linux/dma-mapping.h
67360 @@ -54,7 +54,7 @@ struct dma_map_ops {
67361 u64 (*get_required_mask)(struct device *dev);
67362 #endif
67363 int is_phys;
67364 -};
67365 +} __do_const;
67366
67367 #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
67368
67369 diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
67370 index 91ac8da..a841318 100644
67371 --- a/include/linux/dmaengine.h
67372 +++ b/include/linux/dmaengine.h
67373 @@ -1034,9 +1034,9 @@ struct dma_pinned_list {
67374 struct dma_pinned_list *dma_pin_iovec_pages(struct iovec *iov, size_t len);
67375 void dma_unpin_iovec_pages(struct dma_pinned_list* pinned_list);
67376
67377 -dma_cookie_t dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
67378 +dma_cookie_t __intentional_overflow(0) dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
67379 struct dma_pinned_list *pinned_list, unsigned char *kdata, size_t len);
67380 -dma_cookie_t dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
67381 +dma_cookie_t __intentional_overflow(0) dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
67382 struct dma_pinned_list *pinned_list, struct page *page,
67383 unsigned int offset, size_t len);
67384
67385 diff --git a/include/linux/efi.h b/include/linux/efi.h
67386 index 3d7df3d..301f024 100644
67387 --- a/include/linux/efi.h
67388 +++ b/include/linux/efi.h
67389 @@ -740,6 +740,7 @@ struct efivar_operations {
67390 efi_set_variable_t *set_variable;
67391 efi_query_variable_store_t *query_variable_store;
67392 };
67393 +typedef struct efivar_operations __no_const efivar_operations_no_const;
67394
67395 struct efivars {
67396 /*
67397 diff --git a/include/linux/elf.h b/include/linux/elf.h
67398 index 40a3c0e..4c45a38 100644
67399 --- a/include/linux/elf.h
67400 +++ b/include/linux/elf.h
67401 @@ -24,6 +24,7 @@ extern Elf32_Dyn _DYNAMIC [];
67402 #define elf_note elf32_note
67403 #define elf_addr_t Elf32_Off
67404 #define Elf_Half Elf32_Half
67405 +#define elf_dyn Elf32_Dyn
67406
67407 #else
67408
67409 @@ -34,6 +35,7 @@ extern Elf64_Dyn _DYNAMIC [];
67410 #define elf_note elf64_note
67411 #define elf_addr_t Elf64_Off
67412 #define Elf_Half Elf64_Half
67413 +#define elf_dyn Elf64_Dyn
67414
67415 #endif
67416
67417 diff --git a/include/linux/err.h b/include/linux/err.h
67418 index f2edce2..cc2082c 100644
67419 --- a/include/linux/err.h
67420 +++ b/include/linux/err.h
67421 @@ -19,12 +19,12 @@
67422
67423 #define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
67424
67425 -static inline void * __must_check ERR_PTR(long error)
67426 +static inline void * __must_check __intentional_overflow(-1) ERR_PTR(long error)
67427 {
67428 return (void *) error;
67429 }
67430
67431 -static inline long __must_check PTR_ERR(const void *ptr)
67432 +static inline long __must_check __intentional_overflow(-1) PTR_ERR(const void *ptr)
67433 {
67434 return (long) ptr;
67435 }
67436 diff --git a/include/linux/extcon.h b/include/linux/extcon.h
67437 index fcb51c8..bdafcf6 100644
67438 --- a/include/linux/extcon.h
67439 +++ b/include/linux/extcon.h
67440 @@ -134,7 +134,7 @@ struct extcon_dev {
67441 /* /sys/class/extcon/.../mutually_exclusive/... */
67442 struct attribute_group attr_g_muex;
67443 struct attribute **attrs_muex;
67444 - struct device_attribute *d_attrs_muex;
67445 + device_attribute_no_const *d_attrs_muex;
67446 };
67447
67448 /**
67449 diff --git a/include/linux/fb.h b/include/linux/fb.h
67450 index 58b9860..58e5516 100644
67451 --- a/include/linux/fb.h
67452 +++ b/include/linux/fb.h
67453 @@ -304,7 +304,7 @@ struct fb_ops {
67454 /* called at KDB enter and leave time to prepare the console */
67455 int (*fb_debug_enter)(struct fb_info *info);
67456 int (*fb_debug_leave)(struct fb_info *info);
67457 -};
67458 +} __do_const;
67459
67460 #ifdef CONFIG_FB_TILEBLITTING
67461 #define FB_TILE_CURSOR_NONE 0
67462 diff --git a/include/linux/filter.h b/include/linux/filter.h
67463 index c45eabc..baa0be5 100644
67464 --- a/include/linux/filter.h
67465 +++ b/include/linux/filter.h
67466 @@ -20,6 +20,7 @@ struct compat_sock_fprog {
67467
67468 struct sk_buff;
67469 struct sock;
67470 +struct bpf_jit_work;
67471
67472 struct sk_filter
67473 {
67474 @@ -27,6 +28,9 @@ struct sk_filter
67475 unsigned int len; /* Number of filter blocks */
67476 unsigned int (*bpf_func)(const struct sk_buff *skb,
67477 const struct sock_filter *filter);
67478 +#ifdef CONFIG_BPF_JIT
67479 + struct bpf_jit_work *work;
67480 +#endif
67481 struct rcu_head rcu;
67482 struct sock_filter insns[0];
67483 };
67484 diff --git a/include/linux/frontswap.h b/include/linux/frontswap.h
67485 index 3044254..9767f41 100644
67486 --- a/include/linux/frontswap.h
67487 +++ b/include/linux/frontswap.h
67488 @@ -11,7 +11,7 @@ struct frontswap_ops {
67489 int (*load)(unsigned, pgoff_t, struct page *);
67490 void (*invalidate_page)(unsigned, pgoff_t);
67491 void (*invalidate_area)(unsigned);
67492 -};
67493 +} __no_const;
67494
67495 extern bool frontswap_enabled;
67496 extern struct frontswap_ops
67497 diff --git a/include/linux/fs.h b/include/linux/fs.h
67498 index 2c28271..8d3d74c 100644
67499 --- a/include/linux/fs.h
67500 +++ b/include/linux/fs.h
67501 @@ -1541,7 +1541,8 @@ struct file_operations {
67502 long (*fallocate)(struct file *file, int mode, loff_t offset,
67503 loff_t len);
67504 int (*show_fdinfo)(struct seq_file *m, struct file *f);
67505 -};
67506 +} __do_const;
67507 +typedef struct file_operations __no_const file_operations_no_const;
67508
67509 struct inode_operations {
67510 struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
67511 @@ -2672,4 +2673,14 @@ static inline void inode_has_no_xattr(struct inode *inode)
67512 inode->i_flags |= S_NOSEC;
67513 }
67514
67515 +static inline bool is_sidechannel_device(const struct inode *inode)
67516 +{
67517 +#ifdef CONFIG_GRKERNSEC_DEVICE_SIDECHANNEL
67518 + umode_t mode = inode->i_mode;
67519 + return ((S_ISCHR(mode) || S_ISBLK(mode)) && (mode & (S_IROTH | S_IWOTH)));
67520 +#else
67521 + return false;
67522 +#endif
67523 +}
67524 +
67525 #endif /* _LINUX_FS_H */
67526 diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h
67527 index 2b93a9a..855d94a 100644
67528 --- a/include/linux/fs_struct.h
67529 +++ b/include/linux/fs_struct.h
67530 @@ -6,7 +6,7 @@
67531 #include <linux/seqlock.h>
67532
67533 struct fs_struct {
67534 - int users;
67535 + atomic_t users;
67536 spinlock_t lock;
67537 seqcount_t seq;
67538 int umask;
67539 diff --git a/include/linux/fscache-cache.h b/include/linux/fscache-cache.h
67540 index 5dfa0aa..6acf322 100644
67541 --- a/include/linux/fscache-cache.h
67542 +++ b/include/linux/fscache-cache.h
67543 @@ -112,7 +112,7 @@ struct fscache_operation {
67544 fscache_operation_release_t release;
67545 };
67546
67547 -extern atomic_t fscache_op_debug_id;
67548 +extern atomic_unchecked_t fscache_op_debug_id;
67549 extern void fscache_op_work_func(struct work_struct *work);
67550
67551 extern void fscache_enqueue_operation(struct fscache_operation *);
67552 @@ -134,7 +134,7 @@ static inline void fscache_operation_init(struct fscache_operation *op,
67553 INIT_WORK(&op->work, fscache_op_work_func);
67554 atomic_set(&op->usage, 1);
67555 op->state = FSCACHE_OP_ST_INITIALISED;
67556 - op->debug_id = atomic_inc_return(&fscache_op_debug_id);
67557 + op->debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
67558 op->processor = processor;
67559 op->release = release;
67560 INIT_LIST_HEAD(&op->pend_link);
67561 diff --git a/include/linux/fscache.h b/include/linux/fscache.h
67562 index 7a08623..4c07b0f 100644
67563 --- a/include/linux/fscache.h
67564 +++ b/include/linux/fscache.h
67565 @@ -152,7 +152,7 @@ struct fscache_cookie_def {
67566 * - this is mandatory for any object that may have data
67567 */
67568 void (*now_uncached)(void *cookie_netfs_data);
67569 -};
67570 +} __do_const;
67571
67572 /*
67573 * fscache cached network filesystem type
67574 diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
67575 index a78680a..87bd73e 100644
67576 --- a/include/linux/fsnotify.h
67577 +++ b/include/linux/fsnotify.h
67578 @@ -195,6 +195,9 @@ static inline void fsnotify_access(struct file *file)
67579 struct inode *inode = path->dentry->d_inode;
67580 __u32 mask = FS_ACCESS;
67581
67582 + if (is_sidechannel_device(inode))
67583 + return;
67584 +
67585 if (S_ISDIR(inode->i_mode))
67586 mask |= FS_ISDIR;
67587
67588 @@ -213,6 +216,9 @@ static inline void fsnotify_modify(struct file *file)
67589 struct inode *inode = path->dentry->d_inode;
67590 __u32 mask = FS_MODIFY;
67591
67592 + if (is_sidechannel_device(inode))
67593 + return;
67594 +
67595 if (S_ISDIR(inode->i_mode))
67596 mask |= FS_ISDIR;
67597
67598 @@ -315,7 +321,7 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
67599 */
67600 static inline const unsigned char *fsnotify_oldname_init(const unsigned char *name)
67601 {
67602 - return kstrdup(name, GFP_KERNEL);
67603 + return (const unsigned char *)kstrdup((const char *)name, GFP_KERNEL);
67604 }
67605
67606 /*
67607 diff --git a/include/linux/ftrace_event.h b/include/linux/ftrace_event.h
67608 index 13a54d0..c6ce2a7 100644
67609 --- a/include/linux/ftrace_event.h
67610 +++ b/include/linux/ftrace_event.h
67611 @@ -274,7 +274,7 @@ extern int trace_define_field(struct ftrace_event_call *call, const char *type,
67612 extern int trace_add_event_call(struct ftrace_event_call *call);
67613 extern void trace_remove_event_call(struct ftrace_event_call *call);
67614
67615 -#define is_signed_type(type) (((type)(-1)) < (type)0)
67616 +#define is_signed_type(type) (((type)(-1)) < (type)1)
67617
67618 int trace_set_clr_event(const char *system, const char *event, int set);
67619
67620 diff --git a/include/linux/genhd.h b/include/linux/genhd.h
67621 index 9f3c275..911b591 100644
67622 --- a/include/linux/genhd.h
67623 +++ b/include/linux/genhd.h
67624 @@ -194,7 +194,7 @@ struct gendisk {
67625 struct kobject *slave_dir;
67626
67627 struct timer_rand_state *random;
67628 - atomic_t sync_io; /* RAID */
67629 + atomic_unchecked_t sync_io; /* RAID */
67630 struct disk_events *ev;
67631 #ifdef CONFIG_BLK_DEV_INTEGRITY
67632 struct blk_integrity *integrity;
67633 diff --git a/include/linux/genl_magic_func.h b/include/linux/genl_magic_func.h
67634 index 023bc34..b02b46a 100644
67635 --- a/include/linux/genl_magic_func.h
67636 +++ b/include/linux/genl_magic_func.h
67637 @@ -246,7 +246,7 @@ const char *CONCAT_(GENL_MAGIC_FAMILY, _genl_cmd_to_str)(__u8 cmd)
67638 },
67639
67640 #define ZZZ_genl_ops CONCAT_(GENL_MAGIC_FAMILY, _genl_ops)
67641 -static struct genl_ops ZZZ_genl_ops[] __read_mostly = {
67642 +static struct genl_ops ZZZ_genl_ops[] = {
67643 #include GENL_MAGIC_INCLUDE_FILE
67644 };
67645
67646 diff --git a/include/linux/gfp.h b/include/linux/gfp.h
67647 index 0f615eb..5c3832f 100644
67648 --- a/include/linux/gfp.h
67649 +++ b/include/linux/gfp.h
67650 @@ -35,6 +35,13 @@ struct vm_area_struct;
67651 #define ___GFP_NO_KSWAPD 0x400000u
67652 #define ___GFP_OTHER_NODE 0x800000u
67653 #define ___GFP_WRITE 0x1000000u
67654 +
67655 +#ifdef CONFIG_PAX_USERCOPY_SLABS
67656 +#define ___GFP_USERCOPY 0x2000000u
67657 +#else
67658 +#define ___GFP_USERCOPY 0
67659 +#endif
67660 +
67661 /* If the above are modified, __GFP_BITS_SHIFT may need updating */
67662
67663 /*
67664 @@ -92,6 +99,7 @@ struct vm_area_struct;
67665 #define __GFP_OTHER_NODE ((__force gfp_t)___GFP_OTHER_NODE) /* On behalf of other node */
67666 #define __GFP_KMEMCG ((__force gfp_t)___GFP_KMEMCG) /* Allocation comes from a memcg-accounted resource */
67667 #define __GFP_WRITE ((__force gfp_t)___GFP_WRITE) /* Allocator intends to dirty page */
67668 +#define __GFP_USERCOPY ((__force gfp_t)___GFP_USERCOPY)/* Allocator intends to copy page to/from userland */
67669
67670 /*
67671 * This may seem redundant, but it's a way of annotating false positives vs.
67672 @@ -99,7 +107,7 @@ struct vm_area_struct;
67673 */
67674 #define __GFP_NOTRACK_FALSE_POSITIVE (__GFP_NOTRACK)
67675
67676 -#define __GFP_BITS_SHIFT 25 /* Room for N __GFP_FOO bits */
67677 +#define __GFP_BITS_SHIFT 26 /* Room for N __GFP_FOO bits */
67678 #define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1))
67679
67680 /* This equals 0, but use constants in case they ever change */
67681 @@ -153,6 +161,8 @@ struct vm_area_struct;
67682 /* 4GB DMA on some platforms */
67683 #define GFP_DMA32 __GFP_DMA32
67684
67685 +#define GFP_USERCOPY __GFP_USERCOPY
67686 +
67687 /* Convert GFP flags to their corresponding migrate type */
67688 static inline int allocflags_to_migratetype(gfp_t gfp_flags)
67689 {
67690 diff --git a/include/linux/gracl.h b/include/linux/gracl.h
67691 new file mode 100644
67692 index 0000000..ebe6d72
67693 --- /dev/null
67694 +++ b/include/linux/gracl.h
67695 @@ -0,0 +1,319 @@
67696 +#ifndef GR_ACL_H
67697 +#define GR_ACL_H
67698 +
67699 +#include <linux/grdefs.h>
67700 +#include <linux/resource.h>
67701 +#include <linux/capability.h>
67702 +#include <linux/dcache.h>
67703 +#include <asm/resource.h>
67704 +
67705 +/* Major status information */
67706 +
67707 +#define GR_VERSION "grsecurity 2.9.1"
67708 +#define GRSECURITY_VERSION 0x2901
67709 +
67710 +enum {
67711 + GR_SHUTDOWN = 0,
67712 + GR_ENABLE = 1,
67713 + GR_SPROLE = 2,
67714 + GR_RELOAD = 3,
67715 + GR_SEGVMOD = 4,
67716 + GR_STATUS = 5,
67717 + GR_UNSPROLE = 6,
67718 + GR_PASSSET = 7,
67719 + GR_SPROLEPAM = 8,
67720 +};
67721 +
67722 +/* Password setup definitions
67723 + * kernel/grhash.c */
67724 +enum {
67725 + GR_PW_LEN = 128,
67726 + GR_SALT_LEN = 16,
67727 + GR_SHA_LEN = 32,
67728 +};
67729 +
67730 +enum {
67731 + GR_SPROLE_LEN = 64,
67732 +};
67733 +
67734 +enum {
67735 + GR_NO_GLOB = 0,
67736 + GR_REG_GLOB,
67737 + GR_CREATE_GLOB
67738 +};
67739 +
67740 +#define GR_NLIMITS 32
67741 +
67742 +/* Begin Data Structures */
67743 +
67744 +struct sprole_pw {
67745 + unsigned char *rolename;
67746 + unsigned char salt[GR_SALT_LEN];
67747 + unsigned char sum[GR_SHA_LEN]; /* 256-bit SHA hash of the password */
67748 +};
67749 +
67750 +struct name_entry {
67751 + __u32 key;
67752 + ino_t inode;
67753 + dev_t device;
67754 + char *name;
67755 + __u16 len;
67756 + __u8 deleted;
67757 + struct name_entry *prev;
67758 + struct name_entry *next;
67759 +};
67760 +
67761 +struct inodev_entry {
67762 + struct name_entry *nentry;
67763 + struct inodev_entry *prev;
67764 + struct inodev_entry *next;
67765 +};
67766 +
67767 +struct acl_role_db {
67768 + struct acl_role_label **r_hash;
67769 + __u32 r_size;
67770 +};
67771 +
67772 +struct inodev_db {
67773 + struct inodev_entry **i_hash;
67774 + __u32 i_size;
67775 +};
67776 +
67777 +struct name_db {
67778 + struct name_entry **n_hash;
67779 + __u32 n_size;
67780 +};
67781 +
67782 +struct crash_uid {
67783 + uid_t uid;
67784 + unsigned long expires;
67785 +};
67786 +
67787 +struct gr_hash_struct {
67788 + void **table;
67789 + void **nametable;
67790 + void *first;
67791 + __u32 table_size;
67792 + __u32 used_size;
67793 + int type;
67794 +};
67795 +
67796 +/* Userspace Grsecurity ACL data structures */
67797 +
67798 +struct acl_subject_label {
67799 + char *filename;
67800 + ino_t inode;
67801 + dev_t device;
67802 + __u32 mode;
67803 + kernel_cap_t cap_mask;
67804 + kernel_cap_t cap_lower;
67805 + kernel_cap_t cap_invert_audit;
67806 +
67807 + struct rlimit res[GR_NLIMITS];
67808 + __u32 resmask;
67809 +
67810 + __u8 user_trans_type;
67811 + __u8 group_trans_type;
67812 + uid_t *user_transitions;
67813 + gid_t *group_transitions;
67814 + __u16 user_trans_num;
67815 + __u16 group_trans_num;
67816 +
67817 + __u32 sock_families[2];
67818 + __u32 ip_proto[8];
67819 + __u32 ip_type;
67820 + struct acl_ip_label **ips;
67821 + __u32 ip_num;
67822 + __u32 inaddr_any_override;
67823 +
67824 + __u32 crashes;
67825 + unsigned long expires;
67826 +
67827 + struct acl_subject_label *parent_subject;
67828 + struct gr_hash_struct *hash;
67829 + struct acl_subject_label *prev;
67830 + struct acl_subject_label *next;
67831 +
67832 + struct acl_object_label **obj_hash;
67833 + __u32 obj_hash_size;
67834 + __u16 pax_flags;
67835 +};
67836 +
67837 +struct role_allowed_ip {
67838 + __u32 addr;
67839 + __u32 netmask;
67840 +
67841 + struct role_allowed_ip *prev;
67842 + struct role_allowed_ip *next;
67843 +};
67844 +
67845 +struct role_transition {
67846 + char *rolename;
67847 +
67848 + struct role_transition *prev;
67849 + struct role_transition *next;
67850 +};
67851 +
67852 +struct acl_role_label {
67853 + char *rolename;
67854 + uid_t uidgid;
67855 + __u16 roletype;
67856 +
67857 + __u16 auth_attempts;
67858 + unsigned long expires;
67859 +
67860 + struct acl_subject_label *root_label;
67861 + struct gr_hash_struct *hash;
67862 +
67863 + struct acl_role_label *prev;
67864 + struct acl_role_label *next;
67865 +
67866 + struct role_transition *transitions;
67867 + struct role_allowed_ip *allowed_ips;
67868 + uid_t *domain_children;
67869 + __u16 domain_child_num;
67870 +
67871 + umode_t umask;
67872 +
67873 + struct acl_subject_label **subj_hash;
67874 + __u32 subj_hash_size;
67875 +};
67876 +
67877 +struct user_acl_role_db {
67878 + struct acl_role_label **r_table;
67879 + __u32 num_pointers; /* Number of allocations to track */
67880 + __u32 num_roles; /* Number of roles */
67881 + __u32 num_domain_children; /* Number of domain children */
67882 + __u32 num_subjects; /* Number of subjects */
67883 + __u32 num_objects; /* Number of objects */
67884 +};
67885 +
67886 +struct acl_object_label {
67887 + char *filename;
67888 + ino_t inode;
67889 + dev_t device;
67890 + __u32 mode;
67891 +
67892 + struct acl_subject_label *nested;
67893 + struct acl_object_label *globbed;
67894 +
67895 + /* next two structures not used */
67896 +
67897 + struct acl_object_label *prev;
67898 + struct acl_object_label *next;
67899 +};
67900 +
67901 +struct acl_ip_label {
67902 + char *iface;
67903 + __u32 addr;
67904 + __u32 netmask;
67905 + __u16 low, high;
67906 + __u8 mode;
67907 + __u32 type;
67908 + __u32 proto[8];
67909 +
67910 + /* next two structures not used */
67911 +
67912 + struct acl_ip_label *prev;
67913 + struct acl_ip_label *next;
67914 +};
67915 +
67916 +struct gr_arg {
67917 + struct user_acl_role_db role_db;
67918 + unsigned char pw[GR_PW_LEN];
67919 + unsigned char salt[GR_SALT_LEN];
67920 + unsigned char sum[GR_SHA_LEN];
67921 + unsigned char sp_role[GR_SPROLE_LEN];
67922 + struct sprole_pw *sprole_pws;
67923 + dev_t segv_device;
67924 + ino_t segv_inode;
67925 + uid_t segv_uid;
67926 + __u16 num_sprole_pws;
67927 + __u16 mode;
67928 +};
67929 +
67930 +struct gr_arg_wrapper {
67931 + struct gr_arg *arg;
67932 + __u32 version;
67933 + __u32 size;
67934 +};
67935 +
67936 +struct subject_map {
67937 + struct acl_subject_label *user;
67938 + struct acl_subject_label *kernel;
67939 + struct subject_map *prev;
67940 + struct subject_map *next;
67941 +};
67942 +
67943 +struct acl_subj_map_db {
67944 + struct subject_map **s_hash;
67945 + __u32 s_size;
67946 +};
67947 +
67948 +/* End Data Structures Section */
67949 +
67950 +/* Hash functions generated by empirical testing by Brad Spengler
67951 + Makes good use of the low bits of the inode. Generally 0-1 times
67952 + in loop for successful match. 0-3 for unsuccessful match.
67953 + Shift/add algorithm with modulus of table size and an XOR*/
67954 +
67955 +static __inline__ unsigned int
67956 +gr_rhash(const uid_t uid, const __u16 type, const unsigned int sz)
67957 +{
67958 + return ((((uid + type) << (16 + type)) ^ uid) % sz);
67959 +}
67960 +
67961 + static __inline__ unsigned int
67962 +gr_shash(const struct acl_subject_label *userp, const unsigned int sz)
67963 +{
67964 + return ((const unsigned long)userp % sz);
67965 +}
67966 +
67967 +static __inline__ unsigned int
67968 +gr_fhash(const ino_t ino, const dev_t dev, const unsigned int sz)
67969 +{
67970 + return (((ino + dev) ^ ((ino << 13) + (ino << 23) + (dev << 9))) % sz);
67971 +}
67972 +
67973 +static __inline__ unsigned int
67974 +gr_nhash(const char *name, const __u16 len, const unsigned int sz)
67975 +{
67976 + return full_name_hash((const unsigned char *)name, len) % sz;
67977 +}
67978 +
67979 +#define FOR_EACH_ROLE_START(role) \
67980 + role = role_list; \
67981 + while (role) {
67982 +
67983 +#define FOR_EACH_ROLE_END(role) \
67984 + role = role->prev; \
67985 + }
67986 +
67987 +#define FOR_EACH_SUBJECT_START(role,subj,iter) \
67988 + subj = NULL; \
67989 + iter = 0; \
67990 + while (iter < role->subj_hash_size) { \
67991 + if (subj == NULL) \
67992 + subj = role->subj_hash[iter]; \
67993 + if (subj == NULL) { \
67994 + iter++; \
67995 + continue; \
67996 + }
67997 +
67998 +#define FOR_EACH_SUBJECT_END(subj,iter) \
67999 + subj = subj->next; \
68000 + if (subj == NULL) \
68001 + iter++; \
68002 + }
68003 +
68004 +
68005 +#define FOR_EACH_NESTED_SUBJECT_START(role,subj) \
68006 + subj = role->hash->first; \
68007 + while (subj != NULL) {
68008 +
68009 +#define FOR_EACH_NESTED_SUBJECT_END(subj) \
68010 + subj = subj->next; \
68011 + }
68012 +
68013 +#endif
68014 +
68015 diff --git a/include/linux/gralloc.h b/include/linux/gralloc.h
68016 new file mode 100644
68017 index 0000000..323ecf2
68018 --- /dev/null
68019 +++ b/include/linux/gralloc.h
68020 @@ -0,0 +1,9 @@
68021 +#ifndef __GRALLOC_H
68022 +#define __GRALLOC_H
68023 +
68024 +void acl_free_all(void);
68025 +int acl_alloc_stack_init(unsigned long size);
68026 +void *acl_alloc(unsigned long len);
68027 +void *acl_alloc_num(unsigned long num, unsigned long len);
68028 +
68029 +#endif
68030 diff --git a/include/linux/grdefs.h b/include/linux/grdefs.h
68031 new file mode 100644
68032 index 0000000..be66033
68033 --- /dev/null
68034 +++ b/include/linux/grdefs.h
68035 @@ -0,0 +1,140 @@
68036 +#ifndef GRDEFS_H
68037 +#define GRDEFS_H
68038 +
68039 +/* Begin grsecurity status declarations */
68040 +
68041 +enum {
68042 + GR_READY = 0x01,
68043 + GR_STATUS_INIT = 0x00 // disabled state
68044 +};
68045 +
68046 +/* Begin ACL declarations */
68047 +
68048 +/* Role flags */
68049 +
68050 +enum {
68051 + GR_ROLE_USER = 0x0001,
68052 + GR_ROLE_GROUP = 0x0002,
68053 + GR_ROLE_DEFAULT = 0x0004,
68054 + GR_ROLE_SPECIAL = 0x0008,
68055 + GR_ROLE_AUTH = 0x0010,
68056 + GR_ROLE_NOPW = 0x0020,
68057 + GR_ROLE_GOD = 0x0040,
68058 + GR_ROLE_LEARN = 0x0080,
68059 + GR_ROLE_TPE = 0x0100,
68060 + GR_ROLE_DOMAIN = 0x0200,
68061 + GR_ROLE_PAM = 0x0400,
68062 + GR_ROLE_PERSIST = 0x0800
68063 +};
68064 +
68065 +/* ACL Subject and Object mode flags */
68066 +enum {
68067 + GR_DELETED = 0x80000000
68068 +};
68069 +
68070 +/* ACL Object-only mode flags */
68071 +enum {
68072 + GR_READ = 0x00000001,
68073 + GR_APPEND = 0x00000002,
68074 + GR_WRITE = 0x00000004,
68075 + GR_EXEC = 0x00000008,
68076 + GR_FIND = 0x00000010,
68077 + GR_INHERIT = 0x00000020,
68078 + GR_SETID = 0x00000040,
68079 + GR_CREATE = 0x00000080,
68080 + GR_DELETE = 0x00000100,
68081 + GR_LINK = 0x00000200,
68082 + GR_AUDIT_READ = 0x00000400,
68083 + GR_AUDIT_APPEND = 0x00000800,
68084 + GR_AUDIT_WRITE = 0x00001000,
68085 + GR_AUDIT_EXEC = 0x00002000,
68086 + GR_AUDIT_FIND = 0x00004000,
68087 + GR_AUDIT_INHERIT= 0x00008000,
68088 + GR_AUDIT_SETID = 0x00010000,
68089 + GR_AUDIT_CREATE = 0x00020000,
68090 + GR_AUDIT_DELETE = 0x00040000,
68091 + GR_AUDIT_LINK = 0x00080000,
68092 + GR_PTRACERD = 0x00100000,
68093 + GR_NOPTRACE = 0x00200000,
68094 + GR_SUPPRESS = 0x00400000,
68095 + GR_NOLEARN = 0x00800000,
68096 + GR_INIT_TRANSFER= 0x01000000
68097 +};
68098 +
68099 +#define GR_AUDITS (GR_AUDIT_READ | GR_AUDIT_WRITE | GR_AUDIT_APPEND | GR_AUDIT_EXEC | \
68100 + GR_AUDIT_FIND | GR_AUDIT_INHERIT | GR_AUDIT_SETID | \
68101 + GR_AUDIT_CREATE | GR_AUDIT_DELETE | GR_AUDIT_LINK)
68102 +
68103 +/* ACL subject-only mode flags */
68104 +enum {
68105 + GR_KILL = 0x00000001,
68106 + GR_VIEW = 0x00000002,
68107 + GR_PROTECTED = 0x00000004,
68108 + GR_LEARN = 0x00000008,
68109 + GR_OVERRIDE = 0x00000010,
68110 + /* just a placeholder, this mode is only used in userspace */
68111 + GR_DUMMY = 0x00000020,
68112 + GR_PROTSHM = 0x00000040,
68113 + GR_KILLPROC = 0x00000080,
68114 + GR_KILLIPPROC = 0x00000100,
68115 + /* just a placeholder, this mode is only used in userspace */
68116 + GR_NOTROJAN = 0x00000200,
68117 + GR_PROTPROCFD = 0x00000400,
68118 + GR_PROCACCT = 0x00000800,
68119 + GR_RELAXPTRACE = 0x00001000,
68120 + //GR_NESTED = 0x00002000,
68121 + GR_INHERITLEARN = 0x00004000,
68122 + GR_PROCFIND = 0x00008000,
68123 + GR_POVERRIDE = 0x00010000,
68124 + GR_KERNELAUTH = 0x00020000,
68125 + GR_ATSECURE = 0x00040000,
68126 + GR_SHMEXEC = 0x00080000
68127 +};
68128 +
68129 +enum {
68130 + GR_PAX_ENABLE_SEGMEXEC = 0x0001,
68131 + GR_PAX_ENABLE_PAGEEXEC = 0x0002,
68132 + GR_PAX_ENABLE_MPROTECT = 0x0004,
68133 + GR_PAX_ENABLE_RANDMMAP = 0x0008,
68134 + GR_PAX_ENABLE_EMUTRAMP = 0x0010,
68135 + GR_PAX_DISABLE_SEGMEXEC = 0x0100,
68136 + GR_PAX_DISABLE_PAGEEXEC = 0x0200,
68137 + GR_PAX_DISABLE_MPROTECT = 0x0400,
68138 + GR_PAX_DISABLE_RANDMMAP = 0x0800,
68139 + GR_PAX_DISABLE_EMUTRAMP = 0x1000,
68140 +};
68141 +
68142 +enum {
68143 + GR_ID_USER = 0x01,
68144 + GR_ID_GROUP = 0x02,
68145 +};
68146 +
68147 +enum {
68148 + GR_ID_ALLOW = 0x01,
68149 + GR_ID_DENY = 0x02,
68150 +};
68151 +
68152 +#define GR_CRASH_RES 31
68153 +#define GR_UIDTABLE_MAX 500
68154 +
68155 +/* begin resource learning section */
68156 +enum {
68157 + GR_RLIM_CPU_BUMP = 60,
68158 + GR_RLIM_FSIZE_BUMP = 50000,
68159 + GR_RLIM_DATA_BUMP = 10000,
68160 + GR_RLIM_STACK_BUMP = 1000,
68161 + GR_RLIM_CORE_BUMP = 10000,
68162 + GR_RLIM_RSS_BUMP = 500000,
68163 + GR_RLIM_NPROC_BUMP = 1,
68164 + GR_RLIM_NOFILE_BUMP = 5,
68165 + GR_RLIM_MEMLOCK_BUMP = 50000,
68166 + GR_RLIM_AS_BUMP = 500000,
68167 + GR_RLIM_LOCKS_BUMP = 2,
68168 + GR_RLIM_SIGPENDING_BUMP = 5,
68169 + GR_RLIM_MSGQUEUE_BUMP = 10000,
68170 + GR_RLIM_NICE_BUMP = 1,
68171 + GR_RLIM_RTPRIO_BUMP = 1,
68172 + GR_RLIM_RTTIME_BUMP = 1000000
68173 +};
68174 +
68175 +#endif
68176 diff --git a/include/linux/grinternal.h b/include/linux/grinternal.h
68177 new file mode 100644
68178 index 0000000..5402bce
68179 --- /dev/null
68180 +++ b/include/linux/grinternal.h
68181 @@ -0,0 +1,215 @@
68182 +#ifndef __GRINTERNAL_H
68183 +#define __GRINTERNAL_H
68184 +
68185 +#ifdef CONFIG_GRKERNSEC
68186 +
68187 +#include <linux/fs.h>
68188 +#include <linux/mnt_namespace.h>
68189 +#include <linux/nsproxy.h>
68190 +#include <linux/gracl.h>
68191 +#include <linux/grdefs.h>
68192 +#include <linux/grmsg.h>
68193 +
68194 +void gr_add_learn_entry(const char *fmt, ...)
68195 + __attribute__ ((format (printf, 1, 2)));
68196 +__u32 gr_search_file(const struct dentry *dentry, const __u32 mode,
68197 + const struct vfsmount *mnt);
68198 +__u32 gr_check_create(const struct dentry *new_dentry,
68199 + const struct dentry *parent,
68200 + const struct vfsmount *mnt, const __u32 mode);
68201 +int gr_check_protected_task(const struct task_struct *task);
68202 +__u32 to_gr_audit(const __u32 reqmode);
68203 +int gr_set_acls(const int type);
68204 +int gr_apply_subject_to_task(struct task_struct *task);
68205 +int gr_acl_is_enabled(void);
68206 +char gr_roletype_to_char(void);
68207 +
68208 +void gr_handle_alertkill(struct task_struct *task);
68209 +char *gr_to_filename(const struct dentry *dentry,
68210 + const struct vfsmount *mnt);
68211 +char *gr_to_filename1(const struct dentry *dentry,
68212 + const struct vfsmount *mnt);
68213 +char *gr_to_filename2(const struct dentry *dentry,
68214 + const struct vfsmount *mnt);
68215 +char *gr_to_filename3(const struct dentry *dentry,
68216 + const struct vfsmount *mnt);
68217 +
68218 +extern int grsec_enable_ptrace_readexec;
68219 +extern int grsec_enable_harden_ptrace;
68220 +extern int grsec_enable_link;
68221 +extern int grsec_enable_fifo;
68222 +extern int grsec_enable_execve;
68223 +extern int grsec_enable_shm;
68224 +extern int grsec_enable_execlog;
68225 +extern int grsec_enable_signal;
68226 +extern int grsec_enable_audit_ptrace;
68227 +extern int grsec_enable_forkfail;
68228 +extern int grsec_enable_time;
68229 +extern int grsec_enable_rofs;
68230 +extern int grsec_enable_chroot_shmat;
68231 +extern int grsec_enable_chroot_mount;
68232 +extern int grsec_enable_chroot_double;
68233 +extern int grsec_enable_chroot_pivot;
68234 +extern int grsec_enable_chroot_chdir;
68235 +extern int grsec_enable_chroot_chmod;
68236 +extern int grsec_enable_chroot_mknod;
68237 +extern int grsec_enable_chroot_fchdir;
68238 +extern int grsec_enable_chroot_nice;
68239 +extern int grsec_enable_chroot_execlog;
68240 +extern int grsec_enable_chroot_caps;
68241 +extern int grsec_enable_chroot_sysctl;
68242 +extern int grsec_enable_chroot_unix;
68243 +extern int grsec_enable_symlinkown;
68244 +extern kgid_t grsec_symlinkown_gid;
68245 +extern int grsec_enable_tpe;
68246 +extern kgid_t grsec_tpe_gid;
68247 +extern int grsec_enable_tpe_all;
68248 +extern int grsec_enable_tpe_invert;
68249 +extern int grsec_enable_socket_all;
68250 +extern kgid_t grsec_socket_all_gid;
68251 +extern int grsec_enable_socket_client;
68252 +extern kgid_t grsec_socket_client_gid;
68253 +extern int grsec_enable_socket_server;
68254 +extern kgid_t grsec_socket_server_gid;
68255 +extern kgid_t grsec_audit_gid;
68256 +extern int grsec_enable_group;
68257 +extern int grsec_enable_audit_textrel;
68258 +extern int grsec_enable_log_rwxmaps;
68259 +extern int grsec_enable_mount;
68260 +extern int grsec_enable_chdir;
68261 +extern int grsec_resource_logging;
68262 +extern int grsec_enable_blackhole;
68263 +extern int grsec_lastack_retries;
68264 +extern int grsec_enable_brute;
68265 +extern int grsec_lock;
68266 +
68267 +extern spinlock_t grsec_alert_lock;
68268 +extern unsigned long grsec_alert_wtime;
68269 +extern unsigned long grsec_alert_fyet;
68270 +
68271 +extern spinlock_t grsec_audit_lock;
68272 +
68273 +extern rwlock_t grsec_exec_file_lock;
68274 +
68275 +#define gr_task_fullpath(tsk) ((tsk)->exec_file ? \
68276 + gr_to_filename2((tsk)->exec_file->f_path.dentry, \
68277 + (tsk)->exec_file->f_path.mnt) : "/")
68278 +
68279 +#define gr_parent_task_fullpath(tsk) ((tsk)->real_parent->exec_file ? \
68280 + gr_to_filename3((tsk)->real_parent->exec_file->f_path.dentry, \
68281 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
68282 +
68283 +#define gr_task_fullpath0(tsk) ((tsk)->exec_file ? \
68284 + gr_to_filename((tsk)->exec_file->f_path.dentry, \
68285 + (tsk)->exec_file->f_path.mnt) : "/")
68286 +
68287 +#define gr_parent_task_fullpath0(tsk) ((tsk)->real_parent->exec_file ? \
68288 + gr_to_filename1((tsk)->real_parent->exec_file->f_path.dentry, \
68289 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
68290 +
68291 +#define proc_is_chrooted(tsk_a) ((tsk_a)->gr_is_chrooted)
68292 +
68293 +#define have_same_root(tsk_a,tsk_b) ((tsk_a)->gr_chroot_dentry == (tsk_b)->gr_chroot_dentry)
68294 +
68295 +#define GR_CHROOT_CAPS {{ \
68296 + CAP_TO_MASK(CAP_LINUX_IMMUTABLE) | CAP_TO_MASK(CAP_NET_ADMIN) | \
68297 + CAP_TO_MASK(CAP_SYS_MODULE) | CAP_TO_MASK(CAP_SYS_RAWIO) | \
68298 + CAP_TO_MASK(CAP_SYS_PACCT) | CAP_TO_MASK(CAP_SYS_ADMIN) | \
68299 + CAP_TO_MASK(CAP_SYS_BOOT) | CAP_TO_MASK(CAP_SYS_TIME) | \
68300 + CAP_TO_MASK(CAP_NET_RAW) | CAP_TO_MASK(CAP_SYS_TTY_CONFIG) | \
68301 + CAP_TO_MASK(CAP_IPC_OWNER) | CAP_TO_MASK(CAP_SETFCAP), \
68302 + CAP_TO_MASK(CAP_SYSLOG) | CAP_TO_MASK(CAP_MAC_ADMIN) }}
68303 +
68304 +#define security_learn(normal_msg,args...) \
68305 +({ \
68306 + read_lock(&grsec_exec_file_lock); \
68307 + gr_add_learn_entry(normal_msg "\n", ## args); \
68308 + read_unlock(&grsec_exec_file_lock); \
68309 +})
68310 +
68311 +enum {
68312 + GR_DO_AUDIT,
68313 + GR_DONT_AUDIT,
68314 + /* used for non-audit messages that we shouldn't kill the task on */
68315 + GR_DONT_AUDIT_GOOD
68316 +};
68317 +
68318 +enum {
68319 + GR_TTYSNIFF,
68320 + GR_RBAC,
68321 + GR_RBAC_STR,
68322 + GR_STR_RBAC,
68323 + GR_RBAC_MODE2,
68324 + GR_RBAC_MODE3,
68325 + GR_FILENAME,
68326 + GR_SYSCTL_HIDDEN,
68327 + GR_NOARGS,
68328 + GR_ONE_INT,
68329 + GR_ONE_INT_TWO_STR,
68330 + GR_ONE_STR,
68331 + GR_STR_INT,
68332 + GR_TWO_STR_INT,
68333 + GR_TWO_INT,
68334 + GR_TWO_U64,
68335 + GR_THREE_INT,
68336 + GR_FIVE_INT_TWO_STR,
68337 + GR_TWO_STR,
68338 + GR_THREE_STR,
68339 + GR_FOUR_STR,
68340 + GR_STR_FILENAME,
68341 + GR_FILENAME_STR,
68342 + GR_FILENAME_TWO_INT,
68343 + GR_FILENAME_TWO_INT_STR,
68344 + GR_TEXTREL,
68345 + GR_PTRACE,
68346 + GR_RESOURCE,
68347 + GR_CAP,
68348 + GR_SIG,
68349 + GR_SIG2,
68350 + GR_CRASH1,
68351 + GR_CRASH2,
68352 + GR_PSACCT,
68353 + GR_RWXMAP
68354 +};
68355 +
68356 +#define gr_log_hidden_sysctl(audit, msg, str) gr_log_varargs(audit, msg, GR_SYSCTL_HIDDEN, str)
68357 +#define gr_log_ttysniff(audit, msg, task) gr_log_varargs(audit, msg, GR_TTYSNIFF, task)
68358 +#define gr_log_fs_rbac_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_RBAC, dentry, mnt)
68359 +#define gr_log_fs_rbac_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_RBAC_STR, dentry, mnt, str)
68360 +#define gr_log_fs_str_rbac(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_RBAC, str, dentry, mnt)
68361 +#define gr_log_fs_rbac_mode2(audit, msg, dentry, mnt, str1, str2) gr_log_varargs(audit, msg, GR_RBAC_MODE2, dentry, mnt, str1, str2)
68362 +#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)
68363 +#define gr_log_fs_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_FILENAME, dentry, mnt)
68364 +#define gr_log_noargs(audit, msg) gr_log_varargs(audit, msg, GR_NOARGS)
68365 +#define gr_log_int(audit, msg, num) gr_log_varargs(audit, msg, GR_ONE_INT, num)
68366 +#define gr_log_int_str2(audit, msg, num, str1, str2) gr_log_varargs(audit, msg, GR_ONE_INT_TWO_STR, num, str1, str2)
68367 +#define gr_log_str(audit, msg, str) gr_log_varargs(audit, msg, GR_ONE_STR, str)
68368 +#define gr_log_str_int(audit, msg, str, num) gr_log_varargs(audit, msg, GR_STR_INT, str, num)
68369 +#define gr_log_int_int(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_INT, num1, num2)
68370 +#define gr_log_two_u64(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_U64, num1, num2)
68371 +#define gr_log_int3(audit, msg, num1, num2, num3) gr_log_varargs(audit, msg, GR_THREE_INT, num1, num2, num3)
68372 +#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)
68373 +#define gr_log_str_str(audit, msg, str1, str2) gr_log_varargs(audit, msg, GR_TWO_STR, str1, str2)
68374 +#define gr_log_str2_int(audit, msg, str1, str2, num) gr_log_varargs(audit, msg, GR_TWO_STR_INT, str1, str2, num)
68375 +#define gr_log_str3(audit, msg, str1, str2, str3) gr_log_varargs(audit, msg, GR_THREE_STR, str1, str2, str3)
68376 +#define gr_log_str4(audit, msg, str1, str2, str3, str4) gr_log_varargs(audit, msg, GR_FOUR_STR, str1, str2, str3, str4)
68377 +#define gr_log_str_fs(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_FILENAME, str, dentry, mnt)
68378 +#define gr_log_fs_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_FILENAME_STR, dentry, mnt, str)
68379 +#define gr_log_fs_int2(audit, msg, dentry, mnt, num1, num2) gr_log_varargs(audit, msg, GR_FILENAME_TWO_INT, dentry, mnt, num1, num2)
68380 +#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)
68381 +#define gr_log_textrel_ulong_ulong(audit, msg, file, ulong1, ulong2) gr_log_varargs(audit, msg, GR_TEXTREL, file, ulong1, ulong2)
68382 +#define gr_log_ptrace(audit, msg, task) gr_log_varargs(audit, msg, GR_PTRACE, task)
68383 +#define gr_log_res_ulong2_str(audit, msg, task, ulong1, str, ulong2) gr_log_varargs(audit, msg, GR_RESOURCE, task, ulong1, str, ulong2)
68384 +#define gr_log_cap(audit, msg, task, str) gr_log_varargs(audit, msg, GR_CAP, task, str)
68385 +#define gr_log_sig_addr(audit, msg, str, addr) gr_log_varargs(audit, msg, GR_SIG, str, addr)
68386 +#define gr_log_sig_task(audit, msg, task, num) gr_log_varargs(audit, msg, GR_SIG2, task, num)
68387 +#define gr_log_crash1(audit, msg, task, ulong) gr_log_varargs(audit, msg, GR_CRASH1, task, ulong)
68388 +#define gr_log_crash2(audit, msg, task, ulong1) gr_log_varargs(audit, msg, GR_CRASH2, task, ulong1)
68389 +#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)
68390 +#define gr_log_rwxmap(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAP, str)
68391 +
68392 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...);
68393 +
68394 +#endif
68395 +
68396 +#endif
68397 diff --git a/include/linux/grmsg.h b/include/linux/grmsg.h
68398 new file mode 100644
68399 index 0000000..2bd4c8d
68400 --- /dev/null
68401 +++ b/include/linux/grmsg.h
68402 @@ -0,0 +1,111 @@
68403 +#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"
68404 +#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"
68405 +#define GR_PTRACE_ACL_MSG "denied ptrace of %.950s(%.16s:%d) by "
68406 +#define GR_STOPMOD_MSG "denied modification of module state by "
68407 +#define GR_ROFS_BLOCKWRITE_MSG "denied write to block device %.950s by "
68408 +#define GR_ROFS_MOUNT_MSG "denied writable mount of %.950s by "
68409 +#define GR_IOPERM_MSG "denied use of ioperm() by "
68410 +#define GR_IOPL_MSG "denied use of iopl() by "
68411 +#define GR_SHMAT_ACL_MSG "denied attach of shared memory of UID %u, PID %d, ID %u by "
68412 +#define GR_UNIX_CHROOT_MSG "denied connect() to abstract AF_UNIX socket outside of chroot by "
68413 +#define GR_SHMAT_CHROOT_MSG "denied attach of shared memory outside of chroot by "
68414 +#define GR_MEM_READWRITE_MSG "denied access of range %Lx -> %Lx in /dev/mem by "
68415 +#define GR_SYMLINK_MSG "not following symlink %.950s owned by %d.%d by "
68416 +#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"
68417 +#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"
68418 +#define GR_HIDDEN_ACL_MSG "%s access to hidden file %.950s by "
68419 +#define GR_OPEN_ACL_MSG "%s open of %.950s for%s%s by "
68420 +#define GR_CREATE_ACL_MSG "%s create of %.950s for%s%s by "
68421 +#define GR_FIFO_MSG "denied writing FIFO %.950s of %d.%d by "
68422 +#define GR_MKNOD_CHROOT_MSG "denied mknod of %.950s from chroot by "
68423 +#define GR_MKNOD_ACL_MSG "%s mknod of %.950s by "
68424 +#define GR_UNIXCONNECT_ACL_MSG "%s connect() to the unix domain socket %.950s by "
68425 +#define GR_TTYSNIFF_ACL_MSG "terminal being sniffed by IP:%pI4 %.480s[%.16s:%d], parent %.480s[%.16s:%d] against "
68426 +#define GR_MKDIR_ACL_MSG "%s mkdir of %.950s by "
68427 +#define GR_RMDIR_ACL_MSG "%s rmdir of %.950s by "
68428 +#define GR_UNLINK_ACL_MSG "%s unlink of %.950s by "
68429 +#define GR_SYMLINK_ACL_MSG "%s symlink from %.480s to %.480s by "
68430 +#define GR_HARDLINK_MSG "denied hardlink of %.930s (owned by %d.%d) to %.30s for "
68431 +#define GR_LINK_ACL_MSG "%s link of %.480s to %.480s by "
68432 +#define GR_INHERIT_ACL_MSG "successful inherit of %.480s's ACL for %.480s by "
68433 +#define GR_RENAME_ACL_MSG "%s rename of %.480s to %.480s by "
68434 +#define GR_UNSAFESHARE_EXEC_ACL_MSG "denied exec with cloned fs of %.950s by "
68435 +#define GR_PTRACE_EXEC_ACL_MSG "denied ptrace of %.950s by "
68436 +#define GR_EXEC_ACL_MSG "%s execution of %.950s by "
68437 +#define GR_EXEC_TPE_MSG "denied untrusted exec (due to %.70s) of %.950s by "
68438 +#define GR_SEGVSTART_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning uid %u from login for %lu seconds"
68439 +#define GR_SEGVNOSUID_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning execution for %lu seconds"
68440 +#define GR_MOUNT_CHROOT_MSG "denied mount of %.256s as %.930s from chroot by "
68441 +#define GR_PIVOT_CHROOT_MSG "denied pivot_root from chroot by "
68442 +#define GR_TRUNCATE_ACL_MSG "%s truncate of %.950s by "
68443 +#define GR_ATIME_ACL_MSG "%s access time change of %.950s by "
68444 +#define GR_ACCESS_ACL_MSG "%s access of %.950s for%s%s%s by "
68445 +#define GR_CHROOT_CHROOT_MSG "denied double chroot to %.950s by "
68446 +#define GR_CHMOD_CHROOT_MSG "denied chmod +s of %.950s by "
68447 +#define GR_CHMOD_ACL_MSG "%s chmod of %.950s by "
68448 +#define GR_CHROOT_FCHDIR_MSG "denied fchdir outside of chroot to %.950s by "
68449 +#define GR_CHOWN_ACL_MSG "%s chown of %.950s by "
68450 +#define GR_SETXATTR_ACL_MSG "%s setting extended attributes of %.950s by "
68451 +#define GR_WRITLIB_ACL_MSG "denied load of writable library %.950s by "
68452 +#define GR_INITF_ACL_MSG "init_variables() failed %s by "
68453 +#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"
68454 +#define GR_DEV_ACL_MSG "/dev/grsec: %d bytes sent %d required, being fed garbage by "
68455 +#define GR_SHUTS_ACL_MSG "shutdown auth success for "
68456 +#define GR_SHUTF_ACL_MSG "shutdown auth failure for "
68457 +#define GR_SHUTI_ACL_MSG "ignoring shutdown for disabled RBAC system for "
68458 +#define GR_SEGVMODS_ACL_MSG "segvmod auth success for "
68459 +#define GR_SEGVMODF_ACL_MSG "segvmod auth failure for "
68460 +#define GR_SEGVMODI_ACL_MSG "ignoring segvmod for disabled RBAC system for "
68461 +#define GR_ENABLE_ACL_MSG "%s RBAC system loaded by "
68462 +#define GR_ENABLEF_ACL_MSG "unable to load %s for "
68463 +#define GR_RELOADI_ACL_MSG "ignoring reload request for disabled RBAC system"
68464 +#define GR_RELOAD_ACL_MSG "%s RBAC system reloaded by "
68465 +#define GR_RELOADF_ACL_MSG "failed reload of %s for "
68466 +#define GR_SPROLEI_ACL_MSG "ignoring change to special role for disabled RBAC system for "
68467 +#define GR_SPROLES_ACL_MSG "successful change to special role %s (id %d) by "
68468 +#define GR_SPROLEL_ACL_MSG "special role %s (id %d) exited by "
68469 +#define GR_SPROLEF_ACL_MSG "special role %s failure for "
68470 +#define GR_UNSPROLEI_ACL_MSG "ignoring unauth of special role for disabled RBAC system for "
68471 +#define GR_UNSPROLES_ACL_MSG "successful unauth of special role %s (id %d) by "
68472 +#define GR_INVMODE_ACL_MSG "invalid mode %d by "
68473 +#define GR_PRIORITY_CHROOT_MSG "denied priority change of process (%.16s:%d) by "
68474 +#define GR_FAILFORK_MSG "failed fork with errno %s by "
68475 +#define GR_NICE_CHROOT_MSG "denied priority change by "
68476 +#define GR_UNISIGLOG_MSG "%.32s occurred at %p in "
68477 +#define GR_DUALSIGLOG_MSG "signal %d sent to " DEFAULTSECMSG " by "
68478 +#define GR_SIG_ACL_MSG "denied send of signal %d to protected task " DEFAULTSECMSG " by "
68479 +#define GR_SYSCTL_MSG "denied modification of grsecurity sysctl value : %.32s by "
68480 +#define GR_SYSCTL_ACL_MSG "%s sysctl of %.950s for%s%s by "
68481 +#define GR_TIME_MSG "time set by "
68482 +#define GR_DEFACL_MSG "fatal: unable to find subject for (%.16s:%d), loaded by "
68483 +#define GR_MMAP_ACL_MSG "%s executable mmap of %.950s by "
68484 +#define GR_MPROTECT_ACL_MSG "%s executable mprotect of %.950s by "
68485 +#define GR_SOCK_MSG "denied socket(%.16s,%.16s,%.16s) by "
68486 +#define GR_SOCK_NOINET_MSG "denied socket(%.16s,%.16s,%d) by "
68487 +#define GR_BIND_MSG "denied bind() by "
68488 +#define GR_CONNECT_MSG "denied connect() by "
68489 +#define GR_BIND_ACL_MSG "denied bind() to %pI4 port %u sock type %.16s protocol %.16s by "
68490 +#define GR_CONNECT_ACL_MSG "denied connect() to %pI4 port %u sock type %.16s protocol %.16s by "
68491 +#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"
68492 +#define GR_EXEC_CHROOT_MSG "exec of %.980s within chroot by process "
68493 +#define GR_CAP_ACL_MSG "use of %s denied for "
68494 +#define GR_CAP_CHROOT_MSG "use of %s in chroot denied for "
68495 +#define GR_CAP_ACL_MSG2 "use of %s permitted for "
68496 +#define GR_USRCHANGE_ACL_MSG "change to uid %u denied for "
68497 +#define GR_GRPCHANGE_ACL_MSG "change to gid %u denied for "
68498 +#define GR_REMOUNT_AUDIT_MSG "remount of %.256s by "
68499 +#define GR_UNMOUNT_AUDIT_MSG "unmount of %.256s by "
68500 +#define GR_MOUNT_AUDIT_MSG "mount of %.256s to %.256s by "
68501 +#define GR_CHDIR_AUDIT_MSG "chdir to %.980s by "
68502 +#define GR_EXEC_AUDIT_MSG "exec of %.930s (%.128s) by "
68503 +#define GR_RESOURCE_MSG "denied resource overstep by requesting %lu for %.16s against limit %lu for "
68504 +#define GR_RWXMMAP_MSG "denied RWX mmap of %.950s by "
68505 +#define GR_RWXMPROTECT_MSG "denied RWX mprotect of %.950s by "
68506 +#define GR_TEXTREL_AUDIT_MSG "text relocation in %s, VMA:0x%08lx 0x%08lx by "
68507 +#define GR_VM86_MSG "denied use of vm86 by "
68508 +#define GR_PTRACE_AUDIT_MSG "process %.950s(%.16s:%d) attached to via ptrace by "
68509 +#define GR_PTRACE_READEXEC_MSG "denied ptrace of unreadable binary %.950s by "
68510 +#define GR_INIT_TRANSFER_MSG "persistent special role transferred privilege to init by "
68511 +#define GR_BADPROCPID_MSG "denied read of sensitive /proc/pid/%s entry via fd passed across exec by "
68512 +#define GR_SYMLINKOWNER_MSG "denied following symlink %.950s since symlink owner %u does not match target owner %u, by "
68513 +#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 "
68514 diff --git a/include/linux/grsecurity.h b/include/linux/grsecurity.h
68515 new file mode 100644
68516 index 0000000..d7ef0ac
68517 --- /dev/null
68518 +++ b/include/linux/grsecurity.h
68519 @@ -0,0 +1,242 @@
68520 +#ifndef GR_SECURITY_H
68521 +#define GR_SECURITY_H
68522 +#include <linux/fs.h>
68523 +#include <linux/fs_struct.h>
68524 +#include <linux/binfmts.h>
68525 +#include <linux/gracl.h>
68526 +
68527 +/* notify of brain-dead configs */
68528 +#if defined(CONFIG_GRKERNSEC_PROC_USER) && defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
68529 +#error "CONFIG_GRKERNSEC_PROC_USER and CONFIG_GRKERNSEC_PROC_USERGROUP cannot both be enabled."
68530 +#endif
68531 +#if defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_PAGEEXEC) && !defined(CONFIG_PAX_SEGMEXEC) && !defined(CONFIG_PAX_KERNEXEC)
68532 +#error "CONFIG_PAX_NOEXEC enabled, but PAGEEXEC, SEGMEXEC, and KERNEXEC are disabled."
68533 +#endif
68534 +#if defined(CONFIG_PAX_ASLR) && !defined(CONFIG_PAX_RANDKSTACK) && !defined(CONFIG_PAX_RANDUSTACK) && !defined(CONFIG_PAX_RANDMMAP)
68535 +#error "CONFIG_PAX_ASLR enabled, but RANDKSTACK, RANDUSTACK, and RANDMMAP are disabled."
68536 +#endif
68537 +#if defined(CONFIG_PAX) && !defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_ASLR)
68538 +#error "CONFIG_PAX enabled, but no PaX options are enabled."
68539 +#endif
68540 +
68541 +void gr_handle_brute_attach(unsigned long mm_flags);
68542 +void gr_handle_brute_check(void);
68543 +void gr_handle_kernel_exploit(void);
68544 +int gr_process_user_ban(void);
68545 +
68546 +char gr_roletype_to_char(void);
68547 +
68548 +int gr_acl_enable_at_secure(void);
68549 +
68550 +int gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs);
68551 +int gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs);
68552 +
68553 +void gr_del_task_from_ip_table(struct task_struct *p);
68554 +
68555 +int gr_pid_is_chrooted(struct task_struct *p);
68556 +int gr_handle_chroot_fowner(struct pid *pid, enum pid_type type);
68557 +int gr_handle_chroot_nice(void);
68558 +int gr_handle_chroot_sysctl(const int op);
68559 +int gr_handle_chroot_setpriority(struct task_struct *p,
68560 + const int niceval);
68561 +int gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt);
68562 +int gr_handle_chroot_chroot(const struct dentry *dentry,
68563 + const struct vfsmount *mnt);
68564 +void gr_handle_chroot_chdir(const struct path *path);
68565 +int gr_handle_chroot_chmod(const struct dentry *dentry,
68566 + const struct vfsmount *mnt, const int mode);
68567 +int gr_handle_chroot_mknod(const struct dentry *dentry,
68568 + const struct vfsmount *mnt, const int mode);
68569 +int gr_handle_chroot_mount(const struct dentry *dentry,
68570 + const struct vfsmount *mnt,
68571 + const char *dev_name);
68572 +int gr_handle_chroot_pivot(void);
68573 +int gr_handle_chroot_unix(const pid_t pid);
68574 +
68575 +int gr_handle_rawio(const struct inode *inode);
68576 +
68577 +void gr_handle_ioperm(void);
68578 +void gr_handle_iopl(void);
68579 +
68580 +umode_t gr_acl_umask(void);
68581 +
68582 +int gr_tpe_allow(const struct file *file);
68583 +
68584 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path);
68585 +void gr_clear_chroot_entries(struct task_struct *task);
68586 +
68587 +void gr_log_forkfail(const int retval);
68588 +void gr_log_timechange(void);
68589 +void gr_log_signal(const int sig, const void *addr, const struct task_struct *t);
68590 +void gr_log_chdir(const struct dentry *dentry,
68591 + const struct vfsmount *mnt);
68592 +void gr_log_chroot_exec(const struct dentry *dentry,
68593 + const struct vfsmount *mnt);
68594 +void gr_log_remount(const char *devname, const int retval);
68595 +void gr_log_unmount(const char *devname, const int retval);
68596 +void gr_log_mount(const char *from, const char *to, const int retval);
68597 +void gr_log_textrel(struct vm_area_struct *vma);
68598 +void gr_log_rwxmmap(struct file *file);
68599 +void gr_log_rwxmprotect(struct file *file);
68600 +
68601 +int gr_handle_follow_link(const struct inode *parent,
68602 + const struct inode *inode,
68603 + const struct dentry *dentry,
68604 + const struct vfsmount *mnt);
68605 +int gr_handle_fifo(const struct dentry *dentry,
68606 + const struct vfsmount *mnt,
68607 + const struct dentry *dir, const int flag,
68608 + const int acc_mode);
68609 +int gr_handle_hardlink(const struct dentry *dentry,
68610 + const struct vfsmount *mnt,
68611 + struct inode *inode,
68612 + const int mode, const struct filename *to);
68613 +
68614 +int gr_is_capable(const int cap);
68615 +int gr_is_capable_nolog(const int cap);
68616 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
68617 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap);
68618 +
68619 +void gr_copy_label(struct task_struct *tsk);
68620 +void gr_handle_crash(struct task_struct *task, const int sig);
68621 +int gr_handle_signal(const struct task_struct *p, const int sig);
68622 +int gr_check_crash_uid(const kuid_t uid);
68623 +int gr_check_protected_task(const struct task_struct *task);
68624 +int gr_check_protected_task_fowner(struct pid *pid, enum pid_type type);
68625 +int gr_acl_handle_mmap(const struct file *file,
68626 + const unsigned long prot);
68627 +int gr_acl_handle_mprotect(const struct file *file,
68628 + const unsigned long prot);
68629 +int gr_check_hidden_task(const struct task_struct *tsk);
68630 +__u32 gr_acl_handle_truncate(const struct dentry *dentry,
68631 + const struct vfsmount *mnt);
68632 +__u32 gr_acl_handle_utime(const struct dentry *dentry,
68633 + const struct vfsmount *mnt);
68634 +__u32 gr_acl_handle_access(const struct dentry *dentry,
68635 + const struct vfsmount *mnt, const int fmode);
68636 +__u32 gr_acl_handle_chmod(const struct dentry *dentry,
68637 + const struct vfsmount *mnt, umode_t *mode);
68638 +__u32 gr_acl_handle_chown(const struct dentry *dentry,
68639 + const struct vfsmount *mnt);
68640 +__u32 gr_acl_handle_setxattr(const struct dentry *dentry,
68641 + const struct vfsmount *mnt);
68642 +int gr_handle_ptrace(struct task_struct *task, const long request);
68643 +int gr_handle_proc_ptrace(struct task_struct *task);
68644 +__u32 gr_acl_handle_execve(const struct dentry *dentry,
68645 + const struct vfsmount *mnt);
68646 +int gr_check_crash_exec(const struct file *filp);
68647 +int gr_acl_is_enabled(void);
68648 +void gr_set_kernel_label(struct task_struct *task);
68649 +void gr_set_role_label(struct task_struct *task, const kuid_t uid,
68650 + const kgid_t gid);
68651 +int gr_set_proc_label(const struct dentry *dentry,
68652 + const struct vfsmount *mnt,
68653 + const int unsafe_flags);
68654 +__u32 gr_acl_handle_hidden_file(const struct dentry *dentry,
68655 + const struct vfsmount *mnt);
68656 +__u32 gr_acl_handle_open(const struct dentry *dentry,
68657 + const struct vfsmount *mnt, int acc_mode);
68658 +__u32 gr_acl_handle_creat(const struct dentry *dentry,
68659 + const struct dentry *p_dentry,
68660 + const struct vfsmount *p_mnt,
68661 + int open_flags, int acc_mode, const int imode);
68662 +void gr_handle_create(const struct dentry *dentry,
68663 + const struct vfsmount *mnt);
68664 +void gr_handle_proc_create(const struct dentry *dentry,
68665 + const struct inode *inode);
68666 +__u32 gr_acl_handle_mknod(const struct dentry *new_dentry,
68667 + const struct dentry *parent_dentry,
68668 + const struct vfsmount *parent_mnt,
68669 + const int mode);
68670 +__u32 gr_acl_handle_mkdir(const struct dentry *new_dentry,
68671 + const struct dentry *parent_dentry,
68672 + const struct vfsmount *parent_mnt);
68673 +__u32 gr_acl_handle_rmdir(const struct dentry *dentry,
68674 + const struct vfsmount *mnt);
68675 +void gr_handle_delete(const ino_t ino, const dev_t dev);
68676 +__u32 gr_acl_handle_unlink(const struct dentry *dentry,
68677 + const struct vfsmount *mnt);
68678 +__u32 gr_acl_handle_symlink(const struct dentry *new_dentry,
68679 + const struct dentry *parent_dentry,
68680 + const struct vfsmount *parent_mnt,
68681 + const struct filename *from);
68682 +__u32 gr_acl_handle_link(const struct dentry *new_dentry,
68683 + const struct dentry *parent_dentry,
68684 + const struct vfsmount *parent_mnt,
68685 + const struct dentry *old_dentry,
68686 + const struct vfsmount *old_mnt, const struct filename *to);
68687 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target);
68688 +int gr_acl_handle_rename(struct dentry *new_dentry,
68689 + struct dentry *parent_dentry,
68690 + const struct vfsmount *parent_mnt,
68691 + struct dentry *old_dentry,
68692 + struct inode *old_parent_inode,
68693 + struct vfsmount *old_mnt, const struct filename *newname);
68694 +void gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
68695 + struct dentry *old_dentry,
68696 + struct dentry *new_dentry,
68697 + struct vfsmount *mnt, const __u8 replace);
68698 +__u32 gr_check_link(const struct dentry *new_dentry,
68699 + const struct dentry *parent_dentry,
68700 + const struct vfsmount *parent_mnt,
68701 + const struct dentry *old_dentry,
68702 + const struct vfsmount *old_mnt);
68703 +int gr_acl_handle_filldir(const struct file *file, const char *name,
68704 + const unsigned int namelen, const ino_t ino);
68705 +
68706 +__u32 gr_acl_handle_unix(const struct dentry *dentry,
68707 + const struct vfsmount *mnt);
68708 +void gr_acl_handle_exit(void);
68709 +void gr_acl_handle_psacct(struct task_struct *task, const long code);
68710 +int gr_acl_handle_procpidmem(const struct task_struct *task);
68711 +int gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags);
68712 +int gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode);
68713 +void gr_audit_ptrace(struct task_struct *task);
68714 +dev_t gr_get_dev_from_dentry(struct dentry *dentry);
68715 +void gr_put_exec_file(struct task_struct *task);
68716 +
68717 +int gr_ptrace_readexec(struct file *file, int unsafe_flags);
68718 +
68719 +#if defined(CONFIG_GRKERNSEC) && (defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC))
68720 +extern void gr_learn_resource(const struct task_struct *task, const int res,
68721 + const unsigned long wanted, const int gt);
68722 +#else
68723 +static inline void gr_learn_resource(const struct task_struct *task, const int res,
68724 + const unsigned long wanted, const int gt)
68725 +{
68726 +}
68727 +#endif
68728 +
68729 +#ifdef CONFIG_GRKERNSEC_RESLOG
68730 +extern void gr_log_resource(const struct task_struct *task, const int res,
68731 + const unsigned long wanted, const int gt);
68732 +#else
68733 +static inline void gr_log_resource(const struct task_struct *task, const int res,
68734 + const unsigned long wanted, const int gt)
68735 +{
68736 +}
68737 +#endif
68738 +
68739 +#ifdef CONFIG_GRKERNSEC
68740 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p);
68741 +void gr_handle_vm86(void);
68742 +void gr_handle_mem_readwrite(u64 from, u64 to);
68743 +
68744 +void gr_log_badprocpid(const char *entry);
68745 +
68746 +extern int grsec_enable_dmesg;
68747 +extern int grsec_disable_privio;
68748 +
68749 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
68750 +extern kgid_t grsec_proc_gid;
68751 +#endif
68752 +
68753 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
68754 +extern int grsec_enable_chroot_findtask;
68755 +#endif
68756 +#ifdef CONFIG_GRKERNSEC_SETXID
68757 +extern int grsec_enable_setxid;
68758 +#endif
68759 +#endif
68760 +
68761 +#endif
68762 diff --git a/include/linux/grsock.h b/include/linux/grsock.h
68763 new file mode 100644
68764 index 0000000..e7ffaaf
68765 --- /dev/null
68766 +++ b/include/linux/grsock.h
68767 @@ -0,0 +1,19 @@
68768 +#ifndef __GRSOCK_H
68769 +#define __GRSOCK_H
68770 +
68771 +extern void gr_attach_curr_ip(const struct sock *sk);
68772 +extern int gr_handle_sock_all(const int family, const int type,
68773 + const int protocol);
68774 +extern int gr_handle_sock_server(const struct sockaddr *sck);
68775 +extern int gr_handle_sock_server_other(const struct sock *sck);
68776 +extern int gr_handle_sock_client(const struct sockaddr *sck);
68777 +extern int gr_search_connect(struct socket * sock,
68778 + struct sockaddr_in * addr);
68779 +extern int gr_search_bind(struct socket * sock,
68780 + struct sockaddr_in * addr);
68781 +extern int gr_search_listen(struct socket * sock);
68782 +extern int gr_search_accept(struct socket * sock);
68783 +extern int gr_search_socket(const int domain, const int type,
68784 + const int protocol);
68785 +
68786 +#endif
68787 diff --git a/include/linux/highmem.h b/include/linux/highmem.h
68788 index 7fb31da..08b5114 100644
68789 --- a/include/linux/highmem.h
68790 +++ b/include/linux/highmem.h
68791 @@ -189,6 +189,18 @@ static inline void clear_highpage(struct page *page)
68792 kunmap_atomic(kaddr);
68793 }
68794
68795 +static inline void sanitize_highpage(struct page *page)
68796 +{
68797 + void *kaddr;
68798 + unsigned long flags;
68799 +
68800 + local_irq_save(flags);
68801 + kaddr = kmap_atomic(page);
68802 + clear_page(kaddr);
68803 + kunmap_atomic(kaddr);
68804 + local_irq_restore(flags);
68805 +}
68806 +
68807 static inline void zero_user_segments(struct page *page,
68808 unsigned start1, unsigned end1,
68809 unsigned start2, unsigned end2)
68810 diff --git a/include/linux/hwmon-sysfs.h b/include/linux/hwmon-sysfs.h
68811 index 1c7b89a..7f52502 100644
68812 --- a/include/linux/hwmon-sysfs.h
68813 +++ b/include/linux/hwmon-sysfs.h
68814 @@ -25,7 +25,8 @@
68815 struct sensor_device_attribute{
68816 struct device_attribute dev_attr;
68817 int index;
68818 -};
68819 +} __do_const;
68820 +typedef struct sensor_device_attribute __no_const sensor_device_attribute_no_const;
68821 #define to_sensor_dev_attr(_dev_attr) \
68822 container_of(_dev_attr, struct sensor_device_attribute, dev_attr)
68823
68824 @@ -41,7 +42,7 @@ struct sensor_device_attribute_2 {
68825 struct device_attribute dev_attr;
68826 u8 index;
68827 u8 nr;
68828 -};
68829 +} __do_const;
68830 #define to_sensor_dev_attr_2(_dev_attr) \
68831 container_of(_dev_attr, struct sensor_device_attribute_2, dev_attr)
68832
68833 diff --git a/include/linux/i2c.h b/include/linux/i2c.h
68834 index d0c4db7..61b3577 100644
68835 --- a/include/linux/i2c.h
68836 +++ b/include/linux/i2c.h
68837 @@ -369,6 +369,7 @@ struct i2c_algorithm {
68838 /* To determine what the adapter supports */
68839 u32 (*functionality) (struct i2c_adapter *);
68840 };
68841 +typedef struct i2c_algorithm __no_const i2c_algorithm_no_const;
68842
68843 /*
68844 * i2c_adapter is the structure used to identify a physical i2c bus along
68845 diff --git a/include/linux/i2o.h b/include/linux/i2o.h
68846 index d23c3c2..eb63c81 100644
68847 --- a/include/linux/i2o.h
68848 +++ b/include/linux/i2o.h
68849 @@ -565,7 +565,7 @@ struct i2o_controller {
68850 struct i2o_device *exec; /* Executive */
68851 #if BITS_PER_LONG == 64
68852 spinlock_t context_list_lock; /* lock for context_list */
68853 - atomic_t context_list_counter; /* needed for unique contexts */
68854 + atomic_unchecked_t context_list_counter; /* needed for unique contexts */
68855 struct list_head context_list; /* list of context id's
68856 and pointers */
68857 #endif
68858 diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h
68859 index aff7ad8..3942bbd 100644
68860 --- a/include/linux/if_pppox.h
68861 +++ b/include/linux/if_pppox.h
68862 @@ -76,7 +76,7 @@ struct pppox_proto {
68863 int (*ioctl)(struct socket *sock, unsigned int cmd,
68864 unsigned long arg);
68865 struct module *owner;
68866 -};
68867 +} __do_const;
68868
68869 extern int register_pppox_proto(int proto_num, const struct pppox_proto *pp);
68870 extern void unregister_pppox_proto(int proto_num);
68871 diff --git a/include/linux/init.h b/include/linux/init.h
68872 index 8618147..0821126 100644
68873 --- a/include/linux/init.h
68874 +++ b/include/linux/init.h
68875 @@ -39,9 +39,36 @@
68876 * Also note, that this data cannot be "const".
68877 */
68878
68879 +#ifdef MODULE
68880 +#define add_init_latent_entropy
68881 +#define add_devinit_latent_entropy
68882 +#define add_cpuinit_latent_entropy
68883 +#define add_meminit_latent_entropy
68884 +#else
68885 +#define add_init_latent_entropy __latent_entropy
68886 +
68887 +#ifdef CONFIG_HOTPLUG
68888 +#define add_devinit_latent_entropy
68889 +#else
68890 +#define add_devinit_latent_entropy __latent_entropy
68891 +#endif
68892 +
68893 +#ifdef CONFIG_HOTPLUG_CPU
68894 +#define add_cpuinit_latent_entropy
68895 +#else
68896 +#define add_cpuinit_latent_entropy __latent_entropy
68897 +#endif
68898 +
68899 +#ifdef CONFIG_MEMORY_HOTPLUG
68900 +#define add_meminit_latent_entropy
68901 +#else
68902 +#define add_meminit_latent_entropy __latent_entropy
68903 +#endif
68904 +#endif
68905 +
68906 /* These are for everybody (although not all archs will actually
68907 discard it in modules) */
68908 -#define __init __section(.init.text) __cold notrace
68909 +#define __init __section(.init.text) __cold notrace add_init_latent_entropy
68910 #define __initdata __section(.init.data)
68911 #define __initconst __constsection(.init.rodata)
68912 #define __exitdata __section(.exit.data)
68913 @@ -94,7 +121,7 @@
68914 #define __exit __section(.exit.text) __exitused __cold notrace
68915
68916 /* Used for HOTPLUG_CPU */
68917 -#define __cpuinit __section(.cpuinit.text) __cold notrace
68918 +#define __cpuinit __section(.cpuinit.text) __cold notrace add_cpuinit_latent_entropy
68919 #define __cpuinitdata __section(.cpuinit.data)
68920 #define __cpuinitconst __constsection(.cpuinit.rodata)
68921 #define __cpuexit __section(.cpuexit.text) __exitused __cold notrace
68922 @@ -102,7 +129,7 @@
68923 #define __cpuexitconst __constsection(.cpuexit.rodata)
68924
68925 /* Used for MEMORY_HOTPLUG */
68926 -#define __meminit __section(.meminit.text) __cold notrace
68927 +#define __meminit __section(.meminit.text) __cold notrace add_meminit_latent_entropy
68928 #define __meminitdata __section(.meminit.data)
68929 #define __meminitconst __constsection(.meminit.rodata)
68930 #define __memexit __section(.memexit.text) __exitused __cold notrace
68931 diff --git a/include/linux/init_task.h b/include/linux/init_task.h
68932 index 5cd0f09..c9f67cc 100644
68933 --- a/include/linux/init_task.h
68934 +++ b/include/linux/init_task.h
68935 @@ -154,6 +154,12 @@ extern struct task_group root_task_group;
68936
68937 #define INIT_TASK_COMM "swapper"
68938
68939 +#ifdef CONFIG_X86
68940 +#define INIT_TASK_THREAD_INFO .tinfo = INIT_THREAD_INFO,
68941 +#else
68942 +#define INIT_TASK_THREAD_INFO
68943 +#endif
68944 +
68945 /*
68946 * INIT_TASK is used to set up the first task table, touch at
68947 * your own risk!. Base=0, limit=0x1fffff (=2MB)
68948 @@ -193,6 +199,7 @@ extern struct task_group root_task_group;
68949 RCU_POINTER_INITIALIZER(cred, &init_cred), \
68950 .comm = INIT_TASK_COMM, \
68951 .thread = INIT_THREAD, \
68952 + INIT_TASK_THREAD_INFO \
68953 .fs = &init_fs, \
68954 .files = &init_files, \
68955 .signal = &init_signals, \
68956 diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
68957 index 5fa5afe..ac55b25 100644
68958 --- a/include/linux/interrupt.h
68959 +++ b/include/linux/interrupt.h
68960 @@ -430,7 +430,7 @@ enum
68961 /* map softirq index to softirq name. update 'softirq_to_name' in
68962 * kernel/softirq.c when adding a new softirq.
68963 */
68964 -extern char *softirq_to_name[NR_SOFTIRQS];
68965 +extern const char * const softirq_to_name[NR_SOFTIRQS];
68966
68967 /* softirq mask and active fields moved to irq_cpustat_t in
68968 * asm/hardirq.h to get better cache usage. KAO
68969 @@ -438,12 +438,12 @@ extern char *softirq_to_name[NR_SOFTIRQS];
68970
68971 struct softirq_action
68972 {
68973 - void (*action)(struct softirq_action *);
68974 -};
68975 + void (*action)(void);
68976 +} __no_const;
68977
68978 asmlinkage void do_softirq(void);
68979 asmlinkage void __do_softirq(void);
68980 -extern void open_softirq(int nr, void (*action)(struct softirq_action *));
68981 +extern void open_softirq(int nr, void (*action)(void));
68982 extern void softirq_init(void);
68983 extern void __raise_softirq_irqoff(unsigned int nr);
68984
68985 diff --git a/include/linux/iommu.h b/include/linux/iommu.h
68986 index ba3b8a9..7e14ed8 100644
68987 --- a/include/linux/iommu.h
68988 +++ b/include/linux/iommu.h
68989 @@ -113,7 +113,7 @@ struct iommu_ops {
68990 u32 (*domain_get_windows)(struct iommu_domain *domain);
68991
68992 unsigned long pgsize_bitmap;
68993 -};
68994 +} __do_const;
68995
68996 #define IOMMU_GROUP_NOTIFY_ADD_DEVICE 1 /* Device added */
68997 #define IOMMU_GROUP_NOTIFY_DEL_DEVICE 2 /* Pre Device removed */
68998 diff --git a/include/linux/ioport.h b/include/linux/ioport.h
68999 index 85ac9b9b..e5759ab 100644
69000 --- a/include/linux/ioport.h
69001 +++ b/include/linux/ioport.h
69002 @@ -161,7 +161,7 @@ struct resource *lookup_resource(struct resource *root, resource_size_t start);
69003 int adjust_resource(struct resource *res, resource_size_t start,
69004 resource_size_t size);
69005 resource_size_t resource_alignment(struct resource *res);
69006 -static inline resource_size_t resource_size(const struct resource *res)
69007 +static inline resource_size_t __intentional_overflow(-1) resource_size(const struct resource *res)
69008 {
69009 return res->end - res->start + 1;
69010 }
69011 diff --git a/include/linux/irq.h b/include/linux/irq.h
69012 index bc4e066..50468a9 100644
69013 --- a/include/linux/irq.h
69014 +++ b/include/linux/irq.h
69015 @@ -328,7 +328,8 @@ struct irq_chip {
69016 void (*irq_print_chip)(struct irq_data *data, struct seq_file *p);
69017
69018 unsigned long flags;
69019 -};
69020 +} __do_const;
69021 +typedef struct irq_chip __no_const irq_chip_no_const;
69022
69023 /*
69024 * irq_chip specific flags
69025 diff --git a/include/linux/irqchip/arm-gic.h b/include/linux/irqchip/arm-gic.h
69026 index 3fd8e42..a73e966 100644
69027 --- a/include/linux/irqchip/arm-gic.h
69028 +++ b/include/linux/irqchip/arm-gic.h
69029 @@ -59,9 +59,11 @@
69030
69031 #ifndef __ASSEMBLY__
69032
69033 +#include <linux/irq.h>
69034 +
69035 struct device_node;
69036
69037 -extern struct irq_chip gic_arch_extn;
69038 +extern irq_chip_no_const gic_arch_extn;
69039
69040 void gic_init_bases(unsigned int, int, void __iomem *, void __iomem *,
69041 u32 offset, struct device_node *);
69042 diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
69043 index 6883e19..06992b1 100644
69044 --- a/include/linux/kallsyms.h
69045 +++ b/include/linux/kallsyms.h
69046 @@ -15,7 +15,8 @@
69047
69048 struct module;
69049
69050 -#ifdef CONFIG_KALLSYMS
69051 +#if !defined(__INCLUDED_BY_HIDESYM) || !defined(CONFIG_KALLSYMS)
69052 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
69053 /* Lookup the address for a symbol. Returns 0 if not found. */
69054 unsigned long kallsyms_lookup_name(const char *name);
69055
69056 @@ -106,6 +107,17 @@ static inline int lookup_symbol_attrs(unsigned long addr, unsigned long *size, u
69057 /* Stupid that this does nothing, but I didn't create this mess. */
69058 #define __print_symbol(fmt, addr)
69059 #endif /*CONFIG_KALLSYMS*/
69060 +#else /* when included by kallsyms.c, vsnprintf.c, or
69061 + arch/x86/kernel/dumpstack.c, with HIDESYM enabled */
69062 +extern void __print_symbol(const char *fmt, unsigned long address);
69063 +extern int sprint_backtrace(char *buffer, unsigned long address);
69064 +extern int sprint_symbol(char *buffer, unsigned long address);
69065 +extern int sprint_symbol_no_offset(char *buffer, unsigned long address);
69066 +const char *kallsyms_lookup(unsigned long addr,
69067 + unsigned long *symbolsize,
69068 + unsigned long *offset,
69069 + char **modname, char *namebuf);
69070 +#endif
69071
69072 /* This macro allows us to keep printk typechecking */
69073 static __printf(1, 2)
69074 diff --git a/include/linux/key-type.h b/include/linux/key-type.h
69075 index 518a53a..5e28358 100644
69076 --- a/include/linux/key-type.h
69077 +++ b/include/linux/key-type.h
69078 @@ -125,7 +125,7 @@ struct key_type {
69079 /* internal fields */
69080 struct list_head link; /* link in types list */
69081 struct lock_class_key lock_class; /* key->sem lock class */
69082 -};
69083 +} __do_const;
69084
69085 extern struct key_type key_type_keyring;
69086
69087 diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h
69088 index c6e091b..a940adf 100644
69089 --- a/include/linux/kgdb.h
69090 +++ b/include/linux/kgdb.h
69091 @@ -52,7 +52,7 @@ extern int kgdb_connected;
69092 extern int kgdb_io_module_registered;
69093
69094 extern atomic_t kgdb_setting_breakpoint;
69095 -extern atomic_t kgdb_cpu_doing_single_step;
69096 +extern atomic_unchecked_t kgdb_cpu_doing_single_step;
69097
69098 extern struct task_struct *kgdb_usethread;
69099 extern struct task_struct *kgdb_contthread;
69100 @@ -254,7 +254,7 @@ struct kgdb_arch {
69101 void (*correct_hw_break)(void);
69102
69103 void (*enable_nmi)(bool on);
69104 -};
69105 +} __do_const;
69106
69107 /**
69108 * struct kgdb_io - Describe the interface for an I/O driver to talk with KGDB.
69109 @@ -279,7 +279,7 @@ struct kgdb_io {
69110 void (*pre_exception) (void);
69111 void (*post_exception) (void);
69112 int is_console;
69113 -};
69114 +} __do_const;
69115
69116 extern struct kgdb_arch arch_kgdb_ops;
69117
69118 diff --git a/include/linux/kmod.h b/include/linux/kmod.h
69119 index 5398d58..5883a34 100644
69120 --- a/include/linux/kmod.h
69121 +++ b/include/linux/kmod.h
69122 @@ -34,6 +34,8 @@ extern char modprobe_path[]; /* for sysctl */
69123 * usually useless though. */
69124 extern __printf(2, 3)
69125 int __request_module(bool wait, const char *name, ...);
69126 +extern __printf(3, 4)
69127 +int ___request_module(bool wait, char *param_name, const char *name, ...);
69128 #define request_module(mod...) __request_module(true, mod)
69129 #define request_module_nowait(mod...) __request_module(false, mod)
69130 #define try_then_request_module(x, mod...) \
69131 diff --git a/include/linux/kobject.h b/include/linux/kobject.h
69132 index 939b112..ed6ed51 100644
69133 --- a/include/linux/kobject.h
69134 +++ b/include/linux/kobject.h
69135 @@ -111,7 +111,7 @@ struct kobj_type {
69136 struct attribute **default_attrs;
69137 const struct kobj_ns_type_operations *(*child_ns_type)(struct kobject *kobj);
69138 const void *(*namespace)(struct kobject *kobj);
69139 -};
69140 +} __do_const;
69141
69142 struct kobj_uevent_env {
69143 char *envp[UEVENT_NUM_ENVP];
69144 @@ -134,6 +134,7 @@ struct kobj_attribute {
69145 ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
69146 const char *buf, size_t count);
69147 };
69148 +typedef struct kobj_attribute __no_const kobj_attribute_no_const;
69149
69150 extern const struct sysfs_ops kobj_sysfs_ops;
69151
69152 diff --git a/include/linux/kobject_ns.h b/include/linux/kobject_ns.h
69153 index f66b065..c2c29b4 100644
69154 --- a/include/linux/kobject_ns.h
69155 +++ b/include/linux/kobject_ns.h
69156 @@ -43,7 +43,7 @@ struct kobj_ns_type_operations {
69157 const void *(*netlink_ns)(struct sock *sk);
69158 const void *(*initial_ns)(void);
69159 void (*drop_ns)(void *);
69160 -};
69161 +} __do_const;
69162
69163 int kobj_ns_type_register(const struct kobj_ns_type_operations *ops);
69164 int kobj_ns_type_registered(enum kobj_ns_type type);
69165 diff --git a/include/linux/kref.h b/include/linux/kref.h
69166 index 7419c02..aa2f02d 100644
69167 --- a/include/linux/kref.h
69168 +++ b/include/linux/kref.h
69169 @@ -65,7 +65,7 @@ static inline void kref_get(struct kref *kref)
69170 static inline int kref_sub(struct kref *kref, unsigned int count,
69171 void (*release)(struct kref *kref))
69172 {
69173 - WARN_ON(release == NULL);
69174 + BUG_ON(release == NULL);
69175
69176 if (atomic_sub_and_test((int) count, &kref->refcount)) {
69177 release(kref);
69178 diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
69179 index c139582..0b5b102 100644
69180 --- a/include/linux/kvm_host.h
69181 +++ b/include/linux/kvm_host.h
69182 @@ -424,7 +424,7 @@ void kvm_vcpu_uninit(struct kvm_vcpu *vcpu);
69183 int __must_check vcpu_load(struct kvm_vcpu *vcpu);
69184 void vcpu_put(struct kvm_vcpu *vcpu);
69185
69186 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
69187 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
69188 struct module *module);
69189 void kvm_exit(void);
69190
69191 @@ -582,7 +582,7 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
69192 struct kvm_guest_debug *dbg);
69193 int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);
69194
69195 -int kvm_arch_init(void *opaque);
69196 +int kvm_arch_init(const void *opaque);
69197 void kvm_arch_exit(void);
69198
69199 int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu);
69200 diff --git a/include/linux/libata.h b/include/linux/libata.h
69201 index eae7a05..2cdd875 100644
69202 --- a/include/linux/libata.h
69203 +++ b/include/linux/libata.h
69204 @@ -919,7 +919,7 @@ struct ata_port_operations {
69205 * fields must be pointers.
69206 */
69207 const struct ata_port_operations *inherits;
69208 -};
69209 +} __do_const;
69210
69211 struct ata_port_info {
69212 unsigned long flags;
69213 diff --git a/include/linux/list.h b/include/linux/list.h
69214 index 6a1f8df..eaec1ff 100644
69215 --- a/include/linux/list.h
69216 +++ b/include/linux/list.h
69217 @@ -112,6 +112,19 @@ extern void __list_del_entry(struct list_head *entry);
69218 extern void list_del(struct list_head *entry);
69219 #endif
69220
69221 +extern void __pax_list_add(struct list_head *new,
69222 + struct list_head *prev,
69223 + struct list_head *next);
69224 +static inline void pax_list_add(struct list_head *new, struct list_head *head)
69225 +{
69226 + __pax_list_add(new, head, head->next);
69227 +}
69228 +static inline void pax_list_add_tail(struct list_head *new, struct list_head *head)
69229 +{
69230 + __pax_list_add(new, head->prev, head);
69231 +}
69232 +extern void pax_list_del(struct list_head *entry);
69233 +
69234 /**
69235 * list_replace - replace old entry by new one
69236 * @old : the element to be replaced
69237 @@ -145,6 +158,8 @@ static inline void list_del_init(struct list_head *entry)
69238 INIT_LIST_HEAD(entry);
69239 }
69240
69241 +extern void pax_list_del_init(struct list_head *entry);
69242 +
69243 /**
69244 * list_move - delete from one list and add as another's head
69245 * @list: the entry to move
69246 diff --git a/include/linux/math64.h b/include/linux/math64.h
69247 index b8ba855..0148090 100644
69248 --- a/include/linux/math64.h
69249 +++ b/include/linux/math64.h
69250 @@ -14,7 +14,7 @@
69251 * This is commonly provided by 32bit archs to provide an optimized 64bit
69252 * divide.
69253 */
69254 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
69255 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
69256 {
69257 *remainder = dividend % divisor;
69258 return dividend / divisor;
69259 @@ -50,7 +50,7 @@ static inline s64 div64_s64(s64 dividend, s64 divisor)
69260 #define div64_long(x,y) div_s64((x),(y))
69261
69262 #ifndef div_u64_rem
69263 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
69264 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
69265 {
69266 *remainder = do_div(dividend, divisor);
69267 return dividend;
69268 @@ -79,7 +79,7 @@ extern s64 div64_s64(s64 dividend, s64 divisor);
69269 * divide.
69270 */
69271 #ifndef div_u64
69272 -static inline u64 div_u64(u64 dividend, u32 divisor)
69273 +static inline u64 __intentional_overflow(-1) div_u64(u64 dividend, u32 divisor)
69274 {
69275 u32 remainder;
69276 return div_u64_rem(dividend, divisor, &remainder);
69277 diff --git a/include/linux/mm.h b/include/linux/mm.h
69278 index e2091b8..821db54 100644
69279 --- a/include/linux/mm.h
69280 +++ b/include/linux/mm.h
69281 @@ -101,6 +101,11 @@ extern unsigned int kobjsize(const void *objp);
69282 #define VM_HUGETLB 0x00400000 /* Huge TLB Page VM */
69283 #define VM_NONLINEAR 0x00800000 /* Is non-linear (remap_file_pages) */
69284 #define VM_ARCH_1 0x01000000 /* Architecture-specific flag */
69285 +
69286 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
69287 +#define VM_PAGEEXEC 0x02000000 /* vma->vm_page_prot needs special handling */
69288 +#endif
69289 +
69290 #define VM_DONTDUMP 0x04000000 /* Do not include in the core dump */
69291
69292 #define VM_MIXEDMAP 0x10000000 /* Can contain "struct page" and pure PFN pages */
69293 @@ -202,8 +207,8 @@ struct vm_operations_struct {
69294 /* called by access_process_vm when get_user_pages() fails, typically
69295 * for use by special VMAs that can switch between memory and hardware
69296 */
69297 - int (*access)(struct vm_area_struct *vma, unsigned long addr,
69298 - void *buf, int len, int write);
69299 + ssize_t (*access)(struct vm_area_struct *vma, unsigned long addr,
69300 + void *buf, size_t len, int write);
69301 #ifdef CONFIG_NUMA
69302 /*
69303 * set_policy() op must add a reference to any non-NULL @new mempolicy
69304 @@ -233,6 +238,7 @@ struct vm_operations_struct {
69305 int (*remap_pages)(struct vm_area_struct *vma, unsigned long addr,
69306 unsigned long size, pgoff_t pgoff);
69307 };
69308 +typedef struct vm_operations_struct __no_const vm_operations_struct_no_const;
69309
69310 struct mmu_gather;
69311 struct inode;
69312 @@ -970,8 +976,8 @@ int follow_pfn(struct vm_area_struct *vma, unsigned long address,
69313 unsigned long *pfn);
69314 int follow_phys(struct vm_area_struct *vma, unsigned long address,
69315 unsigned int flags, unsigned long *prot, resource_size_t *phys);
69316 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
69317 - void *buf, int len, int write);
69318 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
69319 + void *buf, size_t len, int write);
69320
69321 static inline void unmap_shared_mapping_range(struct address_space *mapping,
69322 loff_t const holebegin, loff_t const holelen)
69323 @@ -1010,9 +1016,9 @@ static inline int fixup_user_fault(struct task_struct *tsk,
69324 }
69325 #endif
69326
69327 -extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);
69328 -extern int access_remote_vm(struct mm_struct *mm, unsigned long addr,
69329 - void *buf, int len, int write);
69330 +extern ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write);
69331 +extern ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
69332 + void *buf, size_t len, int write);
69333
69334 long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
69335 unsigned long start, unsigned long nr_pages,
69336 @@ -1043,34 +1049,6 @@ int set_page_dirty(struct page *page);
69337 int set_page_dirty_lock(struct page *page);
69338 int clear_page_dirty_for_io(struct page *page);
69339
69340 -/* Is the vma a continuation of the stack vma above it? */
69341 -static inline int vma_growsdown(struct vm_area_struct *vma, unsigned long addr)
69342 -{
69343 - return vma && (vma->vm_end == addr) && (vma->vm_flags & VM_GROWSDOWN);
69344 -}
69345 -
69346 -static inline int stack_guard_page_start(struct vm_area_struct *vma,
69347 - unsigned long addr)
69348 -{
69349 - return (vma->vm_flags & VM_GROWSDOWN) &&
69350 - (vma->vm_start == addr) &&
69351 - !vma_growsdown(vma->vm_prev, addr);
69352 -}
69353 -
69354 -/* Is the vma a continuation of the stack vma below it? */
69355 -static inline int vma_growsup(struct vm_area_struct *vma, unsigned long addr)
69356 -{
69357 - return vma && (vma->vm_start == addr) && (vma->vm_flags & VM_GROWSUP);
69358 -}
69359 -
69360 -static inline int stack_guard_page_end(struct vm_area_struct *vma,
69361 - unsigned long addr)
69362 -{
69363 - return (vma->vm_flags & VM_GROWSUP) &&
69364 - (vma->vm_end == addr) &&
69365 - !vma_growsup(vma->vm_next, addr);
69366 -}
69367 -
69368 extern pid_t
69369 vm_is_stack(struct task_struct *task, struct vm_area_struct *vma, int in_group);
69370
69371 @@ -1173,6 +1151,15 @@ static inline void sync_mm_rss(struct mm_struct *mm)
69372 }
69373 #endif
69374
69375 +#ifdef CONFIG_MMU
69376 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags);
69377 +#else
69378 +static inline pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
69379 +{
69380 + return __pgprot(0);
69381 +}
69382 +#endif
69383 +
69384 int vma_wants_writenotify(struct vm_area_struct *vma);
69385
69386 extern pte_t *__get_locked_pte(struct mm_struct *mm, unsigned long addr,
69387 @@ -1191,8 +1178,15 @@ static inline int __pud_alloc(struct mm_struct *mm, pgd_t *pgd,
69388 {
69389 return 0;
69390 }
69391 +
69392 +static inline int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd,
69393 + unsigned long address)
69394 +{
69395 + return 0;
69396 +}
69397 #else
69398 int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
69399 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
69400 #endif
69401
69402 #ifdef __PAGETABLE_PMD_FOLDED
69403 @@ -1201,8 +1195,15 @@ static inline int __pmd_alloc(struct mm_struct *mm, pud_t *pud,
69404 {
69405 return 0;
69406 }
69407 +
69408 +static inline int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud,
69409 + unsigned long address)
69410 +{
69411 + return 0;
69412 +}
69413 #else
69414 int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address);
69415 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address);
69416 #endif
69417
69418 int __pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma,
69419 @@ -1220,11 +1221,23 @@ static inline pud_t *pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long a
69420 NULL: pud_offset(pgd, address);
69421 }
69422
69423 +static inline pud_t *pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
69424 +{
69425 + return (unlikely(pgd_none(*pgd)) && __pud_alloc_kernel(mm, pgd, address))?
69426 + NULL: pud_offset(pgd, address);
69427 +}
69428 +
69429 static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
69430 {
69431 return (unlikely(pud_none(*pud)) && __pmd_alloc(mm, pud, address))?
69432 NULL: pmd_offset(pud, address);
69433 }
69434 +
69435 +static inline pmd_t *pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
69436 +{
69437 + return (unlikely(pud_none(*pud)) && __pmd_alloc_kernel(mm, pud, address))?
69438 + NULL: pmd_offset(pud, address);
69439 +}
69440 #endif /* CONFIG_MMU && !__ARCH_HAS_4LEVEL_HACK */
69441
69442 #if USE_SPLIT_PTLOCKS
69443 @@ -1455,6 +1468,7 @@ extern unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
69444 unsigned long len, unsigned long prot, unsigned long flags,
69445 unsigned long pgoff, unsigned long *populate);
69446 extern int do_munmap(struct mm_struct *, unsigned long, size_t);
69447 +extern int __do_munmap(struct mm_struct *, unsigned long, size_t);
69448
69449 #ifdef CONFIG_MMU
69450 extern int __mm_populate(unsigned long addr, unsigned long len,
69451 @@ -1483,6 +1497,7 @@ struct vm_unmapped_area_info {
69452 unsigned long high_limit;
69453 unsigned long align_mask;
69454 unsigned long align_offset;
69455 + unsigned long threadstack_offset;
69456 };
69457
69458 extern unsigned long unmapped_area(struct vm_unmapped_area_info *info);
69459 @@ -1561,6 +1576,10 @@ extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long add
69460 extern struct vm_area_struct * find_vma_prev(struct mm_struct * mm, unsigned long addr,
69461 struct vm_area_struct **pprev);
69462
69463 +extern struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma);
69464 +extern __must_check long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma);
69465 +extern void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl);
69466 +
69467 /* Look up the first VMA which intersects the interval start_addr..end_addr-1,
69468 NULL if none. Assume start_addr < end_addr. */
69469 static inline struct vm_area_struct * find_vma_intersection(struct mm_struct * mm, unsigned long start_addr, unsigned long end_addr)
69470 @@ -1589,15 +1608,6 @@ static inline struct vm_area_struct *find_exact_vma(struct mm_struct *mm,
69471 return vma;
69472 }
69473
69474 -#ifdef CONFIG_MMU
69475 -pgprot_t vm_get_page_prot(unsigned long vm_flags);
69476 -#else
69477 -static inline pgprot_t vm_get_page_prot(unsigned long vm_flags)
69478 -{
69479 - return __pgprot(0);
69480 -}
69481 -#endif
69482 -
69483 #ifdef CONFIG_ARCH_USES_NUMA_PROT_NONE
69484 unsigned long change_prot_numa(struct vm_area_struct *vma,
69485 unsigned long start, unsigned long end);
69486 @@ -1649,6 +1659,11 @@ void vm_stat_account(struct mm_struct *, unsigned long, struct file *, long);
69487 static inline void vm_stat_account(struct mm_struct *mm,
69488 unsigned long flags, struct file *file, long pages)
69489 {
69490 +
69491 +#ifdef CONFIG_PAX_RANDMMAP
69492 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
69493 +#endif
69494 +
69495 mm->total_vm += pages;
69496 }
69497 #endif /* CONFIG_PROC_FS */
69498 @@ -1725,7 +1740,7 @@ extern int unpoison_memory(unsigned long pfn);
69499 extern int sysctl_memory_failure_early_kill;
69500 extern int sysctl_memory_failure_recovery;
69501 extern void shake_page(struct page *p, int access);
69502 -extern atomic_long_t num_poisoned_pages;
69503 +extern atomic_long_unchecked_t num_poisoned_pages;
69504 extern int soft_offline_page(struct page *page, int flags);
69505
69506 extern void dump_page(struct page *page);
69507 @@ -1756,5 +1771,11 @@ static inline unsigned int debug_guardpage_minorder(void) { return 0; }
69508 static inline bool page_is_guard(struct page *page) { return false; }
69509 #endif /* CONFIG_DEBUG_PAGEALLOC */
69510
69511 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
69512 +extern void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot);
69513 +#else
69514 +static inline void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot) {}
69515 +#endif
69516 +
69517 #endif /* __KERNEL__ */
69518 #endif /* _LINUX_MM_H */
69519 diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
69520 index ace9a5f..81bdb59 100644
69521 --- a/include/linux/mm_types.h
69522 +++ b/include/linux/mm_types.h
69523 @@ -289,6 +289,8 @@ struct vm_area_struct {
69524 #ifdef CONFIG_NUMA
69525 struct mempolicy *vm_policy; /* NUMA policy for the VMA */
69526 #endif
69527 +
69528 + struct vm_area_struct *vm_mirror;/* PaX: mirror vma or NULL */
69529 };
69530
69531 struct core_thread {
69532 @@ -437,6 +439,24 @@ struct mm_struct {
69533 int first_nid;
69534 #endif
69535 struct uprobes_state uprobes_state;
69536 +
69537 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
69538 + unsigned long pax_flags;
69539 +#endif
69540 +
69541 +#ifdef CONFIG_PAX_DLRESOLVE
69542 + unsigned long call_dl_resolve;
69543 +#endif
69544 +
69545 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
69546 + unsigned long call_syscall;
69547 +#endif
69548 +
69549 +#ifdef CONFIG_PAX_ASLR
69550 + unsigned long delta_mmap; /* randomized offset */
69551 + unsigned long delta_stack; /* randomized offset */
69552 +#endif
69553 +
69554 };
69555
69556 /* first nid will either be a valid NID or one of these values */
69557 diff --git a/include/linux/mmiotrace.h b/include/linux/mmiotrace.h
69558 index c5d5278..f0b68c8 100644
69559 --- a/include/linux/mmiotrace.h
69560 +++ b/include/linux/mmiotrace.h
69561 @@ -46,7 +46,7 @@ extern int kmmio_handler(struct pt_regs *regs, unsigned long addr);
69562 /* Called from ioremap.c */
69563 extern void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
69564 void __iomem *addr);
69565 -extern void mmiotrace_iounmap(volatile void __iomem *addr);
69566 +extern void mmiotrace_iounmap(const volatile void __iomem *addr);
69567
69568 /* For anyone to insert markers. Remember trailing newline. */
69569 extern __printf(1, 2) int mmiotrace_printk(const char *fmt, ...);
69570 @@ -66,7 +66,7 @@ static inline void mmiotrace_ioremap(resource_size_t offset,
69571 {
69572 }
69573
69574 -static inline void mmiotrace_iounmap(volatile void __iomem *addr)
69575 +static inline void mmiotrace_iounmap(const volatile void __iomem *addr)
69576 {
69577 }
69578
69579 diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
69580 index c74092e..b663967 100644
69581 --- a/include/linux/mmzone.h
69582 +++ b/include/linux/mmzone.h
69583 @@ -396,7 +396,7 @@ struct zone {
69584 unsigned long flags; /* zone flags, see below */
69585
69586 /* Zone statistics */
69587 - atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
69588 + atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
69589
69590 /*
69591 * The target ratio of ACTIVE_ANON to INACTIVE_ANON pages on
69592 diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
69593 index 779cf7c..e6768240 100644
69594 --- a/include/linux/mod_devicetable.h
69595 +++ b/include/linux/mod_devicetable.h
69596 @@ -12,7 +12,7 @@
69597 typedef unsigned long kernel_ulong_t;
69598 #endif
69599
69600 -#define PCI_ANY_ID (~0)
69601 +#define PCI_ANY_ID ((__u16)~0)
69602
69603 struct pci_device_id {
69604 __u32 vendor, device; /* Vendor and device ID or PCI_ANY_ID*/
69605 @@ -138,7 +138,7 @@ struct usb_device_id {
69606 #define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200
69607 #define USB_DEVICE_ID_MATCH_INT_NUMBER 0x0400
69608
69609 -#define HID_ANY_ID (~0)
69610 +#define HID_ANY_ID (~0U)
69611 #define HID_BUS_ANY 0xffff
69612 #define HID_GROUP_ANY 0x0000
69613
69614 @@ -464,7 +464,7 @@ struct dmi_system_id {
69615 const char *ident;
69616 struct dmi_strmatch matches[4];
69617 void *driver_data;
69618 -};
69619 +} __do_const;
69620 /*
69621 * struct dmi_device_id appears during expansion of
69622 * "MODULE_DEVICE_TABLE(dmi, x)". Compiler doesn't look inside it
69623 diff --git a/include/linux/module.h b/include/linux/module.h
69624 index ead1b57..81a3b6c 100644
69625 --- a/include/linux/module.h
69626 +++ b/include/linux/module.h
69627 @@ -17,9 +17,11 @@
69628 #include <linux/moduleparam.h>
69629 #include <linux/tracepoint.h>
69630 #include <linux/export.h>
69631 +#include <linux/fs.h>
69632
69633 #include <linux/percpu.h>
69634 #include <asm/module.h>
69635 +#include <asm/pgtable.h>
69636
69637 /* In stripped ARM and x86-64 modules, ~ is surprisingly rare. */
69638 #define MODULE_SIG_STRING "~Module signature appended~\n"
69639 @@ -54,12 +56,13 @@ struct module_attribute {
69640 int (*test)(struct module *);
69641 void (*free)(struct module *);
69642 };
69643 +typedef struct module_attribute __no_const module_attribute_no_const;
69644
69645 struct module_version_attribute {
69646 struct module_attribute mattr;
69647 const char *module_name;
69648 const char *version;
69649 -} __attribute__ ((__aligned__(sizeof(void *))));
69650 +} __do_const __attribute__ ((__aligned__(sizeof(void *))));
69651
69652 extern ssize_t __modver_version_show(struct module_attribute *,
69653 struct module_kobject *, char *);
69654 @@ -232,7 +235,7 @@ struct module
69655
69656 /* Sysfs stuff. */
69657 struct module_kobject mkobj;
69658 - struct module_attribute *modinfo_attrs;
69659 + module_attribute_no_const *modinfo_attrs;
69660 const char *version;
69661 const char *srcversion;
69662 struct kobject *holders_dir;
69663 @@ -281,19 +284,16 @@ struct module
69664 int (*init)(void);
69665
69666 /* If this is non-NULL, vfree after init() returns */
69667 - void *module_init;
69668 + void *module_init_rx, *module_init_rw;
69669
69670 /* Here is the actual code + data, vfree'd on unload. */
69671 - void *module_core;
69672 + void *module_core_rx, *module_core_rw;
69673
69674 /* Here are the sizes of the init and core sections */
69675 - unsigned int init_size, core_size;
69676 + unsigned int init_size_rw, core_size_rw;
69677
69678 /* The size of the executable code in each section. */
69679 - unsigned int init_text_size, core_text_size;
69680 -
69681 - /* Size of RO sections of the module (text+rodata) */
69682 - unsigned int init_ro_size, core_ro_size;
69683 + unsigned int init_size_rx, core_size_rx;
69684
69685 /* Arch-specific module values */
69686 struct mod_arch_specific arch;
69687 @@ -349,6 +349,10 @@ struct module
69688 #ifdef CONFIG_EVENT_TRACING
69689 struct ftrace_event_call **trace_events;
69690 unsigned int num_trace_events;
69691 + struct file_operations trace_id;
69692 + struct file_operations trace_enable;
69693 + struct file_operations trace_format;
69694 + struct file_operations trace_filter;
69695 #endif
69696 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
69697 unsigned int num_ftrace_callsites;
69698 @@ -396,16 +400,46 @@ bool is_module_address(unsigned long addr);
69699 bool is_module_percpu_address(unsigned long addr);
69700 bool is_module_text_address(unsigned long addr);
69701
69702 +static inline int within_module_range(unsigned long addr, void *start, unsigned long size)
69703 +{
69704 +
69705 +#ifdef CONFIG_PAX_KERNEXEC
69706 + if (ktla_ktva(addr) >= (unsigned long)start &&
69707 + ktla_ktva(addr) < (unsigned long)start + size)
69708 + return 1;
69709 +#endif
69710 +
69711 + return ((void *)addr >= start && (void *)addr < start + size);
69712 +}
69713 +
69714 +static inline int within_module_core_rx(unsigned long addr, const struct module *mod)
69715 +{
69716 + return within_module_range(addr, mod->module_core_rx, mod->core_size_rx);
69717 +}
69718 +
69719 +static inline int within_module_core_rw(unsigned long addr, const struct module *mod)
69720 +{
69721 + return within_module_range(addr, mod->module_core_rw, mod->core_size_rw);
69722 +}
69723 +
69724 +static inline int within_module_init_rx(unsigned long addr, const struct module *mod)
69725 +{
69726 + return within_module_range(addr, mod->module_init_rx, mod->init_size_rx);
69727 +}
69728 +
69729 +static inline int within_module_init_rw(unsigned long addr, const struct module *mod)
69730 +{
69731 + return within_module_range(addr, mod->module_init_rw, mod->init_size_rw);
69732 +}
69733 +
69734 static inline int within_module_core(unsigned long addr, const struct module *mod)
69735 {
69736 - return (unsigned long)mod->module_core <= addr &&
69737 - addr < (unsigned long)mod->module_core + mod->core_size;
69738 + return within_module_core_rx(addr, mod) || within_module_core_rw(addr, mod);
69739 }
69740
69741 static inline int within_module_init(unsigned long addr, const struct module *mod)
69742 {
69743 - return (unsigned long)mod->module_init <= addr &&
69744 - addr < (unsigned long)mod->module_init + mod->init_size;
69745 + return within_module_init_rx(addr, mod) || within_module_init_rw(addr, mod);
69746 }
69747
69748 /* Search for module by name: must hold module_mutex. */
69749 diff --git a/include/linux/moduleloader.h b/include/linux/moduleloader.h
69750 index 560ca53..ef621ef 100644
69751 --- a/include/linux/moduleloader.h
69752 +++ b/include/linux/moduleloader.h
69753 @@ -25,9 +25,21 @@ unsigned int arch_mod_section_prepend(struct module *mod, unsigned int section);
69754 sections. Returns NULL on failure. */
69755 void *module_alloc(unsigned long size);
69756
69757 +#ifdef CONFIG_PAX_KERNEXEC
69758 +void *module_alloc_exec(unsigned long size);
69759 +#else
69760 +#define module_alloc_exec(x) module_alloc(x)
69761 +#endif
69762 +
69763 /* Free memory returned from module_alloc. */
69764 void module_free(struct module *mod, void *module_region);
69765
69766 +#ifdef CONFIG_PAX_KERNEXEC
69767 +void module_free_exec(struct module *mod, void *module_region);
69768 +#else
69769 +#define module_free_exec(x, y) module_free((x), (y))
69770 +#endif
69771 +
69772 /*
69773 * Apply the given relocation to the (simplified) ELF. Return -error
69774 * or 0.
69775 @@ -45,7 +57,9 @@ static inline int apply_relocate(Elf_Shdr *sechdrs,
69776 unsigned int relsec,
69777 struct module *me)
69778 {
69779 +#ifdef CONFIG_MODULES
69780 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
69781 +#endif
69782 return -ENOEXEC;
69783 }
69784 #endif
69785 @@ -67,7 +81,9 @@ static inline int apply_relocate_add(Elf_Shdr *sechdrs,
69786 unsigned int relsec,
69787 struct module *me)
69788 {
69789 +#ifdef CONFIG_MODULES
69790 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
69791 +#endif
69792 return -ENOEXEC;
69793 }
69794 #endif
69795 diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
69796 index 137b419..fe663ec 100644
69797 --- a/include/linux/moduleparam.h
69798 +++ b/include/linux/moduleparam.h
69799 @@ -284,7 +284,7 @@ static inline void __kernel_param_unlock(void)
69800 * @len is usually just sizeof(string).
69801 */
69802 #define module_param_string(name, string, len, perm) \
69803 - static const struct kparam_string __param_string_##name \
69804 + static const struct kparam_string __param_string_##name __used \
69805 = { len, string }; \
69806 __module_param_call(MODULE_PARAM_PREFIX, name, \
69807 &param_ops_string, \
69808 @@ -423,7 +423,7 @@ extern int param_set_bint(const char *val, const struct kernel_param *kp);
69809 */
69810 #define module_param_array_named(name, array, type, nump, perm) \
69811 param_check_##type(name, &(array)[0]); \
69812 - static const struct kparam_array __param_arr_##name \
69813 + static const struct kparam_array __param_arr_##name __used \
69814 = { .max = ARRAY_SIZE(array), .num = nump, \
69815 .ops = &param_ops_##type, \
69816 .elemsize = sizeof(array[0]), .elem = array }; \
69817 diff --git a/include/linux/namei.h b/include/linux/namei.h
69818 index 5a5ff57..5ae5070 100644
69819 --- a/include/linux/namei.h
69820 +++ b/include/linux/namei.h
69821 @@ -19,7 +19,7 @@ struct nameidata {
69822 unsigned seq;
69823 int last_type;
69824 unsigned depth;
69825 - char *saved_names[MAX_NESTED_LINKS + 1];
69826 + const char *saved_names[MAX_NESTED_LINKS + 1];
69827 };
69828
69829 /*
69830 @@ -84,12 +84,12 @@ extern void unlock_rename(struct dentry *, struct dentry *);
69831
69832 extern void nd_jump_link(struct nameidata *nd, struct path *path);
69833
69834 -static inline void nd_set_link(struct nameidata *nd, char *path)
69835 +static inline void nd_set_link(struct nameidata *nd, const char *path)
69836 {
69837 nd->saved_names[nd->depth] = path;
69838 }
69839
69840 -static inline char *nd_get_link(struct nameidata *nd)
69841 +static inline const char *nd_get_link(const struct nameidata *nd)
69842 {
69843 return nd->saved_names[nd->depth];
69844 }
69845 diff --git a/include/linux/net.h b/include/linux/net.h
69846 index aa16731..514b875 100644
69847 --- a/include/linux/net.h
69848 +++ b/include/linux/net.h
69849 @@ -183,7 +183,7 @@ struct net_proto_family {
69850 int (*create)(struct net *net, struct socket *sock,
69851 int protocol, int kern);
69852 struct module *owner;
69853 -};
69854 +} __do_const;
69855
69856 struct iovec;
69857 struct kvec;
69858 diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
69859 index 6151e90..2e0afb0 100644
69860 --- a/include/linux/netdevice.h
69861 +++ b/include/linux/netdevice.h
69862 @@ -1028,6 +1028,7 @@ struct net_device_ops {
69863 int (*ndo_change_carrier)(struct net_device *dev,
69864 bool new_carrier);
69865 };
69866 +typedef struct net_device_ops __no_const net_device_ops_no_const;
69867
69868 /*
69869 * The DEVICE structure.
69870 @@ -1094,7 +1095,7 @@ struct net_device {
69871 int iflink;
69872
69873 struct net_device_stats stats;
69874 - atomic_long_t rx_dropped; /* dropped packets by core network
69875 + atomic_long_unchecked_t rx_dropped; /* dropped packets by core network
69876 * Do not use this in drivers.
69877 */
69878
69879 diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
69880 index ee14284..bc65d63 100644
69881 --- a/include/linux/netfilter.h
69882 +++ b/include/linux/netfilter.h
69883 @@ -82,7 +82,7 @@ struct nf_sockopt_ops {
69884 #endif
69885 /* Use the module struct to lock set/get code in place */
69886 struct module *owner;
69887 -};
69888 +} __do_const;
69889
69890 /* Function to register/unregister hook points. */
69891 int nf_register_hook(struct nf_hook_ops *reg);
69892 diff --git a/include/linux/netfilter/ipset/ip_set.h b/include/linux/netfilter/ipset/ip_set.h
69893 index 7958e84..ed74d7a 100644
69894 --- a/include/linux/netfilter/ipset/ip_set.h
69895 +++ b/include/linux/netfilter/ipset/ip_set.h
69896 @@ -98,7 +98,7 @@ struct ip_set_type_variant {
69897 /* Return true if "b" set is the same as "a"
69898 * according to the create set parameters */
69899 bool (*same_set)(const struct ip_set *a, const struct ip_set *b);
69900 -};
69901 +} __do_const;
69902
69903 /* The core set type structure */
69904 struct ip_set_type {
69905 diff --git a/include/linux/netfilter/nfnetlink.h b/include/linux/netfilter/nfnetlink.h
69906 index ecbb8e4..8a1c4e1 100644
69907 --- a/include/linux/netfilter/nfnetlink.h
69908 +++ b/include/linux/netfilter/nfnetlink.h
69909 @@ -16,7 +16,7 @@ struct nfnl_callback {
69910 const struct nlattr * const cda[]);
69911 const struct nla_policy *policy; /* netlink attribute policy */
69912 const u_int16_t attr_count; /* number of nlattr's */
69913 -};
69914 +} __do_const;
69915
69916 struct nfnetlink_subsystem {
69917 const char *name;
69918 diff --git a/include/linux/netfilter/xt_gradm.h b/include/linux/netfilter/xt_gradm.h
69919 new file mode 100644
69920 index 0000000..33f4af8
69921 --- /dev/null
69922 +++ b/include/linux/netfilter/xt_gradm.h
69923 @@ -0,0 +1,9 @@
69924 +#ifndef _LINUX_NETFILTER_XT_GRADM_H
69925 +#define _LINUX_NETFILTER_XT_GRADM_H 1
69926 +
69927 +struct xt_gradm_mtinfo {
69928 + __u16 flags;
69929 + __u16 invflags;
69930 +};
69931 +
69932 +#endif
69933 diff --git a/include/linux/nls.h b/include/linux/nls.h
69934 index 5dc635f..35f5e11 100644
69935 --- a/include/linux/nls.h
69936 +++ b/include/linux/nls.h
69937 @@ -31,7 +31,7 @@ struct nls_table {
69938 const unsigned char *charset2upper;
69939 struct module *owner;
69940 struct nls_table *next;
69941 -};
69942 +} __do_const;
69943
69944 /* this value hold the maximum octet of charset */
69945 #define NLS_MAX_CHARSET_SIZE 6 /* for UTF-8 */
69946 diff --git a/include/linux/notifier.h b/include/linux/notifier.h
69947 index d65746e..62e72c2 100644
69948 --- a/include/linux/notifier.h
69949 +++ b/include/linux/notifier.h
69950 @@ -51,7 +51,8 @@ struct notifier_block {
69951 int (*notifier_call)(struct notifier_block *, unsigned long, void *);
69952 struct notifier_block __rcu *next;
69953 int priority;
69954 -};
69955 +} __do_const;
69956 +typedef struct notifier_block __no_const notifier_block_no_const;
69957
69958 struct atomic_notifier_head {
69959 spinlock_t lock;
69960 diff --git a/include/linux/oprofile.h b/include/linux/oprofile.h
69961 index a4c5624..79d6d88 100644
69962 --- a/include/linux/oprofile.h
69963 +++ b/include/linux/oprofile.h
69964 @@ -139,9 +139,9 @@ int oprofilefs_create_ulong(struct super_block * sb, struct dentry * root,
69965 int oprofilefs_create_ro_ulong(struct super_block * sb, struct dentry * root,
69966 char const * name, ulong * val);
69967
69968 -/** Create a file for read-only access to an atomic_t. */
69969 +/** Create a file for read-only access to an atomic_unchecked_t. */
69970 int oprofilefs_create_ro_atomic(struct super_block * sb, struct dentry * root,
69971 - char const * name, atomic_t * val);
69972 + char const * name, atomic_unchecked_t * val);
69973
69974 /** create a directory */
69975 struct dentry * oprofilefs_mkdir(struct super_block * sb, struct dentry * root,
69976 diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h
69977 index 45fc162..01a4068 100644
69978 --- a/include/linux/pci_hotplug.h
69979 +++ b/include/linux/pci_hotplug.h
69980 @@ -80,7 +80,8 @@ struct hotplug_slot_ops {
69981 int (*get_attention_status) (struct hotplug_slot *slot, u8 *value);
69982 int (*get_latch_status) (struct hotplug_slot *slot, u8 *value);
69983 int (*get_adapter_status) (struct hotplug_slot *slot, u8 *value);
69984 -};
69985 +} __do_const;
69986 +typedef struct hotplug_slot_ops __no_const hotplug_slot_ops_no_const;
69987
69988 /**
69989 * struct hotplug_slot_info - used to notify the hotplug pci core of the state of the slot
69990 diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
69991 index 1d795df..727aa7b 100644
69992 --- a/include/linux/perf_event.h
69993 +++ b/include/linux/perf_event.h
69994 @@ -333,8 +333,8 @@ struct perf_event {
69995
69996 enum perf_event_active_state state;
69997 unsigned int attach_state;
69998 - local64_t count;
69999 - atomic64_t child_count;
70000 + local64_t count; /* PaX: fix it one day */
70001 + atomic64_unchecked_t child_count;
70002
70003 /*
70004 * These are the total time in nanoseconds that the event
70005 @@ -385,8 +385,8 @@ struct perf_event {
70006 * These accumulate total time (in nanoseconds) that children
70007 * events have been enabled and running, respectively.
70008 */
70009 - atomic64_t child_total_time_enabled;
70010 - atomic64_t child_total_time_running;
70011 + atomic64_unchecked_t child_total_time_enabled;
70012 + atomic64_unchecked_t child_total_time_running;
70013
70014 /*
70015 * Protect attach/detach and child_list:
70016 @@ -704,7 +704,7 @@ static inline void perf_callchain_store(struct perf_callchain_entry *entry, u64
70017 entry->ip[entry->nr++] = ip;
70018 }
70019
70020 -extern int sysctl_perf_event_paranoid;
70021 +extern int sysctl_perf_event_legitimately_concerned;
70022 extern int sysctl_perf_event_mlock;
70023 extern int sysctl_perf_event_sample_rate;
70024
70025 @@ -714,17 +714,17 @@ extern int perf_proc_update_handler(struct ctl_table *table, int write,
70026
70027 static inline bool perf_paranoid_tracepoint_raw(void)
70028 {
70029 - return sysctl_perf_event_paranoid > -1;
70030 + return sysctl_perf_event_legitimately_concerned > -1;
70031 }
70032
70033 static inline bool perf_paranoid_cpu(void)
70034 {
70035 - return sysctl_perf_event_paranoid > 0;
70036 + return sysctl_perf_event_legitimately_concerned > 0;
70037 }
70038
70039 static inline bool perf_paranoid_kernel(void)
70040 {
70041 - return sysctl_perf_event_paranoid > 1;
70042 + return sysctl_perf_event_legitimately_concerned > 1;
70043 }
70044
70045 extern void perf_event_init(void);
70046 @@ -812,7 +812,7 @@ static inline void perf_restore_debug_store(void) { }
70047 */
70048 #define perf_cpu_notifier(fn) \
70049 do { \
70050 - static struct notifier_block fn##_nb __cpuinitdata = \
70051 + static struct notifier_block fn##_nb = \
70052 { .notifier_call = fn, .priority = CPU_PRI_PERF }; \
70053 unsigned long cpu = smp_processor_id(); \
70054 unsigned long flags; \
70055 @@ -831,7 +831,7 @@ do { \
70056 struct perf_pmu_events_attr {
70057 struct device_attribute attr;
70058 u64 id;
70059 -};
70060 +} __do_const;
70061
70062 #define PMU_EVENT_ATTR(_name, _var, _id, _show) \
70063 static struct perf_pmu_events_attr _var = { \
70064 diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
70065 index ad1a427..6419649 100644
70066 --- a/include/linux/pipe_fs_i.h
70067 +++ b/include/linux/pipe_fs_i.h
70068 @@ -45,9 +45,9 @@ struct pipe_buffer {
70069 struct pipe_inode_info {
70070 wait_queue_head_t wait;
70071 unsigned int nrbufs, curbuf, buffers;
70072 - unsigned int readers;
70073 - unsigned int writers;
70074 - unsigned int waiting_writers;
70075 + atomic_t readers;
70076 + atomic_t writers;
70077 + atomic_t waiting_writers;
70078 unsigned int r_counter;
70079 unsigned int w_counter;
70080 struct page *tmp_page;
70081 diff --git a/include/linux/platform_data/usb-ehci-s5p.h b/include/linux/platform_data/usb-ehci-s5p.h
70082 index 5f28cae..3d23723 100644
70083 --- a/include/linux/platform_data/usb-ehci-s5p.h
70084 +++ b/include/linux/platform_data/usb-ehci-s5p.h
70085 @@ -14,7 +14,7 @@
70086 struct s5p_ehci_platdata {
70087 int (*phy_init)(struct platform_device *pdev, int type);
70088 int (*phy_exit)(struct platform_device *pdev, int type);
70089 -};
70090 +} __no_const;
70091
70092 extern void s5p_ehci_set_platdata(struct s5p_ehci_platdata *pd);
70093
70094 diff --git a/include/linux/platform_data/usb-exynos.h b/include/linux/platform_data/usb-exynos.h
70095 index c256c59..8ea94c7 100644
70096 --- a/include/linux/platform_data/usb-exynos.h
70097 +++ b/include/linux/platform_data/usb-exynos.h
70098 @@ -14,7 +14,7 @@
70099 struct exynos4_ohci_platdata {
70100 int (*phy_init)(struct platform_device *pdev, int type);
70101 int (*phy_exit)(struct platform_device *pdev, int type);
70102 -};
70103 +} __no_const;
70104
70105 extern void exynos4_ohci_set_platdata(struct exynos4_ohci_platdata *pd);
70106
70107 diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
70108 index 7c1d252..c5c773e 100644
70109 --- a/include/linux/pm_domain.h
70110 +++ b/include/linux/pm_domain.h
70111 @@ -48,7 +48,7 @@ struct gpd_dev_ops {
70112
70113 struct gpd_cpu_data {
70114 unsigned int saved_exit_latency;
70115 - struct cpuidle_state *idle_state;
70116 + cpuidle_state_no_const *idle_state;
70117 };
70118
70119 struct generic_pm_domain {
70120 diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
70121 index 7d7e09e..8671ef8 100644
70122 --- a/include/linux/pm_runtime.h
70123 +++ b/include/linux/pm_runtime.h
70124 @@ -104,7 +104,7 @@ static inline bool pm_runtime_callbacks_present(struct device *dev)
70125
70126 static inline void pm_runtime_mark_last_busy(struct device *dev)
70127 {
70128 - ACCESS_ONCE(dev->power.last_busy) = jiffies;
70129 + ACCESS_ONCE_RW(dev->power.last_busy) = jiffies;
70130 }
70131
70132 #else /* !CONFIG_PM_RUNTIME */
70133 diff --git a/include/linux/pnp.h b/include/linux/pnp.h
70134 index 195aafc..49a7bc2 100644
70135 --- a/include/linux/pnp.h
70136 +++ b/include/linux/pnp.h
70137 @@ -297,7 +297,7 @@ static inline void pnp_set_drvdata(struct pnp_dev *pdev, void *data)
70138 struct pnp_fixup {
70139 char id[7];
70140 void (*quirk_function) (struct pnp_dev * dev); /* fixup function */
70141 -};
70142 +} __do_const;
70143
70144 /* config parameters */
70145 #define PNP_CONFIG_NORMAL 0x0001
70146 diff --git a/include/linux/poison.h b/include/linux/poison.h
70147 index 2110a81..13a11bb 100644
70148 --- a/include/linux/poison.h
70149 +++ b/include/linux/poison.h
70150 @@ -19,8 +19,8 @@
70151 * under normal circumstances, used to verify that nobody uses
70152 * non-initialized list entries.
70153 */
70154 -#define LIST_POISON1 ((void *) 0x00100100 + POISON_POINTER_DELTA)
70155 -#define LIST_POISON2 ((void *) 0x00200200 + POISON_POINTER_DELTA)
70156 +#define LIST_POISON1 ((void *) (long)0xFFFFFF01)
70157 +#define LIST_POISON2 ((void *) (long)0xFFFFFF02)
70158
70159 /********** include/linux/timer.h **********/
70160 /*
70161 diff --git a/include/linux/power/smartreflex.h b/include/linux/power/smartreflex.h
70162 index c0f44c2..1572583 100644
70163 --- a/include/linux/power/smartreflex.h
70164 +++ b/include/linux/power/smartreflex.h
70165 @@ -238,7 +238,7 @@ struct omap_sr_class_data {
70166 int (*notify)(struct omap_sr *sr, u32 status);
70167 u8 notify_flags;
70168 u8 class_type;
70169 -};
70170 +} __do_const;
70171
70172 /**
70173 * struct omap_sr_nvalue_table - Smartreflex n-target value info
70174 diff --git a/include/linux/ppp-comp.h b/include/linux/ppp-comp.h
70175 index 4ea1d37..80f4b33 100644
70176 --- a/include/linux/ppp-comp.h
70177 +++ b/include/linux/ppp-comp.h
70178 @@ -84,7 +84,7 @@ struct compressor {
70179 struct module *owner;
70180 /* Extra skb space needed by the compressor algorithm */
70181 unsigned int comp_extra;
70182 -};
70183 +} __do_const;
70184
70185 /*
70186 * The return value from decompress routine is the length of the
70187 diff --git a/include/linux/printk.h b/include/linux/printk.h
70188 index 822171f..12b30e8 100644
70189 --- a/include/linux/printk.h
70190 +++ b/include/linux/printk.h
70191 @@ -98,6 +98,8 @@ int no_printk(const char *fmt, ...)
70192 extern asmlinkage __printf(1, 2)
70193 void early_printk(const char *fmt, ...);
70194
70195 +extern int kptr_restrict;
70196 +
70197 #ifdef CONFIG_PRINTK
70198 asmlinkage __printf(5, 0)
70199 int vprintk_emit(int facility, int level,
70200 @@ -132,7 +134,6 @@ extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
70201
70202 extern int printk_delay_msec;
70203 extern int dmesg_restrict;
70204 -extern int kptr_restrict;
70205
70206 extern void wake_up_klogd(void);
70207
70208 diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
70209 index 94dfb2a..88b9d3b 100644
70210 --- a/include/linux/proc_fs.h
70211 +++ b/include/linux/proc_fs.h
70212 @@ -165,6 +165,18 @@ static inline struct proc_dir_entry *proc_create(const char *name, umode_t mode,
70213 return proc_create_data(name, mode, parent, proc_fops, NULL);
70214 }
70215
70216 +static inline struct proc_dir_entry *proc_create_grsec(const char *name, umode_t mode,
70217 + struct proc_dir_entry *parent, const struct file_operations *proc_fops)
70218 +{
70219 +#ifdef CONFIG_GRKERNSEC_PROC_USER
70220 + return proc_create_data(name, S_IRUSR, parent, proc_fops, NULL);
70221 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
70222 + return proc_create_data(name, S_IRUSR | S_IRGRP, parent, proc_fops, NULL);
70223 +#else
70224 + return proc_create_data(name, mode, parent, proc_fops, NULL);
70225 +#endif
70226 +}
70227 +
70228 static inline struct proc_dir_entry *create_proc_read_entry(const char *name,
70229 umode_t mode, struct proc_dir_entry *base,
70230 read_proc_t *read_proc, void * data)
70231 @@ -266,7 +278,7 @@ struct proc_ns_operations {
70232 void (*put)(void *ns);
70233 int (*install)(struct nsproxy *nsproxy, void *ns);
70234 unsigned int (*inum)(void *ns);
70235 -};
70236 +} __do_const;
70237 extern const struct proc_ns_operations netns_operations;
70238 extern const struct proc_ns_operations utsns_operations;
70239 extern const struct proc_ns_operations ipcns_operations;
70240 diff --git a/include/linux/random.h b/include/linux/random.h
70241 index 347ce55..880f97c 100644
70242 --- a/include/linux/random.h
70243 +++ b/include/linux/random.h
70244 @@ -39,6 +39,11 @@ void prandom_seed(u32 seed);
70245 u32 prandom_u32_state(struct rnd_state *);
70246 void prandom_bytes_state(struct rnd_state *state, void *buf, int nbytes);
70247
70248 +static inline unsigned long pax_get_random_long(void)
70249 +{
70250 + return prandom_u32() + (sizeof(long) > 4 ? (unsigned long)prandom_u32() << 32 : 0);
70251 +}
70252 +
70253 /*
70254 * Handle minimum values for seeds
70255 */
70256 diff --git a/include/linux/rculist.h b/include/linux/rculist.h
70257 index 8089e35..3a0d59a 100644
70258 --- a/include/linux/rculist.h
70259 +++ b/include/linux/rculist.h
70260 @@ -44,6 +44,9 @@ extern void __list_add_rcu(struct list_head *new,
70261 struct list_head *prev, struct list_head *next);
70262 #endif
70263
70264 +extern void __pax_list_add_rcu(struct list_head *new,
70265 + struct list_head *prev, struct list_head *next);
70266 +
70267 /**
70268 * list_add_rcu - add a new entry to rcu-protected list
70269 * @new: new entry to be added
70270 @@ -65,6 +68,11 @@ static inline void list_add_rcu(struct list_head *new, struct list_head *head)
70271 __list_add_rcu(new, head, head->next);
70272 }
70273
70274 +static inline void pax_list_add_rcu(struct list_head *new, struct list_head *head)
70275 +{
70276 + __pax_list_add_rcu(new, head, head->next);
70277 +}
70278 +
70279 /**
70280 * list_add_tail_rcu - add a new entry to rcu-protected list
70281 * @new: new entry to be added
70282 @@ -87,6 +95,12 @@ static inline void list_add_tail_rcu(struct list_head *new,
70283 __list_add_rcu(new, head->prev, head);
70284 }
70285
70286 +static inline void pax_list_add_tail_rcu(struct list_head *new,
70287 + struct list_head *head)
70288 +{
70289 + __pax_list_add_rcu(new, head->prev, head);
70290 +}
70291 +
70292 /**
70293 * list_del_rcu - deletes entry from list without re-initialization
70294 * @entry: the element to delete from the list.
70295 @@ -117,6 +131,8 @@ static inline void list_del_rcu(struct list_head *entry)
70296 entry->prev = LIST_POISON2;
70297 }
70298
70299 +extern void pax_list_del_rcu(struct list_head *entry);
70300 +
70301 /**
70302 * hlist_del_init_rcu - deletes entry from hash list with re-initialization
70303 * @n: the element to delete from the hash list.
70304 diff --git a/include/linux/reboot.h b/include/linux/reboot.h
70305 index 23b3630..e1bc12b 100644
70306 --- a/include/linux/reboot.h
70307 +++ b/include/linux/reboot.h
70308 @@ -18,9 +18,9 @@ extern int unregister_reboot_notifier(struct notifier_block *);
70309 * Architecture-specific implementations of sys_reboot commands.
70310 */
70311
70312 -extern void machine_restart(char *cmd);
70313 -extern void machine_halt(void);
70314 -extern void machine_power_off(void);
70315 +extern void machine_restart(char *cmd) __noreturn;
70316 +extern void machine_halt(void) __noreturn;
70317 +extern void machine_power_off(void) __noreturn;
70318
70319 extern void machine_shutdown(void);
70320 struct pt_regs;
70321 @@ -31,9 +31,9 @@ extern void machine_crash_shutdown(struct pt_regs *);
70322 */
70323
70324 extern void kernel_restart_prepare(char *cmd);
70325 -extern void kernel_restart(char *cmd);
70326 -extern void kernel_halt(void);
70327 -extern void kernel_power_off(void);
70328 +extern void kernel_restart(char *cmd) __noreturn;
70329 +extern void kernel_halt(void) __noreturn;
70330 +extern void kernel_power_off(void) __noreturn;
70331
70332 extern int C_A_D; /* for sysctl */
70333 void ctrl_alt_del(void);
70334 @@ -47,7 +47,7 @@ extern int orderly_poweroff(bool force);
70335 * Emergency restart, callable from an interrupt handler.
70336 */
70337
70338 -extern void emergency_restart(void);
70339 +extern void emergency_restart(void) __noreturn;
70340 #include <asm/emergency-restart.h>
70341
70342 #endif /* _LINUX_REBOOT_H */
70343 diff --git a/include/linux/regset.h b/include/linux/regset.h
70344 index 8e0c9fe..ac4d221 100644
70345 --- a/include/linux/regset.h
70346 +++ b/include/linux/regset.h
70347 @@ -161,7 +161,8 @@ struct user_regset {
70348 unsigned int align;
70349 unsigned int bias;
70350 unsigned int core_note_type;
70351 -};
70352 +} __do_const;
70353 +typedef struct user_regset __no_const user_regset_no_const;
70354
70355 /**
70356 * struct user_regset_view - available regsets
70357 diff --git a/include/linux/relay.h b/include/linux/relay.h
70358 index 91cacc3..b55ff74 100644
70359 --- a/include/linux/relay.h
70360 +++ b/include/linux/relay.h
70361 @@ -160,7 +160,7 @@ struct rchan_callbacks
70362 * The callback should return 0 if successful, negative if not.
70363 */
70364 int (*remove_buf_file)(struct dentry *dentry);
70365 -};
70366 +} __no_const;
70367
70368 /*
70369 * CONFIG_RELAY kernel API, kernel/relay.c
70370 diff --git a/include/linux/rio.h b/include/linux/rio.h
70371 index a3e7842..d973ca6 100644
70372 --- a/include/linux/rio.h
70373 +++ b/include/linux/rio.h
70374 @@ -339,7 +339,7 @@ struct rio_ops {
70375 int (*map_inb)(struct rio_mport *mport, dma_addr_t lstart,
70376 u64 rstart, u32 size, u32 flags);
70377 void (*unmap_inb)(struct rio_mport *mport, dma_addr_t lstart);
70378 -};
70379 +} __no_const;
70380
70381 #define RIO_RESOURCE_MEM 0x00000100
70382 #define RIO_RESOURCE_DOORBELL 0x00000200
70383 diff --git a/include/linux/rmap.h b/include/linux/rmap.h
70384 index 6dacb93..6174423 100644
70385 --- a/include/linux/rmap.h
70386 +++ b/include/linux/rmap.h
70387 @@ -145,8 +145,8 @@ static inline void anon_vma_unlock_read(struct anon_vma *anon_vma)
70388 void anon_vma_init(void); /* create anon_vma_cachep */
70389 int anon_vma_prepare(struct vm_area_struct *);
70390 void unlink_anon_vmas(struct vm_area_struct *);
70391 -int anon_vma_clone(struct vm_area_struct *, struct vm_area_struct *);
70392 -int anon_vma_fork(struct vm_area_struct *, struct vm_area_struct *);
70393 +int anon_vma_clone(struct vm_area_struct *, const struct vm_area_struct *);
70394 +int anon_vma_fork(struct vm_area_struct *, const struct vm_area_struct *);
70395
70396 static inline void anon_vma_merge(struct vm_area_struct *vma,
70397 struct vm_area_struct *next)
70398 diff --git a/include/linux/sched.h b/include/linux/sched.h
70399 index be4e742..7f9d593 100644
70400 --- a/include/linux/sched.h
70401 +++ b/include/linux/sched.h
70402 @@ -62,6 +62,7 @@ struct bio_list;
70403 struct fs_struct;
70404 struct perf_event_context;
70405 struct blk_plug;
70406 +struct linux_binprm;
70407
70408 /*
70409 * List of flags we want to share for kernel threads,
70410 @@ -315,7 +316,7 @@ extern char __sched_text_start[], __sched_text_end[];
70411 extern int in_sched_functions(unsigned long addr);
70412
70413 #define MAX_SCHEDULE_TIMEOUT LONG_MAX
70414 -extern signed long schedule_timeout(signed long timeout);
70415 +extern signed long schedule_timeout(signed long timeout) __intentional_overflow(-1);
70416 extern signed long schedule_timeout_interruptible(signed long timeout);
70417 extern signed long schedule_timeout_killable(signed long timeout);
70418 extern signed long schedule_timeout_uninterruptible(signed long timeout);
70419 @@ -329,6 +330,18 @@ struct user_namespace;
70420 #include <linux/aio.h>
70421
70422 #ifdef CONFIG_MMU
70423 +
70424 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
70425 +extern unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags);
70426 +#else
70427 +static inline unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
70428 +{
70429 + return 0;
70430 +}
70431 +#endif
70432 +
70433 +extern bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset);
70434 +extern unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset);
70435 extern void arch_pick_mmap_layout(struct mm_struct *mm);
70436 extern unsigned long
70437 arch_get_unmapped_area(struct file *, unsigned long, unsigned long,
70438 @@ -605,6 +618,17 @@ struct signal_struct {
70439 #ifdef CONFIG_TASKSTATS
70440 struct taskstats *stats;
70441 #endif
70442 +
70443 +#ifdef CONFIG_GRKERNSEC
70444 + u32 curr_ip;
70445 + u32 saved_ip;
70446 + u32 gr_saddr;
70447 + u32 gr_daddr;
70448 + u16 gr_sport;
70449 + u16 gr_dport;
70450 + u8 used_accept:1;
70451 +#endif
70452 +
70453 #ifdef CONFIG_AUDIT
70454 unsigned audit_tty;
70455 struct tty_audit_buf *tty_audit_buf;
70456 @@ -683,6 +707,11 @@ struct user_struct {
70457 struct key *session_keyring; /* UID's default session keyring */
70458 #endif
70459
70460 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
70461 + unsigned int banned;
70462 + unsigned long ban_expires;
70463 +#endif
70464 +
70465 /* Hash table maintenance information */
70466 struct hlist_node uidhash_node;
70467 kuid_t uid;
70468 @@ -1082,7 +1111,7 @@ struct sched_class {
70469 #ifdef CONFIG_FAIR_GROUP_SCHED
70470 void (*task_move_group) (struct task_struct *p, int on_rq);
70471 #endif
70472 -};
70473 +} __do_const;
70474
70475 struct load_weight {
70476 unsigned long weight, inv_weight;
70477 @@ -1323,8 +1352,8 @@ struct task_struct {
70478 struct list_head thread_group;
70479
70480 struct completion *vfork_done; /* for vfork() */
70481 - int __user *set_child_tid; /* CLONE_CHILD_SETTID */
70482 - int __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
70483 + pid_t __user *set_child_tid; /* CLONE_CHILD_SETTID */
70484 + pid_t __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
70485
70486 cputime_t utime, stime, utimescaled, stimescaled;
70487 cputime_t gtime;
70488 @@ -1349,11 +1378,6 @@ struct task_struct {
70489 struct task_cputime cputime_expires;
70490 struct list_head cpu_timers[3];
70491
70492 -/* process credentials */
70493 - const struct cred __rcu *real_cred; /* objective and real subjective task
70494 - * credentials (COW) */
70495 - const struct cred __rcu *cred; /* effective (overridable) subjective task
70496 - * credentials (COW) */
70497 char comm[TASK_COMM_LEN]; /* executable name excluding path
70498 - access with [gs]et_task_comm (which lock
70499 it with task_lock())
70500 @@ -1370,6 +1394,10 @@ struct task_struct {
70501 #endif
70502 /* CPU-specific state of this task */
70503 struct thread_struct thread;
70504 +/* thread_info moved to task_struct */
70505 +#ifdef CONFIG_X86
70506 + struct thread_info tinfo;
70507 +#endif
70508 /* filesystem information */
70509 struct fs_struct *fs;
70510 /* open file information */
70511 @@ -1443,6 +1471,10 @@ struct task_struct {
70512 gfp_t lockdep_reclaim_gfp;
70513 #endif
70514
70515 +/* process credentials */
70516 + const struct cred __rcu *real_cred; /* objective and real subjective task
70517 + * credentials (COW) */
70518 +
70519 /* journalling filesystem info */
70520 void *journal_info;
70521
70522 @@ -1481,6 +1513,10 @@ struct task_struct {
70523 /* cg_list protected by css_set_lock and tsk->alloc_lock */
70524 struct list_head cg_list;
70525 #endif
70526 +
70527 + const struct cred __rcu *cred; /* effective (overridable) subjective task
70528 + * credentials (COW) */
70529 +
70530 #ifdef CONFIG_FUTEX
70531 struct robust_list_head __user *robust_list;
70532 #ifdef CONFIG_COMPAT
70533 @@ -1577,8 +1613,74 @@ struct task_struct {
70534 #ifdef CONFIG_UPROBES
70535 struct uprobe_task *utask;
70536 #endif
70537 +
70538 +#ifdef CONFIG_GRKERNSEC
70539 + /* grsecurity */
70540 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
70541 + u64 exec_id;
70542 +#endif
70543 +#ifdef CONFIG_GRKERNSEC_SETXID
70544 + const struct cred *delayed_cred;
70545 +#endif
70546 + struct dentry *gr_chroot_dentry;
70547 + struct acl_subject_label *acl;
70548 + struct acl_role_label *role;
70549 + struct file *exec_file;
70550 + unsigned long brute_expires;
70551 + u16 acl_role_id;
70552 + /* is this the task that authenticated to the special role */
70553 + u8 acl_sp_role;
70554 + u8 is_writable;
70555 + u8 brute;
70556 + u8 gr_is_chrooted;
70557 +#endif
70558 +
70559 };
70560
70561 +#define MF_PAX_PAGEEXEC 0x01000000 /* Paging based non-executable pages */
70562 +#define MF_PAX_EMUTRAMP 0x02000000 /* Emulate trampolines */
70563 +#define MF_PAX_MPROTECT 0x04000000 /* Restrict mprotect() */
70564 +#define MF_PAX_RANDMMAP 0x08000000 /* Randomize mmap() base */
70565 +/*#define MF_PAX_RANDEXEC 0x10000000*/ /* Randomize ET_EXEC base */
70566 +#define MF_PAX_SEGMEXEC 0x20000000 /* Segmentation based non-executable pages */
70567 +
70568 +#ifdef CONFIG_PAX_SOFTMODE
70569 +extern int pax_softmode;
70570 +#endif
70571 +
70572 +extern int pax_check_flags(unsigned long *);
70573 +
70574 +/* if tsk != current then task_lock must be held on it */
70575 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
70576 +static inline unsigned long pax_get_flags(struct task_struct *tsk)
70577 +{
70578 + if (likely(tsk->mm))
70579 + return tsk->mm->pax_flags;
70580 + else
70581 + return 0UL;
70582 +}
70583 +
70584 +/* if tsk != current then task_lock must be held on it */
70585 +static inline long pax_set_flags(struct task_struct *tsk, unsigned long flags)
70586 +{
70587 + if (likely(tsk->mm)) {
70588 + tsk->mm->pax_flags = flags;
70589 + return 0;
70590 + }
70591 + return -EINVAL;
70592 +}
70593 +#endif
70594 +
70595 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
70596 +extern void pax_set_initial_flags(struct linux_binprm *bprm);
70597 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
70598 +extern void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
70599 +#endif
70600 +
70601 +extern void pax_report_fault(struct pt_regs *regs, void *pc, void *sp);
70602 +extern void pax_report_insns(struct pt_regs *regs, void *pc, void *sp);
70603 +extern void pax_report_refcount_overflow(struct pt_regs *regs);
70604 +
70605 /* Future-safe accessor for struct task_struct's cpus_allowed. */
70606 #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed)
70607
70608 @@ -1637,7 +1739,7 @@ struct pid_namespace;
70609 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
70610 struct pid_namespace *ns);
70611
70612 -static inline pid_t task_pid_nr(struct task_struct *tsk)
70613 +static inline pid_t task_pid_nr(const struct task_struct *tsk)
70614 {
70615 return tsk->pid;
70616 }
70617 @@ -2073,7 +2175,9 @@ void yield(void);
70618 extern struct exec_domain default_exec_domain;
70619
70620 union thread_union {
70621 +#ifndef CONFIG_X86
70622 struct thread_info thread_info;
70623 +#endif
70624 unsigned long stack[THREAD_SIZE/sizeof(long)];
70625 };
70626
70627 @@ -2106,6 +2210,7 @@ extern struct pid_namespace init_pid_ns;
70628 */
70629
70630 extern struct task_struct *find_task_by_vpid(pid_t nr);
70631 +extern struct task_struct *find_task_by_vpid_unrestricted(pid_t nr);
70632 extern struct task_struct *find_task_by_pid_ns(pid_t nr,
70633 struct pid_namespace *ns);
70634
70635 @@ -2272,7 +2377,7 @@ extern void __cleanup_sighand(struct sighand_struct *);
70636 extern void exit_itimers(struct signal_struct *);
70637 extern void flush_itimer_signals(void);
70638
70639 -extern void do_group_exit(int);
70640 +extern __noreturn void do_group_exit(int);
70641
70642 extern int allow_signal(int);
70643 extern int disallow_signal(int);
70644 @@ -2463,9 +2568,9 @@ static inline unsigned long *end_of_stack(struct task_struct *p)
70645
70646 #endif
70647
70648 -static inline int object_is_on_stack(void *obj)
70649 +static inline int object_starts_on_stack(void *obj)
70650 {
70651 - void *stack = task_stack_page(current);
70652 + const void *stack = task_stack_page(current);
70653
70654 return (obj >= stack) && (obj < (stack + THREAD_SIZE));
70655 }
70656 diff --git a/include/linux/sched/sysctl.h b/include/linux/sched/sysctl.h
70657 index bf8086b..962b035 100644
70658 --- a/include/linux/sched/sysctl.h
70659 +++ b/include/linux/sched/sysctl.h
70660 @@ -30,6 +30,7 @@ enum { sysctl_hung_task_timeout_secs = 0 };
70661 #define DEFAULT_MAX_MAP_COUNT (USHRT_MAX - MAPCOUNT_ELF_CORE_MARGIN)
70662
70663 extern int sysctl_max_map_count;
70664 +extern unsigned long sysctl_heap_stack_gap;
70665
70666 extern unsigned int sysctl_sched_latency;
70667 extern unsigned int sysctl_sched_min_granularity;
70668 diff --git a/include/linux/security.h b/include/linux/security.h
70669 index 032c366..2c1c2dc2 100644
70670 --- a/include/linux/security.h
70671 +++ b/include/linux/security.h
70672 @@ -26,6 +26,7 @@
70673 #include <linux/capability.h>
70674 #include <linux/slab.h>
70675 #include <linux/err.h>
70676 +#include <linux/grsecurity.h>
70677
70678 struct linux_binprm;
70679 struct cred;
70680 diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
70681 index 68a04a3..866e6a1 100644
70682 --- a/include/linux/seq_file.h
70683 +++ b/include/linux/seq_file.h
70684 @@ -26,6 +26,9 @@ struct seq_file {
70685 struct mutex lock;
70686 const struct seq_operations *op;
70687 int poll_event;
70688 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
70689 + u64 exec_id;
70690 +#endif
70691 #ifdef CONFIG_USER_NS
70692 struct user_namespace *user_ns;
70693 #endif
70694 @@ -38,6 +41,7 @@ struct seq_operations {
70695 void * (*next) (struct seq_file *m, void *v, loff_t *pos);
70696 int (*show) (struct seq_file *m, void *v);
70697 };
70698 +typedef struct seq_operations __no_const seq_operations_no_const;
70699
70700 #define SEQ_SKIP 1
70701
70702 diff --git a/include/linux/shm.h b/include/linux/shm.h
70703 index 429c199..4d42e38 100644
70704 --- a/include/linux/shm.h
70705 +++ b/include/linux/shm.h
70706 @@ -21,6 +21,10 @@ struct shmid_kernel /* private to the kernel */
70707
70708 /* The task created the shm object. NULL if the task is dead. */
70709 struct task_struct *shm_creator;
70710 +#ifdef CONFIG_GRKERNSEC
70711 + time_t shm_createtime;
70712 + pid_t shm_lapid;
70713 +#endif
70714 };
70715
70716 /* shm_mode upper byte flags */
70717 diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
70718 index b8292d8..96db310 100644
70719 --- a/include/linux/skbuff.h
70720 +++ b/include/linux/skbuff.h
70721 @@ -599,7 +599,7 @@ extern bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
70722 extern struct sk_buff *__alloc_skb(unsigned int size,
70723 gfp_t priority, int flags, int node);
70724 extern struct sk_buff *build_skb(void *data, unsigned int frag_size);
70725 -static inline struct sk_buff *alloc_skb(unsigned int size,
70726 +static inline struct sk_buff * __intentional_overflow(0) alloc_skb(unsigned int size,
70727 gfp_t priority)
70728 {
70729 return __alloc_skb(size, priority, 0, NUMA_NO_NODE);
70730 @@ -709,7 +709,7 @@ static inline struct skb_shared_hwtstamps *skb_hwtstamps(struct sk_buff *skb)
70731 */
70732 static inline int skb_queue_empty(const struct sk_buff_head *list)
70733 {
70734 - return list->next == (struct sk_buff *)list;
70735 + return list->next == (const struct sk_buff *)list;
70736 }
70737
70738 /**
70739 @@ -722,7 +722,7 @@ static inline int skb_queue_empty(const struct sk_buff_head *list)
70740 static inline bool skb_queue_is_last(const struct sk_buff_head *list,
70741 const struct sk_buff *skb)
70742 {
70743 - return skb->next == (struct sk_buff *)list;
70744 + return skb->next == (const struct sk_buff *)list;
70745 }
70746
70747 /**
70748 @@ -735,7 +735,7 @@ static inline bool skb_queue_is_last(const struct sk_buff_head *list,
70749 static inline bool skb_queue_is_first(const struct sk_buff_head *list,
70750 const struct sk_buff *skb)
70751 {
70752 - return skb->prev == (struct sk_buff *)list;
70753 + return skb->prev == (const struct sk_buff *)list;
70754 }
70755
70756 /**
70757 @@ -1756,7 +1756,7 @@ static inline int pskb_network_may_pull(struct sk_buff *skb, unsigned int len)
70758 * NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8)
70759 */
70760 #ifndef NET_SKB_PAD
70761 -#define NET_SKB_PAD max(32, L1_CACHE_BYTES)
70762 +#define NET_SKB_PAD max(_AC(32,UL), L1_CACHE_BYTES)
70763 #endif
70764
70765 extern int ___pskb_trim(struct sk_buff *skb, unsigned int len);
70766 @@ -2351,7 +2351,7 @@ extern struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags,
70767 int noblock, int *err);
70768 extern unsigned int datagram_poll(struct file *file, struct socket *sock,
70769 struct poll_table_struct *wait);
70770 -extern int skb_copy_datagram_iovec(const struct sk_buff *from,
70771 +extern int __intentional_overflow(0) skb_copy_datagram_iovec(const struct sk_buff *from,
70772 int offset, struct iovec *to,
70773 int size);
70774 extern int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb,
70775 @@ -2641,6 +2641,9 @@ static inline void nf_reset(struct sk_buff *skb)
70776 nf_bridge_put(skb->nf_bridge);
70777 skb->nf_bridge = NULL;
70778 #endif
70779 +#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE)
70780 + skb->nf_trace = 0;
70781 +#endif
70782 }
70783
70784 static inline void nf_reset_trace(struct sk_buff *skb)
70785 diff --git a/include/linux/slab.h b/include/linux/slab.h
70786 index 5d168d7..720bff3 100644
70787 --- a/include/linux/slab.h
70788 +++ b/include/linux/slab.h
70789 @@ -12,13 +12,20 @@
70790 #include <linux/gfp.h>
70791 #include <linux/types.h>
70792 #include <linux/workqueue.h>
70793 -
70794 +#include <linux/err.h>
70795
70796 /*
70797 * Flags to pass to kmem_cache_create().
70798 * The ones marked DEBUG are only valid if CONFIG_SLAB_DEBUG is set.
70799 */
70800 #define SLAB_DEBUG_FREE 0x00000100UL /* DEBUG: Perform (expensive) checks on free */
70801 +
70802 +#ifdef CONFIG_PAX_USERCOPY_SLABS
70803 +#define SLAB_USERCOPY 0x00000200UL /* PaX: Allow copying objs to/from userland */
70804 +#else
70805 +#define SLAB_USERCOPY 0x00000000UL
70806 +#endif
70807 +
70808 #define SLAB_RED_ZONE 0x00000400UL /* DEBUG: Red zone objs in a cache */
70809 #define SLAB_POISON 0x00000800UL /* DEBUG: Poison objects */
70810 #define SLAB_HWCACHE_ALIGN 0x00002000UL /* Align objs on cache lines */
70811 @@ -89,10 +96,13 @@
70812 * ZERO_SIZE_PTR can be passed to kfree though in the same way that NULL can.
70813 * Both make kfree a no-op.
70814 */
70815 -#define ZERO_SIZE_PTR ((void *)16)
70816 +#define ZERO_SIZE_PTR \
70817 +({ \
70818 + BUILD_BUG_ON(!(MAX_ERRNO & ~PAGE_MASK));\
70819 + (void *)(-MAX_ERRNO-1L); \
70820 +})
70821
70822 -#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) <= \
70823 - (unsigned long)ZERO_SIZE_PTR)
70824 +#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) - 1 >= (unsigned long)ZERO_SIZE_PTR - 1)
70825
70826 /*
70827 * Common fields provided in kmem_cache by all slab allocators
70828 @@ -112,7 +122,7 @@ struct kmem_cache {
70829 unsigned int align; /* Alignment as calculated */
70830 unsigned long flags; /* Active flags on the slab */
70831 const char *name; /* Slab name for sysfs */
70832 - int refcount; /* Use counter */
70833 + atomic_t refcount; /* Use counter */
70834 void (*ctor)(void *); /* Called on object slot creation */
70835 struct list_head list; /* List of all slab caches on the system */
70836 };
70837 @@ -232,6 +242,8 @@ void * __must_check krealloc(const void *, size_t, gfp_t);
70838 void kfree(const void *);
70839 void kzfree(const void *);
70840 size_t ksize(const void *);
70841 +const char *check_heap_object(const void *ptr, unsigned long n);
70842 +bool is_usercopy_object(const void *ptr);
70843
70844 /*
70845 * Allocator specific definitions. These are mainly used to establish optimized
70846 @@ -311,6 +323,7 @@ size_t ksize(const void *);
70847 * for general use, and so are not documented here. For a full list of
70848 * potential flags, always refer to linux/gfp.h.
70849 */
70850 +
70851 static inline void *kmalloc_array(size_t n, size_t size, gfp_t flags)
70852 {
70853 if (size != 0 && n > SIZE_MAX / size)
70854 @@ -370,7 +383,7 @@ static inline void *kmem_cache_alloc_node(struct kmem_cache *cachep,
70855 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
70856 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
70857 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
70858 -extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
70859 +extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long) __size_overflow(1);
70860 #define kmalloc_track_caller(size, flags) \
70861 __kmalloc_track_caller(size, flags, _RET_IP_)
70862 #else
70863 @@ -390,7 +403,7 @@ extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
70864 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
70865 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
70866 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
70867 -extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long);
70868 +extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long) __size_overflow(1);
70869 #define kmalloc_node_track_caller(size, flags, node) \
70870 __kmalloc_node_track_caller(size, flags, node, \
70871 _RET_IP_)
70872 diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
70873 index 8bb6e0e..8eb0dbe 100644
70874 --- a/include/linux/slab_def.h
70875 +++ b/include/linux/slab_def.h
70876 @@ -52,7 +52,7 @@ struct kmem_cache {
70877 /* 4) cache creation/removal */
70878 const char *name;
70879 struct list_head list;
70880 - int refcount;
70881 + atomic_t refcount;
70882 int object_size;
70883 int align;
70884
70885 @@ -68,10 +68,10 @@ struct kmem_cache {
70886 unsigned long node_allocs;
70887 unsigned long node_frees;
70888 unsigned long node_overflow;
70889 - atomic_t allochit;
70890 - atomic_t allocmiss;
70891 - atomic_t freehit;
70892 - atomic_t freemiss;
70893 + atomic_unchecked_t allochit;
70894 + atomic_unchecked_t allocmiss;
70895 + atomic_unchecked_t freehit;
70896 + atomic_unchecked_t freemiss;
70897
70898 /*
70899 * If debugging is enabled, then the allocator can add additional
70900 @@ -111,11 +111,16 @@ struct cache_sizes {
70901 #ifdef CONFIG_ZONE_DMA
70902 struct kmem_cache *cs_dmacachep;
70903 #endif
70904 +
70905 +#ifdef CONFIG_PAX_USERCOPY_SLABS
70906 + struct kmem_cache *cs_usercopycachep;
70907 +#endif
70908 +
70909 };
70910 extern struct cache_sizes malloc_sizes[];
70911
70912 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
70913 -void *__kmalloc(size_t size, gfp_t flags);
70914 +void *__kmalloc(size_t size, gfp_t flags) __size_overflow(1);
70915
70916 #ifdef CONFIG_TRACING
70917 extern void *kmem_cache_alloc_trace(struct kmem_cache *, gfp_t, size_t);
70918 @@ -152,6 +157,13 @@ found:
70919 cachep = malloc_sizes[i].cs_dmacachep;
70920 else
70921 #endif
70922 +
70923 +#ifdef CONFIG_PAX_USERCOPY_SLABS
70924 + if (flags & GFP_USERCOPY)
70925 + cachep = malloc_sizes[i].cs_usercopycachep;
70926 + else
70927 +#endif
70928 +
70929 cachep = malloc_sizes[i].cs_cachep;
70930
70931 ret = kmem_cache_alloc_trace(cachep, flags, size);
70932 @@ -162,7 +174,7 @@ found:
70933 }
70934
70935 #ifdef CONFIG_NUMA
70936 -extern void *__kmalloc_node(size_t size, gfp_t flags, int node);
70937 +extern void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
70938 extern void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
70939
70940 #ifdef CONFIG_TRACING
70941 @@ -205,6 +217,13 @@ found:
70942 cachep = malloc_sizes[i].cs_dmacachep;
70943 else
70944 #endif
70945 +
70946 +#ifdef CONFIG_PAX_USERCOPY_SLABS
70947 + if (flags & GFP_USERCOPY)
70948 + cachep = malloc_sizes[i].cs_usercopycachep;
70949 + else
70950 +#endif
70951 +
70952 cachep = malloc_sizes[i].cs_cachep;
70953
70954 return kmem_cache_alloc_node_trace(cachep, flags, node, size);
70955 diff --git a/include/linux/slob_def.h b/include/linux/slob_def.h
70956 index f28e14a..7831211 100644
70957 --- a/include/linux/slob_def.h
70958 +++ b/include/linux/slob_def.h
70959 @@ -11,7 +11,7 @@ static __always_inline void *kmem_cache_alloc(struct kmem_cache *cachep,
70960 return kmem_cache_alloc_node(cachep, flags, NUMA_NO_NODE);
70961 }
70962
70963 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
70964 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
70965
70966 static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
70967 {
70968 @@ -31,7 +31,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
70969 return __kmalloc_node(size, flags, NUMA_NO_NODE);
70970 }
70971
70972 -static __always_inline void *__kmalloc(size_t size, gfp_t flags)
70973 +static __always_inline __size_overflow(1) void *__kmalloc(size_t size, gfp_t flags)
70974 {
70975 return kmalloc(size, flags);
70976 }
70977 diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
70978 index 9db4825..ed42fb5 100644
70979 --- a/include/linux/slub_def.h
70980 +++ b/include/linux/slub_def.h
70981 @@ -91,7 +91,7 @@ struct kmem_cache {
70982 struct kmem_cache_order_objects max;
70983 struct kmem_cache_order_objects min;
70984 gfp_t allocflags; /* gfp flags to use on each alloc */
70985 - int refcount; /* Refcount for slab cache destroy */
70986 + atomic_t refcount; /* Refcount for slab cache destroy */
70987 void (*ctor)(void *);
70988 int inuse; /* Offset to metadata */
70989 int align; /* Alignment */
70990 @@ -156,7 +156,7 @@ extern struct kmem_cache *kmalloc_caches[SLUB_PAGE_SHIFT];
70991 * Sorry that the following has to be that ugly but some versions of GCC
70992 * have trouble with constant propagation and loops.
70993 */
70994 -static __always_inline int kmalloc_index(size_t size)
70995 +static __always_inline __size_overflow(1) int kmalloc_index(size_t size)
70996 {
70997 if (!size)
70998 return 0;
70999 @@ -221,7 +221,7 @@ static __always_inline struct kmem_cache *kmalloc_slab(size_t size)
71000 }
71001
71002 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
71003 -void *__kmalloc(size_t size, gfp_t flags);
71004 +void *__kmalloc(size_t size, gfp_t flags) __alloc_size(1) __size_overflow(1);
71005
71006 static __always_inline void *
71007 kmalloc_order(size_t size, gfp_t flags, unsigned int order)
71008 @@ -265,7 +265,7 @@ kmalloc_order_trace(size_t size, gfp_t flags, unsigned int order)
71009 }
71010 #endif
71011
71012 -static __always_inline void *kmalloc_large(size_t size, gfp_t flags)
71013 +static __always_inline __size_overflow(1) void *kmalloc_large(size_t size, gfp_t flags)
71014 {
71015 unsigned int order = get_order(size);
71016 return kmalloc_order_trace(size, flags, order);
71017 @@ -290,7 +290,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
71018 }
71019
71020 #ifdef CONFIG_NUMA
71021 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
71022 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
71023 void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
71024
71025 #ifdef CONFIG_TRACING
71026 diff --git a/include/linux/sock_diag.h b/include/linux/sock_diag.h
71027 index e8d702e..0a56eb4 100644
71028 --- a/include/linux/sock_diag.h
71029 +++ b/include/linux/sock_diag.h
71030 @@ -10,7 +10,7 @@ struct sock;
71031 struct sock_diag_handler {
71032 __u8 family;
71033 int (*dump)(struct sk_buff *skb, struct nlmsghdr *nlh);
71034 -};
71035 +} __do_const;
71036
71037 int sock_diag_register(const struct sock_diag_handler *h);
71038 void sock_diag_unregister(const struct sock_diag_handler *h);
71039 diff --git a/include/linux/sonet.h b/include/linux/sonet.h
71040 index 680f9a3..f13aeb0 100644
71041 --- a/include/linux/sonet.h
71042 +++ b/include/linux/sonet.h
71043 @@ -7,7 +7,7 @@
71044 #include <uapi/linux/sonet.h>
71045
71046 struct k_sonet_stats {
71047 -#define __HANDLE_ITEM(i) atomic_t i
71048 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
71049 __SONET_ITEMS
71050 #undef __HANDLE_ITEM
71051 };
71052 diff --git a/include/linux/sunrpc/addr.h b/include/linux/sunrpc/addr.h
71053 index 07d8e53..dc934c9 100644
71054 --- a/include/linux/sunrpc/addr.h
71055 +++ b/include/linux/sunrpc/addr.h
71056 @@ -23,9 +23,9 @@ static inline unsigned short rpc_get_port(const struct sockaddr *sap)
71057 {
71058 switch (sap->sa_family) {
71059 case AF_INET:
71060 - return ntohs(((struct sockaddr_in *)sap)->sin_port);
71061 + return ntohs(((const struct sockaddr_in *)sap)->sin_port);
71062 case AF_INET6:
71063 - return ntohs(((struct sockaddr_in6 *)sap)->sin6_port);
71064 + return ntohs(((const struct sockaddr_in6 *)sap)->sin6_port);
71065 }
71066 return 0;
71067 }
71068 @@ -58,7 +58,7 @@ static inline bool __rpc_cmp_addr4(const struct sockaddr *sap1,
71069 static inline bool __rpc_copy_addr4(struct sockaddr *dst,
71070 const struct sockaddr *src)
71071 {
71072 - const struct sockaddr_in *ssin = (struct sockaddr_in *) src;
71073 + const struct sockaddr_in *ssin = (const struct sockaddr_in *) src;
71074 struct sockaddr_in *dsin = (struct sockaddr_in *) dst;
71075
71076 dsin->sin_family = ssin->sin_family;
71077 @@ -164,7 +164,7 @@ static inline u32 rpc_get_scope_id(const struct sockaddr *sa)
71078 if (sa->sa_family != AF_INET6)
71079 return 0;
71080
71081 - return ((struct sockaddr_in6 *) sa)->sin6_scope_id;
71082 + return ((const struct sockaddr_in6 *) sa)->sin6_scope_id;
71083 }
71084
71085 #endif /* _LINUX_SUNRPC_ADDR_H */
71086 diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
71087 index 2cf4ffa..470d140 100644
71088 --- a/include/linux/sunrpc/clnt.h
71089 +++ b/include/linux/sunrpc/clnt.h
71090 @@ -96,7 +96,7 @@ struct rpc_procinfo {
71091 unsigned int p_timer; /* Which RTT timer to use */
71092 u32 p_statidx; /* Which procedure to account */
71093 const char * p_name; /* name of procedure */
71094 -};
71095 +} __do_const;
71096
71097 #ifdef __KERNEL__
71098
71099 diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
71100 index 1f0216b..6a4fa50 100644
71101 --- a/include/linux/sunrpc/svc.h
71102 +++ b/include/linux/sunrpc/svc.h
71103 @@ -411,7 +411,7 @@ struct svc_procedure {
71104 unsigned int pc_count; /* call count */
71105 unsigned int pc_cachetype; /* cache info (NFS) */
71106 unsigned int pc_xdrressize; /* maximum size of XDR reply */
71107 -};
71108 +} __do_const;
71109
71110 /*
71111 * Function prototypes.
71112 diff --git a/include/linux/sunrpc/svc_rdma.h b/include/linux/sunrpc/svc_rdma.h
71113 index 0b8e3e6..33e0a01 100644
71114 --- a/include/linux/sunrpc/svc_rdma.h
71115 +++ b/include/linux/sunrpc/svc_rdma.h
71116 @@ -53,15 +53,15 @@ extern unsigned int svcrdma_ord;
71117 extern unsigned int svcrdma_max_requests;
71118 extern unsigned int svcrdma_max_req_size;
71119
71120 -extern atomic_t rdma_stat_recv;
71121 -extern atomic_t rdma_stat_read;
71122 -extern atomic_t rdma_stat_write;
71123 -extern atomic_t rdma_stat_sq_starve;
71124 -extern atomic_t rdma_stat_rq_starve;
71125 -extern atomic_t rdma_stat_rq_poll;
71126 -extern atomic_t rdma_stat_rq_prod;
71127 -extern atomic_t rdma_stat_sq_poll;
71128 -extern atomic_t rdma_stat_sq_prod;
71129 +extern atomic_unchecked_t rdma_stat_recv;
71130 +extern atomic_unchecked_t rdma_stat_read;
71131 +extern atomic_unchecked_t rdma_stat_write;
71132 +extern atomic_unchecked_t rdma_stat_sq_starve;
71133 +extern atomic_unchecked_t rdma_stat_rq_starve;
71134 +extern atomic_unchecked_t rdma_stat_rq_poll;
71135 +extern atomic_unchecked_t rdma_stat_rq_prod;
71136 +extern atomic_unchecked_t rdma_stat_sq_poll;
71137 +extern atomic_unchecked_t rdma_stat_sq_prod;
71138
71139 #define RPCRDMA_VERSION 1
71140
71141 diff --git a/include/linux/sunrpc/svcauth.h b/include/linux/sunrpc/svcauth.h
71142 index ff374ab..7fd2ecb 100644
71143 --- a/include/linux/sunrpc/svcauth.h
71144 +++ b/include/linux/sunrpc/svcauth.h
71145 @@ -109,7 +109,7 @@ struct auth_ops {
71146 int (*release)(struct svc_rqst *rq);
71147 void (*domain_release)(struct auth_domain *);
71148 int (*set_client)(struct svc_rqst *rq);
71149 -};
71150 +} __do_const;
71151
71152 #define SVC_GARBAGE 1
71153 #define SVC_SYSERR 2
71154 diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
71155 index a5ffd32..0935dea 100644
71156 --- a/include/linux/swiotlb.h
71157 +++ b/include/linux/swiotlb.h
71158 @@ -60,7 +60,8 @@ extern void
71159
71160 extern void
71161 swiotlb_free_coherent(struct device *hwdev, size_t size,
71162 - void *vaddr, dma_addr_t dma_handle);
71163 + void *vaddr, dma_addr_t dma_handle,
71164 + struct dma_attrs *attrs);
71165
71166 extern dma_addr_t swiotlb_map_page(struct device *dev, struct page *page,
71167 unsigned long offset, size_t size,
71168 diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
71169 index 313a8e0..1da8fc6 100644
71170 --- a/include/linux/syscalls.h
71171 +++ b/include/linux/syscalls.h
71172 @@ -634,7 +634,7 @@ asmlinkage long sys_getsockname(int, struct sockaddr __user *, int __user *);
71173 asmlinkage long sys_getpeername(int, struct sockaddr __user *, int __user *);
71174 asmlinkage long sys_send(int, void __user *, size_t, unsigned);
71175 asmlinkage long sys_sendto(int, void __user *, size_t, unsigned,
71176 - struct sockaddr __user *, int);
71177 + struct sockaddr __user *, int) __intentional_overflow(0);
71178 asmlinkage long sys_sendmsg(int fd, struct msghdr __user *msg, unsigned flags);
71179 asmlinkage long sys_sendmmsg(int fd, struct mmsghdr __user *msg,
71180 unsigned int vlen, unsigned flags);
71181 diff --git a/include/linux/syscore_ops.h b/include/linux/syscore_ops.h
71182 index 27b3b0b..e093dd9 100644
71183 --- a/include/linux/syscore_ops.h
71184 +++ b/include/linux/syscore_ops.h
71185 @@ -16,7 +16,7 @@ struct syscore_ops {
71186 int (*suspend)(void);
71187 void (*resume)(void);
71188 void (*shutdown)(void);
71189 -};
71190 +} __do_const;
71191
71192 extern void register_syscore_ops(struct syscore_ops *ops);
71193 extern void unregister_syscore_ops(struct syscore_ops *ops);
71194 diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
71195 index 14a8ff2..af52bad 100644
71196 --- a/include/linux/sysctl.h
71197 +++ b/include/linux/sysctl.h
71198 @@ -34,13 +34,13 @@ struct ctl_table_root;
71199 struct ctl_table_header;
71200 struct ctl_dir;
71201
71202 -typedef struct ctl_table ctl_table;
71203 -
71204 typedef int proc_handler (struct ctl_table *ctl, int write,
71205 void __user *buffer, size_t *lenp, loff_t *ppos);
71206
71207 extern int proc_dostring(struct ctl_table *, int,
71208 void __user *, size_t *, loff_t *);
71209 +extern int proc_dostring_modpriv(struct ctl_table *, int,
71210 + void __user *, size_t *, loff_t *);
71211 extern int proc_dointvec(struct ctl_table *, int,
71212 void __user *, size_t *, loff_t *);
71213 extern int proc_dointvec_minmax(struct ctl_table *, int,
71214 @@ -115,7 +115,9 @@ struct ctl_table
71215 struct ctl_table_poll *poll;
71216 void *extra1;
71217 void *extra2;
71218 -};
71219 +} __do_const;
71220 +typedef struct ctl_table __no_const ctl_table_no_const;
71221 +typedef struct ctl_table ctl_table;
71222
71223 struct ctl_node {
71224 struct rb_node node;
71225 diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
71226 index e2cee22..3ddb921 100644
71227 --- a/include/linux/sysfs.h
71228 +++ b/include/linux/sysfs.h
71229 @@ -31,7 +31,8 @@ struct attribute {
71230 struct lock_class_key *key;
71231 struct lock_class_key skey;
71232 #endif
71233 -};
71234 +} __do_const;
71235 +typedef struct attribute __no_const attribute_no_const;
71236
71237 /**
71238 * sysfs_attr_init - initialize a dynamically allocated sysfs attribute
71239 @@ -59,8 +60,8 @@ struct attribute_group {
71240 umode_t (*is_visible)(struct kobject *,
71241 struct attribute *, int);
71242 struct attribute **attrs;
71243 -};
71244 -
71245 +} __do_const;
71246 +typedef struct attribute_group __no_const attribute_group_no_const;
71247
71248
71249 /**
71250 @@ -107,7 +108,8 @@ struct bin_attribute {
71251 char *, loff_t, size_t);
71252 int (*mmap)(struct file *, struct kobject *, struct bin_attribute *attr,
71253 struct vm_area_struct *vma);
71254 -};
71255 +} __do_const;
71256 +typedef struct bin_attribute __no_const bin_attribute_no_const;
71257
71258 /**
71259 * sysfs_bin_attr_init - initialize a dynamically allocated bin_attribute
71260 diff --git a/include/linux/sysrq.h b/include/linux/sysrq.h
71261 index 7faf933..9b85a0c 100644
71262 --- a/include/linux/sysrq.h
71263 +++ b/include/linux/sysrq.h
71264 @@ -16,6 +16,7 @@
71265
71266 #include <linux/errno.h>
71267 #include <linux/types.h>
71268 +#include <linux/compiler.h>
71269
71270 /* Enable/disable SYSRQ support by default (0==no, 1==yes). */
71271 #define SYSRQ_DEFAULT_ENABLE 1
71272 @@ -36,7 +37,7 @@ struct sysrq_key_op {
71273 char *help_msg;
71274 char *action_msg;
71275 int enable_mask;
71276 -};
71277 +} __do_const;
71278
71279 #ifdef CONFIG_MAGIC_SYSRQ
71280
71281 diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
71282 index e7e0473..7989295 100644
71283 --- a/include/linux/thread_info.h
71284 +++ b/include/linux/thread_info.h
71285 @@ -148,6 +148,15 @@ static inline bool test_and_clear_restore_sigmask(void)
71286 #error "no set_restore_sigmask() provided and default one won't work"
71287 #endif
71288
71289 +extern void __check_object_size(const void *ptr, unsigned long n, bool to_user);
71290 +static inline void check_object_size(const void *ptr, unsigned long n, bool to_user)
71291 +{
71292 +#ifndef CONFIG_PAX_USERCOPY_DEBUG
71293 + if (!__builtin_constant_p(n))
71294 +#endif
71295 + __check_object_size(ptr, n, to_user);
71296 +}
71297 +
71298 #endif /* __KERNEL__ */
71299
71300 #endif /* _LINUX_THREAD_INFO_H */
71301 diff --git a/include/linux/tty.h b/include/linux/tty.h
71302 index c75d886..04cb148 100644
71303 --- a/include/linux/tty.h
71304 +++ b/include/linux/tty.h
71305 @@ -194,7 +194,7 @@ struct tty_port {
71306 const struct tty_port_operations *ops; /* Port operations */
71307 spinlock_t lock; /* Lock protecting tty field */
71308 int blocked_open; /* Waiting to open */
71309 - int count; /* Usage count */
71310 + atomic_t count; /* Usage count */
71311 wait_queue_head_t open_wait; /* Open waiters */
71312 wait_queue_head_t close_wait; /* Close waiters */
71313 wait_queue_head_t delta_msr_wait; /* Modem status change */
71314 @@ -515,7 +515,7 @@ extern int tty_port_open(struct tty_port *port,
71315 struct tty_struct *tty, struct file *filp);
71316 static inline int tty_port_users(struct tty_port *port)
71317 {
71318 - return port->count + port->blocked_open;
71319 + return atomic_read(&port->count) + port->blocked_open;
71320 }
71321
71322 extern int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc);
71323 diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
71324 index 756a609..b302dd6 100644
71325 --- a/include/linux/tty_driver.h
71326 +++ b/include/linux/tty_driver.h
71327 @@ -285,7 +285,7 @@ struct tty_operations {
71328 void (*poll_put_char)(struct tty_driver *driver, int line, char ch);
71329 #endif
71330 const struct file_operations *proc_fops;
71331 -};
71332 +} __do_const;
71333
71334 struct tty_driver {
71335 int magic; /* magic number for this structure */
71336 diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
71337 index 455a0d7..bf97ff5 100644
71338 --- a/include/linux/tty_ldisc.h
71339 +++ b/include/linux/tty_ldisc.h
71340 @@ -146,7 +146,7 @@ struct tty_ldisc_ops {
71341
71342 struct module *owner;
71343
71344 - int refcount;
71345 + atomic_t refcount;
71346 };
71347
71348 struct tty_ldisc {
71349 diff --git a/include/linux/types.h b/include/linux/types.h
71350 index 4d118ba..c3ee9bf 100644
71351 --- a/include/linux/types.h
71352 +++ b/include/linux/types.h
71353 @@ -176,10 +176,26 @@ typedef struct {
71354 int counter;
71355 } atomic_t;
71356
71357 +#ifdef CONFIG_PAX_REFCOUNT
71358 +typedef struct {
71359 + int counter;
71360 +} atomic_unchecked_t;
71361 +#else
71362 +typedef atomic_t atomic_unchecked_t;
71363 +#endif
71364 +
71365 #ifdef CONFIG_64BIT
71366 typedef struct {
71367 long counter;
71368 } atomic64_t;
71369 +
71370 +#ifdef CONFIG_PAX_REFCOUNT
71371 +typedef struct {
71372 + long counter;
71373 +} atomic64_unchecked_t;
71374 +#else
71375 +typedef atomic64_t atomic64_unchecked_t;
71376 +#endif
71377 #endif
71378
71379 struct list_head {
71380 diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
71381 index 5ca0951..ab496a5 100644
71382 --- a/include/linux/uaccess.h
71383 +++ b/include/linux/uaccess.h
71384 @@ -76,11 +76,11 @@ static inline unsigned long __copy_from_user_nocache(void *to,
71385 long ret; \
71386 mm_segment_t old_fs = get_fs(); \
71387 \
71388 - set_fs(KERNEL_DS); \
71389 pagefault_disable(); \
71390 - ret = __copy_from_user_inatomic(&(retval), (__force typeof(retval) __user *)(addr), sizeof(retval)); \
71391 - pagefault_enable(); \
71392 + set_fs(KERNEL_DS); \
71393 + ret = __copy_from_user_inatomic(&(retval), (typeof(retval) __force_user *)(addr), sizeof(retval)); \
71394 set_fs(old_fs); \
71395 + pagefault_enable(); \
71396 ret; \
71397 })
71398
71399 diff --git a/include/linux/uidgid.h b/include/linux/uidgid.h
71400 index 8e522cbc..aa8572d 100644
71401 --- a/include/linux/uidgid.h
71402 +++ b/include/linux/uidgid.h
71403 @@ -197,4 +197,9 @@ static inline bool kgid_has_mapping(struct user_namespace *ns, kgid_t gid)
71404
71405 #endif /* CONFIG_USER_NS */
71406
71407 +#define GR_GLOBAL_UID(x) from_kuid_munged(&init_user_ns, (x))
71408 +#define GR_GLOBAL_GID(x) from_kgid_munged(&init_user_ns, (x))
71409 +#define gr_is_global_root(x) uid_eq((x), GLOBAL_ROOT_UID)
71410 +#define gr_is_global_nonroot(x) (!uid_eq((x), GLOBAL_ROOT_UID))
71411 +
71412 #endif /* _LINUX_UIDGID_H */
71413 diff --git a/include/linux/unaligned/access_ok.h b/include/linux/unaligned/access_ok.h
71414 index 99c1b4d..562e6f3 100644
71415 --- a/include/linux/unaligned/access_ok.h
71416 +++ b/include/linux/unaligned/access_ok.h
71417 @@ -4,34 +4,34 @@
71418 #include <linux/kernel.h>
71419 #include <asm/byteorder.h>
71420
71421 -static inline u16 get_unaligned_le16(const void *p)
71422 +static inline u16 __intentional_overflow(-1) get_unaligned_le16(const void *p)
71423 {
71424 - return le16_to_cpup((__le16 *)p);
71425 + return le16_to_cpup((const __le16 *)p);
71426 }
71427
71428 -static inline u32 get_unaligned_le32(const void *p)
71429 +static inline u32 __intentional_overflow(-1) get_unaligned_le32(const void *p)
71430 {
71431 - return le32_to_cpup((__le32 *)p);
71432 + return le32_to_cpup((const __le32 *)p);
71433 }
71434
71435 -static inline u64 get_unaligned_le64(const void *p)
71436 +static inline u64 __intentional_overflow(-1) get_unaligned_le64(const void *p)
71437 {
71438 - return le64_to_cpup((__le64 *)p);
71439 + return le64_to_cpup((const __le64 *)p);
71440 }
71441
71442 -static inline u16 get_unaligned_be16(const void *p)
71443 +static inline u16 __intentional_overflow(-1) get_unaligned_be16(const void *p)
71444 {
71445 - return be16_to_cpup((__be16 *)p);
71446 + return be16_to_cpup((const __be16 *)p);
71447 }
71448
71449 -static inline u32 get_unaligned_be32(const void *p)
71450 +static inline u32 __intentional_overflow(-1) get_unaligned_be32(const void *p)
71451 {
71452 - return be32_to_cpup((__be32 *)p);
71453 + return be32_to_cpup((const __be32 *)p);
71454 }
71455
71456 -static inline u64 get_unaligned_be64(const void *p)
71457 +static inline u64 __intentional_overflow(-1) get_unaligned_be64(const void *p)
71458 {
71459 - return be64_to_cpup((__be64 *)p);
71460 + return be64_to_cpup((const __be64 *)p);
71461 }
71462
71463 static inline void put_unaligned_le16(u16 val, void *p)
71464 diff --git a/include/linux/usb.h b/include/linux/usb.h
71465 index 4d22d0f..8d0e8f8 100644
71466 --- a/include/linux/usb.h
71467 +++ b/include/linux/usb.h
71468 @@ -554,7 +554,7 @@ struct usb_device {
71469 int maxchild;
71470
71471 u32 quirks;
71472 - atomic_t urbnum;
71473 + atomic_unchecked_t urbnum;
71474
71475 unsigned long active_duration;
71476
71477 @@ -1604,7 +1604,7 @@ void usb_buffer_unmap_sg(const struct usb_device *dev, int is_in,
71478
71479 extern int usb_control_msg(struct usb_device *dev, unsigned int pipe,
71480 __u8 request, __u8 requesttype, __u16 value, __u16 index,
71481 - void *data, __u16 size, int timeout);
71482 + void *data, __u16 size, int timeout) __intentional_overflow(-1);
71483 extern int usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
71484 void *data, int len, int *actual_length, int timeout);
71485 extern int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
71486 diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h
71487 index c5d36c6..108f4f9 100644
71488 --- a/include/linux/usb/renesas_usbhs.h
71489 +++ b/include/linux/usb/renesas_usbhs.h
71490 @@ -39,7 +39,7 @@ enum {
71491 */
71492 struct renesas_usbhs_driver_callback {
71493 int (*notify_hotplug)(struct platform_device *pdev);
71494 -};
71495 +} __no_const;
71496
71497 /*
71498 * callback functions for platform
71499 diff --git a/include/linux/vermagic.h b/include/linux/vermagic.h
71500 index 6f8fbcf..8259001 100644
71501 --- a/include/linux/vermagic.h
71502 +++ b/include/linux/vermagic.h
71503 @@ -25,9 +25,35 @@
71504 #define MODULE_ARCH_VERMAGIC ""
71505 #endif
71506
71507 +#ifdef CONFIG_PAX_REFCOUNT
71508 +#define MODULE_PAX_REFCOUNT "REFCOUNT "
71509 +#else
71510 +#define MODULE_PAX_REFCOUNT ""
71511 +#endif
71512 +
71513 +#ifdef CONSTIFY_PLUGIN
71514 +#define MODULE_CONSTIFY_PLUGIN "CONSTIFY_PLUGIN "
71515 +#else
71516 +#define MODULE_CONSTIFY_PLUGIN ""
71517 +#endif
71518 +
71519 +#ifdef STACKLEAK_PLUGIN
71520 +#define MODULE_STACKLEAK_PLUGIN "STACKLEAK_PLUGIN "
71521 +#else
71522 +#define MODULE_STACKLEAK_PLUGIN ""
71523 +#endif
71524 +
71525 +#ifdef CONFIG_GRKERNSEC
71526 +#define MODULE_GRSEC "GRSEC "
71527 +#else
71528 +#define MODULE_GRSEC ""
71529 +#endif
71530 +
71531 #define VERMAGIC_STRING \
71532 UTS_RELEASE " " \
71533 MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT \
71534 MODULE_VERMAGIC_MODULE_UNLOAD MODULE_VERMAGIC_MODVERSIONS \
71535 - MODULE_ARCH_VERMAGIC
71536 + MODULE_ARCH_VERMAGIC \
71537 + MODULE_PAX_REFCOUNT MODULE_CONSTIFY_PLUGIN MODULE_STACKLEAK_PLUGIN \
71538 + MODULE_GRSEC
71539
71540 diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
71541 index 6071e91..ca6a489 100644
71542 --- a/include/linux/vmalloc.h
71543 +++ b/include/linux/vmalloc.h
71544 @@ -14,6 +14,11 @@ struct vm_area_struct; /* vma defining user mapping in mm_types.h */
71545 #define VM_USERMAP 0x00000008 /* suitable for remap_vmalloc_range */
71546 #define VM_VPAGES 0x00000010 /* buffer for pages was vmalloc'ed */
71547 #define VM_UNLIST 0x00000020 /* vm_struct is not listed in vmlist */
71548 +
71549 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
71550 +#define VM_KERNEXEC 0x00000040 /* allocate from executable kernel memory range */
71551 +#endif
71552 +
71553 /* bits [20..32] reserved for arch specific ioremap internals */
71554
71555 /*
71556 @@ -62,7 +67,7 @@ extern void *vmalloc_32_user(unsigned long size);
71557 extern void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot);
71558 extern void *__vmalloc_node_range(unsigned long size, unsigned long align,
71559 unsigned long start, unsigned long end, gfp_t gfp_mask,
71560 - pgprot_t prot, int node, const void *caller);
71561 + pgprot_t prot, int node, const void *caller) __size_overflow(1);
71562 extern void vfree(const void *addr);
71563
71564 extern void *vmap(struct page **pages, unsigned int count,
71565 @@ -124,8 +129,8 @@ extern struct vm_struct *alloc_vm_area(size_t size, pte_t **ptes);
71566 extern void free_vm_area(struct vm_struct *area);
71567
71568 /* for /dev/kmem */
71569 -extern long vread(char *buf, char *addr, unsigned long count);
71570 -extern long vwrite(char *buf, char *addr, unsigned long count);
71571 +extern long vread(char *buf, char *addr, unsigned long count) __size_overflow(3);
71572 +extern long vwrite(char *buf, char *addr, unsigned long count) __size_overflow(3);
71573
71574 /*
71575 * Internals. Dont't use..
71576 diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
71577 index 5fd71a7..e5ef9a9 100644
71578 --- a/include/linux/vmstat.h
71579 +++ b/include/linux/vmstat.h
71580 @@ -95,18 +95,18 @@ static inline void vm_events_fold_cpu(int cpu)
71581 /*
71582 * Zone based page accounting with per cpu differentials.
71583 */
71584 -extern atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
71585 +extern atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
71586
71587 static inline void zone_page_state_add(long x, struct zone *zone,
71588 enum zone_stat_item item)
71589 {
71590 - atomic_long_add(x, &zone->vm_stat[item]);
71591 - atomic_long_add(x, &vm_stat[item]);
71592 + atomic_long_add_unchecked(x, &zone->vm_stat[item]);
71593 + atomic_long_add_unchecked(x, &vm_stat[item]);
71594 }
71595
71596 static inline unsigned long global_page_state(enum zone_stat_item item)
71597 {
71598 - long x = atomic_long_read(&vm_stat[item]);
71599 + long x = atomic_long_read_unchecked(&vm_stat[item]);
71600 #ifdef CONFIG_SMP
71601 if (x < 0)
71602 x = 0;
71603 @@ -117,7 +117,7 @@ static inline unsigned long global_page_state(enum zone_stat_item item)
71604 static inline unsigned long zone_page_state(struct zone *zone,
71605 enum zone_stat_item item)
71606 {
71607 - long x = atomic_long_read(&zone->vm_stat[item]);
71608 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
71609 #ifdef CONFIG_SMP
71610 if (x < 0)
71611 x = 0;
71612 @@ -134,7 +134,7 @@ static inline unsigned long zone_page_state(struct zone *zone,
71613 static inline unsigned long zone_page_state_snapshot(struct zone *zone,
71614 enum zone_stat_item item)
71615 {
71616 - long x = atomic_long_read(&zone->vm_stat[item]);
71617 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
71618
71619 #ifdef CONFIG_SMP
71620 int cpu;
71621 @@ -226,8 +226,8 @@ static inline void __mod_zone_page_state(struct zone *zone,
71622
71623 static inline void __inc_zone_state(struct zone *zone, enum zone_stat_item item)
71624 {
71625 - atomic_long_inc(&zone->vm_stat[item]);
71626 - atomic_long_inc(&vm_stat[item]);
71627 + atomic_long_inc_unchecked(&zone->vm_stat[item]);
71628 + atomic_long_inc_unchecked(&vm_stat[item]);
71629 }
71630
71631 static inline void __inc_zone_page_state(struct page *page,
71632 @@ -238,8 +238,8 @@ static inline void __inc_zone_page_state(struct page *page,
71633
71634 static inline void __dec_zone_state(struct zone *zone, enum zone_stat_item item)
71635 {
71636 - atomic_long_dec(&zone->vm_stat[item]);
71637 - atomic_long_dec(&vm_stat[item]);
71638 + atomic_long_dec_unchecked(&zone->vm_stat[item]);
71639 + atomic_long_dec_unchecked(&vm_stat[item]);
71640 }
71641
71642 static inline void __dec_zone_page_state(struct page *page,
71643 diff --git a/include/linux/xattr.h b/include/linux/xattr.h
71644 index fdbafc6..49dfe4f 100644
71645 --- a/include/linux/xattr.h
71646 +++ b/include/linux/xattr.h
71647 @@ -28,7 +28,7 @@ struct xattr_handler {
71648 size_t size, int handler_flags);
71649 int (*set)(struct dentry *dentry, const char *name, const void *buffer,
71650 size_t size, int flags, int handler_flags);
71651 -};
71652 +} __do_const;
71653
71654 struct xattr {
71655 char *name;
71656 @@ -37,6 +37,9 @@ struct xattr {
71657 };
71658
71659 ssize_t xattr_getsecurity(struct inode *, const char *, void *, size_t);
71660 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
71661 +ssize_t pax_getxattr(struct dentry *, void *, size_t);
71662 +#endif
71663 ssize_t vfs_getxattr(struct dentry *, const char *, void *, size_t);
71664 ssize_t vfs_listxattr(struct dentry *d, char *list, size_t size);
71665 int __vfs_setxattr_noperm(struct dentry *, const char *, const void *, size_t, int);
71666 diff --git a/include/linux/zlib.h b/include/linux/zlib.h
71667 index 9c5a6b4..09c9438 100644
71668 --- a/include/linux/zlib.h
71669 +++ b/include/linux/zlib.h
71670 @@ -31,6 +31,7 @@
71671 #define _ZLIB_H
71672
71673 #include <linux/zconf.h>
71674 +#include <linux/compiler.h>
71675
71676 /* zlib deflate based on ZLIB_VERSION "1.1.3" */
71677 /* zlib inflate based on ZLIB_VERSION "1.2.3" */
71678 @@ -179,7 +180,7 @@ typedef z_stream *z_streamp;
71679
71680 /* basic functions */
71681
71682 -extern int zlib_deflate_workspacesize (int windowBits, int memLevel);
71683 +extern int zlib_deflate_workspacesize (int windowBits, int memLevel) __intentional_overflow(0);
71684 /*
71685 Returns the number of bytes that needs to be allocated for a per-
71686 stream workspace with the specified parameters. A pointer to this
71687 diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
71688 index 95d1c91..6798cca 100644
71689 --- a/include/media/v4l2-dev.h
71690 +++ b/include/media/v4l2-dev.h
71691 @@ -76,7 +76,7 @@ struct v4l2_file_operations {
71692 int (*mmap) (struct file *, struct vm_area_struct *);
71693 int (*open) (struct file *);
71694 int (*release) (struct file *);
71695 -};
71696 +} __do_const;
71697
71698 /*
71699 * Newer version of video_device, handled by videodev2.c
71700 diff --git a/include/media/v4l2-ioctl.h b/include/media/v4l2-ioctl.h
71701 index 4118ad1..cb7e25f 100644
71702 --- a/include/media/v4l2-ioctl.h
71703 +++ b/include/media/v4l2-ioctl.h
71704 @@ -284,7 +284,6 @@ struct v4l2_ioctl_ops {
71705 bool valid_prio, int cmd, void *arg);
71706 };
71707
71708 -
71709 /* v4l debugging and diagnostics */
71710
71711 /* Debug bitmask flags to be used on V4L2 */
71712 diff --git a/include/net/9p/transport.h b/include/net/9p/transport.h
71713 index adcbb20..62c2559 100644
71714 --- a/include/net/9p/transport.h
71715 +++ b/include/net/9p/transport.h
71716 @@ -57,7 +57,7 @@ struct p9_trans_module {
71717 int (*cancel) (struct p9_client *, struct p9_req_t *req);
71718 int (*zc_request)(struct p9_client *, struct p9_req_t *,
71719 char *, char *, int , int, int, int);
71720 -};
71721 +} __do_const;
71722
71723 void v9fs_register_trans(struct p9_trans_module *m);
71724 void v9fs_unregister_trans(struct p9_trans_module *m);
71725 diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
71726 index cdd3302..76f8ede 100644
71727 --- a/include/net/bluetooth/l2cap.h
71728 +++ b/include/net/bluetooth/l2cap.h
71729 @@ -551,7 +551,7 @@ struct l2cap_ops {
71730 void (*defer) (struct l2cap_chan *chan);
71731 struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
71732 unsigned long len, int nb);
71733 -};
71734 +} __do_const;
71735
71736 struct l2cap_conn {
71737 struct hci_conn *hcon;
71738 diff --git a/include/net/caif/cfctrl.h b/include/net/caif/cfctrl.h
71739 index 9e5425b..8136ffc 100644
71740 --- a/include/net/caif/cfctrl.h
71741 +++ b/include/net/caif/cfctrl.h
71742 @@ -52,7 +52,7 @@ struct cfctrl_rsp {
71743 void (*radioset_rsp)(void);
71744 void (*reject_rsp)(struct cflayer *layer, u8 linkid,
71745 struct cflayer *client_layer);
71746 -};
71747 +} __no_const;
71748
71749 /* Link Setup Parameters for CAIF-Links. */
71750 struct cfctrl_link_param {
71751 @@ -101,8 +101,8 @@ struct cfctrl_request_info {
71752 struct cfctrl {
71753 struct cfsrvl serv;
71754 struct cfctrl_rsp res;
71755 - atomic_t req_seq_no;
71756 - atomic_t rsp_seq_no;
71757 + atomic_unchecked_t req_seq_no;
71758 + atomic_unchecked_t rsp_seq_no;
71759 struct list_head list;
71760 /* Protects from simultaneous access to first_req list */
71761 spinlock_t info_list_lock;
71762 diff --git a/include/net/flow.h b/include/net/flow.h
71763 index 628e11b..4c475df 100644
71764 --- a/include/net/flow.h
71765 +++ b/include/net/flow.h
71766 @@ -221,6 +221,6 @@ extern struct flow_cache_object *flow_cache_lookup(
71767
71768 extern void flow_cache_flush(void);
71769 extern void flow_cache_flush_deferred(void);
71770 -extern atomic_t flow_cache_genid;
71771 +extern atomic_unchecked_t flow_cache_genid;
71772
71773 #endif
71774 diff --git a/include/net/genetlink.h b/include/net/genetlink.h
71775 index bdfbe68..4402ebe 100644
71776 --- a/include/net/genetlink.h
71777 +++ b/include/net/genetlink.h
71778 @@ -118,7 +118,7 @@ struct genl_ops {
71779 struct netlink_callback *cb);
71780 int (*done)(struct netlink_callback *cb);
71781 struct list_head ops_list;
71782 -};
71783 +} __do_const;
71784
71785 extern int genl_register_family(struct genl_family *family);
71786 extern int genl_register_family_with_ops(struct genl_family *family,
71787 diff --git a/include/net/gro_cells.h b/include/net/gro_cells.h
71788 index 734d9b5..48a9a4b 100644
71789 --- a/include/net/gro_cells.h
71790 +++ b/include/net/gro_cells.h
71791 @@ -29,7 +29,7 @@ static inline void gro_cells_receive(struct gro_cells *gcells, struct sk_buff *s
71792 cell += skb_get_rx_queue(skb) & gcells->gro_cells_mask;
71793
71794 if (skb_queue_len(&cell->napi_skbs) > netdev_max_backlog) {
71795 - atomic_long_inc(&dev->rx_dropped);
71796 + atomic_long_inc_unchecked(&dev->rx_dropped);
71797 kfree_skb(skb);
71798 return;
71799 }
71800 diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
71801 index 1832927..ce39aea 100644
71802 --- a/include/net/inet_connection_sock.h
71803 +++ b/include/net/inet_connection_sock.h
71804 @@ -62,7 +62,7 @@ struct inet_connection_sock_af_ops {
71805 void (*addr2sockaddr)(struct sock *sk, struct sockaddr *);
71806 int (*bind_conflict)(const struct sock *sk,
71807 const struct inet_bind_bucket *tb, bool relax);
71808 -};
71809 +} __do_const;
71810
71811 /** inet_connection_sock - INET connection oriented sock
71812 *
71813 diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
71814 index 53f464d..ba76aaa 100644
71815 --- a/include/net/inetpeer.h
71816 +++ b/include/net/inetpeer.h
71817 @@ -47,8 +47,8 @@ struct inet_peer {
71818 */
71819 union {
71820 struct {
71821 - atomic_t rid; /* Frag reception counter */
71822 - atomic_t ip_id_count; /* IP ID for the next packet */
71823 + atomic_unchecked_t rid; /* Frag reception counter */
71824 + atomic_unchecked_t ip_id_count; /* IP ID for the next packet */
71825 };
71826 struct rcu_head rcu;
71827 struct inet_peer *gc_next;
71828 @@ -182,11 +182,11 @@ static inline int inet_getid(struct inet_peer *p, int more)
71829 more++;
71830 inet_peer_refcheck(p);
71831 do {
71832 - old = atomic_read(&p->ip_id_count);
71833 + old = atomic_read_unchecked(&p->ip_id_count);
71834 new = old + more;
71835 if (!new)
71836 new = 1;
71837 - } while (atomic_cmpxchg(&p->ip_id_count, old, new) != old);
71838 + } while (atomic_cmpxchg_unchecked(&p->ip_id_count, old, new) != old);
71839 return new;
71840 }
71841
71842 diff --git a/include/net/ip.h b/include/net/ip.h
71843 index a68f838..74518ab 100644
71844 --- a/include/net/ip.h
71845 +++ b/include/net/ip.h
71846 @@ -202,7 +202,7 @@ extern struct local_ports {
71847 } sysctl_local_ports;
71848 extern void inet_get_local_port_range(int *low, int *high);
71849
71850 -extern unsigned long *sysctl_local_reserved_ports;
71851 +extern unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
71852 static inline int inet_is_reserved_local_port(int port)
71853 {
71854 return test_bit(port, sysctl_local_reserved_ports);
71855 diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
71856 index e49db91..76a81de 100644
71857 --- a/include/net/ip_fib.h
71858 +++ b/include/net/ip_fib.h
71859 @@ -167,7 +167,7 @@ extern __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh);
71860
71861 #define FIB_RES_SADDR(net, res) \
71862 ((FIB_RES_NH(res).nh_saddr_genid == \
71863 - atomic_read(&(net)->ipv4.dev_addr_genid)) ? \
71864 + atomic_read_unchecked(&(net)->ipv4.dev_addr_genid)) ? \
71865 FIB_RES_NH(res).nh_saddr : \
71866 fib_info_update_nh_saddr((net), &FIB_RES_NH(res)))
71867 #define FIB_RES_GW(res) (FIB_RES_NH(res).nh_gw)
71868 diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
71869 index fce8e6b..3ca4916 100644
71870 --- a/include/net/ip_vs.h
71871 +++ b/include/net/ip_vs.h
71872 @@ -599,7 +599,7 @@ struct ip_vs_conn {
71873 struct ip_vs_conn *control; /* Master control connection */
71874 atomic_t n_control; /* Number of controlled ones */
71875 struct ip_vs_dest *dest; /* real server */
71876 - atomic_t in_pkts; /* incoming packet counter */
71877 + atomic_unchecked_t in_pkts; /* incoming packet counter */
71878
71879 /* packet transmitter for different forwarding methods. If it
71880 mangles the packet, it must return NF_DROP or better NF_STOLEN,
71881 @@ -737,7 +737,7 @@ struct ip_vs_dest {
71882 __be16 port; /* port number of the server */
71883 union nf_inet_addr addr; /* IP address of the server */
71884 volatile unsigned int flags; /* dest status flags */
71885 - atomic_t conn_flags; /* flags to copy to conn */
71886 + atomic_unchecked_t conn_flags; /* flags to copy to conn */
71887 atomic_t weight; /* server weight */
71888
71889 atomic_t refcnt; /* reference counter */
71890 @@ -981,11 +981,11 @@ struct netns_ipvs {
71891 /* ip_vs_lblc */
71892 int sysctl_lblc_expiration;
71893 struct ctl_table_header *lblc_ctl_header;
71894 - struct ctl_table *lblc_ctl_table;
71895 + ctl_table_no_const *lblc_ctl_table;
71896 /* ip_vs_lblcr */
71897 int sysctl_lblcr_expiration;
71898 struct ctl_table_header *lblcr_ctl_header;
71899 - struct ctl_table *lblcr_ctl_table;
71900 + ctl_table_no_const *lblcr_ctl_table;
71901 /* ip_vs_est */
71902 struct list_head est_list; /* estimator list */
71903 spinlock_t est_lock;
71904 diff --git a/include/net/irda/ircomm_tty.h b/include/net/irda/ircomm_tty.h
71905 index 80ffde3..968b0f4 100644
71906 --- a/include/net/irda/ircomm_tty.h
71907 +++ b/include/net/irda/ircomm_tty.h
71908 @@ -35,6 +35,7 @@
71909 #include <linux/termios.h>
71910 #include <linux/timer.h>
71911 #include <linux/tty.h> /* struct tty_struct */
71912 +#include <asm/local.h>
71913
71914 #include <net/irda/irias_object.h>
71915 #include <net/irda/ircomm_core.h>
71916 diff --git a/include/net/iucv/af_iucv.h b/include/net/iucv/af_iucv.h
71917 index 714cc9a..ea05f3e 100644
71918 --- a/include/net/iucv/af_iucv.h
71919 +++ b/include/net/iucv/af_iucv.h
71920 @@ -149,7 +149,7 @@ struct iucv_skb_cb {
71921 struct iucv_sock_list {
71922 struct hlist_head head;
71923 rwlock_t lock;
71924 - atomic_t autobind_name;
71925 + atomic_unchecked_t autobind_name;
71926 };
71927
71928 unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
71929 diff --git a/include/net/llc_c_ac.h b/include/net/llc_c_ac.h
71930 index df83f69..9b640b8 100644
71931 --- a/include/net/llc_c_ac.h
71932 +++ b/include/net/llc_c_ac.h
71933 @@ -87,7 +87,7 @@
71934 #define LLC_CONN_AC_STOP_SENDACK_TMR 70
71935 #define LLC_CONN_AC_START_SENDACK_TMR_IF_NOT_RUNNING 71
71936
71937 -typedef int (*llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
71938 +typedef int (* const llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
71939
71940 extern int llc_conn_ac_clear_remote_busy(struct sock *sk, struct sk_buff *skb);
71941 extern int llc_conn_ac_conn_ind(struct sock *sk, struct sk_buff *skb);
71942 diff --git a/include/net/llc_c_ev.h b/include/net/llc_c_ev.h
71943 index 6ca3113..f8026dd 100644
71944 --- a/include/net/llc_c_ev.h
71945 +++ b/include/net/llc_c_ev.h
71946 @@ -125,8 +125,8 @@ static __inline__ struct llc_conn_state_ev *llc_conn_ev(struct sk_buff *skb)
71947 return (struct llc_conn_state_ev *)skb->cb;
71948 }
71949
71950 -typedef int (*llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
71951 -typedef int (*llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
71952 +typedef int (* const llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
71953 +typedef int (* const llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
71954
71955 extern int llc_conn_ev_conn_req(struct sock *sk, struct sk_buff *skb);
71956 extern int llc_conn_ev_data_req(struct sock *sk, struct sk_buff *skb);
71957 diff --git a/include/net/llc_c_st.h b/include/net/llc_c_st.h
71958 index 0e79cfb..f46db31 100644
71959 --- a/include/net/llc_c_st.h
71960 +++ b/include/net/llc_c_st.h
71961 @@ -37,7 +37,7 @@ struct llc_conn_state_trans {
71962 u8 next_state;
71963 llc_conn_ev_qfyr_t *ev_qualifiers;
71964 llc_conn_action_t *ev_actions;
71965 -};
71966 +} __do_const;
71967
71968 struct llc_conn_state {
71969 u8 current_state;
71970 diff --git a/include/net/llc_s_ac.h b/include/net/llc_s_ac.h
71971 index 37a3bbd..55a4241 100644
71972 --- a/include/net/llc_s_ac.h
71973 +++ b/include/net/llc_s_ac.h
71974 @@ -23,7 +23,7 @@
71975 #define SAP_ACT_TEST_IND 9
71976
71977 /* All action functions must look like this */
71978 -typedef int (*llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
71979 +typedef int (* const llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
71980
71981 extern int llc_sap_action_unitdata_ind(struct llc_sap *sap,
71982 struct sk_buff *skb);
71983 diff --git a/include/net/llc_s_st.h b/include/net/llc_s_st.h
71984 index 567c681..cd73ac0 100644
71985 --- a/include/net/llc_s_st.h
71986 +++ b/include/net/llc_s_st.h
71987 @@ -20,7 +20,7 @@ struct llc_sap_state_trans {
71988 llc_sap_ev_t ev;
71989 u8 next_state;
71990 llc_sap_action_t *ev_actions;
71991 -};
71992 +} __do_const;
71993
71994 struct llc_sap_state {
71995 u8 curr_state;
71996 diff --git a/include/net/mac80211.h b/include/net/mac80211.h
71997 index f7eba13..91ed983 100644
71998 --- a/include/net/mac80211.h
71999 +++ b/include/net/mac80211.h
72000 @@ -4119,7 +4119,7 @@ struct rate_control_ops {
72001 void (*add_sta_debugfs)(void *priv, void *priv_sta,
72002 struct dentry *dir);
72003 void (*remove_sta_debugfs)(void *priv, void *priv_sta);
72004 -};
72005 +} __do_const;
72006
72007 static inline int rate_supported(struct ieee80211_sta *sta,
72008 enum ieee80211_band band,
72009 diff --git a/include/net/neighbour.h b/include/net/neighbour.h
72010 index 7e748ad..5c6229b 100644
72011 --- a/include/net/neighbour.h
72012 +++ b/include/net/neighbour.h
72013 @@ -123,7 +123,7 @@ struct neigh_ops {
72014 void (*error_report)(struct neighbour *, struct sk_buff *);
72015 int (*output)(struct neighbour *, struct sk_buff *);
72016 int (*connected_output)(struct neighbour *, struct sk_buff *);
72017 -};
72018 +} __do_const;
72019
72020 struct pneigh_entry {
72021 struct pneigh_entry *next;
72022 diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
72023 index de644bc..dfbcc4c 100644
72024 --- a/include/net/net_namespace.h
72025 +++ b/include/net/net_namespace.h
72026 @@ -115,7 +115,7 @@ struct net {
72027 #endif
72028 struct netns_ipvs *ipvs;
72029 struct sock *diag_nlsk;
72030 - atomic_t rt_genid;
72031 + atomic_unchecked_t rt_genid;
72032 };
72033
72034 /*
72035 @@ -272,7 +272,11 @@ static inline struct net *read_pnet(struct net * const *pnet)
72036 #define __net_init __init
72037 #define __net_exit __exit_refok
72038 #define __net_initdata __initdata
72039 +#ifdef CONSTIFY_PLUGIN
72040 #define __net_initconst __initconst
72041 +#else
72042 +#define __net_initconst __initdata
72043 +#endif
72044 #endif
72045
72046 struct pernet_operations {
72047 @@ -282,7 +286,7 @@ struct pernet_operations {
72048 void (*exit_batch)(struct list_head *net_exit_list);
72049 int *id;
72050 size_t size;
72051 -};
72052 +} __do_const;
72053
72054 /*
72055 * Use these carefully. If you implement a network device and it
72056 @@ -330,12 +334,12 @@ static inline void unregister_net_sysctl_table(struct ctl_table_header *header)
72057
72058 static inline int rt_genid(struct net *net)
72059 {
72060 - return atomic_read(&net->rt_genid);
72061 + return atomic_read_unchecked(&net->rt_genid);
72062 }
72063
72064 static inline void rt_genid_bump(struct net *net)
72065 {
72066 - atomic_inc(&net->rt_genid);
72067 + atomic_inc_unchecked(&net->rt_genid);
72068 }
72069
72070 #endif /* __NET_NET_NAMESPACE_H */
72071 diff --git a/include/net/netdma.h b/include/net/netdma.h
72072 index 8ba8ce2..99b7fff 100644
72073 --- a/include/net/netdma.h
72074 +++ b/include/net/netdma.h
72075 @@ -24,7 +24,7 @@
72076 #include <linux/dmaengine.h>
72077 #include <linux/skbuff.h>
72078
72079 -int dma_skb_copy_datagram_iovec(struct dma_chan* chan,
72080 +int __intentional_overflow(3,5) dma_skb_copy_datagram_iovec(struct dma_chan* chan,
72081 struct sk_buff *skb, int offset, struct iovec *to,
72082 size_t len, struct dma_pinned_list *pinned_list);
72083
72084 diff --git a/include/net/netlink.h b/include/net/netlink.h
72085 index 9690b0f..87aded7 100644
72086 --- a/include/net/netlink.h
72087 +++ b/include/net/netlink.h
72088 @@ -534,7 +534,7 @@ static inline void *nlmsg_get_pos(struct sk_buff *skb)
72089 static inline void nlmsg_trim(struct sk_buff *skb, const void *mark)
72090 {
72091 if (mark)
72092 - skb_trim(skb, (unsigned char *) mark - skb->data);
72093 + skb_trim(skb, (const unsigned char *) mark - skb->data);
72094 }
72095
72096 /**
72097 diff --git a/include/net/netns/conntrack.h b/include/net/netns/conntrack.h
72098 index c9c0c53..53f24c3 100644
72099 --- a/include/net/netns/conntrack.h
72100 +++ b/include/net/netns/conntrack.h
72101 @@ -12,10 +12,10 @@ struct nf_conntrack_ecache;
72102 struct nf_proto_net {
72103 #ifdef CONFIG_SYSCTL
72104 struct ctl_table_header *ctl_table_header;
72105 - struct ctl_table *ctl_table;
72106 + ctl_table_no_const *ctl_table;
72107 #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
72108 struct ctl_table_header *ctl_compat_header;
72109 - struct ctl_table *ctl_compat_table;
72110 + ctl_table_no_const *ctl_compat_table;
72111 #endif
72112 #endif
72113 unsigned int users;
72114 @@ -58,7 +58,7 @@ struct nf_ip_net {
72115 struct nf_icmp_net icmpv6;
72116 #if defined(CONFIG_SYSCTL) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT)
72117 struct ctl_table_header *ctl_table_header;
72118 - struct ctl_table *ctl_table;
72119 + ctl_table_no_const *ctl_table;
72120 #endif
72121 };
72122
72123 diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
72124 index 2ba9de8..47bd6c7 100644
72125 --- a/include/net/netns/ipv4.h
72126 +++ b/include/net/netns/ipv4.h
72127 @@ -67,7 +67,7 @@ struct netns_ipv4 {
72128 kgid_t sysctl_ping_group_range[2];
72129 long sysctl_tcp_mem[3];
72130
72131 - atomic_t dev_addr_genid;
72132 + atomic_unchecked_t dev_addr_genid;
72133
72134 #ifdef CONFIG_IP_MROUTE
72135 #ifndef CONFIG_IP_MROUTE_MULTIPLE_TABLES
72136 diff --git a/include/net/protocol.h b/include/net/protocol.h
72137 index 047c047..b9dad15 100644
72138 --- a/include/net/protocol.h
72139 +++ b/include/net/protocol.h
72140 @@ -44,7 +44,7 @@ struct net_protocol {
72141 void (*err_handler)(struct sk_buff *skb, u32 info);
72142 unsigned int no_policy:1,
72143 netns_ok:1;
72144 -};
72145 +} __do_const;
72146
72147 #if IS_ENABLED(CONFIG_IPV6)
72148 struct inet6_protocol {
72149 @@ -57,7 +57,7 @@ struct inet6_protocol {
72150 u8 type, u8 code, int offset,
72151 __be32 info);
72152 unsigned int flags; /* INET6_PROTO_xxx */
72153 -};
72154 +} __do_const;
72155
72156 #define INET6_PROTO_NOPOLICY 0x1
72157 #define INET6_PROTO_FINAL 0x2
72158 diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
72159 index 5a15fab..d799ea7 100644
72160 --- a/include/net/rtnetlink.h
72161 +++ b/include/net/rtnetlink.h
72162 @@ -81,7 +81,7 @@ struct rtnl_link_ops {
72163 const struct net_device *dev);
72164 unsigned int (*get_num_tx_queues)(void);
72165 unsigned int (*get_num_rx_queues)(void);
72166 -};
72167 +} __do_const;
72168
72169 extern int __rtnl_link_register(struct rtnl_link_ops *ops);
72170 extern void __rtnl_link_unregister(struct rtnl_link_ops *ops);
72171 diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
72172 index df85a0c..19ac300 100644
72173 --- a/include/net/sctp/sctp.h
72174 +++ b/include/net/sctp/sctp.h
72175 @@ -330,9 +330,9 @@ do { \
72176
72177 #else /* SCTP_DEBUG */
72178
72179 -#define SCTP_DEBUG_PRINTK(whatever...)
72180 -#define SCTP_DEBUG_PRINTK_CONT(fmt, args...)
72181 -#define SCTP_DEBUG_PRINTK_IPADDR(whatever...)
72182 +#define SCTP_DEBUG_PRINTK(whatever...) do {} while (0)
72183 +#define SCTP_DEBUG_PRINTK_CONT(fmt, args...) do {} while (0)
72184 +#define SCTP_DEBUG_PRINTK_IPADDR(whatever...) do {} while (0)
72185 #define SCTP_ENABLE_DEBUG
72186 #define SCTP_DISABLE_DEBUG
72187 #define SCTP_ASSERT(expr, str, func)
72188 diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
72189 index 2a82d13..62a31c2 100644
72190 --- a/include/net/sctp/sm.h
72191 +++ b/include/net/sctp/sm.h
72192 @@ -87,7 +87,7 @@ typedef void (sctp_timer_event_t) (unsigned long);
72193 typedef struct {
72194 sctp_state_fn_t *fn;
72195 const char *name;
72196 -} sctp_sm_table_entry_t;
72197 +} __do_const sctp_sm_table_entry_t;
72198
72199 /* A naming convention of "sctp_sf_xxx" applies to all the state functions
72200 * currently in use.
72201 @@ -299,7 +299,7 @@ __u32 sctp_generate_tag(const struct sctp_endpoint *);
72202 __u32 sctp_generate_tsn(const struct sctp_endpoint *);
72203
72204 /* Extern declarations for major data structures. */
72205 -extern sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
72206 +extern sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
72207
72208
72209 /* Get the size of a DATA chunk payload. */
72210 diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
72211 index 0e0f9d2..cd05ebb 100644
72212 --- a/include/net/sctp/structs.h
72213 +++ b/include/net/sctp/structs.h
72214 @@ -517,7 +517,7 @@ struct sctp_pf {
72215 struct sctp_association *asoc);
72216 void (*addr_v4map) (struct sctp_sock *, union sctp_addr *);
72217 struct sctp_af *af;
72218 -};
72219 +} __do_const;
72220
72221
72222 /* Structure to track chunk fragments that have been acked, but peer
72223 diff --git a/include/net/secure_seq.h b/include/net/secure_seq.h
72224 index c2e542b..6ca975b 100644
72225 --- a/include/net/secure_seq.h
72226 +++ b/include/net/secure_seq.h
72227 @@ -3,6 +3,7 @@
72228
72229 #include <linux/types.h>
72230
72231 +extern void net_secret_init(void);
72232 extern __u32 secure_ip_id(__be32 daddr);
72233 extern __u32 secure_ipv6_id(const __be32 daddr[4]);
72234 extern u32 secure_ipv4_port_ephemeral(__be32 saddr, __be32 daddr, __be16 dport);
72235 diff --git a/include/net/sock.h b/include/net/sock.h
72236 index 0be480a..586232f 100644
72237 --- a/include/net/sock.h
72238 +++ b/include/net/sock.h
72239 @@ -325,7 +325,7 @@ struct sock {
72240 #ifdef CONFIG_RPS
72241 __u32 sk_rxhash;
72242 #endif
72243 - atomic_t sk_drops;
72244 + atomic_unchecked_t sk_drops;
72245 int sk_rcvbuf;
72246
72247 struct sk_filter __rcu *sk_filter;
72248 @@ -1796,7 +1796,7 @@ static inline void sk_nocaps_add(struct sock *sk, netdev_features_t flags)
72249 }
72250
72251 static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb,
72252 - char __user *from, char *to,
72253 + char __user *from, unsigned char *to,
72254 int copy, int offset)
72255 {
72256 if (skb->ip_summed == CHECKSUM_NONE) {
72257 @@ -2055,7 +2055,7 @@ static inline void sk_stream_moderate_sndbuf(struct sock *sk)
72258 }
72259 }
72260
72261 -struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
72262 +struct sk_buff * __intentional_overflow(0) sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
72263
72264 /**
72265 * sk_page_frag - return an appropriate page_frag
72266 diff --git a/include/net/tcp.h b/include/net/tcp.h
72267 index a345480..3c65cf4 100644
72268 --- a/include/net/tcp.h
72269 +++ b/include/net/tcp.h
72270 @@ -529,7 +529,7 @@ extern void tcp_retransmit_timer(struct sock *sk);
72271 extern void tcp_xmit_retransmit_queue(struct sock *);
72272 extern void tcp_simple_retransmit(struct sock *);
72273 extern int tcp_trim_head(struct sock *, struct sk_buff *, u32);
72274 -extern int tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
72275 +extern int __intentional_overflow(3) tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
72276
72277 extern void tcp_send_probe0(struct sock *);
72278 extern void tcp_send_partial(struct sock *);
72279 @@ -700,8 +700,8 @@ struct tcp_skb_cb {
72280 struct inet6_skb_parm h6;
72281 #endif
72282 } header; /* For incoming frames */
72283 - __u32 seq; /* Starting sequence number */
72284 - __u32 end_seq; /* SEQ + FIN + SYN + datalen */
72285 + __u32 seq __intentional_overflow(0); /* Starting sequence number */
72286 + __u32 end_seq __intentional_overflow(0); /* SEQ + FIN + SYN + datalen */
72287 __u32 when; /* used to compute rtt's */
72288 __u8 tcp_flags; /* TCP header flags. (tcp[13]) */
72289
72290 @@ -715,7 +715,7 @@ struct tcp_skb_cb {
72291
72292 __u8 ip_dsfield; /* IPv4 tos or IPv6 dsfield */
72293 /* 1 byte hole */
72294 - __u32 ack_seq; /* Sequence number ACK'd */
72295 + __u32 ack_seq __intentional_overflow(0); /* Sequence number ACK'd */
72296 };
72297
72298 #define TCP_SKB_CB(__skb) ((struct tcp_skb_cb *)&((__skb)->cb[0]))
72299 diff --git a/include/net/xfrm.h b/include/net/xfrm.h
72300 index 24c8886..e6fb816 100644
72301 --- a/include/net/xfrm.h
72302 +++ b/include/net/xfrm.h
72303 @@ -304,7 +304,7 @@ struct xfrm_policy_afinfo {
72304 struct net_device *dev,
72305 const struct flowi *fl);
72306 struct dst_entry *(*blackhole_route)(struct net *net, struct dst_entry *orig);
72307 -};
72308 +} __do_const;
72309
72310 extern int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo);
72311 extern int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo);
72312 @@ -340,7 +340,7 @@ struct xfrm_state_afinfo {
72313 struct sk_buff *skb);
72314 int (*transport_finish)(struct sk_buff *skb,
72315 int async);
72316 -};
72317 +} __do_const;
72318
72319 extern int xfrm_state_register_afinfo(struct xfrm_state_afinfo *afinfo);
72320 extern int xfrm_state_unregister_afinfo(struct xfrm_state_afinfo *afinfo);
72321 @@ -423,7 +423,7 @@ struct xfrm_mode {
72322 struct module *owner;
72323 unsigned int encap;
72324 int flags;
72325 -};
72326 +} __do_const;
72327
72328 /* Flags for xfrm_mode. */
72329 enum {
72330 @@ -520,7 +520,7 @@ struct xfrm_policy {
72331 struct timer_list timer;
72332
72333 struct flow_cache_object flo;
72334 - atomic_t genid;
72335 + atomic_unchecked_t genid;
72336 u32 priority;
72337 u32 index;
72338 struct xfrm_mark mark;
72339 diff --git a/include/rdma/iw_cm.h b/include/rdma/iw_cm.h
72340 index 1a046b1..ee0bef0 100644
72341 --- a/include/rdma/iw_cm.h
72342 +++ b/include/rdma/iw_cm.h
72343 @@ -122,7 +122,7 @@ struct iw_cm_verbs {
72344 int backlog);
72345
72346 int (*destroy_listen)(struct iw_cm_id *cm_id);
72347 -};
72348 +} __no_const;
72349
72350 /**
72351 * iw_create_cm_id - Create an IW CM identifier.
72352 diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
72353 index e1379b4..67eafbe 100644
72354 --- a/include/scsi/libfc.h
72355 +++ b/include/scsi/libfc.h
72356 @@ -762,6 +762,7 @@ struct libfc_function_template {
72357 */
72358 void (*disc_stop_final) (struct fc_lport *);
72359 };
72360 +typedef struct libfc_function_template __no_const libfc_function_template_no_const;
72361
72362 /**
72363 * struct fc_disc - Discovery context
72364 @@ -866,7 +867,7 @@ struct fc_lport {
72365 struct fc_vport *vport;
72366
72367 /* Operational Information */
72368 - struct libfc_function_template tt;
72369 + libfc_function_template_no_const tt;
72370 u8 link_up;
72371 u8 qfull;
72372 enum fc_lport_state state;
72373 diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
72374 index a7f9cba..b1f44d0 100644
72375 --- a/include/scsi/scsi_device.h
72376 +++ b/include/scsi/scsi_device.h
72377 @@ -171,9 +171,9 @@ struct scsi_device {
72378 unsigned int max_device_blocked; /* what device_blocked counts down from */
72379 #define SCSI_DEFAULT_DEVICE_BLOCKED 3
72380
72381 - atomic_t iorequest_cnt;
72382 - atomic_t iodone_cnt;
72383 - atomic_t ioerr_cnt;
72384 + atomic_unchecked_t iorequest_cnt;
72385 + atomic_unchecked_t iodone_cnt;
72386 + atomic_unchecked_t ioerr_cnt;
72387
72388 struct device sdev_gendev,
72389 sdev_dev;
72390 diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
72391 index b797e8f..8e2c3aa 100644
72392 --- a/include/scsi/scsi_transport_fc.h
72393 +++ b/include/scsi/scsi_transport_fc.h
72394 @@ -751,7 +751,8 @@ struct fc_function_template {
72395 unsigned long show_host_system_hostname:1;
72396
72397 unsigned long disable_target_scan:1;
72398 -};
72399 +} __do_const;
72400 +typedef struct fc_function_template __no_const fc_function_template_no_const;
72401
72402
72403 /**
72404 diff --git a/include/sound/compress_driver.h b/include/sound/compress_driver.h
72405 index ff6c741..393815f 100644
72406 --- a/include/sound/compress_driver.h
72407 +++ b/include/sound/compress_driver.h
72408 @@ -130,7 +130,7 @@ struct snd_compr_ops {
72409 struct snd_compr_caps *caps);
72410 int (*get_codec_caps) (struct snd_compr_stream *stream,
72411 struct snd_compr_codec_caps *codec);
72412 -};
72413 +} __no_const;
72414
72415 /**
72416 * struct snd_compr: Compressed device
72417 diff --git a/include/sound/soc.h b/include/sound/soc.h
72418 index a6a059c..2243336 100644
72419 --- a/include/sound/soc.h
72420 +++ b/include/sound/soc.h
72421 @@ -771,7 +771,7 @@ struct snd_soc_codec_driver {
72422 /* probe ordering - for components with runtime dependencies */
72423 int probe_order;
72424 int remove_order;
72425 -};
72426 +} __do_const;
72427
72428 /* SoC platform interface */
72429 struct snd_soc_platform_driver {
72430 @@ -817,7 +817,7 @@ struct snd_soc_platform_driver {
72431 unsigned int (*read)(struct snd_soc_platform *, unsigned int);
72432 int (*write)(struct snd_soc_platform *, unsigned int, unsigned int);
72433 int (*bespoke_trigger)(struct snd_pcm_substream *, int);
72434 -};
72435 +} __do_const;
72436
72437 struct snd_soc_platform {
72438 const char *name;
72439 diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
72440 index c4af592..20c52d2 100644
72441 --- a/include/target/target_core_base.h
72442 +++ b/include/target/target_core_base.h
72443 @@ -657,7 +657,7 @@ struct se_device {
72444 spinlock_t stats_lock;
72445 /* Active commands on this virtual SE device */
72446 atomic_t simple_cmds;
72447 - atomic_t dev_ordered_id;
72448 + atomic_unchecked_t dev_ordered_id;
72449 atomic_t dev_ordered_sync;
72450 atomic_t dev_qf_count;
72451 int export_count;
72452 diff --git a/include/trace/events/fs.h b/include/trace/events/fs.h
72453 new file mode 100644
72454 index 0000000..fb634b7
72455 --- /dev/null
72456 +++ b/include/trace/events/fs.h
72457 @@ -0,0 +1,53 @@
72458 +#undef TRACE_SYSTEM
72459 +#define TRACE_SYSTEM fs
72460 +
72461 +#if !defined(_TRACE_FS_H) || defined(TRACE_HEADER_MULTI_READ)
72462 +#define _TRACE_FS_H
72463 +
72464 +#include <linux/fs.h>
72465 +#include <linux/tracepoint.h>
72466 +
72467 +TRACE_EVENT(do_sys_open,
72468 +
72469 + TP_PROTO(const char *filename, int flags, int mode),
72470 +
72471 + TP_ARGS(filename, flags, mode),
72472 +
72473 + TP_STRUCT__entry(
72474 + __string( filename, filename )
72475 + __field( int, flags )
72476 + __field( int, mode )
72477 + ),
72478 +
72479 + TP_fast_assign(
72480 + __assign_str(filename, filename);
72481 + __entry->flags = flags;
72482 + __entry->mode = mode;
72483 + ),
72484 +
72485 + TP_printk("\"%s\" %x %o",
72486 + __get_str(filename), __entry->flags, __entry->mode)
72487 +);
72488 +
72489 +TRACE_EVENT(open_exec,
72490 +
72491 + TP_PROTO(const char *filename),
72492 +
72493 + TP_ARGS(filename),
72494 +
72495 + TP_STRUCT__entry(
72496 + __string( filename, filename )
72497 + ),
72498 +
72499 + TP_fast_assign(
72500 + __assign_str(filename, filename);
72501 + ),
72502 +
72503 + TP_printk("\"%s\"",
72504 + __get_str(filename))
72505 +);
72506 +
72507 +#endif /* _TRACE_FS_H */
72508 +
72509 +/* This part must be outside protection */
72510 +#include <trace/define_trace.h>
72511 diff --git a/include/trace/events/irq.h b/include/trace/events/irq.h
72512 index 1c09820..7f5ec79 100644
72513 --- a/include/trace/events/irq.h
72514 +++ b/include/trace/events/irq.h
72515 @@ -36,7 +36,7 @@ struct softirq_action;
72516 */
72517 TRACE_EVENT(irq_handler_entry,
72518
72519 - TP_PROTO(int irq, struct irqaction *action),
72520 + TP_PROTO(int irq, const struct irqaction *action),
72521
72522 TP_ARGS(irq, action),
72523
72524 @@ -66,7 +66,7 @@ TRACE_EVENT(irq_handler_entry,
72525 */
72526 TRACE_EVENT(irq_handler_exit,
72527
72528 - TP_PROTO(int irq, struct irqaction *action, int ret),
72529 + TP_PROTO(int irq, const struct irqaction *action, int ret),
72530
72531 TP_ARGS(irq, action, ret),
72532
72533 diff --git a/include/uapi/linux/a.out.h b/include/uapi/linux/a.out.h
72534 index 7caf44c..23c6f27 100644
72535 --- a/include/uapi/linux/a.out.h
72536 +++ b/include/uapi/linux/a.out.h
72537 @@ -39,6 +39,14 @@ enum machine_type {
72538 M_MIPS2 = 152 /* MIPS R6000/R4000 binary */
72539 };
72540
72541 +/* Constants for the N_FLAGS field */
72542 +#define F_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
72543 +#define F_PAX_EMUTRAMP 2 /* Emulate trampolines */
72544 +#define F_PAX_MPROTECT 4 /* Restrict mprotect() */
72545 +#define F_PAX_RANDMMAP 8 /* Randomize mmap() base */
72546 +/*#define F_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
72547 +#define F_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
72548 +
72549 #if !defined (N_MAGIC)
72550 #define N_MAGIC(exec) ((exec).a_info & 0xffff)
72551 #endif
72552 diff --git a/include/uapi/linux/byteorder/little_endian.h b/include/uapi/linux/byteorder/little_endian.h
72553 index d876736..ccce5c0 100644
72554 --- a/include/uapi/linux/byteorder/little_endian.h
72555 +++ b/include/uapi/linux/byteorder/little_endian.h
72556 @@ -42,51 +42,51 @@
72557
72558 static inline __le64 __cpu_to_le64p(const __u64 *p)
72559 {
72560 - return (__force __le64)*p;
72561 + return (__force const __le64)*p;
72562 }
72563 -static inline __u64 __le64_to_cpup(const __le64 *p)
72564 +static inline __u64 __intentional_overflow(-1) __le64_to_cpup(const __le64 *p)
72565 {
72566 - return (__force __u64)*p;
72567 + return (__force const __u64)*p;
72568 }
72569 static inline __le32 __cpu_to_le32p(const __u32 *p)
72570 {
72571 - return (__force __le32)*p;
72572 + return (__force const __le32)*p;
72573 }
72574 static inline __u32 __le32_to_cpup(const __le32 *p)
72575 {
72576 - return (__force __u32)*p;
72577 + return (__force const __u32)*p;
72578 }
72579 static inline __le16 __cpu_to_le16p(const __u16 *p)
72580 {
72581 - return (__force __le16)*p;
72582 + return (__force const __le16)*p;
72583 }
72584 static inline __u16 __le16_to_cpup(const __le16 *p)
72585 {
72586 - return (__force __u16)*p;
72587 + return (__force const __u16)*p;
72588 }
72589 static inline __be64 __cpu_to_be64p(const __u64 *p)
72590 {
72591 - return (__force __be64)__swab64p(p);
72592 + return (__force const __be64)__swab64p(p);
72593 }
72594 static inline __u64 __be64_to_cpup(const __be64 *p)
72595 {
72596 - return __swab64p((__u64 *)p);
72597 + return __swab64p((const __u64 *)p);
72598 }
72599 static inline __be32 __cpu_to_be32p(const __u32 *p)
72600 {
72601 - return (__force __be32)__swab32p(p);
72602 + return (__force const __be32)__swab32p(p);
72603 }
72604 -static inline __u32 __be32_to_cpup(const __be32 *p)
72605 +static inline __u32 __intentional_overflow(-1) __be32_to_cpup(const __be32 *p)
72606 {
72607 - return __swab32p((__u32 *)p);
72608 + return __swab32p((const __u32 *)p);
72609 }
72610 static inline __be16 __cpu_to_be16p(const __u16 *p)
72611 {
72612 - return (__force __be16)__swab16p(p);
72613 + return (__force const __be16)__swab16p(p);
72614 }
72615 static inline __u16 __be16_to_cpup(const __be16 *p)
72616 {
72617 - return __swab16p((__u16 *)p);
72618 + return __swab16p((const __u16 *)p);
72619 }
72620 #define __cpu_to_le64s(x) do { (void)(x); } while (0)
72621 #define __le64_to_cpus(x) do { (void)(x); } while (0)
72622 diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h
72623 index 8072d35..e77aeb8 100644
72624 --- a/include/uapi/linux/elf.h
72625 +++ b/include/uapi/linux/elf.h
72626 @@ -37,6 +37,17 @@ typedef __s64 Elf64_Sxword;
72627 #define PT_GNU_EH_FRAME 0x6474e550
72628
72629 #define PT_GNU_STACK (PT_LOOS + 0x474e551)
72630 +#define PT_GNU_RELRO (PT_LOOS + 0x474e552)
72631 +
72632 +#define PT_PAX_FLAGS (PT_LOOS + 0x5041580)
72633 +
72634 +/* Constants for the e_flags field */
72635 +#define EF_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
72636 +#define EF_PAX_EMUTRAMP 2 /* Emulate trampolines */
72637 +#define EF_PAX_MPROTECT 4 /* Restrict mprotect() */
72638 +#define EF_PAX_RANDMMAP 8 /* Randomize mmap() base */
72639 +/*#define EF_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
72640 +#define EF_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
72641
72642 /*
72643 * Extended Numbering
72644 @@ -94,6 +105,8 @@ typedef __s64 Elf64_Sxword;
72645 #define DT_DEBUG 21
72646 #define DT_TEXTREL 22
72647 #define DT_JMPREL 23
72648 +#define DT_FLAGS 30
72649 + #define DF_TEXTREL 0x00000004
72650 #define DT_ENCODING 32
72651 #define OLD_DT_LOOS 0x60000000
72652 #define DT_LOOS 0x6000000d
72653 @@ -240,6 +253,19 @@ typedef struct elf64_hdr {
72654 #define PF_W 0x2
72655 #define PF_X 0x1
72656
72657 +#define PF_PAGEEXEC (1U << 4) /* Enable PAGEEXEC */
72658 +#define PF_NOPAGEEXEC (1U << 5) /* Disable PAGEEXEC */
72659 +#define PF_SEGMEXEC (1U << 6) /* Enable SEGMEXEC */
72660 +#define PF_NOSEGMEXEC (1U << 7) /* Disable SEGMEXEC */
72661 +#define PF_MPROTECT (1U << 8) /* Enable MPROTECT */
72662 +#define PF_NOMPROTECT (1U << 9) /* Disable MPROTECT */
72663 +/*#define PF_RANDEXEC (1U << 10)*/ /* Enable RANDEXEC */
72664 +/*#define PF_NORANDEXEC (1U << 11)*/ /* Disable RANDEXEC */
72665 +#define PF_EMUTRAMP (1U << 12) /* Enable EMUTRAMP */
72666 +#define PF_NOEMUTRAMP (1U << 13) /* Disable EMUTRAMP */
72667 +#define PF_RANDMMAP (1U << 14) /* Enable RANDMMAP */
72668 +#define PF_NORANDMMAP (1U << 15) /* Disable RANDMMAP */
72669 +
72670 typedef struct elf32_phdr{
72671 Elf32_Word p_type;
72672 Elf32_Off p_offset;
72673 @@ -332,6 +358,8 @@ typedef struct elf64_shdr {
72674 #define EI_OSABI 7
72675 #define EI_PAD 8
72676
72677 +#define EI_PAX 14
72678 +
72679 #define ELFMAG0 0x7f /* EI_MAG */
72680 #define ELFMAG1 'E'
72681 #define ELFMAG2 'L'
72682 diff --git a/include/uapi/linux/personality.h b/include/uapi/linux/personality.h
72683 index aa169c4..6a2771d 100644
72684 --- a/include/uapi/linux/personality.h
72685 +++ b/include/uapi/linux/personality.h
72686 @@ -30,6 +30,7 @@ enum {
72687 #define PER_CLEAR_ON_SETID (READ_IMPLIES_EXEC | \
72688 ADDR_NO_RANDOMIZE | \
72689 ADDR_COMPAT_LAYOUT | \
72690 + ADDR_LIMIT_3GB | \
72691 MMAP_PAGE_ZERO)
72692
72693 /*
72694 diff --git a/include/uapi/linux/screen_info.h b/include/uapi/linux/screen_info.h
72695 index 7530e74..e714828 100644
72696 --- a/include/uapi/linux/screen_info.h
72697 +++ b/include/uapi/linux/screen_info.h
72698 @@ -43,7 +43,8 @@ struct screen_info {
72699 __u16 pages; /* 0x32 */
72700 __u16 vesa_attributes; /* 0x34 */
72701 __u32 capabilities; /* 0x36 */
72702 - __u8 _reserved[6]; /* 0x3a */
72703 + __u16 vesapm_size; /* 0x3a */
72704 + __u8 _reserved[4]; /* 0x3c */
72705 } __attribute__((packed));
72706
72707 #define VIDEO_TYPE_MDA 0x10 /* Monochrome Text Display */
72708 diff --git a/include/uapi/linux/swab.h b/include/uapi/linux/swab.h
72709 index 0e011eb..82681b1 100644
72710 --- a/include/uapi/linux/swab.h
72711 +++ b/include/uapi/linux/swab.h
72712 @@ -43,7 +43,7 @@
72713 * ___swab16, ___swab32, ___swab64, ___swahw32, ___swahb32
72714 */
72715
72716 -static inline __attribute_const__ __u16 __fswab16(__u16 val)
72717 +static inline __intentional_overflow(-1) __attribute_const__ __u16 __fswab16(__u16 val)
72718 {
72719 #ifdef __HAVE_BUILTIN_BSWAP16__
72720 return __builtin_bswap16(val);
72721 @@ -54,7 +54,7 @@ static inline __attribute_const__ __u16 __fswab16(__u16 val)
72722 #endif
72723 }
72724
72725 -static inline __attribute_const__ __u32 __fswab32(__u32 val)
72726 +static inline __intentional_overflow(-1) __attribute_const__ __u32 __fswab32(__u32 val)
72727 {
72728 #ifdef __HAVE_BUILTIN_BSWAP32__
72729 return __builtin_bswap32(val);
72730 @@ -65,7 +65,7 @@ static inline __attribute_const__ __u32 __fswab32(__u32 val)
72731 #endif
72732 }
72733
72734 -static inline __attribute_const__ __u64 __fswab64(__u64 val)
72735 +static inline __intentional_overflow(-1) __attribute_const__ __u64 __fswab64(__u64 val)
72736 {
72737 #ifdef __HAVE_BUILTIN_BSWAP64__
72738 return __builtin_bswap64(val);
72739 diff --git a/include/uapi/linux/sysctl.h b/include/uapi/linux/sysctl.h
72740 index 6d67213..8dab561 100644
72741 --- a/include/uapi/linux/sysctl.h
72742 +++ b/include/uapi/linux/sysctl.h
72743 @@ -155,7 +155,11 @@ enum
72744 KERN_PANIC_ON_NMI=76, /* int: whether we will panic on an unrecovered */
72745 };
72746
72747 -
72748 +#ifdef CONFIG_PAX_SOFTMODE
72749 +enum {
72750 + PAX_SOFTMODE=1 /* PaX: disable/enable soft mode */
72751 +};
72752 +#endif
72753
72754 /* CTL_VM names: */
72755 enum
72756 diff --git a/include/uapi/linux/xattr.h b/include/uapi/linux/xattr.h
72757 index e4629b9..6958086 100644
72758 --- a/include/uapi/linux/xattr.h
72759 +++ b/include/uapi/linux/xattr.h
72760 @@ -63,5 +63,9 @@
72761 #define XATTR_POSIX_ACL_DEFAULT "posix_acl_default"
72762 #define XATTR_NAME_POSIX_ACL_DEFAULT XATTR_SYSTEM_PREFIX XATTR_POSIX_ACL_DEFAULT
72763
72764 +/* User namespace */
72765 +#define XATTR_PAX_PREFIX XATTR_USER_PREFIX "pax."
72766 +#define XATTR_PAX_FLAGS_SUFFIX "flags"
72767 +#define XATTR_NAME_PAX_FLAGS XATTR_PAX_PREFIX XATTR_PAX_FLAGS_SUFFIX
72768
72769 #endif /* _UAPI_LINUX_XATTR_H */
72770 diff --git a/include/video/udlfb.h b/include/video/udlfb.h
72771 index f9466fa..f4e2b81 100644
72772 --- a/include/video/udlfb.h
72773 +++ b/include/video/udlfb.h
72774 @@ -53,10 +53,10 @@ struct dlfb_data {
72775 u32 pseudo_palette[256];
72776 int blank_mode; /*one of FB_BLANK_ */
72777 /* blit-only rendering path metrics, exposed through sysfs */
72778 - atomic_t bytes_rendered; /* raw pixel-bytes driver asked to render */
72779 - atomic_t bytes_identical; /* saved effort with backbuffer comparison */
72780 - atomic_t bytes_sent; /* to usb, after compression including overhead */
72781 - atomic_t cpu_kcycles_used; /* transpired during pixel processing */
72782 + atomic_unchecked_t bytes_rendered; /* raw pixel-bytes driver asked to render */
72783 + atomic_unchecked_t bytes_identical; /* saved effort with backbuffer comparison */
72784 + atomic_unchecked_t bytes_sent; /* to usb, after compression including overhead */
72785 + atomic_unchecked_t cpu_kcycles_used; /* transpired during pixel processing */
72786 };
72787
72788 #define NR_USB_REQUEST_I2C_SUB_IO 0x02
72789 diff --git a/include/video/uvesafb.h b/include/video/uvesafb.h
72790 index 1a91850..28573f8 100644
72791 --- a/include/video/uvesafb.h
72792 +++ b/include/video/uvesafb.h
72793 @@ -122,6 +122,7 @@ struct uvesafb_par {
72794 u8 ypan; /* 0 - nothing, 1 - ypan, 2 - ywrap */
72795 u8 pmi_setpal; /* PMI for palette changes */
72796 u16 *pmi_base; /* protected mode interface location */
72797 + u8 *pmi_code; /* protected mode code location */
72798 void *pmi_start;
72799 void *pmi_pal;
72800 u8 *vbe_state_orig; /*
72801 diff --git a/init/Kconfig b/init/Kconfig
72802 index 5341d72..153f24f 100644
72803 --- a/init/Kconfig
72804 +++ b/init/Kconfig
72805 @@ -984,6 +984,7 @@ endif # CGROUPS
72806
72807 config CHECKPOINT_RESTORE
72808 bool "Checkpoint/restore support" if EXPERT
72809 + depends on !GRKERNSEC
72810 default n
72811 help
72812 Enables additional kernel features in a sake of checkpoint/restore.
72813 @@ -1471,7 +1472,7 @@ config SLUB_DEBUG
72814
72815 config COMPAT_BRK
72816 bool "Disable heap randomization"
72817 - default y
72818 + default n
72819 help
72820 Randomizing heap placement makes heap exploits harder, but it
72821 also breaks ancient binaries (including anything libc5 based).
72822 @@ -1734,7 +1735,7 @@ config INIT_ALL_POSSIBLE
72823 config STOP_MACHINE
72824 bool
72825 default y
72826 - depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU
72827 + depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU || GRKERNSEC
72828 help
72829 Need stop_machine() primitive.
72830
72831 diff --git a/init/Makefile b/init/Makefile
72832 index 7bc47ee..6da2dc7 100644
72833 --- a/init/Makefile
72834 +++ b/init/Makefile
72835 @@ -2,6 +2,9 @@
72836 # Makefile for the linux kernel.
72837 #
72838
72839 +ccflags-y := $(GCC_PLUGINS_CFLAGS)
72840 +asflags-y := $(GCC_PLUGINS_AFLAGS)
72841 +
72842 obj-y := main.o version.o mounts.o
72843 ifneq ($(CONFIG_BLK_DEV_INITRD),y)
72844 obj-y += noinitramfs.o
72845 diff --git a/init/do_mounts.c b/init/do_mounts.c
72846 index a2b49f2..03a0e17c 100644
72847 --- a/init/do_mounts.c
72848 +++ b/init/do_mounts.c
72849 @@ -355,11 +355,11 @@ static void __init get_fs_names(char *page)
72850 static int __init do_mount_root(char *name, char *fs, int flags, void *data)
72851 {
72852 struct super_block *s;
72853 - int err = sys_mount(name, "/root", fs, flags, data);
72854 + int err = sys_mount((char __force_user *)name, (char __force_user *)"/root", (char __force_user *)fs, flags, (void __force_user *)data);
72855 if (err)
72856 return err;
72857
72858 - sys_chdir("/root");
72859 + sys_chdir((const char __force_user *)"/root");
72860 s = current->fs->pwd.dentry->d_sb;
72861 ROOT_DEV = s->s_dev;
72862 printk(KERN_INFO
72863 @@ -480,18 +480,18 @@ void __init change_floppy(char *fmt, ...)
72864 va_start(args, fmt);
72865 vsprintf(buf, fmt, args);
72866 va_end(args);
72867 - fd = sys_open("/dev/root", O_RDWR | O_NDELAY, 0);
72868 + fd = sys_open((char __user *)"/dev/root", O_RDWR | O_NDELAY, 0);
72869 if (fd >= 0) {
72870 sys_ioctl(fd, FDEJECT, 0);
72871 sys_close(fd);
72872 }
72873 printk(KERN_NOTICE "VFS: Insert %s and press ENTER\n", buf);
72874 - fd = sys_open("/dev/console", O_RDWR, 0);
72875 + fd = sys_open((__force const char __user *)"/dev/console", O_RDWR, 0);
72876 if (fd >= 0) {
72877 sys_ioctl(fd, TCGETS, (long)&termios);
72878 termios.c_lflag &= ~ICANON;
72879 sys_ioctl(fd, TCSETSF, (long)&termios);
72880 - sys_read(fd, &c, 1);
72881 + sys_read(fd, (char __user *)&c, 1);
72882 termios.c_lflag |= ICANON;
72883 sys_ioctl(fd, TCSETSF, (long)&termios);
72884 sys_close(fd);
72885 @@ -585,6 +585,6 @@ void __init prepare_namespace(void)
72886 mount_root();
72887 out:
72888 devtmpfs_mount("dev");
72889 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
72890 - sys_chroot(".");
72891 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
72892 + sys_chroot((const char __force_user *)".");
72893 }
72894 diff --git a/init/do_mounts.h b/init/do_mounts.h
72895 index f5b978a..69dbfe8 100644
72896 --- a/init/do_mounts.h
72897 +++ b/init/do_mounts.h
72898 @@ -15,15 +15,15 @@ extern int root_mountflags;
72899
72900 static inline int create_dev(char *name, dev_t dev)
72901 {
72902 - sys_unlink(name);
72903 - return sys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
72904 + sys_unlink((char __force_user *)name);
72905 + return sys_mknod((char __force_user *)name, S_IFBLK|0600, new_encode_dev(dev));
72906 }
72907
72908 #if BITS_PER_LONG == 32
72909 static inline u32 bstat(char *name)
72910 {
72911 struct stat64 stat;
72912 - if (sys_stat64(name, &stat) != 0)
72913 + if (sys_stat64((char __force_user *)name, (struct stat64 __force_user *)&stat) != 0)
72914 return 0;
72915 if (!S_ISBLK(stat.st_mode))
72916 return 0;
72917 @@ -35,7 +35,7 @@ static inline u32 bstat(char *name)
72918 static inline u32 bstat(char *name)
72919 {
72920 struct stat stat;
72921 - if (sys_newstat(name, &stat) != 0)
72922 + if (sys_newstat((const char __force_user *)name, (struct stat __force_user *)&stat) != 0)
72923 return 0;
72924 if (!S_ISBLK(stat.st_mode))
72925 return 0;
72926 diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
72927 index a32ec1c..ac08811 100644
72928 --- a/init/do_mounts_initrd.c
72929 +++ b/init/do_mounts_initrd.c
72930 @@ -58,8 +58,8 @@ static void __init handle_initrd(void)
72931 create_dev("/dev/root.old", Root_RAM0);
72932 /* mount initrd on rootfs' /root */
72933 mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);
72934 - sys_mkdir("/old", 0700);
72935 - sys_chdir("/old");
72936 + sys_mkdir((const char __force_user *)"/old", 0700);
72937 + sys_chdir((const char __force_user *)"/old");
72938
72939 /* try loading default modules from initrd */
72940 load_default_modules();
72941 @@ -76,31 +76,31 @@ static void __init handle_initrd(void)
72942 current->flags &= ~PF_FREEZER_SKIP;
72943
72944 /* move initrd to rootfs' /old */
72945 - sys_mount("..", ".", NULL, MS_MOVE, NULL);
72946 + sys_mount((char __force_user *)"..", (char __force_user *)".", NULL, MS_MOVE, NULL);
72947 /* switch root and cwd back to / of rootfs */
72948 - sys_chroot("..");
72949 + sys_chroot((const char __force_user *)"..");
72950
72951 if (new_decode_dev(real_root_dev) == Root_RAM0) {
72952 - sys_chdir("/old");
72953 + sys_chdir((const char __force_user *)"/old");
72954 return;
72955 }
72956
72957 - sys_chdir("/");
72958 + sys_chdir((const char __force_user *)"/");
72959 ROOT_DEV = new_decode_dev(real_root_dev);
72960 mount_root();
72961
72962 printk(KERN_NOTICE "Trying to move old root to /initrd ... ");
72963 - error = sys_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL);
72964 + error = sys_mount((char __force_user *)"/old", (char __force_user *)"/root/initrd", NULL, MS_MOVE, NULL);
72965 if (!error)
72966 printk("okay\n");
72967 else {
72968 - int fd = sys_open("/dev/root.old", O_RDWR, 0);
72969 + int fd = sys_open((const char __force_user *)"/dev/root.old", O_RDWR, 0);
72970 if (error == -ENOENT)
72971 printk("/initrd does not exist. Ignored.\n");
72972 else
72973 printk("failed\n");
72974 printk(KERN_NOTICE "Unmounting old root\n");
72975 - sys_umount("/old", MNT_DETACH);
72976 + sys_umount((char __force_user *)"/old", MNT_DETACH);
72977 printk(KERN_NOTICE "Trying to free ramdisk memory ... ");
72978 if (fd < 0) {
72979 error = fd;
72980 @@ -123,11 +123,11 @@ int __init initrd_load(void)
72981 * mounted in the normal path.
72982 */
72983 if (rd_load_image("/initrd.image") && ROOT_DEV != Root_RAM0) {
72984 - sys_unlink("/initrd.image");
72985 + sys_unlink((const char __force_user *)"/initrd.image");
72986 handle_initrd();
72987 return 1;
72988 }
72989 }
72990 - sys_unlink("/initrd.image");
72991 + sys_unlink((const char __force_user *)"/initrd.image");
72992 return 0;
72993 }
72994 diff --git a/init/do_mounts_md.c b/init/do_mounts_md.c
72995 index 8cb6db5..d729f50 100644
72996 --- a/init/do_mounts_md.c
72997 +++ b/init/do_mounts_md.c
72998 @@ -180,7 +180,7 @@ static void __init md_setup_drive(void)
72999 partitioned ? "_d" : "", minor,
73000 md_setup_args[ent].device_names);
73001
73002 - fd = sys_open(name, 0, 0);
73003 + fd = sys_open((char __force_user *)name, 0, 0);
73004 if (fd < 0) {
73005 printk(KERN_ERR "md: open failed - cannot start "
73006 "array %s\n", name);
73007 @@ -243,7 +243,7 @@ static void __init md_setup_drive(void)
73008 * array without it
73009 */
73010 sys_close(fd);
73011 - fd = sys_open(name, 0, 0);
73012 + fd = sys_open((char __force_user *)name, 0, 0);
73013 sys_ioctl(fd, BLKRRPART, 0);
73014 }
73015 sys_close(fd);
73016 @@ -293,7 +293,7 @@ static void __init autodetect_raid(void)
73017
73018 wait_for_device_probe();
73019
73020 - fd = sys_open("/dev/md0", 0, 0);
73021 + fd = sys_open((const char __force_user *) "/dev/md0", 0, 0);
73022 if (fd >= 0) {
73023 sys_ioctl(fd, RAID_AUTORUN, raid_autopart);
73024 sys_close(fd);
73025 diff --git a/init/init_task.c b/init/init_task.c
73026 index ba0a7f36..2bcf1d5 100644
73027 --- a/init/init_task.c
73028 +++ b/init/init_task.c
73029 @@ -22,5 +22,9 @@ EXPORT_SYMBOL(init_task);
73030 * Initial thread structure. Alignment of this is handled by a special
73031 * linker map entry.
73032 */
73033 +#ifdef CONFIG_X86
73034 +union thread_union init_thread_union __init_task_data;
73035 +#else
73036 union thread_union init_thread_union __init_task_data =
73037 { INIT_THREAD_INFO(init_task) };
73038 +#endif
73039 diff --git a/init/initramfs.c b/init/initramfs.c
73040 index a67ef9d..3d88592 100644
73041 --- a/init/initramfs.c
73042 +++ b/init/initramfs.c
73043 @@ -84,7 +84,7 @@ static void __init free_hash(void)
73044 }
73045 }
73046
73047 -static long __init do_utime(char *filename, time_t mtime)
73048 +static long __init do_utime(char __force_user *filename, time_t mtime)
73049 {
73050 struct timespec t[2];
73051
73052 @@ -119,7 +119,7 @@ static void __init dir_utime(void)
73053 struct dir_entry *de, *tmp;
73054 list_for_each_entry_safe(de, tmp, &dir_list, list) {
73055 list_del(&de->list);
73056 - do_utime(de->name, de->mtime);
73057 + do_utime((char __force_user *)de->name, de->mtime);
73058 kfree(de->name);
73059 kfree(de);
73060 }
73061 @@ -281,7 +281,7 @@ static int __init maybe_link(void)
73062 if (nlink >= 2) {
73063 char *old = find_link(major, minor, ino, mode, collected);
73064 if (old)
73065 - return (sys_link(old, collected) < 0) ? -1 : 1;
73066 + return (sys_link((char __force_user *)old, (char __force_user *)collected) < 0) ? -1 : 1;
73067 }
73068 return 0;
73069 }
73070 @@ -290,11 +290,11 @@ static void __init clean_path(char *path, umode_t mode)
73071 {
73072 struct stat st;
73073
73074 - if (!sys_newlstat(path, &st) && (st.st_mode^mode) & S_IFMT) {
73075 + if (!sys_newlstat((char __force_user *)path, (struct stat __force_user *)&st) && (st.st_mode^mode) & S_IFMT) {
73076 if (S_ISDIR(st.st_mode))
73077 - sys_rmdir(path);
73078 + sys_rmdir((char __force_user *)path);
73079 else
73080 - sys_unlink(path);
73081 + sys_unlink((char __force_user *)path);
73082 }
73083 }
73084
73085 @@ -315,7 +315,7 @@ static int __init do_name(void)
73086 int openflags = O_WRONLY|O_CREAT;
73087 if (ml != 1)
73088 openflags |= O_TRUNC;
73089 - wfd = sys_open(collected, openflags, mode);
73090 + wfd = sys_open((char __force_user *)collected, openflags, mode);
73091
73092 if (wfd >= 0) {
73093 sys_fchown(wfd, uid, gid);
73094 @@ -327,17 +327,17 @@ static int __init do_name(void)
73095 }
73096 }
73097 } else if (S_ISDIR(mode)) {
73098 - sys_mkdir(collected, mode);
73099 - sys_chown(collected, uid, gid);
73100 - sys_chmod(collected, mode);
73101 + sys_mkdir((char __force_user *)collected, mode);
73102 + sys_chown((char __force_user *)collected, uid, gid);
73103 + sys_chmod((char __force_user *)collected, mode);
73104 dir_add(collected, mtime);
73105 } else if (S_ISBLK(mode) || S_ISCHR(mode) ||
73106 S_ISFIFO(mode) || S_ISSOCK(mode)) {
73107 if (maybe_link() == 0) {
73108 - sys_mknod(collected, mode, rdev);
73109 - sys_chown(collected, uid, gid);
73110 - sys_chmod(collected, mode);
73111 - do_utime(collected, mtime);
73112 + sys_mknod((char __force_user *)collected, mode, rdev);
73113 + sys_chown((char __force_user *)collected, uid, gid);
73114 + sys_chmod((char __force_user *)collected, mode);
73115 + do_utime((char __force_user *)collected, mtime);
73116 }
73117 }
73118 return 0;
73119 @@ -346,15 +346,15 @@ static int __init do_name(void)
73120 static int __init do_copy(void)
73121 {
73122 if (count >= body_len) {
73123 - sys_write(wfd, victim, body_len);
73124 + sys_write(wfd, (char __force_user *)victim, body_len);
73125 sys_close(wfd);
73126 - do_utime(vcollected, mtime);
73127 + do_utime((char __force_user *)vcollected, mtime);
73128 kfree(vcollected);
73129 eat(body_len);
73130 state = SkipIt;
73131 return 0;
73132 } else {
73133 - sys_write(wfd, victim, count);
73134 + sys_write(wfd, (char __force_user *)victim, count);
73135 body_len -= count;
73136 eat(count);
73137 return 1;
73138 @@ -365,9 +365,9 @@ static int __init do_symlink(void)
73139 {
73140 collected[N_ALIGN(name_len) + body_len] = '\0';
73141 clean_path(collected, 0);
73142 - sys_symlink(collected + N_ALIGN(name_len), collected);
73143 - sys_lchown(collected, uid, gid);
73144 - do_utime(collected, mtime);
73145 + sys_symlink((char __force_user *)collected + N_ALIGN(name_len), (char __force_user *)collected);
73146 + sys_lchown((char __force_user *)collected, uid, gid);
73147 + do_utime((char __force_user *)collected, mtime);
73148 state = SkipIt;
73149 next_state = Reset;
73150 return 0;
73151 diff --git a/init/main.c b/init/main.c
73152 index 63534a1..8abcaf1 100644
73153 --- a/init/main.c
73154 +++ b/init/main.c
73155 @@ -98,6 +98,8 @@ static inline void mark_rodata_ro(void) { }
73156 extern void tc_init(void);
73157 #endif
73158
73159 +extern void grsecurity_init(void);
73160 +
73161 /*
73162 * Debug helper: via this flag we know that we are in 'early bootup code'
73163 * where only the boot processor is running with IRQ disabled. This means
73164 @@ -151,6 +153,64 @@ static int __init set_reset_devices(char *str)
73165
73166 __setup("reset_devices", set_reset_devices);
73167
73168 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
73169 +kgid_t grsec_proc_gid = KGIDT_INIT(CONFIG_GRKERNSEC_PROC_GID);
73170 +static int __init setup_grsec_proc_gid(char *str)
73171 +{
73172 + grsec_proc_gid = KGIDT_INIT(simple_strtol(str, NULL, 0));
73173 + return 1;
73174 +}
73175 +__setup("grsec_proc_gid=", setup_grsec_proc_gid);
73176 +#endif
73177 +
73178 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
73179 +unsigned long pax_user_shadow_base __read_only = 1UL << TASK_SIZE_MAX_SHIFT;
73180 +EXPORT_SYMBOL(pax_user_shadow_base);
73181 +extern char pax_enter_kernel_user[];
73182 +extern char pax_exit_kernel_user[];
73183 +extern pgdval_t clone_pgd_mask;
73184 +#endif
73185 +
73186 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_MEMORY_UDEREF)
73187 +static int __init setup_pax_nouderef(char *str)
73188 +{
73189 +#ifdef CONFIG_X86_32
73190 + unsigned int cpu;
73191 + struct desc_struct *gdt;
73192 +
73193 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
73194 + gdt = get_cpu_gdt_table(cpu);
73195 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
73196 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
73197 + gdt[GDT_ENTRY_DEFAULT_USER_CS].limit = 0xf;
73198 + gdt[GDT_ENTRY_DEFAULT_USER_DS].limit = 0xf;
73199 + }
73200 + loadsegment(ds, __KERNEL_DS);
73201 + loadsegment(es, __KERNEL_DS);
73202 + loadsegment(ss, __KERNEL_DS);
73203 +#else
73204 + memcpy(pax_enter_kernel_user, (unsigned char []){0xc3}, 1);
73205 + memcpy(pax_exit_kernel_user, (unsigned char []){0xc3}, 1);
73206 + clone_pgd_mask = ~(pgdval_t)0UL;
73207 + pax_user_shadow_base = 0UL;
73208 +#endif
73209 +
73210 + return 0;
73211 +}
73212 +early_param("pax_nouderef", setup_pax_nouderef);
73213 +#endif
73214 +
73215 +#ifdef CONFIG_PAX_SOFTMODE
73216 +int pax_softmode;
73217 +
73218 +static int __init setup_pax_softmode(char *str)
73219 +{
73220 + get_option(&str, &pax_softmode);
73221 + return 1;
73222 +}
73223 +__setup("pax_softmode=", setup_pax_softmode);
73224 +#endif
73225 +
73226 static const char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
73227 const char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
73228 static const char *panic_later, *panic_param;
73229 @@ -683,6 +743,7 @@ int __init_or_module do_one_initcall(initcall_t fn)
73230 {
73231 int count = preempt_count();
73232 int ret;
73233 + const char *msg1 = "", *msg2 = "";
73234
73235 if (initcall_debug)
73236 ret = do_one_initcall_debug(fn);
73237 @@ -695,15 +756,15 @@ int __init_or_module do_one_initcall(initcall_t fn)
73238 sprintf(msgbuf, "error code %d ", ret);
73239
73240 if (preempt_count() != count) {
73241 - strlcat(msgbuf, "preemption imbalance ", sizeof(msgbuf));
73242 + msg1 = " preemption imbalance";
73243 preempt_count() = count;
73244 }
73245 if (irqs_disabled()) {
73246 - strlcat(msgbuf, "disabled interrupts ", sizeof(msgbuf));
73247 + msg2 = " disabled interrupts";
73248 local_irq_enable();
73249 }
73250 - if (msgbuf[0]) {
73251 - printk("initcall %pF returned with %s\n", fn, msgbuf);
73252 + if (msgbuf[0] || *msg1 || *msg2) {
73253 + printk("initcall %pF returned with %s%s%s\n", fn, msgbuf, msg1, msg2);
73254 }
73255
73256 return ret;
73257 @@ -757,8 +818,14 @@ static void __init do_initcall_level(int level)
73258 level, level,
73259 &repair_env_string);
73260
73261 - for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++)
73262 + for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++) {
73263 do_one_initcall(*fn);
73264 +
73265 +#ifdef LATENT_ENTROPY_PLUGIN
73266 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
73267 +#endif
73268 +
73269 + }
73270 }
73271
73272 static void __init do_initcalls(void)
73273 @@ -792,8 +859,14 @@ static void __init do_pre_smp_initcalls(void)
73274 {
73275 initcall_t *fn;
73276
73277 - for (fn = __initcall_start; fn < __initcall0_start; fn++)
73278 + for (fn = __initcall_start; fn < __initcall0_start; fn++) {
73279 do_one_initcall(*fn);
73280 +
73281 +#ifdef LATENT_ENTROPY_PLUGIN
73282 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
73283 +#endif
73284 +
73285 + }
73286 }
73287
73288 /*
73289 @@ -890,7 +963,7 @@ static noinline void __init kernel_init_freeable(void)
73290 do_basic_setup();
73291
73292 /* Open the /dev/console on the rootfs, this should never fail */
73293 - if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
73294 + if (sys_open((const char __force_user *) "/dev/console", O_RDWR, 0) < 0)
73295 printk(KERN_WARNING "Warning: unable to open an initial console.\n");
73296
73297 (void) sys_dup(0);
73298 @@ -903,11 +976,13 @@ static noinline void __init kernel_init_freeable(void)
73299 if (!ramdisk_execute_command)
73300 ramdisk_execute_command = "/init";
73301
73302 - if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
73303 + if (sys_access((const char __force_user *) ramdisk_execute_command, 0) != 0) {
73304 ramdisk_execute_command = NULL;
73305 prepare_namespace();
73306 }
73307
73308 + grsecurity_init();
73309 +
73310 /*
73311 * Ok, we have completed the initial bootup, and
73312 * we're essentially up and running. Get rid of the
73313 diff --git a/ipc/ipc_sysctl.c b/ipc/ipc_sysctl.c
73314 index 130dfec..cc88451 100644
73315 --- a/ipc/ipc_sysctl.c
73316 +++ b/ipc/ipc_sysctl.c
73317 @@ -30,7 +30,7 @@ static void *get_ipc(ctl_table *table)
73318 static int proc_ipc_dointvec(ctl_table *table, int write,
73319 void __user *buffer, size_t *lenp, loff_t *ppos)
73320 {
73321 - struct ctl_table ipc_table;
73322 + ctl_table_no_const ipc_table;
73323
73324 memcpy(&ipc_table, table, sizeof(ipc_table));
73325 ipc_table.data = get_ipc(table);
73326 @@ -41,7 +41,7 @@ static int proc_ipc_dointvec(ctl_table *table, int write,
73327 static int proc_ipc_dointvec_minmax(ctl_table *table, int write,
73328 void __user *buffer, size_t *lenp, loff_t *ppos)
73329 {
73330 - struct ctl_table ipc_table;
73331 + ctl_table_no_const ipc_table;
73332
73333 memcpy(&ipc_table, table, sizeof(ipc_table));
73334 ipc_table.data = get_ipc(table);
73335 @@ -65,7 +65,7 @@ static int proc_ipc_dointvec_minmax_orphans(ctl_table *table, int write,
73336 static int proc_ipc_callback_dointvec(ctl_table *table, int write,
73337 void __user *buffer, size_t *lenp, loff_t *ppos)
73338 {
73339 - struct ctl_table ipc_table;
73340 + ctl_table_no_const ipc_table;
73341 size_t lenp_bef = *lenp;
73342 int rc;
73343
73344 @@ -88,7 +88,7 @@ static int proc_ipc_callback_dointvec(ctl_table *table, int write,
73345 static int proc_ipc_doulongvec_minmax(ctl_table *table, int write,
73346 void __user *buffer, size_t *lenp, loff_t *ppos)
73347 {
73348 - struct ctl_table ipc_table;
73349 + ctl_table_no_const ipc_table;
73350 memcpy(&ipc_table, table, sizeof(ipc_table));
73351 ipc_table.data = get_ipc(table);
73352
73353 @@ -122,7 +122,7 @@ static void ipc_auto_callback(int val)
73354 static int proc_ipcauto_dointvec_minmax(ctl_table *table, int write,
73355 void __user *buffer, size_t *lenp, loff_t *ppos)
73356 {
73357 - struct ctl_table ipc_table;
73358 + ctl_table_no_const ipc_table;
73359 size_t lenp_bef = *lenp;
73360 int oldval;
73361 int rc;
73362 diff --git a/ipc/mq_sysctl.c b/ipc/mq_sysctl.c
73363 index 383d638..943fdbb 100644
73364 --- a/ipc/mq_sysctl.c
73365 +++ b/ipc/mq_sysctl.c
73366 @@ -25,7 +25,7 @@ static void *get_mq(ctl_table *table)
73367 static int proc_mq_dointvec_minmax(ctl_table *table, int write,
73368 void __user *buffer, size_t *lenp, loff_t *ppos)
73369 {
73370 - struct ctl_table mq_table;
73371 + ctl_table_no_const mq_table;
73372 memcpy(&mq_table, table, sizeof(mq_table));
73373 mq_table.data = get_mq(table);
73374
73375 diff --git a/ipc/mqueue.c b/ipc/mqueue.c
73376 index e4e47f6..a85e0ad 100644
73377 --- a/ipc/mqueue.c
73378 +++ b/ipc/mqueue.c
73379 @@ -278,6 +278,7 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
73380 mq_bytes = mq_treesize + (info->attr.mq_maxmsg *
73381 info->attr.mq_msgsize);
73382
73383 + gr_learn_resource(current, RLIMIT_MSGQUEUE, u->mq_bytes + mq_bytes, 1);
73384 spin_lock(&mq_lock);
73385 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
73386 u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE)) {
73387 diff --git a/ipc/msg.c b/ipc/msg.c
73388 index fede1d0..9778e0f8 100644
73389 --- a/ipc/msg.c
73390 +++ b/ipc/msg.c
73391 @@ -309,18 +309,19 @@ static inline int msg_security(struct kern_ipc_perm *ipcp, int msgflg)
73392 return security_msg_queue_associate(msq, msgflg);
73393 }
73394
73395 +static struct ipc_ops msg_ops = {
73396 + .getnew = newque,
73397 + .associate = msg_security,
73398 + .more_checks = NULL
73399 +};
73400 +
73401 SYSCALL_DEFINE2(msgget, key_t, key, int, msgflg)
73402 {
73403 struct ipc_namespace *ns;
73404 - struct ipc_ops msg_ops;
73405 struct ipc_params msg_params;
73406
73407 ns = current->nsproxy->ipc_ns;
73408
73409 - msg_ops.getnew = newque;
73410 - msg_ops.associate = msg_security;
73411 - msg_ops.more_checks = NULL;
73412 -
73413 msg_params.key = key;
73414 msg_params.flg = msgflg;
73415
73416 diff --git a/ipc/sem.c b/ipc/sem.c
73417 index 58d31f1..cce7a55 100644
73418 --- a/ipc/sem.c
73419 +++ b/ipc/sem.c
73420 @@ -364,10 +364,15 @@ static inline int sem_more_checks(struct kern_ipc_perm *ipcp,
73421 return 0;
73422 }
73423
73424 +static struct ipc_ops sem_ops = {
73425 + .getnew = newary,
73426 + .associate = sem_security,
73427 + .more_checks = sem_more_checks
73428 +};
73429 +
73430 SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
73431 {
73432 struct ipc_namespace *ns;
73433 - struct ipc_ops sem_ops;
73434 struct ipc_params sem_params;
73435
73436 ns = current->nsproxy->ipc_ns;
73437 @@ -375,10 +380,6 @@ SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
73438 if (nsems < 0 || nsems > ns->sc_semmsl)
73439 return -EINVAL;
73440
73441 - sem_ops.getnew = newary;
73442 - sem_ops.associate = sem_security;
73443 - sem_ops.more_checks = sem_more_checks;
73444 -
73445 sem_params.key = key;
73446 sem_params.flg = semflg;
73447 sem_params.u.nsems = nsems;
73448 diff --git a/ipc/shm.c b/ipc/shm.c
73449 index 7e199fa..180a1ca 100644
73450 --- a/ipc/shm.c
73451 +++ b/ipc/shm.c
73452 @@ -69,6 +69,14 @@ static void shm_destroy (struct ipc_namespace *ns, struct shmid_kernel *shp);
73453 static int sysvipc_shm_proc_show(struct seq_file *s, void *it);
73454 #endif
73455
73456 +#ifdef CONFIG_GRKERNSEC
73457 +extern int gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
73458 + const time_t shm_createtime, const kuid_t cuid,
73459 + const int shmid);
73460 +extern int gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
73461 + const time_t shm_createtime);
73462 +#endif
73463 +
73464 void shm_init_ns(struct ipc_namespace *ns)
73465 {
73466 ns->shm_ctlmax = SHMMAX;
73467 @@ -531,6 +539,14 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
73468 shp->shm_lprid = 0;
73469 shp->shm_atim = shp->shm_dtim = 0;
73470 shp->shm_ctim = get_seconds();
73471 +#ifdef CONFIG_GRKERNSEC
73472 + {
73473 + struct timespec timeval;
73474 + do_posix_clock_monotonic_gettime(&timeval);
73475 +
73476 + shp->shm_createtime = timeval.tv_sec;
73477 + }
73478 +#endif
73479 shp->shm_segsz = size;
73480 shp->shm_nattch = 0;
73481 shp->shm_file = file;
73482 @@ -582,18 +598,19 @@ static inline int shm_more_checks(struct kern_ipc_perm *ipcp,
73483 return 0;
73484 }
73485
73486 +static struct ipc_ops shm_ops = {
73487 + .getnew = newseg,
73488 + .associate = shm_security,
73489 + .more_checks = shm_more_checks
73490 +};
73491 +
73492 SYSCALL_DEFINE3(shmget, key_t, key, size_t, size, int, shmflg)
73493 {
73494 struct ipc_namespace *ns;
73495 - struct ipc_ops shm_ops;
73496 struct ipc_params shm_params;
73497
73498 ns = current->nsproxy->ipc_ns;
73499
73500 - shm_ops.getnew = newseg;
73501 - shm_ops.associate = shm_security;
73502 - shm_ops.more_checks = shm_more_checks;
73503 -
73504 shm_params.key = key;
73505 shm_params.flg = shmflg;
73506 shm_params.u.size = size;
73507 @@ -1014,6 +1031,12 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
73508 f_mode = FMODE_READ | FMODE_WRITE;
73509 }
73510 if (shmflg & SHM_EXEC) {
73511 +
73512 +#ifdef CONFIG_PAX_MPROTECT
73513 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
73514 + goto out;
73515 +#endif
73516 +
73517 prot |= PROT_EXEC;
73518 acc_mode |= S_IXUGO;
73519 }
73520 @@ -1037,9 +1060,21 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
73521 if (err)
73522 goto out_unlock;
73523
73524 +#ifdef CONFIG_GRKERNSEC
73525 + if (!gr_handle_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime,
73526 + shp->shm_perm.cuid, shmid) ||
73527 + !gr_chroot_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime)) {
73528 + err = -EACCES;
73529 + goto out_unlock;
73530 + }
73531 +#endif
73532 +
73533 path = shp->shm_file->f_path;
73534 path_get(&path);
73535 shp->shm_nattch++;
73536 +#ifdef CONFIG_GRKERNSEC
73537 + shp->shm_lapid = current->pid;
73538 +#endif
73539 size = i_size_read(path.dentry->d_inode);
73540 shm_unlock(shp);
73541
73542 diff --git a/kernel/acct.c b/kernel/acct.c
73543 index b9bd7f0..1762b4a 100644
73544 --- a/kernel/acct.c
73545 +++ b/kernel/acct.c
73546 @@ -550,7 +550,7 @@ static void do_acct_process(struct bsd_acct_struct *acct,
73547 */
73548 flim = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;
73549 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
73550 - file->f_op->write(file, (char *)&ac,
73551 + file->f_op->write(file, (char __force_user *)&ac,
73552 sizeof(acct_t), &file->f_pos);
73553 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = flim;
73554 set_fs(fs);
73555 diff --git a/kernel/audit.c b/kernel/audit.c
73556 index d596e53..dbef3c3 100644
73557 --- a/kernel/audit.c
73558 +++ b/kernel/audit.c
73559 @@ -116,7 +116,7 @@ u32 audit_sig_sid = 0;
73560 3) suppressed due to audit_rate_limit
73561 4) suppressed due to audit_backlog_limit
73562 */
73563 -static atomic_t audit_lost = ATOMIC_INIT(0);
73564 +static atomic_unchecked_t audit_lost = ATOMIC_INIT(0);
73565
73566 /* The netlink socket. */
73567 static struct sock *audit_sock;
73568 @@ -238,7 +238,7 @@ void audit_log_lost(const char *message)
73569 unsigned long now;
73570 int print;
73571
73572 - atomic_inc(&audit_lost);
73573 + atomic_inc_unchecked(&audit_lost);
73574
73575 print = (audit_failure == AUDIT_FAIL_PANIC || !audit_rate_limit);
73576
73577 @@ -257,7 +257,7 @@ void audit_log_lost(const char *message)
73578 printk(KERN_WARNING
73579 "audit: audit_lost=%d audit_rate_limit=%d "
73580 "audit_backlog_limit=%d\n",
73581 - atomic_read(&audit_lost),
73582 + atomic_read_unchecked(&audit_lost),
73583 audit_rate_limit,
73584 audit_backlog_limit);
73585 audit_panic(message);
73586 @@ -681,7 +681,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
73587 status_set.pid = audit_pid;
73588 status_set.rate_limit = audit_rate_limit;
73589 status_set.backlog_limit = audit_backlog_limit;
73590 - status_set.lost = atomic_read(&audit_lost);
73591 + status_set.lost = atomic_read_unchecked(&audit_lost);
73592 status_set.backlog = skb_queue_len(&audit_skb_queue);
73593 audit_send_reply(NETLINK_CB(skb).portid, seq, AUDIT_GET, 0, 0,
73594 &status_set, sizeof(status_set));
73595 diff --git a/kernel/auditsc.c b/kernel/auditsc.c
73596 index c4b72b0..8654c4e 100644
73597 --- a/kernel/auditsc.c
73598 +++ b/kernel/auditsc.c
73599 @@ -2295,7 +2295,7 @@ int auditsc_get_stamp(struct audit_context *ctx,
73600 }
73601
73602 /* global counter which is incremented every time something logs in */
73603 -static atomic_t session_id = ATOMIC_INIT(0);
73604 +static atomic_unchecked_t session_id = ATOMIC_INIT(0);
73605
73606 /**
73607 * audit_set_loginuid - set current task's audit_context loginuid
73608 @@ -2319,7 +2319,7 @@ int audit_set_loginuid(kuid_t loginuid)
73609 return -EPERM;
73610 #endif /* CONFIG_AUDIT_LOGINUID_IMMUTABLE */
73611
73612 - sessionid = atomic_inc_return(&session_id);
73613 + sessionid = atomic_inc_return_unchecked(&session_id);
73614 if (context && context->in_syscall) {
73615 struct audit_buffer *ab;
73616
73617 diff --git a/kernel/capability.c b/kernel/capability.c
73618 index f6c2ce5..982c0f9 100644
73619 --- a/kernel/capability.c
73620 +++ b/kernel/capability.c
73621 @@ -202,6 +202,9 @@ SYSCALL_DEFINE2(capget, cap_user_header_t, header, cap_user_data_t, dataptr)
73622 * before modification is attempted and the application
73623 * fails.
73624 */
73625 + if (tocopy > ARRAY_SIZE(kdata))
73626 + return -EFAULT;
73627 +
73628 if (copy_to_user(dataptr, kdata, tocopy
73629 * sizeof(struct __user_cap_data_struct))) {
73630 return -EFAULT;
73631 @@ -303,10 +306,11 @@ bool has_ns_capability(struct task_struct *t,
73632 int ret;
73633
73634 rcu_read_lock();
73635 - ret = security_capable(__task_cred(t), ns, cap);
73636 + ret = security_capable(__task_cred(t), ns, cap) == 0 &&
73637 + gr_task_is_capable(t, __task_cred(t), cap);
73638 rcu_read_unlock();
73639
73640 - return (ret == 0);
73641 + return ret;
73642 }
73643
73644 /**
73645 @@ -343,10 +347,10 @@ bool has_ns_capability_noaudit(struct task_struct *t,
73646 int ret;
73647
73648 rcu_read_lock();
73649 - ret = security_capable_noaudit(__task_cred(t), ns, cap);
73650 + ret = security_capable_noaudit(__task_cred(t), ns, cap) == 0 && gr_task_is_capable_nolog(t, cap);
73651 rcu_read_unlock();
73652
73653 - return (ret == 0);
73654 + return ret;
73655 }
73656
73657 /**
73658 @@ -384,7 +388,7 @@ bool ns_capable(struct user_namespace *ns, int cap)
73659 BUG();
73660 }
73661
73662 - if (security_capable(current_cred(), ns, cap) == 0) {
73663 + if (security_capable(current_cred(), ns, cap) == 0 && gr_is_capable(cap)) {
73664 current->flags |= PF_SUPERPRIV;
73665 return true;
73666 }
73667 @@ -392,6 +396,21 @@ bool ns_capable(struct user_namespace *ns, int cap)
73668 }
73669 EXPORT_SYMBOL(ns_capable);
73670
73671 +bool ns_capable_nolog(struct user_namespace *ns, int cap)
73672 +{
73673 + if (unlikely(!cap_valid(cap))) {
73674 + printk(KERN_CRIT "capable_nolog() called with invalid cap=%u\n", cap);
73675 + BUG();
73676 + }
73677 +
73678 + if (security_capable_noaudit(current_cred(), ns, cap) == 0 && gr_is_capable_nolog(cap)) {
73679 + current->flags |= PF_SUPERPRIV;
73680 + return true;
73681 + }
73682 + return false;
73683 +}
73684 +EXPORT_SYMBOL(ns_capable_nolog);
73685 +
73686 /**
73687 * file_ns_capable - Determine if the file's opener had a capability in effect
73688 * @file: The file we want to check
73689 @@ -432,6 +451,12 @@ bool capable(int cap)
73690 }
73691 EXPORT_SYMBOL(capable);
73692
73693 +bool capable_nolog(int cap)
73694 +{
73695 + return ns_capable_nolog(&init_user_ns, cap);
73696 +}
73697 +EXPORT_SYMBOL(capable_nolog);
73698 +
73699 /**
73700 * nsown_capable - Check superior capability to one's own user_ns
73701 * @cap: The capability in question
73702 @@ -464,3 +489,10 @@ bool inode_capable(const struct inode *inode, int cap)
73703
73704 return ns_capable(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
73705 }
73706 +
73707 +bool inode_capable_nolog(const struct inode *inode, int cap)
73708 +{
73709 + struct user_namespace *ns = current_user_ns();
73710 +
73711 + return ns_capable_nolog(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
73712 +}
73713 diff --git a/kernel/cgroup.c b/kernel/cgroup.c
73714 index ba1f977..f840d9c 100644
73715 --- a/kernel/cgroup.c
73716 +++ b/kernel/cgroup.c
73717 @@ -5569,7 +5569,7 @@ static int cgroup_css_links_read(struct cgroup *cont,
73718 struct css_set *cg = link->cg;
73719 struct task_struct *task;
73720 int count = 0;
73721 - seq_printf(seq, "css_set %p\n", cg);
73722 + seq_printf(seq, "css_set %pK\n", cg);
73723 list_for_each_entry(task, &cg->tasks, cg_list) {
73724 if (count++ > MAX_TASKS_SHOWN_PER_CSS) {
73725 seq_puts(seq, " ...\n");
73726 diff --git a/kernel/compat.c b/kernel/compat.c
73727 index 19971d8..02fe2df 100644
73728 --- a/kernel/compat.c
73729 +++ b/kernel/compat.c
73730 @@ -13,6 +13,7 @@
73731
73732 #include <linux/linkage.h>
73733 #include <linux/compat.h>
73734 +#include <linux/module.h>
73735 #include <linux/errno.h>
73736 #include <linux/time.h>
73737 #include <linux/signal.h>
73738 @@ -220,7 +221,7 @@ static long compat_nanosleep_restart(struct restart_block *restart)
73739 mm_segment_t oldfs;
73740 long ret;
73741
73742 - restart->nanosleep.rmtp = (struct timespec __user *) &rmt;
73743 + restart->nanosleep.rmtp = (struct timespec __force_user *) &rmt;
73744 oldfs = get_fs();
73745 set_fs(KERNEL_DS);
73746 ret = hrtimer_nanosleep_restart(restart);
73747 @@ -252,7 +253,7 @@ asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp,
73748 oldfs = get_fs();
73749 set_fs(KERNEL_DS);
73750 ret = hrtimer_nanosleep(&tu,
73751 - rmtp ? (struct timespec __user *)&rmt : NULL,
73752 + rmtp ? (struct timespec __force_user *)&rmt : NULL,
73753 HRTIMER_MODE_REL, CLOCK_MONOTONIC);
73754 set_fs(oldfs);
73755
73756 @@ -361,7 +362,7 @@ asmlinkage long compat_sys_sigpending(compat_old_sigset_t __user *set)
73757 mm_segment_t old_fs = get_fs();
73758
73759 set_fs(KERNEL_DS);
73760 - ret = sys_sigpending((old_sigset_t __user *) &s);
73761 + ret = sys_sigpending((old_sigset_t __force_user *) &s);
73762 set_fs(old_fs);
73763 if (ret == 0)
73764 ret = put_user(s, set);
73765 @@ -451,7 +452,7 @@ asmlinkage long compat_sys_old_getrlimit(unsigned int resource,
73766 mm_segment_t old_fs = get_fs();
73767
73768 set_fs(KERNEL_DS);
73769 - ret = sys_old_getrlimit(resource, &r);
73770 + ret = sys_old_getrlimit(resource, (struct rlimit __force_user *)&r);
73771 set_fs(old_fs);
73772
73773 if (!ret) {
73774 @@ -523,7 +524,7 @@ asmlinkage long compat_sys_getrusage(int who, struct compat_rusage __user *ru)
73775 mm_segment_t old_fs = get_fs();
73776
73777 set_fs(KERNEL_DS);
73778 - ret = sys_getrusage(who, (struct rusage __user *) &r);
73779 + ret = sys_getrusage(who, (struct rusage __force_user *) &r);
73780 set_fs(old_fs);
73781
73782 if (ret)
73783 @@ -552,8 +553,8 @@ COMPAT_SYSCALL_DEFINE4(wait4,
73784 set_fs (KERNEL_DS);
73785 ret = sys_wait4(pid,
73786 (stat_addr ?
73787 - (unsigned int __user *) &status : NULL),
73788 - options, (struct rusage __user *) &r);
73789 + (unsigned int __force_user *) &status : NULL),
73790 + options, (struct rusage __force_user *) &r);
73791 set_fs (old_fs);
73792
73793 if (ret > 0) {
73794 @@ -579,8 +580,8 @@ COMPAT_SYSCALL_DEFINE5(waitid,
73795 memset(&info, 0, sizeof(info));
73796
73797 set_fs(KERNEL_DS);
73798 - ret = sys_waitid(which, pid, (siginfo_t __user *)&info, options,
73799 - uru ? (struct rusage __user *)&ru : NULL);
73800 + ret = sys_waitid(which, pid, (siginfo_t __force_user *)&info, options,
73801 + uru ? (struct rusage __force_user *)&ru : NULL);
73802 set_fs(old_fs);
73803
73804 if ((ret < 0) || (info.si_signo == 0))
73805 @@ -714,8 +715,8 @@ long compat_sys_timer_settime(timer_t timer_id, int flags,
73806 oldfs = get_fs();
73807 set_fs(KERNEL_DS);
73808 err = sys_timer_settime(timer_id, flags,
73809 - (struct itimerspec __user *) &newts,
73810 - (struct itimerspec __user *) &oldts);
73811 + (struct itimerspec __force_user *) &newts,
73812 + (struct itimerspec __force_user *) &oldts);
73813 set_fs(oldfs);
73814 if (!err && old && put_compat_itimerspec(old, &oldts))
73815 return -EFAULT;
73816 @@ -732,7 +733,7 @@ long compat_sys_timer_gettime(timer_t timer_id,
73817 oldfs = get_fs();
73818 set_fs(KERNEL_DS);
73819 err = sys_timer_gettime(timer_id,
73820 - (struct itimerspec __user *) &ts);
73821 + (struct itimerspec __force_user *) &ts);
73822 set_fs(oldfs);
73823 if (!err && put_compat_itimerspec(setting, &ts))
73824 return -EFAULT;
73825 @@ -751,7 +752,7 @@ long compat_sys_clock_settime(clockid_t which_clock,
73826 oldfs = get_fs();
73827 set_fs(KERNEL_DS);
73828 err = sys_clock_settime(which_clock,
73829 - (struct timespec __user *) &ts);
73830 + (struct timespec __force_user *) &ts);
73831 set_fs(oldfs);
73832 return err;
73833 }
73834 @@ -766,7 +767,7 @@ long compat_sys_clock_gettime(clockid_t which_clock,
73835 oldfs = get_fs();
73836 set_fs(KERNEL_DS);
73837 err = sys_clock_gettime(which_clock,
73838 - (struct timespec __user *) &ts);
73839 + (struct timespec __force_user *) &ts);
73840 set_fs(oldfs);
73841 if (!err && put_compat_timespec(&ts, tp))
73842 return -EFAULT;
73843 @@ -786,7 +787,7 @@ long compat_sys_clock_adjtime(clockid_t which_clock,
73844
73845 oldfs = get_fs();
73846 set_fs(KERNEL_DS);
73847 - ret = sys_clock_adjtime(which_clock, (struct timex __user *) &txc);
73848 + ret = sys_clock_adjtime(which_clock, (struct timex __force_user *) &txc);
73849 set_fs(oldfs);
73850
73851 err = compat_put_timex(utp, &txc);
73852 @@ -806,7 +807,7 @@ long compat_sys_clock_getres(clockid_t which_clock,
73853 oldfs = get_fs();
73854 set_fs(KERNEL_DS);
73855 err = sys_clock_getres(which_clock,
73856 - (struct timespec __user *) &ts);
73857 + (struct timespec __force_user *) &ts);
73858 set_fs(oldfs);
73859 if (!err && tp && put_compat_timespec(&ts, tp))
73860 return -EFAULT;
73861 @@ -818,9 +819,9 @@ static long compat_clock_nanosleep_restart(struct restart_block *restart)
73862 long err;
73863 mm_segment_t oldfs;
73864 struct timespec tu;
73865 - struct compat_timespec *rmtp = restart->nanosleep.compat_rmtp;
73866 + struct compat_timespec __user *rmtp = restart->nanosleep.compat_rmtp;
73867
73868 - restart->nanosleep.rmtp = (struct timespec __user *) &tu;
73869 + restart->nanosleep.rmtp = (struct timespec __force_user *) &tu;
73870 oldfs = get_fs();
73871 set_fs(KERNEL_DS);
73872 err = clock_nanosleep_restart(restart);
73873 @@ -852,8 +853,8 @@ long compat_sys_clock_nanosleep(clockid_t which_clock, int flags,
73874 oldfs = get_fs();
73875 set_fs(KERNEL_DS);
73876 err = sys_clock_nanosleep(which_clock, flags,
73877 - (struct timespec __user *) &in,
73878 - (struct timespec __user *) &out);
73879 + (struct timespec __force_user *) &in,
73880 + (struct timespec __force_user *) &out);
73881 set_fs(oldfs);
73882
73883 if ((err == -ERESTART_RESTARTBLOCK) && rmtp &&
73884 diff --git a/kernel/configs.c b/kernel/configs.c
73885 index 42e8fa0..9e7406b 100644
73886 --- a/kernel/configs.c
73887 +++ b/kernel/configs.c
73888 @@ -74,8 +74,19 @@ static int __init ikconfig_init(void)
73889 struct proc_dir_entry *entry;
73890
73891 /* create the current config file */
73892 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
73893 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_HIDESYM)
73894 + entry = proc_create("config.gz", S_IFREG | S_IRUSR, NULL,
73895 + &ikconfig_file_ops);
73896 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
73897 + entry = proc_create("config.gz", S_IFREG | S_IRUSR | S_IRGRP, NULL,
73898 + &ikconfig_file_ops);
73899 +#endif
73900 +#else
73901 entry = proc_create("config.gz", S_IFREG | S_IRUGO, NULL,
73902 &ikconfig_file_ops);
73903 +#endif
73904 +
73905 if (!entry)
73906 return -ENOMEM;
73907
73908 diff --git a/kernel/cred.c b/kernel/cred.c
73909 index e0573a4..3874e41 100644
73910 --- a/kernel/cred.c
73911 +++ b/kernel/cred.c
73912 @@ -164,6 +164,16 @@ void exit_creds(struct task_struct *tsk)
73913 validate_creds(cred);
73914 alter_cred_subscribers(cred, -1);
73915 put_cred(cred);
73916 +
73917 +#ifdef CONFIG_GRKERNSEC_SETXID
73918 + cred = (struct cred *) tsk->delayed_cred;
73919 + if (cred != NULL) {
73920 + tsk->delayed_cred = NULL;
73921 + validate_creds(cred);
73922 + alter_cred_subscribers(cred, -1);
73923 + put_cred(cred);
73924 + }
73925 +#endif
73926 }
73927
73928 /**
73929 @@ -411,7 +421,7 @@ static bool cred_cap_issubset(const struct cred *set, const struct cred *subset)
73930 * Always returns 0 thus allowing this function to be tail-called at the end
73931 * of, say, sys_setgid().
73932 */
73933 -int commit_creds(struct cred *new)
73934 +static int __commit_creds(struct cred *new)
73935 {
73936 struct task_struct *task = current;
73937 const struct cred *old = task->real_cred;
73938 @@ -430,6 +440,8 @@ int commit_creds(struct cred *new)
73939
73940 get_cred(new); /* we will require a ref for the subj creds too */
73941
73942 + gr_set_role_label(task, new->uid, new->gid);
73943 +
73944 /* dumpability changes */
73945 if (!uid_eq(old->euid, new->euid) ||
73946 !gid_eq(old->egid, new->egid) ||
73947 @@ -479,6 +491,102 @@ int commit_creds(struct cred *new)
73948 put_cred(old);
73949 return 0;
73950 }
73951 +#ifdef CONFIG_GRKERNSEC_SETXID
73952 +extern int set_user(struct cred *new);
73953 +
73954 +void gr_delayed_cred_worker(void)
73955 +{
73956 + const struct cred *new = current->delayed_cred;
73957 + struct cred *ncred;
73958 +
73959 + current->delayed_cred = NULL;
73960 +
73961 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID) && new != NULL) {
73962 + // from doing get_cred on it when queueing this
73963 + put_cred(new);
73964 + return;
73965 + } else if (new == NULL)
73966 + return;
73967 +
73968 + ncred = prepare_creds();
73969 + if (!ncred)
73970 + goto die;
73971 + // uids
73972 + ncred->uid = new->uid;
73973 + ncred->euid = new->euid;
73974 + ncred->suid = new->suid;
73975 + ncred->fsuid = new->fsuid;
73976 + // gids
73977 + ncred->gid = new->gid;
73978 + ncred->egid = new->egid;
73979 + ncred->sgid = new->sgid;
73980 + ncred->fsgid = new->fsgid;
73981 + // groups
73982 + if (set_groups(ncred, new->group_info) < 0) {
73983 + abort_creds(ncred);
73984 + goto die;
73985 + }
73986 + // caps
73987 + ncred->securebits = new->securebits;
73988 + ncred->cap_inheritable = new->cap_inheritable;
73989 + ncred->cap_permitted = new->cap_permitted;
73990 + ncred->cap_effective = new->cap_effective;
73991 + ncred->cap_bset = new->cap_bset;
73992 +
73993 + if (set_user(ncred)) {
73994 + abort_creds(ncred);
73995 + goto die;
73996 + }
73997 +
73998 + // from doing get_cred on it when queueing this
73999 + put_cred(new);
74000 +
74001 + __commit_creds(ncred);
74002 + return;
74003 +die:
74004 + // from doing get_cred on it when queueing this
74005 + put_cred(new);
74006 + do_group_exit(SIGKILL);
74007 +}
74008 +#endif
74009 +
74010 +int commit_creds(struct cred *new)
74011 +{
74012 +#ifdef CONFIG_GRKERNSEC_SETXID
74013 + int ret;
74014 + int schedule_it = 0;
74015 + struct task_struct *t;
74016 +
74017 + /* we won't get called with tasklist_lock held for writing
74018 + and interrupts disabled as the cred struct in that case is
74019 + init_cred
74020 + */
74021 + if (grsec_enable_setxid && !current_is_single_threaded() &&
74022 + uid_eq(current_uid(), GLOBAL_ROOT_UID) &&
74023 + !uid_eq(new->uid, GLOBAL_ROOT_UID)) {
74024 + schedule_it = 1;
74025 + }
74026 + ret = __commit_creds(new);
74027 + if (schedule_it) {
74028 + rcu_read_lock();
74029 + read_lock(&tasklist_lock);
74030 + for (t = next_thread(current); t != current;
74031 + t = next_thread(t)) {
74032 + if (t->delayed_cred == NULL) {
74033 + t->delayed_cred = get_cred(new);
74034 + set_tsk_thread_flag(t, TIF_GRSEC_SETXID);
74035 + set_tsk_need_resched(t);
74036 + }
74037 + }
74038 + read_unlock(&tasklist_lock);
74039 + rcu_read_unlock();
74040 + }
74041 + return ret;
74042 +#else
74043 + return __commit_creds(new);
74044 +#endif
74045 +}
74046 +
74047 EXPORT_SYMBOL(commit_creds);
74048
74049 /**
74050 diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
74051 index c26278f..e323fb8 100644
74052 --- a/kernel/debug/debug_core.c
74053 +++ b/kernel/debug/debug_core.c
74054 @@ -123,7 +123,7 @@ static DEFINE_RAW_SPINLOCK(dbg_slave_lock);
74055 */
74056 static atomic_t masters_in_kgdb;
74057 static atomic_t slaves_in_kgdb;
74058 -static atomic_t kgdb_break_tasklet_var;
74059 +static atomic_unchecked_t kgdb_break_tasklet_var;
74060 atomic_t kgdb_setting_breakpoint;
74061
74062 struct task_struct *kgdb_usethread;
74063 @@ -133,7 +133,7 @@ int kgdb_single_step;
74064 static pid_t kgdb_sstep_pid;
74065
74066 /* to keep track of the CPU which is doing the single stepping*/
74067 -atomic_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
74068 +atomic_unchecked_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
74069
74070 /*
74071 * If you are debugging a problem where roundup (the collection of
74072 @@ -541,7 +541,7 @@ return_normal:
74073 * kernel will only try for the value of sstep_tries before
74074 * giving up and continuing on.
74075 */
74076 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1 &&
74077 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1 &&
74078 (kgdb_info[cpu].task &&
74079 kgdb_info[cpu].task->pid != kgdb_sstep_pid) && --sstep_tries) {
74080 atomic_set(&kgdb_active, -1);
74081 @@ -635,8 +635,8 @@ cpu_master_loop:
74082 }
74083
74084 kgdb_restore:
74085 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
74086 - int sstep_cpu = atomic_read(&kgdb_cpu_doing_single_step);
74087 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
74088 + int sstep_cpu = atomic_read_unchecked(&kgdb_cpu_doing_single_step);
74089 if (kgdb_info[sstep_cpu].task)
74090 kgdb_sstep_pid = kgdb_info[sstep_cpu].task->pid;
74091 else
74092 @@ -888,18 +888,18 @@ static void kgdb_unregister_callbacks(void)
74093 static void kgdb_tasklet_bpt(unsigned long ing)
74094 {
74095 kgdb_breakpoint();
74096 - atomic_set(&kgdb_break_tasklet_var, 0);
74097 + atomic_set_unchecked(&kgdb_break_tasklet_var, 0);
74098 }
74099
74100 static DECLARE_TASKLET(kgdb_tasklet_breakpoint, kgdb_tasklet_bpt, 0);
74101
74102 void kgdb_schedule_breakpoint(void)
74103 {
74104 - if (atomic_read(&kgdb_break_tasklet_var) ||
74105 + if (atomic_read_unchecked(&kgdb_break_tasklet_var) ||
74106 atomic_read(&kgdb_active) != -1 ||
74107 atomic_read(&kgdb_setting_breakpoint))
74108 return;
74109 - atomic_inc(&kgdb_break_tasklet_var);
74110 + atomic_inc_unchecked(&kgdb_break_tasklet_var);
74111 tasklet_schedule(&kgdb_tasklet_breakpoint);
74112 }
74113 EXPORT_SYMBOL_GPL(kgdb_schedule_breakpoint);
74114 diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
74115 index 00eb8f7..d7e3244 100644
74116 --- a/kernel/debug/kdb/kdb_main.c
74117 +++ b/kernel/debug/kdb/kdb_main.c
74118 @@ -1974,7 +1974,7 @@ static int kdb_lsmod(int argc, const char **argv)
74119 continue;
74120
74121 kdb_printf("%-20s%8u 0x%p ", mod->name,
74122 - mod->core_size, (void *)mod);
74123 + mod->core_size_rx + mod->core_size_rw, (void *)mod);
74124 #ifdef CONFIG_MODULE_UNLOAD
74125 kdb_printf("%4ld ", module_refcount(mod));
74126 #endif
74127 @@ -1984,7 +1984,7 @@ static int kdb_lsmod(int argc, const char **argv)
74128 kdb_printf(" (Loading)");
74129 else
74130 kdb_printf(" (Live)");
74131 - kdb_printf(" 0x%p", mod->module_core);
74132 + kdb_printf(" 0x%p 0x%p", mod->module_core_rx, mod->module_core_rw);
74133
74134 #ifdef CONFIG_MODULE_UNLOAD
74135 {
74136 diff --git a/kernel/events/core.c b/kernel/events/core.c
74137 index 9fcb094..5c06aeb 100644
74138 --- a/kernel/events/core.c
74139 +++ b/kernel/events/core.c
74140 @@ -155,7 +155,11 @@ static struct srcu_struct pmus_srcu;
74141 * 1 - disallow cpu events for unpriv
74142 * 2 - disallow kernel profiling for unpriv
74143 */
74144 -int sysctl_perf_event_paranoid __read_mostly = 1;
74145 +#ifdef CONFIG_GRKERNSEC_HIDESYM
74146 +int sysctl_perf_event_legitimately_concerned __read_mostly = 2;
74147 +#else
74148 +int sysctl_perf_event_legitimately_concerned __read_mostly = 1;
74149 +#endif
74150
74151 /* Minimum for 512 kiB + 1 user control page */
74152 int sysctl_perf_event_mlock __read_mostly = 512 + (PAGE_SIZE / 1024); /* 'free' kiB per user */
74153 @@ -182,7 +186,7 @@ int perf_proc_update_handler(struct ctl_table *table, int write,
74154 return 0;
74155 }
74156
74157 -static atomic64_t perf_event_id;
74158 +static atomic64_unchecked_t perf_event_id;
74159
74160 static void cpu_ctx_sched_out(struct perf_cpu_context *cpuctx,
74161 enum event_type_t event_type);
74162 @@ -2677,7 +2681,7 @@ static void __perf_event_read(void *info)
74163
74164 static inline u64 perf_event_count(struct perf_event *event)
74165 {
74166 - return local64_read(&event->count) + atomic64_read(&event->child_count);
74167 + return local64_read(&event->count) + atomic64_read_unchecked(&event->child_count);
74168 }
74169
74170 static u64 perf_event_read(struct perf_event *event)
74171 @@ -3007,9 +3011,9 @@ u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running)
74172 mutex_lock(&event->child_mutex);
74173 total += perf_event_read(event);
74174 *enabled += event->total_time_enabled +
74175 - atomic64_read(&event->child_total_time_enabled);
74176 + atomic64_read_unchecked(&event->child_total_time_enabled);
74177 *running += event->total_time_running +
74178 - atomic64_read(&event->child_total_time_running);
74179 + atomic64_read_unchecked(&event->child_total_time_running);
74180
74181 list_for_each_entry(child, &event->child_list, child_list) {
74182 total += perf_event_read(child);
74183 @@ -3412,10 +3416,10 @@ void perf_event_update_userpage(struct perf_event *event)
74184 userpg->offset -= local64_read(&event->hw.prev_count);
74185
74186 userpg->time_enabled = enabled +
74187 - atomic64_read(&event->child_total_time_enabled);
74188 + atomic64_read_unchecked(&event->child_total_time_enabled);
74189
74190 userpg->time_running = running +
74191 - atomic64_read(&event->child_total_time_running);
74192 + atomic64_read_unchecked(&event->child_total_time_running);
74193
74194 arch_perf_update_userpage(userpg, now);
74195
74196 @@ -3974,11 +3978,11 @@ static void perf_output_read_one(struct perf_output_handle *handle,
74197 values[n++] = perf_event_count(event);
74198 if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) {
74199 values[n++] = enabled +
74200 - atomic64_read(&event->child_total_time_enabled);
74201 + atomic64_read_unchecked(&event->child_total_time_enabled);
74202 }
74203 if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) {
74204 values[n++] = running +
74205 - atomic64_read(&event->child_total_time_running);
74206 + atomic64_read_unchecked(&event->child_total_time_running);
74207 }
74208 if (read_format & PERF_FORMAT_ID)
74209 values[n++] = primary_event_id(event);
74210 @@ -4726,12 +4730,12 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
74211 * need to add enough zero bytes after the string to handle
74212 * the 64bit alignment we do later.
74213 */
74214 - buf = kzalloc(PATH_MAX + sizeof(u64), GFP_KERNEL);
74215 + buf = kzalloc(PATH_MAX, GFP_KERNEL);
74216 if (!buf) {
74217 name = strncpy(tmp, "//enomem", sizeof(tmp));
74218 goto got_name;
74219 }
74220 - name = d_path(&file->f_path, buf, PATH_MAX);
74221 + name = d_path(&file->f_path, buf, PATH_MAX - sizeof(u64));
74222 if (IS_ERR(name)) {
74223 name = strncpy(tmp, "//toolong", sizeof(tmp));
74224 goto got_name;
74225 @@ -6167,7 +6171,7 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
74226 event->parent = parent_event;
74227
74228 event->ns = get_pid_ns(task_active_pid_ns(current));
74229 - event->id = atomic64_inc_return(&perf_event_id);
74230 + event->id = atomic64_inc_return_unchecked(&perf_event_id);
74231
74232 event->state = PERF_EVENT_STATE_INACTIVE;
74233
74234 @@ -6795,10 +6799,10 @@ static void sync_child_event(struct perf_event *child_event,
74235 /*
74236 * Add back the child's count to the parent's count:
74237 */
74238 - atomic64_add(child_val, &parent_event->child_count);
74239 - atomic64_add(child_event->total_time_enabled,
74240 + atomic64_add_unchecked(child_val, &parent_event->child_count);
74241 + atomic64_add_unchecked(child_event->total_time_enabled,
74242 &parent_event->child_total_time_enabled);
74243 - atomic64_add(child_event->total_time_running,
74244 + atomic64_add_unchecked(child_event->total_time_running,
74245 &parent_event->child_total_time_running);
74246
74247 /*
74248 diff --git a/kernel/exit.c b/kernel/exit.c
74249 index 60bc027..ca6d727 100644
74250 --- a/kernel/exit.c
74251 +++ b/kernel/exit.c
74252 @@ -172,6 +172,10 @@ void release_task(struct task_struct * p)
74253 struct task_struct *leader;
74254 int zap_leader;
74255 repeat:
74256 +#ifdef CONFIG_NET
74257 + gr_del_task_from_ip_table(p);
74258 +#endif
74259 +
74260 /* don't need to get the RCU readlock here - the process is dead and
74261 * can't be modifying its own credentials. But shut RCU-lockdep up */
74262 rcu_read_lock();
74263 @@ -340,7 +344,7 @@ int allow_signal(int sig)
74264 * know it'll be handled, so that they don't get converted to
74265 * SIGKILL or just silently dropped.
74266 */
74267 - current->sighand->action[(sig)-1].sa.sa_handler = (void __user *)2;
74268 + current->sighand->action[(sig)-1].sa.sa_handler = (__force void __user *)2;
74269 recalc_sigpending();
74270 spin_unlock_irq(&current->sighand->siglock);
74271 return 0;
74272 @@ -710,6 +714,8 @@ void do_exit(long code)
74273 struct task_struct *tsk = current;
74274 int group_dead;
74275
74276 + set_fs(USER_DS);
74277 +
74278 profile_task_exit(tsk);
74279
74280 WARN_ON(blk_needs_flush_plug(tsk));
74281 @@ -726,7 +732,6 @@ void do_exit(long code)
74282 * mm_release()->clear_child_tid() from writing to a user-controlled
74283 * kernel address.
74284 */
74285 - set_fs(USER_DS);
74286
74287 ptrace_event(PTRACE_EVENT_EXIT, code);
74288
74289 @@ -785,6 +790,9 @@ void do_exit(long code)
74290 tsk->exit_code = code;
74291 taskstats_exit(tsk, group_dead);
74292
74293 + gr_acl_handle_psacct(tsk, code);
74294 + gr_acl_handle_exit();
74295 +
74296 exit_mm(tsk);
74297
74298 if (group_dead)
74299 @@ -905,7 +913,7 @@ SYSCALL_DEFINE1(exit, int, error_code)
74300 * Take down every thread in the group. This is called by fatal signals
74301 * as well as by sys_exit_group (below).
74302 */
74303 -void
74304 +__noreturn void
74305 do_group_exit(int exit_code)
74306 {
74307 struct signal_struct *sig = current->signal;
74308 diff --git a/kernel/fork.c b/kernel/fork.c
74309 index 1766d32..c0e44e2 100644
74310 --- a/kernel/fork.c
74311 +++ b/kernel/fork.c
74312 @@ -318,7 +318,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
74313 *stackend = STACK_END_MAGIC; /* for overflow detection */
74314
74315 #ifdef CONFIG_CC_STACKPROTECTOR
74316 - tsk->stack_canary = get_random_int();
74317 + tsk->stack_canary = pax_get_random_long();
74318 #endif
74319
74320 /*
74321 @@ -344,13 +344,81 @@ free_tsk:
74322 }
74323
74324 #ifdef CONFIG_MMU
74325 +static struct vm_area_struct *dup_vma(struct mm_struct *mm, struct mm_struct *oldmm, struct vm_area_struct *mpnt)
74326 +{
74327 + struct vm_area_struct *tmp;
74328 + unsigned long charge;
74329 + struct mempolicy *pol;
74330 + struct file *file;
74331 +
74332 + charge = 0;
74333 + if (mpnt->vm_flags & VM_ACCOUNT) {
74334 + unsigned long len = vma_pages(mpnt);
74335 +
74336 + if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
74337 + goto fail_nomem;
74338 + charge = len;
74339 + }
74340 + tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
74341 + if (!tmp)
74342 + goto fail_nomem;
74343 + *tmp = *mpnt;
74344 + tmp->vm_mm = mm;
74345 + INIT_LIST_HEAD(&tmp->anon_vma_chain);
74346 + pol = mpol_dup(vma_policy(mpnt));
74347 + if (IS_ERR(pol))
74348 + goto fail_nomem_policy;
74349 + vma_set_policy(tmp, pol);
74350 + if (anon_vma_fork(tmp, mpnt))
74351 + goto fail_nomem_anon_vma_fork;
74352 + tmp->vm_flags &= ~VM_LOCKED;
74353 + tmp->vm_next = tmp->vm_prev = NULL;
74354 + tmp->vm_mirror = NULL;
74355 + file = tmp->vm_file;
74356 + if (file) {
74357 + struct inode *inode = file_inode(file);
74358 + struct address_space *mapping = file->f_mapping;
74359 +
74360 + get_file(file);
74361 + if (tmp->vm_flags & VM_DENYWRITE)
74362 + atomic_dec(&inode->i_writecount);
74363 + mutex_lock(&mapping->i_mmap_mutex);
74364 + if (tmp->vm_flags & VM_SHARED)
74365 + mapping->i_mmap_writable++;
74366 + flush_dcache_mmap_lock(mapping);
74367 + /* insert tmp into the share list, just after mpnt */
74368 + if (unlikely(tmp->vm_flags & VM_NONLINEAR))
74369 + vma_nonlinear_insert(tmp, &mapping->i_mmap_nonlinear);
74370 + else
74371 + vma_interval_tree_insert_after(tmp, mpnt, &mapping->i_mmap);
74372 + flush_dcache_mmap_unlock(mapping);
74373 + mutex_unlock(&mapping->i_mmap_mutex);
74374 + }
74375 +
74376 + /*
74377 + * Clear hugetlb-related page reserves for children. This only
74378 + * affects MAP_PRIVATE mappings. Faults generated by the child
74379 + * are not guaranteed to succeed, even if read-only
74380 + */
74381 + if (is_vm_hugetlb_page(tmp))
74382 + reset_vma_resv_huge_pages(tmp);
74383 +
74384 + return tmp;
74385 +
74386 +fail_nomem_anon_vma_fork:
74387 + mpol_put(pol);
74388 +fail_nomem_policy:
74389 + kmem_cache_free(vm_area_cachep, tmp);
74390 +fail_nomem:
74391 + vm_unacct_memory(charge);
74392 + return NULL;
74393 +}
74394 +
74395 static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
74396 {
74397 struct vm_area_struct *mpnt, *tmp, *prev, **pprev;
74398 struct rb_node **rb_link, *rb_parent;
74399 int retval;
74400 - unsigned long charge;
74401 - struct mempolicy *pol;
74402
74403 uprobe_start_dup_mmap();
74404 down_write(&oldmm->mmap_sem);
74405 @@ -364,8 +432,8 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
74406 mm->locked_vm = 0;
74407 mm->mmap = NULL;
74408 mm->mmap_cache = NULL;
74409 - mm->free_area_cache = oldmm->mmap_base;
74410 - mm->cached_hole_size = ~0UL;
74411 + mm->free_area_cache = oldmm->free_area_cache;
74412 + mm->cached_hole_size = oldmm->cached_hole_size;
74413 mm->map_count = 0;
74414 cpumask_clear(mm_cpumask(mm));
74415 mm->mm_rb = RB_ROOT;
74416 @@ -381,57 +449,15 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
74417
74418 prev = NULL;
74419 for (mpnt = oldmm->mmap; mpnt; mpnt = mpnt->vm_next) {
74420 - struct file *file;
74421 -
74422 if (mpnt->vm_flags & VM_DONTCOPY) {
74423 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
74424 -vma_pages(mpnt));
74425 continue;
74426 }
74427 - charge = 0;
74428 - if (mpnt->vm_flags & VM_ACCOUNT) {
74429 - unsigned long len = vma_pages(mpnt);
74430 -
74431 - if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
74432 - goto fail_nomem;
74433 - charge = len;
74434 - }
74435 - tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
74436 - if (!tmp)
74437 - goto fail_nomem;
74438 - *tmp = *mpnt;
74439 - INIT_LIST_HEAD(&tmp->anon_vma_chain);
74440 - pol = mpol_dup(vma_policy(mpnt));
74441 - retval = PTR_ERR(pol);
74442 - if (IS_ERR(pol))
74443 - goto fail_nomem_policy;
74444 - vma_set_policy(tmp, pol);
74445 - tmp->vm_mm = mm;
74446 - if (anon_vma_fork(tmp, mpnt))
74447 - goto fail_nomem_anon_vma_fork;
74448 - tmp->vm_flags &= ~VM_LOCKED;
74449 - tmp->vm_next = tmp->vm_prev = NULL;
74450 - file = tmp->vm_file;
74451 - if (file) {
74452 - struct inode *inode = file_inode(file);
74453 - struct address_space *mapping = file->f_mapping;
74454 -
74455 - get_file(file);
74456 - if (tmp->vm_flags & VM_DENYWRITE)
74457 - atomic_dec(&inode->i_writecount);
74458 - mutex_lock(&mapping->i_mmap_mutex);
74459 - if (tmp->vm_flags & VM_SHARED)
74460 - mapping->i_mmap_writable++;
74461 - flush_dcache_mmap_lock(mapping);
74462 - /* insert tmp into the share list, just after mpnt */
74463 - if (unlikely(tmp->vm_flags & VM_NONLINEAR))
74464 - vma_nonlinear_insert(tmp,
74465 - &mapping->i_mmap_nonlinear);
74466 - else
74467 - vma_interval_tree_insert_after(tmp, mpnt,
74468 - &mapping->i_mmap);
74469 - flush_dcache_mmap_unlock(mapping);
74470 - mutex_unlock(&mapping->i_mmap_mutex);
74471 + tmp = dup_vma(mm, oldmm, mpnt);
74472 + if (!tmp) {
74473 + retval = -ENOMEM;
74474 + goto out;
74475 }
74476
74477 /*
74478 @@ -463,6 +489,31 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
74479 if (retval)
74480 goto out;
74481 }
74482 +
74483 +#ifdef CONFIG_PAX_SEGMEXEC
74484 + if (oldmm->pax_flags & MF_PAX_SEGMEXEC) {
74485 + struct vm_area_struct *mpnt_m;
74486 +
74487 + for (mpnt = oldmm->mmap, mpnt_m = mm->mmap; mpnt; mpnt = mpnt->vm_next, mpnt_m = mpnt_m->vm_next) {
74488 + BUG_ON(!mpnt_m || mpnt_m->vm_mirror || mpnt->vm_mm != oldmm || mpnt_m->vm_mm != mm);
74489 +
74490 + if (!mpnt->vm_mirror)
74491 + continue;
74492 +
74493 + if (mpnt->vm_end <= SEGMEXEC_TASK_SIZE) {
74494 + BUG_ON(mpnt->vm_mirror->vm_mirror != mpnt);
74495 + mpnt->vm_mirror = mpnt_m;
74496 + } else {
74497 + BUG_ON(mpnt->vm_mirror->vm_mirror == mpnt || mpnt->vm_mirror->vm_mirror->vm_mm != mm);
74498 + mpnt_m->vm_mirror = mpnt->vm_mirror->vm_mirror;
74499 + mpnt_m->vm_mirror->vm_mirror = mpnt_m;
74500 + mpnt->vm_mirror->vm_mirror = mpnt;
74501 + }
74502 + }
74503 + BUG_ON(mpnt_m);
74504 + }
74505 +#endif
74506 +
74507 /* a new mm has just been created */
74508 arch_dup_mmap(oldmm, mm);
74509 retval = 0;
74510 @@ -472,14 +523,6 @@ out:
74511 up_write(&oldmm->mmap_sem);
74512 uprobe_end_dup_mmap();
74513 return retval;
74514 -fail_nomem_anon_vma_fork:
74515 - mpol_put(pol);
74516 -fail_nomem_policy:
74517 - kmem_cache_free(vm_area_cachep, tmp);
74518 -fail_nomem:
74519 - retval = -ENOMEM;
74520 - vm_unacct_memory(charge);
74521 - goto out;
74522 }
74523
74524 static inline int mm_alloc_pgd(struct mm_struct *mm)
74525 @@ -694,8 +737,8 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)
74526 return ERR_PTR(err);
74527
74528 mm = get_task_mm(task);
74529 - if (mm && mm != current->mm &&
74530 - !ptrace_may_access(task, mode)) {
74531 + if (mm && ((mm != current->mm && !ptrace_may_access(task, mode)) ||
74532 + (mode == PTRACE_MODE_ATTACH && (gr_handle_proc_ptrace(task) || gr_acl_handle_procpidmem(task))))) {
74533 mmput(mm);
74534 mm = ERR_PTR(-EACCES);
74535 }
74536 @@ -917,13 +960,20 @@ static int copy_fs(unsigned long clone_flags, struct task_struct *tsk)
74537 spin_unlock(&fs->lock);
74538 return -EAGAIN;
74539 }
74540 - fs->users++;
74541 + atomic_inc(&fs->users);
74542 spin_unlock(&fs->lock);
74543 return 0;
74544 }
74545 tsk->fs = copy_fs_struct(fs);
74546 if (!tsk->fs)
74547 return -ENOMEM;
74548 + /* Carry through gr_chroot_dentry and is_chrooted instead
74549 + of recomputing it here. Already copied when the task struct
74550 + is duplicated. This allows pivot_root to not be treated as
74551 + a chroot
74552 + */
74553 + //gr_set_chroot_entries(tsk, &tsk->fs->root);
74554 +
74555 return 0;
74556 }
74557
74558 @@ -1196,6 +1246,9 @@ static struct task_struct *copy_process(unsigned long clone_flags,
74559 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
74560 #endif
74561 retval = -EAGAIN;
74562 +
74563 + gr_learn_resource(p, RLIMIT_NPROC, atomic_read(&p->real_cred->user->processes), 0);
74564 +
74565 if (atomic_read(&p->real_cred->user->processes) >=
74566 task_rlimit(p, RLIMIT_NPROC)) {
74567 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
74568 @@ -1441,6 +1494,11 @@ static struct task_struct *copy_process(unsigned long clone_flags,
74569 goto bad_fork_free_pid;
74570 }
74571
74572 + /* synchronizes with gr_set_acls()
74573 + we need to call this past the point of no return for fork()
74574 + */
74575 + gr_copy_label(p);
74576 +
74577 if (clone_flags & CLONE_THREAD) {
74578 current->signal->nr_threads++;
74579 atomic_inc(&current->signal->live);
74580 @@ -1524,6 +1582,8 @@ bad_fork_cleanup_count:
74581 bad_fork_free:
74582 free_task(p);
74583 fork_out:
74584 + gr_log_forkfail(retval);
74585 +
74586 return ERR_PTR(retval);
74587 }
74588
74589 @@ -1574,6 +1634,23 @@ long do_fork(unsigned long clone_flags,
74590 return -EINVAL;
74591 }
74592
74593 +#ifdef CONFIG_GRKERNSEC
74594 + if (clone_flags & CLONE_NEWUSER) {
74595 + /*
74596 + * This doesn't really inspire confidence:
74597 + * http://marc.info/?l=linux-kernel&m=135543612731939&w=2
74598 + * http://marc.info/?l=linux-kernel&m=135545831607095&w=2
74599 + * Increases kernel attack surface in areas developers
74600 + * previously cared little about ("low importance due
74601 + * to requiring "root" capability")
74602 + * To be removed when this code receives *proper* review
74603 + */
74604 + if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SETUID) ||
74605 + !capable(CAP_SETGID))
74606 + return -EPERM;
74607 + }
74608 +#endif
74609 +
74610 /*
74611 * Determine whether and which event to report to ptracer. When
74612 * called from kernel_thread or CLONE_UNTRACED is explicitly
74613 @@ -1608,6 +1685,8 @@ long do_fork(unsigned long clone_flags,
74614 if (clone_flags & CLONE_PARENT_SETTID)
74615 put_user(nr, parent_tidptr);
74616
74617 + gr_handle_brute_check();
74618 +
74619 if (clone_flags & CLONE_VFORK) {
74620 p->vfork_done = &vfork;
74621 init_completion(&vfork);
74622 @@ -1761,7 +1840,7 @@ static int unshare_fs(unsigned long unshare_flags, struct fs_struct **new_fsp)
74623 return 0;
74624
74625 /* don't need lock here; in the worst case we'll do useless copy */
74626 - if (fs->users == 1)
74627 + if (atomic_read(&fs->users) == 1)
74628 return 0;
74629
74630 *new_fsp = copy_fs_struct(fs);
74631 @@ -1873,7 +1952,8 @@ SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags)
74632 fs = current->fs;
74633 spin_lock(&fs->lock);
74634 current->fs = new_fs;
74635 - if (--fs->users)
74636 + gr_set_chroot_entries(current, &current->fs->root);
74637 + if (atomic_dec_return(&fs->users))
74638 new_fs = NULL;
74639 else
74640 new_fs = fs;
74641 diff --git a/kernel/futex.c b/kernel/futex.c
74642 index b26dcfc..39e266a 100644
74643 --- a/kernel/futex.c
74644 +++ b/kernel/futex.c
74645 @@ -54,6 +54,7 @@
74646 #include <linux/mount.h>
74647 #include <linux/pagemap.h>
74648 #include <linux/syscalls.h>
74649 +#include <linux/ptrace.h>
74650 #include <linux/signal.h>
74651 #include <linux/export.h>
74652 #include <linux/magic.h>
74653 @@ -241,6 +242,11 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw)
74654 struct page *page, *page_head;
74655 int err, ro = 0;
74656
74657 +#ifdef CONFIG_PAX_SEGMEXEC
74658 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && address >= SEGMEXEC_TASK_SIZE)
74659 + return -EFAULT;
74660 +#endif
74661 +
74662 /*
74663 * The futex address must be "naturally" aligned.
74664 */
74665 @@ -2732,6 +2738,7 @@ static int __init futex_init(void)
74666 {
74667 u32 curval;
74668 int i;
74669 + mm_segment_t oldfs;
74670
74671 /*
74672 * This will fail and we want it. Some arch implementations do
74673 @@ -2743,8 +2750,11 @@ static int __init futex_init(void)
74674 * implementation, the non-functional ones will return
74675 * -ENOSYS.
74676 */
74677 + oldfs = get_fs();
74678 + set_fs(USER_DS);
74679 if (cmpxchg_futex_value_locked(&curval, NULL, 0, 0) == -EFAULT)
74680 futex_cmpxchg_enabled = 1;
74681 + set_fs(oldfs);
74682
74683 for (i = 0; i < ARRAY_SIZE(futex_queues); i++) {
74684 plist_head_init(&futex_queues[i].chain);
74685 diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c
74686 index f9f44fd..29885e4 100644
74687 --- a/kernel/futex_compat.c
74688 +++ b/kernel/futex_compat.c
74689 @@ -32,7 +32,7 @@ fetch_robust_entry(compat_uptr_t *uentry, struct robust_list __user **entry,
74690 return 0;
74691 }
74692
74693 -static void __user *futex_uaddr(struct robust_list __user *entry,
74694 +static void __user __intentional_overflow(-1) *futex_uaddr(struct robust_list __user *entry,
74695 compat_long_t futex_offset)
74696 {
74697 compat_uptr_t base = ptr_to_compat(entry);
74698 diff --git a/kernel/gcov/base.c b/kernel/gcov/base.c
74699 index 9b22d03..6295b62 100644
74700 --- a/kernel/gcov/base.c
74701 +++ b/kernel/gcov/base.c
74702 @@ -102,11 +102,6 @@ void gcov_enable_events(void)
74703 }
74704
74705 #ifdef CONFIG_MODULES
74706 -static inline int within(void *addr, void *start, unsigned long size)
74707 -{
74708 - return ((addr >= start) && (addr < start + size));
74709 -}
74710 -
74711 /* Update list and generate events when modules are unloaded. */
74712 static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
74713 void *data)
74714 @@ -121,7 +116,7 @@ static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
74715 prev = NULL;
74716 /* Remove entries located in module from linked list. */
74717 for (info = gcov_info_head; info; info = info->next) {
74718 - if (within(info, mod->module_core, mod->core_size)) {
74719 + if (within_module_core_rw((unsigned long)info, mod)) {
74720 if (prev)
74721 prev->next = info->next;
74722 else
74723 diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
74724 index 7ef5556..8247f11 100644
74725 --- a/kernel/hrtimer.c
74726 +++ b/kernel/hrtimer.c
74727 @@ -1416,7 +1416,7 @@ void hrtimer_peek_ahead_timers(void)
74728 local_irq_restore(flags);
74729 }
74730
74731 -static void run_hrtimer_softirq(struct softirq_action *h)
74732 +static void run_hrtimer_softirq(void)
74733 {
74734 struct hrtimer_cpu_base *cpu_base = &__get_cpu_var(hrtimer_bases);
74735
74736 @@ -1758,7 +1758,7 @@ static int __cpuinit hrtimer_cpu_notify(struct notifier_block *self,
74737 return NOTIFY_OK;
74738 }
74739
74740 -static struct notifier_block __cpuinitdata hrtimers_nb = {
74741 +static struct notifier_block hrtimers_nb = {
74742 .notifier_call = hrtimer_cpu_notify,
74743 };
74744
74745 diff --git a/kernel/irq_work.c b/kernel/irq_work.c
74746 index 55fcce6..0e4cf34 100644
74747 --- a/kernel/irq_work.c
74748 +++ b/kernel/irq_work.c
74749 @@ -189,12 +189,13 @@ static int irq_work_cpu_notify(struct notifier_block *self,
74750 return NOTIFY_OK;
74751 }
74752
74753 -static struct notifier_block cpu_notify;
74754 +static struct notifier_block cpu_notify = {
74755 + .notifier_call = irq_work_cpu_notify,
74756 + .priority = 0,
74757 +};
74758
74759 static __init int irq_work_init_cpu_notifier(void)
74760 {
74761 - cpu_notify.notifier_call = irq_work_cpu_notify;
74762 - cpu_notify.priority = 0;
74763 register_cpu_notifier(&cpu_notify);
74764 return 0;
74765 }
74766 diff --git a/kernel/jump_label.c b/kernel/jump_label.c
74767 index 60f48fa..7f3a770 100644
74768 --- a/kernel/jump_label.c
74769 +++ b/kernel/jump_label.c
74770 @@ -13,6 +13,7 @@
74771 #include <linux/sort.h>
74772 #include <linux/err.h>
74773 #include <linux/static_key.h>
74774 +#include <linux/mm.h>
74775
74776 #ifdef HAVE_JUMP_LABEL
74777
74778 @@ -50,7 +51,9 @@ jump_label_sort_entries(struct jump_entry *start, struct jump_entry *stop)
74779
74780 size = (((unsigned long)stop - (unsigned long)start)
74781 / sizeof(struct jump_entry));
74782 + pax_open_kernel();
74783 sort(start, size, sizeof(struct jump_entry), jump_label_cmp, NULL);
74784 + pax_close_kernel();
74785 }
74786
74787 static void jump_label_update(struct static_key *key, int enable);
74788 @@ -357,10 +360,12 @@ static void jump_label_invalidate_module_init(struct module *mod)
74789 struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
74790 struct jump_entry *iter;
74791
74792 + pax_open_kernel();
74793 for (iter = iter_start; iter < iter_stop; iter++) {
74794 if (within_module_init(iter->code, mod))
74795 iter->code = 0;
74796 }
74797 + pax_close_kernel();
74798 }
74799
74800 static int
74801 diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
74802 index 2169fee..706ccca 100644
74803 --- a/kernel/kallsyms.c
74804 +++ b/kernel/kallsyms.c
74805 @@ -11,6 +11,9 @@
74806 * Changed the compression method from stem compression to "table lookup"
74807 * compression (see scripts/kallsyms.c for a more complete description)
74808 */
74809 +#ifdef CONFIG_GRKERNSEC_HIDESYM
74810 +#define __INCLUDED_BY_HIDESYM 1
74811 +#endif
74812 #include <linux/kallsyms.h>
74813 #include <linux/module.h>
74814 #include <linux/init.h>
74815 @@ -53,12 +56,33 @@ extern const unsigned long kallsyms_markers[] __attribute__((weak));
74816
74817 static inline int is_kernel_inittext(unsigned long addr)
74818 {
74819 + if (system_state != SYSTEM_BOOTING)
74820 + return 0;
74821 +
74822 if (addr >= (unsigned long)_sinittext
74823 && addr <= (unsigned long)_einittext)
74824 return 1;
74825 return 0;
74826 }
74827
74828 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
74829 +#ifdef CONFIG_MODULES
74830 +static inline int is_module_text(unsigned long addr)
74831 +{
74832 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END)
74833 + return 1;
74834 +
74835 + addr = ktla_ktva(addr);
74836 + return (unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END;
74837 +}
74838 +#else
74839 +static inline int is_module_text(unsigned long addr)
74840 +{
74841 + return 0;
74842 +}
74843 +#endif
74844 +#endif
74845 +
74846 static inline int is_kernel_text(unsigned long addr)
74847 {
74848 if ((addr >= (unsigned long)_stext && addr <= (unsigned long)_etext) ||
74849 @@ -69,13 +93,28 @@ static inline int is_kernel_text(unsigned long addr)
74850
74851 static inline int is_kernel(unsigned long addr)
74852 {
74853 +
74854 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
74855 + if (is_kernel_text(addr) || is_kernel_inittext(addr))
74856 + return 1;
74857 +
74858 + if (ktla_ktva((unsigned long)_text) <= addr && addr < (unsigned long)_end)
74859 +#else
74860 if (addr >= (unsigned long)_stext && addr <= (unsigned long)_end)
74861 +#endif
74862 +
74863 return 1;
74864 return in_gate_area_no_mm(addr);
74865 }
74866
74867 static int is_ksym_addr(unsigned long addr)
74868 {
74869 +
74870 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
74871 + if (is_module_text(addr))
74872 + return 0;
74873 +#endif
74874 +
74875 if (all_var)
74876 return is_kernel(addr);
74877
74878 @@ -470,7 +509,6 @@ static unsigned long get_ksymbol_core(struct kallsym_iter *iter)
74879
74880 static void reset_iter(struct kallsym_iter *iter, loff_t new_pos)
74881 {
74882 - iter->name[0] = '\0';
74883 iter->nameoff = get_symbol_offset(new_pos);
74884 iter->pos = new_pos;
74885 }
74886 @@ -518,6 +556,11 @@ static int s_show(struct seq_file *m, void *p)
74887 {
74888 struct kallsym_iter *iter = m->private;
74889
74890 +#ifdef CONFIG_GRKERNSEC_HIDESYM
74891 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID))
74892 + return 0;
74893 +#endif
74894 +
74895 /* Some debugging symbols have no name. Ignore them. */
74896 if (!iter->name[0])
74897 return 0;
74898 @@ -531,6 +574,7 @@ static int s_show(struct seq_file *m, void *p)
74899 */
74900 type = iter->exported ? toupper(iter->type) :
74901 tolower(iter->type);
74902 +
74903 seq_printf(m, "%pK %c %s\t[%s]\n", (void *)iter->value,
74904 type, iter->name, iter->module_name);
74905 } else
74906 @@ -556,7 +600,7 @@ static int kallsyms_open(struct inode *inode, struct file *file)
74907 struct kallsym_iter *iter;
74908 int ret;
74909
74910 - iter = kmalloc(sizeof(*iter), GFP_KERNEL);
74911 + iter = kzalloc(sizeof(*iter), GFP_KERNEL);
74912 if (!iter)
74913 return -ENOMEM;
74914 reset_iter(iter, 0);
74915 diff --git a/kernel/kcmp.c b/kernel/kcmp.c
74916 index e30ac0f..3528cac 100644
74917 --- a/kernel/kcmp.c
74918 +++ b/kernel/kcmp.c
74919 @@ -99,6 +99,10 @@ SYSCALL_DEFINE5(kcmp, pid_t, pid1, pid_t, pid2, int, type,
74920 struct task_struct *task1, *task2;
74921 int ret;
74922
74923 +#ifdef CONFIG_GRKERNSEC
74924 + return -ENOSYS;
74925 +#endif
74926 +
74927 rcu_read_lock();
74928
74929 /*
74930 diff --git a/kernel/kexec.c b/kernel/kexec.c
74931 index ffd4e11..c3ff6bf 100644
74932 --- a/kernel/kexec.c
74933 +++ b/kernel/kexec.c
74934 @@ -1048,7 +1048,8 @@ asmlinkage long compat_sys_kexec_load(unsigned long entry,
74935 unsigned long flags)
74936 {
74937 struct compat_kexec_segment in;
74938 - struct kexec_segment out, __user *ksegments;
74939 + struct kexec_segment out;
74940 + struct kexec_segment __user *ksegments;
74941 unsigned long i, result;
74942
74943 /* Don't allow clients that don't understand the native
74944 diff --git a/kernel/kmod.c b/kernel/kmod.c
74945 index 8985c87..f539dbe 100644
74946 --- a/kernel/kmod.c
74947 +++ b/kernel/kmod.c
74948 @@ -75,7 +75,7 @@ static void free_modprobe_argv(struct subprocess_info *info)
74949 kfree(info->argv);
74950 }
74951
74952 -static int call_modprobe(char *module_name, int wait)
74953 +static int call_modprobe(char *module_name, char *module_param, int wait)
74954 {
74955 static char *envp[] = {
74956 "HOME=/",
74957 @@ -84,7 +84,7 @@ static int call_modprobe(char *module_name, int wait)
74958 NULL
74959 };
74960
74961 - char **argv = kmalloc(sizeof(char *[5]), GFP_KERNEL);
74962 + char **argv = kmalloc(sizeof(char *[6]), GFP_KERNEL);
74963 if (!argv)
74964 goto out;
74965
74966 @@ -96,7 +96,8 @@ static int call_modprobe(char *module_name, int wait)
74967 argv[1] = "-q";
74968 argv[2] = "--";
74969 argv[3] = module_name; /* check free_modprobe_argv() */
74970 - argv[4] = NULL;
74971 + argv[4] = module_param;
74972 + argv[5] = NULL;
74973
74974 return call_usermodehelper_fns(modprobe_path, argv, envp,
74975 wait | UMH_KILLABLE, NULL, free_modprobe_argv, NULL);
74976 @@ -121,9 +122,8 @@ out:
74977 * If module auto-loading support is disabled then this function
74978 * becomes a no-operation.
74979 */
74980 -int __request_module(bool wait, const char *fmt, ...)
74981 +static int ____request_module(bool wait, char *module_param, const char *fmt, va_list ap)
74982 {
74983 - va_list args;
74984 char module_name[MODULE_NAME_LEN];
74985 unsigned int max_modprobes;
74986 int ret;
74987 @@ -139,9 +139,7 @@ int __request_module(bool wait, const char *fmt, ...)
74988 */
74989 WARN_ON_ONCE(wait && current_is_async());
74990
74991 - va_start(args, fmt);
74992 - ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, args);
74993 - va_end(args);
74994 + ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, ap);
74995 if (ret >= MODULE_NAME_LEN)
74996 return -ENAMETOOLONG;
74997
74998 @@ -149,6 +147,20 @@ int __request_module(bool wait, const char *fmt, ...)
74999 if (ret)
75000 return ret;
75001
75002 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
75003 + if (uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
75004 + /* hack to workaround consolekit/udisks stupidity */
75005 + read_lock(&tasklist_lock);
75006 + if (!strcmp(current->comm, "mount") &&
75007 + current->real_parent && !strncmp(current->real_parent->comm, "udisk", 5)) {
75008 + read_unlock(&tasklist_lock);
75009 + printk(KERN_ALERT "grsec: denied attempt to auto-load fs module %.64s by udisks\n", module_name);
75010 + return -EPERM;
75011 + }
75012 + read_unlock(&tasklist_lock);
75013 + }
75014 +#endif
75015 +
75016 /* If modprobe needs a service that is in a module, we get a recursive
75017 * loop. Limit the number of running kmod threads to max_threads/2 or
75018 * MAX_KMOD_CONCURRENT, whichever is the smaller. A cleaner method
75019 @@ -177,11 +189,52 @@ int __request_module(bool wait, const char *fmt, ...)
75020
75021 trace_module_request(module_name, wait, _RET_IP_);
75022
75023 - ret = call_modprobe(module_name, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
75024 + ret = call_modprobe(module_name, module_param, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
75025
75026 atomic_dec(&kmod_concurrent);
75027 return ret;
75028 }
75029 +
75030 +int ___request_module(bool wait, char *module_param, const char *fmt, ...)
75031 +{
75032 + va_list args;
75033 + int ret;
75034 +
75035 + va_start(args, fmt);
75036 + ret = ____request_module(wait, module_param, fmt, args);
75037 + va_end(args);
75038 +
75039 + return ret;
75040 +}
75041 +
75042 +int __request_module(bool wait, const char *fmt, ...)
75043 +{
75044 + va_list args;
75045 + int ret;
75046 +
75047 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
75048 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
75049 + char module_param[MODULE_NAME_LEN];
75050 +
75051 + memset(module_param, 0, sizeof(module_param));
75052 +
75053 + snprintf(module_param, sizeof(module_param) - 1, "grsec_modharden_normal%u_", GR_GLOBAL_UID(current_uid()));
75054 +
75055 + va_start(args, fmt);
75056 + ret = ____request_module(wait, module_param, fmt, args);
75057 + va_end(args);
75058 +
75059 + return ret;
75060 + }
75061 +#endif
75062 +
75063 + va_start(args, fmt);
75064 + ret = ____request_module(wait, NULL, fmt, args);
75065 + va_end(args);
75066 +
75067 + return ret;
75068 +}
75069 +
75070 EXPORT_SYMBOL(__request_module);
75071 #endif /* CONFIG_MODULES */
75072
75073 @@ -292,7 +345,7 @@ static int wait_for_helper(void *data)
75074 *
75075 * Thus the __user pointer cast is valid here.
75076 */
75077 - sys_wait4(pid, (int __user *)&ret, 0, NULL);
75078 + sys_wait4(pid, (int __force_user *)&ret, 0, NULL);
75079
75080 /*
75081 * If ret is 0, either ____call_usermodehelper failed and the
75082 @@ -649,7 +702,7 @@ EXPORT_SYMBOL(call_usermodehelper_fns);
75083 static int proc_cap_handler(struct ctl_table *table, int write,
75084 void __user *buffer, size_t *lenp, loff_t *ppos)
75085 {
75086 - struct ctl_table t;
75087 + ctl_table_no_const t;
75088 unsigned long cap_array[_KERNEL_CAPABILITY_U32S];
75089 kernel_cap_t new_cap;
75090 int err, i;
75091 diff --git a/kernel/kprobes.c b/kernel/kprobes.c
75092 index 3fed7f0..a3f95ed 100644
75093 --- a/kernel/kprobes.c
75094 +++ b/kernel/kprobes.c
75095 @@ -185,7 +185,7 @@ static kprobe_opcode_t __kprobes *__get_insn_slot(struct kprobe_insn_cache *c)
75096 * kernel image and loaded module images reside. This is required
75097 * so x86_64 can correctly handle the %rip-relative fixups.
75098 */
75099 - kip->insns = module_alloc(PAGE_SIZE);
75100 + kip->insns = module_alloc_exec(PAGE_SIZE);
75101 if (!kip->insns) {
75102 kfree(kip);
75103 return NULL;
75104 @@ -225,7 +225,7 @@ static int __kprobes collect_one_slot(struct kprobe_insn_page *kip, int idx)
75105 */
75106 if (!list_is_singular(&kip->list)) {
75107 list_del(&kip->list);
75108 - module_free(NULL, kip->insns);
75109 + module_free_exec(NULL, kip->insns);
75110 kfree(kip);
75111 }
75112 return 1;
75113 @@ -2073,7 +2073,7 @@ static int __init init_kprobes(void)
75114 {
75115 int i, err = 0;
75116 unsigned long offset = 0, size = 0;
75117 - char *modname, namebuf[128];
75118 + char *modname, namebuf[KSYM_NAME_LEN];
75119 const char *symbol_name;
75120 void *addr;
75121 struct kprobe_blackpoint *kb;
75122 @@ -2158,11 +2158,11 @@ static void __kprobes report_probe(struct seq_file *pi, struct kprobe *p,
75123 kprobe_type = "k";
75124
75125 if (sym)
75126 - seq_printf(pi, "%p %s %s+0x%x %s ",
75127 + seq_printf(pi, "%pK %s %s+0x%x %s ",
75128 p->addr, kprobe_type, sym, offset,
75129 (modname ? modname : " "));
75130 else
75131 - seq_printf(pi, "%p %s %p ",
75132 + seq_printf(pi, "%pK %s %pK ",
75133 p->addr, kprobe_type, p->addr);
75134
75135 if (!pp)
75136 @@ -2199,7 +2199,7 @@ static int __kprobes show_kprobe_addr(struct seq_file *pi, void *v)
75137 const char *sym = NULL;
75138 unsigned int i = *(loff_t *) v;
75139 unsigned long offset = 0;
75140 - char *modname, namebuf[128];
75141 + char *modname, namebuf[KSYM_NAME_LEN];
75142
75143 head = &kprobe_table[i];
75144 preempt_disable();
75145 diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
75146 index 6ada93c..dce7d5d 100644
75147 --- a/kernel/ksysfs.c
75148 +++ b/kernel/ksysfs.c
75149 @@ -46,6 +46,8 @@ static ssize_t uevent_helper_store(struct kobject *kobj,
75150 {
75151 if (count+1 > UEVENT_HELPER_PATH_LEN)
75152 return -ENOENT;
75153 + if (!capable(CAP_SYS_ADMIN))
75154 + return -EPERM;
75155 memcpy(uevent_helper, buf, count);
75156 uevent_helper[count] = '\0';
75157 if (count && uevent_helper[count-1] == '\n')
75158 @@ -172,7 +174,7 @@ static ssize_t notes_read(struct file *filp, struct kobject *kobj,
75159 return count;
75160 }
75161
75162 -static struct bin_attribute notes_attr = {
75163 +static bin_attribute_no_const notes_attr __read_only = {
75164 .attr = {
75165 .name = "notes",
75166 .mode = S_IRUGO,
75167 diff --git a/kernel/lockdep.c b/kernel/lockdep.c
75168 index 8a0efac..56f1e2d 100644
75169 --- a/kernel/lockdep.c
75170 +++ b/kernel/lockdep.c
75171 @@ -590,6 +590,10 @@ static int static_obj(void *obj)
75172 end = (unsigned long) &_end,
75173 addr = (unsigned long) obj;
75174
75175 +#ifdef CONFIG_PAX_KERNEXEC
75176 + start = ktla_ktva(start);
75177 +#endif
75178 +
75179 /*
75180 * static variable?
75181 */
75182 @@ -730,6 +734,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
75183 if (!static_obj(lock->key)) {
75184 debug_locks_off();
75185 printk("INFO: trying to register non-static key.\n");
75186 + printk("lock:%pS key:%pS.\n", lock, lock->key);
75187 printk("the code is fine but needs lockdep annotation.\n");
75188 printk("turning off the locking correctness validator.\n");
75189 dump_stack();
75190 @@ -3078,7 +3083,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
75191 if (!class)
75192 return 0;
75193 }
75194 - atomic_inc((atomic_t *)&class->ops);
75195 + atomic_inc_unchecked((atomic_unchecked_t *)&class->ops);
75196 if (very_verbose(class)) {
75197 printk("\nacquire class [%p] %s", class->key, class->name);
75198 if (class->name_version > 1)
75199 diff --git a/kernel/lockdep_proc.c b/kernel/lockdep_proc.c
75200 index b2c71c5..7b88d63 100644
75201 --- a/kernel/lockdep_proc.c
75202 +++ b/kernel/lockdep_proc.c
75203 @@ -65,7 +65,7 @@ static int l_show(struct seq_file *m, void *v)
75204 return 0;
75205 }
75206
75207 - seq_printf(m, "%p", class->key);
75208 + seq_printf(m, "%pK", class->key);
75209 #ifdef CONFIG_DEBUG_LOCKDEP
75210 seq_printf(m, " OPS:%8ld", class->ops);
75211 #endif
75212 @@ -83,7 +83,7 @@ static int l_show(struct seq_file *m, void *v)
75213
75214 list_for_each_entry(entry, &class->locks_after, entry) {
75215 if (entry->distance == 1) {
75216 - seq_printf(m, " -> [%p] ", entry->class->key);
75217 + seq_printf(m, " -> [%pK] ", entry->class->key);
75218 print_name(m, entry->class);
75219 seq_puts(m, "\n");
75220 }
75221 @@ -152,7 +152,7 @@ static int lc_show(struct seq_file *m, void *v)
75222 if (!class->key)
75223 continue;
75224
75225 - seq_printf(m, "[%p] ", class->key);
75226 + seq_printf(m, "[%pK] ", class->key);
75227 print_name(m, class);
75228 seq_puts(m, "\n");
75229 }
75230 @@ -495,7 +495,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
75231 if (!i)
75232 seq_line(m, '-', 40-namelen, namelen);
75233
75234 - snprintf(ip, sizeof(ip), "[<%p>]",
75235 + snprintf(ip, sizeof(ip), "[<%pK>]",
75236 (void *)class->contention_point[i]);
75237 seq_printf(m, "%40s %14lu %29s %pS\n",
75238 name, stats->contention_point[i],
75239 @@ -510,7 +510,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
75240 if (!i)
75241 seq_line(m, '-', 40-namelen, namelen);
75242
75243 - snprintf(ip, sizeof(ip), "[<%p>]",
75244 + snprintf(ip, sizeof(ip), "[<%pK>]",
75245 (void *)class->contending_point[i]);
75246 seq_printf(m, "%40s %14lu %29s %pS\n",
75247 name, stats->contending_point[i],
75248 diff --git a/kernel/module.c b/kernel/module.c
75249 index 0925c9a..6b044ac 100644
75250 --- a/kernel/module.c
75251 +++ b/kernel/module.c
75252 @@ -61,6 +61,7 @@
75253 #include <linux/pfn.h>
75254 #include <linux/bsearch.h>
75255 #include <linux/fips.h>
75256 +#include <linux/grsecurity.h>
75257 #include <uapi/linux/module.h>
75258 #include "module-internal.h"
75259
75260 @@ -156,7 +157,8 @@ static BLOCKING_NOTIFIER_HEAD(module_notify_list);
75261
75262 /* Bounds of module allocation, for speeding __module_address.
75263 * Protected by module_mutex. */
75264 -static unsigned long module_addr_min = -1UL, module_addr_max = 0;
75265 +static unsigned long module_addr_min_rw = -1UL, module_addr_max_rw = 0;
75266 +static unsigned long module_addr_min_rx = -1UL, module_addr_max_rx = 0;
75267
75268 int register_module_notifier(struct notifier_block * nb)
75269 {
75270 @@ -323,7 +325,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
75271 return true;
75272
75273 list_for_each_entry_rcu(mod, &modules, list) {
75274 - struct symsearch arr[] = {
75275 + struct symsearch modarr[] = {
75276 { mod->syms, mod->syms + mod->num_syms, mod->crcs,
75277 NOT_GPL_ONLY, false },
75278 { mod->gpl_syms, mod->gpl_syms + mod->num_gpl_syms,
75279 @@ -348,7 +350,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
75280 if (mod->state == MODULE_STATE_UNFORMED)
75281 continue;
75282
75283 - if (each_symbol_in_section(arr, ARRAY_SIZE(arr), mod, fn, data))
75284 + if (each_symbol_in_section(modarr, ARRAY_SIZE(modarr), mod, fn, data))
75285 return true;
75286 }
75287 return false;
75288 @@ -485,7 +487,7 @@ static inline void __percpu *mod_percpu(struct module *mod)
75289 static int percpu_modalloc(struct module *mod,
75290 unsigned long size, unsigned long align)
75291 {
75292 - if (align > PAGE_SIZE) {
75293 + if (align-1 >= PAGE_SIZE) {
75294 printk(KERN_WARNING "%s: per-cpu alignment %li > %li\n",
75295 mod->name, align, PAGE_SIZE);
75296 align = PAGE_SIZE;
75297 @@ -1089,7 +1091,7 @@ struct module_attribute module_uevent =
75298 static ssize_t show_coresize(struct module_attribute *mattr,
75299 struct module_kobject *mk, char *buffer)
75300 {
75301 - return sprintf(buffer, "%u\n", mk->mod->core_size);
75302 + return sprintf(buffer, "%u\n", mk->mod->core_size_rx + mk->mod->core_size_rw);
75303 }
75304
75305 static struct module_attribute modinfo_coresize =
75306 @@ -1098,7 +1100,7 @@ static struct module_attribute modinfo_coresize =
75307 static ssize_t show_initsize(struct module_attribute *mattr,
75308 struct module_kobject *mk, char *buffer)
75309 {
75310 - return sprintf(buffer, "%u\n", mk->mod->init_size);
75311 + return sprintf(buffer, "%u\n", mk->mod->init_size_rx + mk->mod->init_size_rw);
75312 }
75313
75314 static struct module_attribute modinfo_initsize =
75315 @@ -1312,7 +1314,7 @@ resolve_symbol_wait(struct module *mod,
75316 */
75317 #ifdef CONFIG_SYSFS
75318
75319 -#ifdef CONFIG_KALLSYMS
75320 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
75321 static inline bool sect_empty(const Elf_Shdr *sect)
75322 {
75323 return !(sect->sh_flags & SHF_ALLOC) || sect->sh_size == 0;
75324 @@ -1452,7 +1454,7 @@ static void add_notes_attrs(struct module *mod, const struct load_info *info)
75325 {
75326 unsigned int notes, loaded, i;
75327 struct module_notes_attrs *notes_attrs;
75328 - struct bin_attribute *nattr;
75329 + bin_attribute_no_const *nattr;
75330
75331 /* failed to create section attributes, so can't create notes */
75332 if (!mod->sect_attrs)
75333 @@ -1564,7 +1566,7 @@ static void del_usage_links(struct module *mod)
75334 static int module_add_modinfo_attrs(struct module *mod)
75335 {
75336 struct module_attribute *attr;
75337 - struct module_attribute *temp_attr;
75338 + module_attribute_no_const *temp_attr;
75339 int error = 0;
75340 int i;
75341
75342 @@ -1778,21 +1780,21 @@ static void set_section_ro_nx(void *base,
75343
75344 static void unset_module_core_ro_nx(struct module *mod)
75345 {
75346 - set_page_attributes(mod->module_core + mod->core_text_size,
75347 - mod->module_core + mod->core_size,
75348 + set_page_attributes(mod->module_core_rw,
75349 + mod->module_core_rw + mod->core_size_rw,
75350 set_memory_x);
75351 - set_page_attributes(mod->module_core,
75352 - mod->module_core + mod->core_ro_size,
75353 + set_page_attributes(mod->module_core_rx,
75354 + mod->module_core_rx + mod->core_size_rx,
75355 set_memory_rw);
75356 }
75357
75358 static void unset_module_init_ro_nx(struct module *mod)
75359 {
75360 - set_page_attributes(mod->module_init + mod->init_text_size,
75361 - mod->module_init + mod->init_size,
75362 + set_page_attributes(mod->module_init_rw,
75363 + mod->module_init_rw + mod->init_size_rw,
75364 set_memory_x);
75365 - set_page_attributes(mod->module_init,
75366 - mod->module_init + mod->init_ro_size,
75367 + set_page_attributes(mod->module_init_rx,
75368 + mod->module_init_rx + mod->init_size_rx,
75369 set_memory_rw);
75370 }
75371
75372 @@ -1805,14 +1807,14 @@ void set_all_modules_text_rw(void)
75373 list_for_each_entry_rcu(mod, &modules, list) {
75374 if (mod->state == MODULE_STATE_UNFORMED)
75375 continue;
75376 - if ((mod->module_core) && (mod->core_text_size)) {
75377 - set_page_attributes(mod->module_core,
75378 - mod->module_core + mod->core_text_size,
75379 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
75380 + set_page_attributes(mod->module_core_rx,
75381 + mod->module_core_rx + mod->core_size_rx,
75382 set_memory_rw);
75383 }
75384 - if ((mod->module_init) && (mod->init_text_size)) {
75385 - set_page_attributes(mod->module_init,
75386 - mod->module_init + mod->init_text_size,
75387 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
75388 + set_page_attributes(mod->module_init_rx,
75389 + mod->module_init_rx + mod->init_size_rx,
75390 set_memory_rw);
75391 }
75392 }
75393 @@ -1828,14 +1830,14 @@ void set_all_modules_text_ro(void)
75394 list_for_each_entry_rcu(mod, &modules, list) {
75395 if (mod->state == MODULE_STATE_UNFORMED)
75396 continue;
75397 - if ((mod->module_core) && (mod->core_text_size)) {
75398 - set_page_attributes(mod->module_core,
75399 - mod->module_core + mod->core_text_size,
75400 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
75401 + set_page_attributes(mod->module_core_rx,
75402 + mod->module_core_rx + mod->core_size_rx,
75403 set_memory_ro);
75404 }
75405 - if ((mod->module_init) && (mod->init_text_size)) {
75406 - set_page_attributes(mod->module_init,
75407 - mod->module_init + mod->init_text_size,
75408 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
75409 + set_page_attributes(mod->module_init_rx,
75410 + mod->module_init_rx + mod->init_size_rx,
75411 set_memory_ro);
75412 }
75413 }
75414 @@ -1881,16 +1883,19 @@ static void free_module(struct module *mod)
75415
75416 /* This may be NULL, but that's OK */
75417 unset_module_init_ro_nx(mod);
75418 - module_free(mod, mod->module_init);
75419 + module_free(mod, mod->module_init_rw);
75420 + module_free_exec(mod, mod->module_init_rx);
75421 kfree(mod->args);
75422 percpu_modfree(mod);
75423
75424 /* Free lock-classes: */
75425 - lockdep_free_key_range(mod->module_core, mod->core_size);
75426 + lockdep_free_key_range(mod->module_core_rx, mod->core_size_rx);
75427 + lockdep_free_key_range(mod->module_core_rw, mod->core_size_rw);
75428
75429 /* Finally, free the core (containing the module structure) */
75430 unset_module_core_ro_nx(mod);
75431 - module_free(mod, mod->module_core);
75432 + module_free_exec(mod, mod->module_core_rx);
75433 + module_free(mod, mod->module_core_rw);
75434
75435 #ifdef CONFIG_MPU
75436 update_protections(current->mm);
75437 @@ -1960,9 +1965,31 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
75438 int ret = 0;
75439 const struct kernel_symbol *ksym;
75440
75441 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
75442 + int is_fs_load = 0;
75443 + int register_filesystem_found = 0;
75444 + char *p;
75445 +
75446 + p = strstr(mod->args, "grsec_modharden_fs");
75447 + if (p) {
75448 + char *endptr = p + sizeof("grsec_modharden_fs") - 1;
75449 + /* copy \0 as well */
75450 + memmove(p, endptr, strlen(mod->args) - (unsigned int)(endptr - mod->args) + 1);
75451 + is_fs_load = 1;
75452 + }
75453 +#endif
75454 +
75455 for (i = 1; i < symsec->sh_size / sizeof(Elf_Sym); i++) {
75456 const char *name = info->strtab + sym[i].st_name;
75457
75458 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
75459 + /* it's a real shame this will never get ripped and copied
75460 + upstream! ;(
75461 + */
75462 + if (is_fs_load && !strcmp(name, "register_filesystem"))
75463 + register_filesystem_found = 1;
75464 +#endif
75465 +
75466 switch (sym[i].st_shndx) {
75467 case SHN_COMMON:
75468 /* We compiled with -fno-common. These are not
75469 @@ -1983,7 +2010,9 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
75470 ksym = resolve_symbol_wait(mod, info, name);
75471 /* Ok if resolved. */
75472 if (ksym && !IS_ERR(ksym)) {
75473 + pax_open_kernel();
75474 sym[i].st_value = ksym->value;
75475 + pax_close_kernel();
75476 break;
75477 }
75478
75479 @@ -2002,11 +2031,20 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
75480 secbase = (unsigned long)mod_percpu(mod);
75481 else
75482 secbase = info->sechdrs[sym[i].st_shndx].sh_addr;
75483 + pax_open_kernel();
75484 sym[i].st_value += secbase;
75485 + pax_close_kernel();
75486 break;
75487 }
75488 }
75489
75490 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
75491 + if (is_fs_load && !register_filesystem_found) {
75492 + printk(KERN_ALERT "grsec: Denied attempt to load non-fs module %.64s through mount\n", mod->name);
75493 + ret = -EPERM;
75494 + }
75495 +#endif
75496 +
75497 return ret;
75498 }
75499
75500 @@ -2090,22 +2128,12 @@ static void layout_sections(struct module *mod, struct load_info *info)
75501 || s->sh_entsize != ~0UL
75502 || strstarts(sname, ".init"))
75503 continue;
75504 - s->sh_entsize = get_offset(mod, &mod->core_size, s, i);
75505 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
75506 + s->sh_entsize = get_offset(mod, &mod->core_size_rw, s, i);
75507 + else
75508 + s->sh_entsize = get_offset(mod, &mod->core_size_rx, s, i);
75509 pr_debug("\t%s\n", sname);
75510 }
75511 - switch (m) {
75512 - case 0: /* executable */
75513 - mod->core_size = debug_align(mod->core_size);
75514 - mod->core_text_size = mod->core_size;
75515 - break;
75516 - case 1: /* RO: text and ro-data */
75517 - mod->core_size = debug_align(mod->core_size);
75518 - mod->core_ro_size = mod->core_size;
75519 - break;
75520 - case 3: /* whole core */
75521 - mod->core_size = debug_align(mod->core_size);
75522 - break;
75523 - }
75524 }
75525
75526 pr_debug("Init section allocation order:\n");
75527 @@ -2119,23 +2147,13 @@ static void layout_sections(struct module *mod, struct load_info *info)
75528 || s->sh_entsize != ~0UL
75529 || !strstarts(sname, ".init"))
75530 continue;
75531 - s->sh_entsize = (get_offset(mod, &mod->init_size, s, i)
75532 - | INIT_OFFSET_MASK);
75533 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
75534 + s->sh_entsize = get_offset(mod, &mod->init_size_rw, s, i);
75535 + else
75536 + s->sh_entsize = get_offset(mod, &mod->init_size_rx, s, i);
75537 + s->sh_entsize |= INIT_OFFSET_MASK;
75538 pr_debug("\t%s\n", sname);
75539 }
75540 - switch (m) {
75541 - case 0: /* executable */
75542 - mod->init_size = debug_align(mod->init_size);
75543 - mod->init_text_size = mod->init_size;
75544 - break;
75545 - case 1: /* RO: text and ro-data */
75546 - mod->init_size = debug_align(mod->init_size);
75547 - mod->init_ro_size = mod->init_size;
75548 - break;
75549 - case 3: /* whole init */
75550 - mod->init_size = debug_align(mod->init_size);
75551 - break;
75552 - }
75553 }
75554 }
75555
75556 @@ -2308,7 +2326,7 @@ static void layout_symtab(struct module *mod, struct load_info *info)
75557
75558 /* Put symbol section at end of init part of module. */
75559 symsect->sh_flags |= SHF_ALLOC;
75560 - symsect->sh_entsize = get_offset(mod, &mod->init_size, symsect,
75561 + symsect->sh_entsize = get_offset(mod, &mod->init_size_rx, symsect,
75562 info->index.sym) | INIT_OFFSET_MASK;
75563 pr_debug("\t%s\n", info->secstrings + symsect->sh_name);
75564
75565 @@ -2325,13 +2343,13 @@ static void layout_symtab(struct module *mod, struct load_info *info)
75566 }
75567
75568 /* Append room for core symbols at end of core part. */
75569 - info->symoffs = ALIGN(mod->core_size, symsect->sh_addralign ?: 1);
75570 - info->stroffs = mod->core_size = info->symoffs + ndst * sizeof(Elf_Sym);
75571 - mod->core_size += strtab_size;
75572 + info->symoffs = ALIGN(mod->core_size_rx, symsect->sh_addralign ?: 1);
75573 + info->stroffs = mod->core_size_rx = info->symoffs + ndst * sizeof(Elf_Sym);
75574 + mod->core_size_rx += strtab_size;
75575
75576 /* Put string table section at end of init part of module. */
75577 strsect->sh_flags |= SHF_ALLOC;
75578 - strsect->sh_entsize = get_offset(mod, &mod->init_size, strsect,
75579 + strsect->sh_entsize = get_offset(mod, &mod->init_size_rx, strsect,
75580 info->index.str) | INIT_OFFSET_MASK;
75581 pr_debug("\t%s\n", info->secstrings + strsect->sh_name);
75582 }
75583 @@ -2349,12 +2367,14 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
75584 /* Make sure we get permanent strtab: don't use info->strtab. */
75585 mod->strtab = (void *)info->sechdrs[info->index.str].sh_addr;
75586
75587 + pax_open_kernel();
75588 +
75589 /* Set types up while we still have access to sections. */
75590 for (i = 0; i < mod->num_symtab; i++)
75591 mod->symtab[i].st_info = elf_type(&mod->symtab[i], info);
75592
75593 - mod->core_symtab = dst = mod->module_core + info->symoffs;
75594 - mod->core_strtab = s = mod->module_core + info->stroffs;
75595 + mod->core_symtab = dst = mod->module_core_rx + info->symoffs;
75596 + mod->core_strtab = s = mod->module_core_rx + info->stroffs;
75597 src = mod->symtab;
75598 for (ndst = i = 0; i < mod->num_symtab; i++) {
75599 if (i == 0 ||
75600 @@ -2366,6 +2386,8 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
75601 }
75602 }
75603 mod->core_num_syms = ndst;
75604 +
75605 + pax_close_kernel();
75606 }
75607 #else
75608 static inline void layout_symtab(struct module *mod, struct load_info *info)
75609 @@ -2399,17 +2421,33 @@ void * __weak module_alloc(unsigned long size)
75610 return vmalloc_exec(size);
75611 }
75612
75613 -static void *module_alloc_update_bounds(unsigned long size)
75614 +static void *module_alloc_update_bounds_rw(unsigned long size)
75615 {
75616 void *ret = module_alloc(size);
75617
75618 if (ret) {
75619 mutex_lock(&module_mutex);
75620 /* Update module bounds. */
75621 - if ((unsigned long)ret < module_addr_min)
75622 - module_addr_min = (unsigned long)ret;
75623 - if ((unsigned long)ret + size > module_addr_max)
75624 - module_addr_max = (unsigned long)ret + size;
75625 + if ((unsigned long)ret < module_addr_min_rw)
75626 + module_addr_min_rw = (unsigned long)ret;
75627 + if ((unsigned long)ret + size > module_addr_max_rw)
75628 + module_addr_max_rw = (unsigned long)ret + size;
75629 + mutex_unlock(&module_mutex);
75630 + }
75631 + return ret;
75632 +}
75633 +
75634 +static void *module_alloc_update_bounds_rx(unsigned long size)
75635 +{
75636 + void *ret = module_alloc_exec(size);
75637 +
75638 + if (ret) {
75639 + mutex_lock(&module_mutex);
75640 + /* Update module bounds. */
75641 + if ((unsigned long)ret < module_addr_min_rx)
75642 + module_addr_min_rx = (unsigned long)ret;
75643 + if ((unsigned long)ret + size > module_addr_max_rx)
75644 + module_addr_max_rx = (unsigned long)ret + size;
75645 mutex_unlock(&module_mutex);
75646 }
75647 return ret;
75648 @@ -2685,8 +2723,14 @@ static struct module *setup_load_info(struct load_info *info, int flags)
75649 static int check_modinfo(struct module *mod, struct load_info *info, int flags)
75650 {
75651 const char *modmagic = get_modinfo(info, "vermagic");
75652 + const char *license = get_modinfo(info, "license");
75653 int err;
75654
75655 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
75656 + if (!license || !license_is_gpl_compatible(license))
75657 + return -ENOEXEC;
75658 +#endif
75659 +
75660 if (flags & MODULE_INIT_IGNORE_VERMAGIC)
75661 modmagic = NULL;
75662
75663 @@ -2712,7 +2756,7 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags)
75664 }
75665
75666 /* Set up license info based on the info section */
75667 - set_license(mod, get_modinfo(info, "license"));
75668 + set_license(mod, license);
75669
75670 return 0;
75671 }
75672 @@ -2806,7 +2850,7 @@ static int move_module(struct module *mod, struct load_info *info)
75673 void *ptr;
75674
75675 /* Do the allocs. */
75676 - ptr = module_alloc_update_bounds(mod->core_size);
75677 + ptr = module_alloc_update_bounds_rw(mod->core_size_rw);
75678 /*
75679 * The pointer to this block is stored in the module structure
75680 * which is inside the block. Just mark it as not being a
75681 @@ -2816,11 +2860,11 @@ static int move_module(struct module *mod, struct load_info *info)
75682 if (!ptr)
75683 return -ENOMEM;
75684
75685 - memset(ptr, 0, mod->core_size);
75686 - mod->module_core = ptr;
75687 + memset(ptr, 0, mod->core_size_rw);
75688 + mod->module_core_rw = ptr;
75689
75690 - if (mod->init_size) {
75691 - ptr = module_alloc_update_bounds(mod->init_size);
75692 + if (mod->init_size_rw) {
75693 + ptr = module_alloc_update_bounds_rw(mod->init_size_rw);
75694 /*
75695 * The pointer to this block is stored in the module structure
75696 * which is inside the block. This block doesn't need to be
75697 @@ -2829,13 +2873,45 @@ static int move_module(struct module *mod, struct load_info *info)
75698 */
75699 kmemleak_ignore(ptr);
75700 if (!ptr) {
75701 - module_free(mod, mod->module_core);
75702 + module_free(mod, mod->module_core_rw);
75703 return -ENOMEM;
75704 }
75705 - memset(ptr, 0, mod->init_size);
75706 - mod->module_init = ptr;
75707 + memset(ptr, 0, mod->init_size_rw);
75708 + mod->module_init_rw = ptr;
75709 } else
75710 - mod->module_init = NULL;
75711 + mod->module_init_rw = NULL;
75712 +
75713 + ptr = module_alloc_update_bounds_rx(mod->core_size_rx);
75714 + kmemleak_not_leak(ptr);
75715 + if (!ptr) {
75716 + if (mod->module_init_rw)
75717 + module_free(mod, mod->module_init_rw);
75718 + module_free(mod, mod->module_core_rw);
75719 + return -ENOMEM;
75720 + }
75721 +
75722 + pax_open_kernel();
75723 + memset(ptr, 0, mod->core_size_rx);
75724 + pax_close_kernel();
75725 + mod->module_core_rx = ptr;
75726 +
75727 + if (mod->init_size_rx) {
75728 + ptr = module_alloc_update_bounds_rx(mod->init_size_rx);
75729 + kmemleak_ignore(ptr);
75730 + if (!ptr && mod->init_size_rx) {
75731 + module_free_exec(mod, mod->module_core_rx);
75732 + if (mod->module_init_rw)
75733 + module_free(mod, mod->module_init_rw);
75734 + module_free(mod, mod->module_core_rw);
75735 + return -ENOMEM;
75736 + }
75737 +
75738 + pax_open_kernel();
75739 + memset(ptr, 0, mod->init_size_rx);
75740 + pax_close_kernel();
75741 + mod->module_init_rx = ptr;
75742 + } else
75743 + mod->module_init_rx = NULL;
75744
75745 /* Transfer each section which specifies SHF_ALLOC */
75746 pr_debug("final section addresses:\n");
75747 @@ -2846,16 +2922,45 @@ static int move_module(struct module *mod, struct load_info *info)
75748 if (!(shdr->sh_flags & SHF_ALLOC))
75749 continue;
75750
75751 - if (shdr->sh_entsize & INIT_OFFSET_MASK)
75752 - dest = mod->module_init
75753 - + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
75754 - else
75755 - dest = mod->module_core + shdr->sh_entsize;
75756 + if (shdr->sh_entsize & INIT_OFFSET_MASK) {
75757 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
75758 + dest = mod->module_init_rw
75759 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
75760 + else
75761 + dest = mod->module_init_rx
75762 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
75763 + } else {
75764 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
75765 + dest = mod->module_core_rw + shdr->sh_entsize;
75766 + else
75767 + dest = mod->module_core_rx + shdr->sh_entsize;
75768 + }
75769 +
75770 + if (shdr->sh_type != SHT_NOBITS) {
75771 +
75772 +#ifdef CONFIG_PAX_KERNEXEC
75773 +#ifdef CONFIG_X86_64
75774 + if ((shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_EXECINSTR))
75775 + set_memory_x((unsigned long)dest, (shdr->sh_size + PAGE_SIZE) >> PAGE_SHIFT);
75776 +#endif
75777 + if (!(shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_ALLOC)) {
75778 + pax_open_kernel();
75779 + memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
75780 + pax_close_kernel();
75781 + } else
75782 +#endif
75783
75784 - if (shdr->sh_type != SHT_NOBITS)
75785 memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
75786 + }
75787 /* Update sh_addr to point to copy in image. */
75788 - shdr->sh_addr = (unsigned long)dest;
75789 +
75790 +#ifdef CONFIG_PAX_KERNEXEC
75791 + if (shdr->sh_flags & SHF_EXECINSTR)
75792 + shdr->sh_addr = ktva_ktla((unsigned long)dest);
75793 + else
75794 +#endif
75795 +
75796 + shdr->sh_addr = (unsigned long)dest;
75797 pr_debug("\t0x%lx %s\n",
75798 (long)shdr->sh_addr, info->secstrings + shdr->sh_name);
75799 }
75800 @@ -2912,12 +3017,12 @@ static void flush_module_icache(const struct module *mod)
75801 * Do it before processing of module parameters, so the module
75802 * can provide parameter accessor functions of its own.
75803 */
75804 - if (mod->module_init)
75805 - flush_icache_range((unsigned long)mod->module_init,
75806 - (unsigned long)mod->module_init
75807 - + mod->init_size);
75808 - flush_icache_range((unsigned long)mod->module_core,
75809 - (unsigned long)mod->module_core + mod->core_size);
75810 + if (mod->module_init_rx)
75811 + flush_icache_range((unsigned long)mod->module_init_rx,
75812 + (unsigned long)mod->module_init_rx
75813 + + mod->init_size_rx);
75814 + flush_icache_range((unsigned long)mod->module_core_rx,
75815 + (unsigned long)mod->module_core_rx + mod->core_size_rx);
75816
75817 set_fs(old_fs);
75818 }
75819 @@ -2987,8 +3092,10 @@ out:
75820 static void module_deallocate(struct module *mod, struct load_info *info)
75821 {
75822 percpu_modfree(mod);
75823 - module_free(mod, mod->module_init);
75824 - module_free(mod, mod->module_core);
75825 + module_free_exec(mod, mod->module_init_rx);
75826 + module_free_exec(mod, mod->module_core_rx);
75827 + module_free(mod, mod->module_init_rw);
75828 + module_free(mod, mod->module_core_rw);
75829 }
75830
75831 int __weak module_finalize(const Elf_Ehdr *hdr,
75832 @@ -3001,7 +3108,9 @@ int __weak module_finalize(const Elf_Ehdr *hdr,
75833 static int post_relocation(struct module *mod, const struct load_info *info)
75834 {
75835 /* Sort exception table now relocations are done. */
75836 + pax_open_kernel();
75837 sort_extable(mod->extable, mod->extable + mod->num_exentries);
75838 + pax_close_kernel();
75839
75840 /* Copy relocated percpu area over. */
75841 percpu_modcopy(mod, (void *)info->sechdrs[info->index.pcpu].sh_addr,
75842 @@ -3055,16 +3164,16 @@ static int do_init_module(struct module *mod)
75843 MODULE_STATE_COMING, mod);
75844
75845 /* Set RO and NX regions for core */
75846 - set_section_ro_nx(mod->module_core,
75847 - mod->core_text_size,
75848 - mod->core_ro_size,
75849 - mod->core_size);
75850 + set_section_ro_nx(mod->module_core_rx,
75851 + mod->core_size_rx,
75852 + mod->core_size_rx,
75853 + mod->core_size_rx);
75854
75855 /* Set RO and NX regions for init */
75856 - set_section_ro_nx(mod->module_init,
75857 - mod->init_text_size,
75858 - mod->init_ro_size,
75859 - mod->init_size);
75860 + set_section_ro_nx(mod->module_init_rx,
75861 + mod->init_size_rx,
75862 + mod->init_size_rx,
75863 + mod->init_size_rx);
75864
75865 do_mod_ctors(mod);
75866 /* Start the module */
75867 @@ -3126,11 +3235,12 @@ static int do_init_module(struct module *mod)
75868 mod->strtab = mod->core_strtab;
75869 #endif
75870 unset_module_init_ro_nx(mod);
75871 - module_free(mod, mod->module_init);
75872 - mod->module_init = NULL;
75873 - mod->init_size = 0;
75874 - mod->init_ro_size = 0;
75875 - mod->init_text_size = 0;
75876 + module_free(mod, mod->module_init_rw);
75877 + module_free_exec(mod, mod->module_init_rx);
75878 + mod->module_init_rw = NULL;
75879 + mod->module_init_rx = NULL;
75880 + mod->init_size_rw = 0;
75881 + mod->init_size_rx = 0;
75882 mutex_unlock(&module_mutex);
75883 wake_up_all(&module_wq);
75884
75885 @@ -3257,9 +3367,38 @@ static int load_module(struct load_info *info, const char __user *uargs,
75886 if (err)
75887 goto free_unload;
75888
75889 + /* Now copy in args */
75890 + mod->args = strndup_user(uargs, ~0UL >> 1);
75891 + if (IS_ERR(mod->args)) {
75892 + err = PTR_ERR(mod->args);
75893 + goto free_unload;
75894 + }
75895 +
75896 /* Set up MODINFO_ATTR fields */
75897 setup_modinfo(mod, info);
75898
75899 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
75900 + {
75901 + char *p, *p2;
75902 +
75903 + if (strstr(mod->args, "grsec_modharden_netdev")) {
75904 + 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);
75905 + err = -EPERM;
75906 + goto free_modinfo;
75907 + } else if ((p = strstr(mod->args, "grsec_modharden_normal"))) {
75908 + p += sizeof("grsec_modharden_normal") - 1;
75909 + p2 = strstr(p, "_");
75910 + if (p2) {
75911 + *p2 = '\0';
75912 + printk(KERN_ALERT "grsec: denied kernel module auto-load of %.64s by uid %.9s\n", mod->name, p);
75913 + *p2 = '_';
75914 + }
75915 + err = -EPERM;
75916 + goto free_modinfo;
75917 + }
75918 + }
75919 +#endif
75920 +
75921 /* Fix up syms, so that st_value is a pointer to location. */
75922 err = simplify_symbols(mod, info);
75923 if (err < 0)
75924 @@ -3275,13 +3414,6 @@ static int load_module(struct load_info *info, const char __user *uargs,
75925
75926 flush_module_icache(mod);
75927
75928 - /* Now copy in args */
75929 - mod->args = strndup_user(uargs, ~0UL >> 1);
75930 - if (IS_ERR(mod->args)) {
75931 - err = PTR_ERR(mod->args);
75932 - goto free_arch_cleanup;
75933 - }
75934 -
75935 dynamic_debug_setup(info->debug, info->num_debug);
75936
75937 /* Finally it's fully formed, ready to start executing. */
75938 @@ -3316,11 +3448,10 @@ static int load_module(struct load_info *info, const char __user *uargs,
75939 ddebug_cleanup:
75940 dynamic_debug_remove(info->debug);
75941 synchronize_sched();
75942 - kfree(mod->args);
75943 - free_arch_cleanup:
75944 module_arch_cleanup(mod);
75945 free_modinfo:
75946 free_modinfo(mod);
75947 + kfree(mod->args);
75948 free_unload:
75949 module_unload_free(mod);
75950 unlink_mod:
75951 @@ -3403,10 +3534,16 @@ static const char *get_ksymbol(struct module *mod,
75952 unsigned long nextval;
75953
75954 /* At worse, next value is at end of module */
75955 - if (within_module_init(addr, mod))
75956 - nextval = (unsigned long)mod->module_init+mod->init_text_size;
75957 + if (within_module_init_rx(addr, mod))
75958 + nextval = (unsigned long)mod->module_init_rx+mod->init_size_rx;
75959 + else if (within_module_init_rw(addr, mod))
75960 + nextval = (unsigned long)mod->module_init_rw+mod->init_size_rw;
75961 + else if (within_module_core_rx(addr, mod))
75962 + nextval = (unsigned long)mod->module_core_rx+mod->core_size_rx;
75963 + else if (within_module_core_rw(addr, mod))
75964 + nextval = (unsigned long)mod->module_core_rw+mod->core_size_rw;
75965 else
75966 - nextval = (unsigned long)mod->module_core+mod->core_text_size;
75967 + return NULL;
75968
75969 /* Scan for closest preceding symbol, and next symbol. (ELF
75970 starts real symbols at 1). */
75971 @@ -3659,7 +3796,7 @@ static int m_show(struct seq_file *m, void *p)
75972 return 0;
75973
75974 seq_printf(m, "%s %u",
75975 - mod->name, mod->init_size + mod->core_size);
75976 + mod->name, mod->init_size_rx + mod->init_size_rw + mod->core_size_rx + mod->core_size_rw);
75977 print_unload_info(m, mod);
75978
75979 /* Informative for users. */
75980 @@ -3668,7 +3805,7 @@ static int m_show(struct seq_file *m, void *p)
75981 mod->state == MODULE_STATE_COMING ? "Loading":
75982 "Live");
75983 /* Used by oprofile and other similar tools. */
75984 - seq_printf(m, " 0x%pK", mod->module_core);
75985 + seq_printf(m, " 0x%pK 0x%pK", mod->module_core_rx, mod->module_core_rw);
75986
75987 /* Taints info */
75988 if (mod->taints)
75989 @@ -3704,7 +3841,17 @@ static const struct file_operations proc_modules_operations = {
75990
75991 static int __init proc_modules_init(void)
75992 {
75993 +#ifndef CONFIG_GRKERNSEC_HIDESYM
75994 +#ifdef CONFIG_GRKERNSEC_PROC_USER
75995 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
75996 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
75997 + proc_create("modules", S_IRUSR | S_IRGRP, NULL, &proc_modules_operations);
75998 +#else
75999 proc_create("modules", 0, NULL, &proc_modules_operations);
76000 +#endif
76001 +#else
76002 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
76003 +#endif
76004 return 0;
76005 }
76006 module_init(proc_modules_init);
76007 @@ -3765,14 +3912,14 @@ struct module *__module_address(unsigned long addr)
76008 {
76009 struct module *mod;
76010
76011 - if (addr < module_addr_min || addr > module_addr_max)
76012 + if ((addr < module_addr_min_rx || addr > module_addr_max_rx) &&
76013 + (addr < module_addr_min_rw || addr > module_addr_max_rw))
76014 return NULL;
76015
76016 list_for_each_entry_rcu(mod, &modules, list) {
76017 if (mod->state == MODULE_STATE_UNFORMED)
76018 continue;
76019 - if (within_module_core(addr, mod)
76020 - || within_module_init(addr, mod))
76021 + if (within_module_init(addr, mod) || within_module_core(addr, mod))
76022 return mod;
76023 }
76024 return NULL;
76025 @@ -3807,11 +3954,20 @@ bool is_module_text_address(unsigned long addr)
76026 */
76027 struct module *__module_text_address(unsigned long addr)
76028 {
76029 - struct module *mod = __module_address(addr);
76030 + struct module *mod;
76031 +
76032 +#ifdef CONFIG_X86_32
76033 + addr = ktla_ktva(addr);
76034 +#endif
76035 +
76036 + if (addr < module_addr_min_rx || addr > module_addr_max_rx)
76037 + return NULL;
76038 +
76039 + mod = __module_address(addr);
76040 +
76041 if (mod) {
76042 /* Make sure it's within the text section. */
76043 - if (!within(addr, mod->module_init, mod->init_text_size)
76044 - && !within(addr, mod->module_core, mod->core_text_size))
76045 + if (!within_module_init_rx(addr, mod) && !within_module_core_rx(addr, mod))
76046 mod = NULL;
76047 }
76048 return mod;
76049 diff --git a/kernel/mutex-debug.c b/kernel/mutex-debug.c
76050 index 7e3443f..b2a1e6b 100644
76051 --- a/kernel/mutex-debug.c
76052 +++ b/kernel/mutex-debug.c
76053 @@ -49,21 +49,21 @@ void debug_mutex_free_waiter(struct mutex_waiter *waiter)
76054 }
76055
76056 void debug_mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
76057 - struct thread_info *ti)
76058 + struct task_struct *task)
76059 {
76060 SMP_DEBUG_LOCKS_WARN_ON(!spin_is_locked(&lock->wait_lock));
76061
76062 /* Mark the current thread as blocked on the lock: */
76063 - ti->task->blocked_on = waiter;
76064 + task->blocked_on = waiter;
76065 }
76066
76067 void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
76068 - struct thread_info *ti)
76069 + struct task_struct *task)
76070 {
76071 DEBUG_LOCKS_WARN_ON(list_empty(&waiter->list));
76072 - DEBUG_LOCKS_WARN_ON(waiter->task != ti->task);
76073 - DEBUG_LOCKS_WARN_ON(ti->task->blocked_on != waiter);
76074 - ti->task->blocked_on = NULL;
76075 + DEBUG_LOCKS_WARN_ON(waiter->task != task);
76076 + DEBUG_LOCKS_WARN_ON(task->blocked_on != waiter);
76077 + task->blocked_on = NULL;
76078
76079 list_del_init(&waiter->list);
76080 waiter->task = NULL;
76081 diff --git a/kernel/mutex-debug.h b/kernel/mutex-debug.h
76082 index 0799fd3..d06ae3b 100644
76083 --- a/kernel/mutex-debug.h
76084 +++ b/kernel/mutex-debug.h
76085 @@ -20,9 +20,9 @@ extern void debug_mutex_wake_waiter(struct mutex *lock,
76086 extern void debug_mutex_free_waiter(struct mutex_waiter *waiter);
76087 extern void debug_mutex_add_waiter(struct mutex *lock,
76088 struct mutex_waiter *waiter,
76089 - struct thread_info *ti);
76090 + struct task_struct *task);
76091 extern void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
76092 - struct thread_info *ti);
76093 + struct task_struct *task);
76094 extern void debug_mutex_unlock(struct mutex *lock);
76095 extern void debug_mutex_init(struct mutex *lock, const char *name,
76096 struct lock_class_key *key);
76097 diff --git a/kernel/mutex.c b/kernel/mutex.c
76098 index 52f2301..73f7528 100644
76099 --- a/kernel/mutex.c
76100 +++ b/kernel/mutex.c
76101 @@ -199,7 +199,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
76102 spin_lock_mutex(&lock->wait_lock, flags);
76103
76104 debug_mutex_lock_common(lock, &waiter);
76105 - debug_mutex_add_waiter(lock, &waiter, task_thread_info(task));
76106 + debug_mutex_add_waiter(lock, &waiter, task);
76107
76108 /* add waiting tasks to the end of the waitqueue (FIFO): */
76109 list_add_tail(&waiter.list, &lock->wait_list);
76110 @@ -228,8 +228,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
76111 * TASK_UNINTERRUPTIBLE case.)
76112 */
76113 if (unlikely(signal_pending_state(state, task))) {
76114 - mutex_remove_waiter(lock, &waiter,
76115 - task_thread_info(task));
76116 + mutex_remove_waiter(lock, &waiter, task);
76117 mutex_release(&lock->dep_map, 1, ip);
76118 spin_unlock_mutex(&lock->wait_lock, flags);
76119
76120 @@ -248,7 +247,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
76121 done:
76122 lock_acquired(&lock->dep_map, ip);
76123 /* got the lock - rejoice! */
76124 - mutex_remove_waiter(lock, &waiter, current_thread_info());
76125 + mutex_remove_waiter(lock, &waiter, task);
76126 mutex_set_owner(lock);
76127
76128 /* set it to 0 if there are no waiters left: */
76129 diff --git a/kernel/notifier.c b/kernel/notifier.c
76130 index 2d5cc4c..d9ea600 100644
76131 --- a/kernel/notifier.c
76132 +++ b/kernel/notifier.c
76133 @@ -5,6 +5,7 @@
76134 #include <linux/rcupdate.h>
76135 #include <linux/vmalloc.h>
76136 #include <linux/reboot.h>
76137 +#include <linux/mm.h>
76138
76139 /*
76140 * Notifier list for kernel code which wants to be called
76141 @@ -24,10 +25,12 @@ static int notifier_chain_register(struct notifier_block **nl,
76142 while ((*nl) != NULL) {
76143 if (n->priority > (*nl)->priority)
76144 break;
76145 - nl = &((*nl)->next);
76146 + nl = (struct notifier_block **)&((*nl)->next);
76147 }
76148 - n->next = *nl;
76149 + pax_open_kernel();
76150 + *(const void **)&n->next = *nl;
76151 rcu_assign_pointer(*nl, n);
76152 + pax_close_kernel();
76153 return 0;
76154 }
76155
76156 @@ -39,10 +42,12 @@ static int notifier_chain_cond_register(struct notifier_block **nl,
76157 return 0;
76158 if (n->priority > (*nl)->priority)
76159 break;
76160 - nl = &((*nl)->next);
76161 + nl = (struct notifier_block **)&((*nl)->next);
76162 }
76163 - n->next = *nl;
76164 + pax_open_kernel();
76165 + *(const void **)&n->next = *nl;
76166 rcu_assign_pointer(*nl, n);
76167 + pax_close_kernel();
76168 return 0;
76169 }
76170
76171 @@ -51,10 +56,12 @@ static int notifier_chain_unregister(struct notifier_block **nl,
76172 {
76173 while ((*nl) != NULL) {
76174 if ((*nl) == n) {
76175 + pax_open_kernel();
76176 rcu_assign_pointer(*nl, n->next);
76177 + pax_close_kernel();
76178 return 0;
76179 }
76180 - nl = &((*nl)->next);
76181 + nl = (struct notifier_block **)&((*nl)->next);
76182 }
76183 return -ENOENT;
76184 }
76185 diff --git a/kernel/panic.c b/kernel/panic.c
76186 index 7c57cc9..28f1b3f 100644
76187 --- a/kernel/panic.c
76188 +++ b/kernel/panic.c
76189 @@ -403,7 +403,7 @@ static void warn_slowpath_common(const char *file, int line, void *caller,
76190 const char *board;
76191
76192 printk(KERN_WARNING "------------[ cut here ]------------\n");
76193 - printk(KERN_WARNING "WARNING: at %s:%d %pS()\n", file, line, caller);
76194 + printk(KERN_WARNING "WARNING: at %s:%d %pA()\n", file, line, caller);
76195 board = dmi_get_system_info(DMI_PRODUCT_NAME);
76196 if (board)
76197 printk(KERN_WARNING "Hardware name: %s\n", board);
76198 @@ -459,7 +459,8 @@ EXPORT_SYMBOL(warn_slowpath_null);
76199 */
76200 void __stack_chk_fail(void)
76201 {
76202 - panic("stack-protector: Kernel stack is corrupted in: %p\n",
76203 + dump_stack();
76204 + panic("stack-protector: Kernel stack is corrupted in: %pA\n",
76205 __builtin_return_address(0));
76206 }
76207 EXPORT_SYMBOL(__stack_chk_fail);
76208 diff --git a/kernel/pid.c b/kernel/pid.c
76209 index 047dc62..418d74b 100644
76210 --- a/kernel/pid.c
76211 +++ b/kernel/pid.c
76212 @@ -33,6 +33,7 @@
76213 #include <linux/rculist.h>
76214 #include <linux/bootmem.h>
76215 #include <linux/hash.h>
76216 +#include <linux/security.h>
76217 #include <linux/pid_namespace.h>
76218 #include <linux/init_task.h>
76219 #include <linux/syscalls.h>
76220 @@ -46,7 +47,7 @@ struct pid init_struct_pid = INIT_STRUCT_PID;
76221
76222 int pid_max = PID_MAX_DEFAULT;
76223
76224 -#define RESERVED_PIDS 300
76225 +#define RESERVED_PIDS 500
76226
76227 int pid_max_min = RESERVED_PIDS + 1;
76228 int pid_max_max = PID_MAX_LIMIT;
76229 @@ -440,10 +441,18 @@ EXPORT_SYMBOL(pid_task);
76230 */
76231 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
76232 {
76233 + struct task_struct *task;
76234 +
76235 rcu_lockdep_assert(rcu_read_lock_held(),
76236 "find_task_by_pid_ns() needs rcu_read_lock()"
76237 " protection");
76238 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
76239 +
76240 + task = pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
76241 +
76242 + if (gr_pid_is_chrooted(task))
76243 + return NULL;
76244 +
76245 + return task;
76246 }
76247
76248 struct task_struct *find_task_by_vpid(pid_t vnr)
76249 @@ -451,6 +460,14 @@ struct task_struct *find_task_by_vpid(pid_t vnr)
76250 return find_task_by_pid_ns(vnr, task_active_pid_ns(current));
76251 }
76252
76253 +struct task_struct *find_task_by_vpid_unrestricted(pid_t vnr)
76254 +{
76255 + rcu_lockdep_assert(rcu_read_lock_held(),
76256 + "find_task_by_pid_ns() needs rcu_read_lock()"
76257 + " protection");
76258 + return pid_task(find_pid_ns(vnr, task_active_pid_ns(current)), PIDTYPE_PID);
76259 +}
76260 +
76261 struct pid *get_task_pid(struct task_struct *task, enum pid_type type)
76262 {
76263 struct pid *pid;
76264 diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
76265 index bea15bd..789f3d0 100644
76266 --- a/kernel/pid_namespace.c
76267 +++ b/kernel/pid_namespace.c
76268 @@ -249,7 +249,7 @@ static int pid_ns_ctl_handler(struct ctl_table *table, int write,
76269 void __user *buffer, size_t *lenp, loff_t *ppos)
76270 {
76271 struct pid_namespace *pid_ns = task_active_pid_ns(current);
76272 - struct ctl_table tmp = *table;
76273 + ctl_table_no_const tmp = *table;
76274
76275 if (write && !ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN))
76276 return -EPERM;
76277 diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
76278 index 8fd709c..542bf4b 100644
76279 --- a/kernel/posix-cpu-timers.c
76280 +++ b/kernel/posix-cpu-timers.c
76281 @@ -1592,14 +1592,14 @@ struct k_clock clock_posix_cpu = {
76282
76283 static __init int init_posix_cpu_timers(void)
76284 {
76285 - struct k_clock process = {
76286 + static struct k_clock process = {
76287 .clock_getres = process_cpu_clock_getres,
76288 .clock_get = process_cpu_clock_get,
76289 .timer_create = process_cpu_timer_create,
76290 .nsleep = process_cpu_nsleep,
76291 .nsleep_restart = process_cpu_nsleep_restart,
76292 };
76293 - struct k_clock thread = {
76294 + static struct k_clock thread = {
76295 .clock_getres = thread_cpu_clock_getres,
76296 .clock_get = thread_cpu_clock_get,
76297 .timer_create = thread_cpu_timer_create,
76298 diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
76299 index 6edbb2c..334f085 100644
76300 --- a/kernel/posix-timers.c
76301 +++ b/kernel/posix-timers.c
76302 @@ -43,6 +43,7 @@
76303 #include <linux/idr.h>
76304 #include <linux/posix-clock.h>
76305 #include <linux/posix-timers.h>
76306 +#include <linux/grsecurity.h>
76307 #include <linux/syscalls.h>
76308 #include <linux/wait.h>
76309 #include <linux/workqueue.h>
76310 @@ -129,7 +130,7 @@ static DEFINE_SPINLOCK(idr_lock);
76311 * which we beg off on and pass to do_sys_settimeofday().
76312 */
76313
76314 -static struct k_clock posix_clocks[MAX_CLOCKS];
76315 +static struct k_clock *posix_clocks[MAX_CLOCKS];
76316
76317 /*
76318 * These ones are defined below.
76319 @@ -227,7 +228,7 @@ static int posix_get_boottime(const clockid_t which_clock, struct timespec *tp)
76320 */
76321 static __init int init_posix_timers(void)
76322 {
76323 - struct k_clock clock_realtime = {
76324 + static struct k_clock clock_realtime = {
76325 .clock_getres = hrtimer_get_res,
76326 .clock_get = posix_clock_realtime_get,
76327 .clock_set = posix_clock_realtime_set,
76328 @@ -239,7 +240,7 @@ static __init int init_posix_timers(void)
76329 .timer_get = common_timer_get,
76330 .timer_del = common_timer_del,
76331 };
76332 - struct k_clock clock_monotonic = {
76333 + static struct k_clock clock_monotonic = {
76334 .clock_getres = hrtimer_get_res,
76335 .clock_get = posix_ktime_get_ts,
76336 .nsleep = common_nsleep,
76337 @@ -249,19 +250,19 @@ static __init int init_posix_timers(void)
76338 .timer_get = common_timer_get,
76339 .timer_del = common_timer_del,
76340 };
76341 - struct k_clock clock_monotonic_raw = {
76342 + static struct k_clock clock_monotonic_raw = {
76343 .clock_getres = hrtimer_get_res,
76344 .clock_get = posix_get_monotonic_raw,
76345 };
76346 - struct k_clock clock_realtime_coarse = {
76347 + static struct k_clock clock_realtime_coarse = {
76348 .clock_getres = posix_get_coarse_res,
76349 .clock_get = posix_get_realtime_coarse,
76350 };
76351 - struct k_clock clock_monotonic_coarse = {
76352 + static struct k_clock clock_monotonic_coarse = {
76353 .clock_getres = posix_get_coarse_res,
76354 .clock_get = posix_get_monotonic_coarse,
76355 };
76356 - struct k_clock clock_boottime = {
76357 + static struct k_clock clock_boottime = {
76358 .clock_getres = hrtimer_get_res,
76359 .clock_get = posix_get_boottime,
76360 .nsleep = common_nsleep,
76361 @@ -473,7 +474,7 @@ void posix_timers_register_clock(const clockid_t clock_id,
76362 return;
76363 }
76364
76365 - posix_clocks[clock_id] = *new_clock;
76366 + posix_clocks[clock_id] = new_clock;
76367 }
76368 EXPORT_SYMBOL_GPL(posix_timers_register_clock);
76369
76370 @@ -519,9 +520,9 @@ static struct k_clock *clockid_to_kclock(const clockid_t id)
76371 return (id & CLOCKFD_MASK) == CLOCKFD ?
76372 &clock_posix_dynamic : &clock_posix_cpu;
76373
76374 - if (id >= MAX_CLOCKS || !posix_clocks[id].clock_getres)
76375 + if (id >= MAX_CLOCKS || !posix_clocks[id] || !posix_clocks[id]->clock_getres)
76376 return NULL;
76377 - return &posix_clocks[id];
76378 + return posix_clocks[id];
76379 }
76380
76381 static int common_timer_create(struct k_itimer *new_timer)
76382 @@ -964,6 +965,13 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
76383 if (copy_from_user(&new_tp, tp, sizeof (*tp)))
76384 return -EFAULT;
76385
76386 + /* only the CLOCK_REALTIME clock can be set, all other clocks
76387 + have their clock_set fptr set to a nosettime dummy function
76388 + CLOCK_REALTIME has a NULL clock_set fptr which causes it to
76389 + call common_clock_set, which calls do_sys_settimeofday, which
76390 + we hook
76391 + */
76392 +
76393 return kc->clock_set(which_clock, &new_tp);
76394 }
76395
76396 diff --git a/kernel/power/process.c b/kernel/power/process.c
76397 index 98088e0..aaf95c0 100644
76398 --- a/kernel/power/process.c
76399 +++ b/kernel/power/process.c
76400 @@ -33,6 +33,7 @@ static int try_to_freeze_tasks(bool user_only)
76401 u64 elapsed_csecs64;
76402 unsigned int elapsed_csecs;
76403 bool wakeup = false;
76404 + bool timedout = false;
76405
76406 do_gettimeofday(&start);
76407
76408 @@ -43,13 +44,20 @@ static int try_to_freeze_tasks(bool user_only)
76409
76410 while (true) {
76411 todo = 0;
76412 + if (time_after(jiffies, end_time))
76413 + timedout = true;
76414 read_lock(&tasklist_lock);
76415 do_each_thread(g, p) {
76416 if (p == current || !freeze_task(p))
76417 continue;
76418
76419 - if (!freezer_should_skip(p))
76420 + if (!freezer_should_skip(p)) {
76421 todo++;
76422 + if (timedout) {
76423 + printk(KERN_ERR "Task refusing to freeze:\n");
76424 + sched_show_task(p);
76425 + }
76426 + }
76427 } while_each_thread(g, p);
76428 read_unlock(&tasklist_lock);
76429
76430 @@ -58,7 +66,7 @@ static int try_to_freeze_tasks(bool user_only)
76431 todo += wq_busy;
76432 }
76433
76434 - if (!todo || time_after(jiffies, end_time))
76435 + if (!todo || timedout)
76436 break;
76437
76438 if (pm_wakeup_pending()) {
76439 diff --git a/kernel/printk.c b/kernel/printk.c
76440 index abbdd9e..f294251 100644
76441 --- a/kernel/printk.c
76442 +++ b/kernel/printk.c
76443 @@ -615,11 +615,17 @@ static unsigned int devkmsg_poll(struct file *file, poll_table *wait)
76444 return ret;
76445 }
76446
76447 +static int check_syslog_permissions(int type, bool from_file);
76448 +
76449 static int devkmsg_open(struct inode *inode, struct file *file)
76450 {
76451 struct devkmsg_user *user;
76452 int err;
76453
76454 + err = check_syslog_permissions(SYSLOG_ACTION_OPEN, SYSLOG_FROM_FILE);
76455 + if (err)
76456 + return err;
76457 +
76458 /* write-only does not need any file context */
76459 if ((file->f_flags & O_ACCMODE) == O_WRONLY)
76460 return 0;
76461 @@ -828,7 +834,7 @@ static int syslog_action_restricted(int type)
76462 if (dmesg_restrict)
76463 return 1;
76464 /* Unless restricted, we allow "read all" and "get buffer size" for everybody */
76465 - return type != SYSLOG_ACTION_READ_ALL && type != SYSLOG_ACTION_SIZE_BUFFER;
76466 + return type != SYSLOG_ACTION_OPEN && type != SYSLOG_ACTION_READ_ALL && type != SYSLOG_ACTION_SIZE_BUFFER;
76467 }
76468
76469 static int check_syslog_permissions(int type, bool from_file)
76470 @@ -840,6 +846,11 @@ static int check_syslog_permissions(int type, bool from_file)
76471 if (from_file && type != SYSLOG_ACTION_OPEN)
76472 return 0;
76473
76474 +#ifdef CONFIG_GRKERNSEC_DMESG
76475 + if (grsec_enable_dmesg && !capable(CAP_SYSLOG) && !capable_nolog(CAP_SYS_ADMIN))
76476 + return -EPERM;
76477 +#endif
76478 +
76479 if (syslog_action_restricted(type)) {
76480 if (capable(CAP_SYSLOG))
76481 return 0;
76482 diff --git a/kernel/profile.c b/kernel/profile.c
76483 index dc3384e..0de5b49 100644
76484 --- a/kernel/profile.c
76485 +++ b/kernel/profile.c
76486 @@ -37,7 +37,7 @@ struct profile_hit {
76487 #define NR_PROFILE_HIT (PAGE_SIZE/sizeof(struct profile_hit))
76488 #define NR_PROFILE_GRP (NR_PROFILE_HIT/PROFILE_GRPSZ)
76489
76490 -static atomic_t *prof_buffer;
76491 +static atomic_unchecked_t *prof_buffer;
76492 static unsigned long prof_len, prof_shift;
76493
76494 int prof_on __read_mostly;
76495 @@ -260,7 +260,7 @@ static void profile_flip_buffers(void)
76496 hits[i].pc = 0;
76497 continue;
76498 }
76499 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
76500 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
76501 hits[i].hits = hits[i].pc = 0;
76502 }
76503 }
76504 @@ -321,9 +321,9 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
76505 * Add the current hit(s) and flush the write-queue out
76506 * to the global buffer:
76507 */
76508 - atomic_add(nr_hits, &prof_buffer[pc]);
76509 + atomic_add_unchecked(nr_hits, &prof_buffer[pc]);
76510 for (i = 0; i < NR_PROFILE_HIT; ++i) {
76511 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
76512 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
76513 hits[i].pc = hits[i].hits = 0;
76514 }
76515 out:
76516 @@ -398,7 +398,7 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
76517 {
76518 unsigned long pc;
76519 pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift;
76520 - atomic_add(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
76521 + atomic_add_unchecked(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
76522 }
76523 #endif /* !CONFIG_SMP */
76524
76525 @@ -494,7 +494,7 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos)
76526 return -EFAULT;
76527 buf++; p++; count--; read++;
76528 }
76529 - pnt = (char *)prof_buffer + p - sizeof(atomic_t);
76530 + pnt = (char *)prof_buffer + p - sizeof(atomic_unchecked_t);
76531 if (copy_to_user(buf, (void *)pnt, count))
76532 return -EFAULT;
76533 read += count;
76534 @@ -525,7 +525,7 @@ static ssize_t write_profile(struct file *file, const char __user *buf,
76535 }
76536 #endif
76537 profile_discard_flip_buffers();
76538 - memset(prof_buffer, 0, prof_len * sizeof(atomic_t));
76539 + memset(prof_buffer, 0, prof_len * sizeof(atomic_unchecked_t));
76540 return count;
76541 }
76542
76543 diff --git a/kernel/ptrace.c b/kernel/ptrace.c
76544 index acbd284..00bb0c9 100644
76545 --- a/kernel/ptrace.c
76546 +++ b/kernel/ptrace.c
76547 @@ -324,7 +324,7 @@ static int ptrace_attach(struct task_struct *task, long request,
76548 if (seize)
76549 flags |= PT_SEIZED;
76550 rcu_read_lock();
76551 - if (ns_capable(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
76552 + if (ns_capable_nolog(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
76553 flags |= PT_PTRACE_CAP;
76554 rcu_read_unlock();
76555 task->ptrace = flags;
76556 @@ -535,7 +535,7 @@ int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst
76557 break;
76558 return -EIO;
76559 }
76560 - if (copy_to_user(dst, buf, retval))
76561 + if (retval > sizeof(buf) || copy_to_user(dst, buf, retval))
76562 return -EFAULT;
76563 copied += retval;
76564 src += retval;
76565 @@ -726,7 +726,7 @@ int ptrace_request(struct task_struct *child, long request,
76566 bool seized = child->ptrace & PT_SEIZED;
76567 int ret = -EIO;
76568 siginfo_t siginfo, *si;
76569 - void __user *datavp = (void __user *) data;
76570 + void __user *datavp = (__force void __user *) data;
76571 unsigned long __user *datalp = datavp;
76572 unsigned long flags;
76573
76574 @@ -928,14 +928,21 @@ SYSCALL_DEFINE4(ptrace, long, request, long, pid, unsigned long, addr,
76575 goto out;
76576 }
76577
76578 + if (gr_handle_ptrace(child, request)) {
76579 + ret = -EPERM;
76580 + goto out_put_task_struct;
76581 + }
76582 +
76583 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
76584 ret = ptrace_attach(child, request, addr, data);
76585 /*
76586 * Some architectures need to do book-keeping after
76587 * a ptrace attach.
76588 */
76589 - if (!ret)
76590 + if (!ret) {
76591 arch_ptrace_attach(child);
76592 + gr_audit_ptrace(child);
76593 + }
76594 goto out_put_task_struct;
76595 }
76596
76597 @@ -963,7 +970,7 @@ int generic_ptrace_peekdata(struct task_struct *tsk, unsigned long addr,
76598 copied = access_process_vm(tsk, addr, &tmp, sizeof(tmp), 0);
76599 if (copied != sizeof(tmp))
76600 return -EIO;
76601 - return put_user(tmp, (unsigned long __user *)data);
76602 + return put_user(tmp, (__force unsigned long __user *)data);
76603 }
76604
76605 int generic_ptrace_pokedata(struct task_struct *tsk, unsigned long addr,
76606 @@ -1057,7 +1064,7 @@ int compat_ptrace_request(struct task_struct *child, compat_long_t request,
76607 }
76608
76609 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
76610 - compat_long_t addr, compat_long_t data)
76611 + compat_ulong_t addr, compat_ulong_t data)
76612 {
76613 struct task_struct *child;
76614 long ret;
76615 @@ -1073,14 +1080,21 @@ asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
76616 goto out;
76617 }
76618
76619 + if (gr_handle_ptrace(child, request)) {
76620 + ret = -EPERM;
76621 + goto out_put_task_struct;
76622 + }
76623 +
76624 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
76625 ret = ptrace_attach(child, request, addr, data);
76626 /*
76627 * Some architectures need to do book-keeping after
76628 * a ptrace attach.
76629 */
76630 - if (!ret)
76631 + if (!ret) {
76632 arch_ptrace_attach(child);
76633 + gr_audit_ptrace(child);
76634 + }
76635 goto out_put_task_struct;
76636 }
76637
76638 diff --git a/kernel/rcupdate.c b/kernel/rcupdate.c
76639 index 48ab703..07561d4 100644
76640 --- a/kernel/rcupdate.c
76641 +++ b/kernel/rcupdate.c
76642 @@ -439,10 +439,10 @@ int rcu_jiffies_till_stall_check(void)
76643 * for CONFIG_RCU_CPU_STALL_TIMEOUT.
76644 */
76645 if (till_stall_check < 3) {
76646 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 3;
76647 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 3;
76648 till_stall_check = 3;
76649 } else if (till_stall_check > 300) {
76650 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 300;
76651 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 300;
76652 till_stall_check = 300;
76653 }
76654 return till_stall_check * HZ + RCU_STALL_DELAY_DELTA;
76655 diff --git a/kernel/rcutiny.c b/kernel/rcutiny.c
76656 index a0714a5..2ab5e34 100644
76657 --- a/kernel/rcutiny.c
76658 +++ b/kernel/rcutiny.c
76659 @@ -46,7 +46,7 @@
76660 struct rcu_ctrlblk;
76661 static void invoke_rcu_callbacks(void);
76662 static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp);
76663 -static void rcu_process_callbacks(struct softirq_action *unused);
76664 +static void rcu_process_callbacks(void);
76665 static void __call_rcu(struct rcu_head *head,
76666 void (*func)(struct rcu_head *rcu),
76667 struct rcu_ctrlblk *rcp);
76668 @@ -312,7 +312,7 @@ static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp)
76669 rcu_is_callbacks_kthread()));
76670 }
76671
76672 -static void rcu_process_callbacks(struct softirq_action *unused)
76673 +static void rcu_process_callbacks(void)
76674 {
76675 __rcu_process_callbacks(&rcu_sched_ctrlblk);
76676 __rcu_process_callbacks(&rcu_bh_ctrlblk);
76677 diff --git a/kernel/rcutiny_plugin.h b/kernel/rcutiny_plugin.h
76678 index 8a23300..4255818 100644
76679 --- a/kernel/rcutiny_plugin.h
76680 +++ b/kernel/rcutiny_plugin.h
76681 @@ -945,7 +945,7 @@ static int rcu_kthread(void *arg)
76682 have_rcu_kthread_work = morework;
76683 local_irq_restore(flags);
76684 if (work)
76685 - rcu_process_callbacks(NULL);
76686 + rcu_process_callbacks();
76687 schedule_timeout_interruptible(1); /* Leave CPU for others. */
76688 }
76689
76690 diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c
76691 index e1f3a8c..42c94a2 100644
76692 --- a/kernel/rcutorture.c
76693 +++ b/kernel/rcutorture.c
76694 @@ -164,12 +164,12 @@ static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_count) =
76695 { 0 };
76696 static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_batch) =
76697 { 0 };
76698 -static atomic_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
76699 -static atomic_t n_rcu_torture_alloc;
76700 -static atomic_t n_rcu_torture_alloc_fail;
76701 -static atomic_t n_rcu_torture_free;
76702 -static atomic_t n_rcu_torture_mberror;
76703 -static atomic_t n_rcu_torture_error;
76704 +static atomic_unchecked_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
76705 +static atomic_unchecked_t n_rcu_torture_alloc;
76706 +static atomic_unchecked_t n_rcu_torture_alloc_fail;
76707 +static atomic_unchecked_t n_rcu_torture_free;
76708 +static atomic_unchecked_t n_rcu_torture_mberror;
76709 +static atomic_unchecked_t n_rcu_torture_error;
76710 static long n_rcu_torture_barrier_error;
76711 static long n_rcu_torture_boost_ktrerror;
76712 static long n_rcu_torture_boost_rterror;
76713 @@ -287,11 +287,11 @@ rcu_torture_alloc(void)
76714
76715 spin_lock_bh(&rcu_torture_lock);
76716 if (list_empty(&rcu_torture_freelist)) {
76717 - atomic_inc(&n_rcu_torture_alloc_fail);
76718 + atomic_inc_unchecked(&n_rcu_torture_alloc_fail);
76719 spin_unlock_bh(&rcu_torture_lock);
76720 return NULL;
76721 }
76722 - atomic_inc(&n_rcu_torture_alloc);
76723 + atomic_inc_unchecked(&n_rcu_torture_alloc);
76724 p = rcu_torture_freelist.next;
76725 list_del_init(p);
76726 spin_unlock_bh(&rcu_torture_lock);
76727 @@ -304,7 +304,7 @@ rcu_torture_alloc(void)
76728 static void
76729 rcu_torture_free(struct rcu_torture *p)
76730 {
76731 - atomic_inc(&n_rcu_torture_free);
76732 + atomic_inc_unchecked(&n_rcu_torture_free);
76733 spin_lock_bh(&rcu_torture_lock);
76734 list_add_tail(&p->rtort_free, &rcu_torture_freelist);
76735 spin_unlock_bh(&rcu_torture_lock);
76736 @@ -424,7 +424,7 @@ rcu_torture_cb(struct rcu_head *p)
76737 i = rp->rtort_pipe_count;
76738 if (i > RCU_TORTURE_PIPE_LEN)
76739 i = RCU_TORTURE_PIPE_LEN;
76740 - atomic_inc(&rcu_torture_wcount[i]);
76741 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
76742 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
76743 rp->rtort_mbtest = 0;
76744 rcu_torture_free(rp);
76745 @@ -472,7 +472,7 @@ static void rcu_sync_torture_deferred_free(struct rcu_torture *p)
76746 i = rp->rtort_pipe_count;
76747 if (i > RCU_TORTURE_PIPE_LEN)
76748 i = RCU_TORTURE_PIPE_LEN;
76749 - atomic_inc(&rcu_torture_wcount[i]);
76750 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
76751 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
76752 rp->rtort_mbtest = 0;
76753 list_del(&rp->rtort_free);
76754 @@ -990,7 +990,7 @@ rcu_torture_writer(void *arg)
76755 i = old_rp->rtort_pipe_count;
76756 if (i > RCU_TORTURE_PIPE_LEN)
76757 i = RCU_TORTURE_PIPE_LEN;
76758 - atomic_inc(&rcu_torture_wcount[i]);
76759 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
76760 old_rp->rtort_pipe_count++;
76761 cur_ops->deferred_free(old_rp);
76762 }
76763 @@ -1076,7 +1076,7 @@ static void rcu_torture_timer(unsigned long unused)
76764 return;
76765 }
76766 if (p->rtort_mbtest == 0)
76767 - atomic_inc(&n_rcu_torture_mberror);
76768 + atomic_inc_unchecked(&n_rcu_torture_mberror);
76769 spin_lock(&rand_lock);
76770 cur_ops->read_delay(&rand);
76771 n_rcu_torture_timers++;
76772 @@ -1146,7 +1146,7 @@ rcu_torture_reader(void *arg)
76773 continue;
76774 }
76775 if (p->rtort_mbtest == 0)
76776 - atomic_inc(&n_rcu_torture_mberror);
76777 + atomic_inc_unchecked(&n_rcu_torture_mberror);
76778 cur_ops->read_delay(&rand);
76779 preempt_disable();
76780 pipe_count = p->rtort_pipe_count;
76781 @@ -1209,11 +1209,11 @@ rcu_torture_printk(char *page)
76782 rcu_torture_current,
76783 rcu_torture_current_version,
76784 list_empty(&rcu_torture_freelist),
76785 - atomic_read(&n_rcu_torture_alloc),
76786 - atomic_read(&n_rcu_torture_alloc_fail),
76787 - atomic_read(&n_rcu_torture_free));
76788 + atomic_read_unchecked(&n_rcu_torture_alloc),
76789 + atomic_read_unchecked(&n_rcu_torture_alloc_fail),
76790 + atomic_read_unchecked(&n_rcu_torture_free));
76791 cnt += sprintf(&page[cnt], "rtmbe: %d rtbke: %ld rtbre: %ld ",
76792 - atomic_read(&n_rcu_torture_mberror),
76793 + atomic_read_unchecked(&n_rcu_torture_mberror),
76794 n_rcu_torture_boost_ktrerror,
76795 n_rcu_torture_boost_rterror);
76796 cnt += sprintf(&page[cnt], "rtbf: %ld rtb: %ld nt: %ld ",
76797 @@ -1232,14 +1232,14 @@ rcu_torture_printk(char *page)
76798 n_barrier_attempts,
76799 n_rcu_torture_barrier_error);
76800 cnt += sprintf(&page[cnt], "\n%s%s ", torture_type, TORTURE_FLAG);
76801 - if (atomic_read(&n_rcu_torture_mberror) != 0 ||
76802 + if (atomic_read_unchecked(&n_rcu_torture_mberror) != 0 ||
76803 n_rcu_torture_barrier_error != 0 ||
76804 n_rcu_torture_boost_ktrerror != 0 ||
76805 n_rcu_torture_boost_rterror != 0 ||
76806 n_rcu_torture_boost_failure != 0 ||
76807 i > 1) {
76808 cnt += sprintf(&page[cnt], "!!! ");
76809 - atomic_inc(&n_rcu_torture_error);
76810 + atomic_inc_unchecked(&n_rcu_torture_error);
76811 WARN_ON_ONCE(1);
76812 }
76813 cnt += sprintf(&page[cnt], "Reader Pipe: ");
76814 @@ -1253,7 +1253,7 @@ rcu_torture_printk(char *page)
76815 cnt += sprintf(&page[cnt], "Free-Block Circulation: ");
76816 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
76817 cnt += sprintf(&page[cnt], " %d",
76818 - atomic_read(&rcu_torture_wcount[i]));
76819 + atomic_read_unchecked(&rcu_torture_wcount[i]));
76820 }
76821 cnt += sprintf(&page[cnt], "\n");
76822 if (cur_ops->stats)
76823 @@ -1962,7 +1962,7 @@ rcu_torture_cleanup(void)
76824
76825 rcu_torture_stats_print(); /* -After- the stats thread is stopped! */
76826
76827 - if (atomic_read(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
76828 + if (atomic_read_unchecked(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
76829 rcu_torture_print_module_parms(cur_ops, "End of test: FAILURE");
76830 else if (n_online_successes != n_online_attempts ||
76831 n_offline_successes != n_offline_attempts)
76832 @@ -2031,18 +2031,18 @@ rcu_torture_init(void)
76833
76834 rcu_torture_current = NULL;
76835 rcu_torture_current_version = 0;
76836 - atomic_set(&n_rcu_torture_alloc, 0);
76837 - atomic_set(&n_rcu_torture_alloc_fail, 0);
76838 - atomic_set(&n_rcu_torture_free, 0);
76839 - atomic_set(&n_rcu_torture_mberror, 0);
76840 - atomic_set(&n_rcu_torture_error, 0);
76841 + atomic_set_unchecked(&n_rcu_torture_alloc, 0);
76842 + atomic_set_unchecked(&n_rcu_torture_alloc_fail, 0);
76843 + atomic_set_unchecked(&n_rcu_torture_free, 0);
76844 + atomic_set_unchecked(&n_rcu_torture_mberror, 0);
76845 + atomic_set_unchecked(&n_rcu_torture_error, 0);
76846 n_rcu_torture_barrier_error = 0;
76847 n_rcu_torture_boost_ktrerror = 0;
76848 n_rcu_torture_boost_rterror = 0;
76849 n_rcu_torture_boost_failure = 0;
76850 n_rcu_torture_boosts = 0;
76851 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
76852 - atomic_set(&rcu_torture_wcount[i], 0);
76853 + atomic_set_unchecked(&rcu_torture_wcount[i], 0);
76854 for_each_possible_cpu(cpu) {
76855 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
76856 per_cpu(rcu_torture_count, cpu)[i] = 0;
76857 diff --git a/kernel/rcutree.c b/kernel/rcutree.c
76858 index 5b8ad82..17274d1 100644
76859 --- a/kernel/rcutree.c
76860 +++ b/kernel/rcutree.c
76861 @@ -353,9 +353,9 @@ static void rcu_eqs_enter_common(struct rcu_dynticks *rdtp, long long oldval,
76862 rcu_prepare_for_idle(smp_processor_id());
76863 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
76864 smp_mb__before_atomic_inc(); /* See above. */
76865 - atomic_inc(&rdtp->dynticks);
76866 + atomic_inc_unchecked(&rdtp->dynticks);
76867 smp_mb__after_atomic_inc(); /* Force ordering with next sojourn. */
76868 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
76869 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
76870
76871 /*
76872 * It is illegal to enter an extended quiescent state while
76873 @@ -491,10 +491,10 @@ static void rcu_eqs_exit_common(struct rcu_dynticks *rdtp, long long oldval,
76874 int user)
76875 {
76876 smp_mb__before_atomic_inc(); /* Force ordering w/previous sojourn. */
76877 - atomic_inc(&rdtp->dynticks);
76878 + atomic_inc_unchecked(&rdtp->dynticks);
76879 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
76880 smp_mb__after_atomic_inc(); /* See above. */
76881 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
76882 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
76883 rcu_cleanup_after_idle(smp_processor_id());
76884 trace_rcu_dyntick("End", oldval, rdtp->dynticks_nesting);
76885 if (!user && !is_idle_task(current)) {
76886 @@ -633,14 +633,14 @@ void rcu_nmi_enter(void)
76887 struct rcu_dynticks *rdtp = &__get_cpu_var(rcu_dynticks);
76888
76889 if (rdtp->dynticks_nmi_nesting == 0 &&
76890 - (atomic_read(&rdtp->dynticks) & 0x1))
76891 + (atomic_read_unchecked(&rdtp->dynticks) & 0x1))
76892 return;
76893 rdtp->dynticks_nmi_nesting++;
76894 smp_mb__before_atomic_inc(); /* Force delay from prior write. */
76895 - atomic_inc(&rdtp->dynticks);
76896 + atomic_inc_unchecked(&rdtp->dynticks);
76897 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
76898 smp_mb__after_atomic_inc(); /* See above. */
76899 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
76900 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
76901 }
76902
76903 /**
76904 @@ -659,9 +659,9 @@ void rcu_nmi_exit(void)
76905 return;
76906 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
76907 smp_mb__before_atomic_inc(); /* See above. */
76908 - atomic_inc(&rdtp->dynticks);
76909 + atomic_inc_unchecked(&rdtp->dynticks);
76910 smp_mb__after_atomic_inc(); /* Force delay to next write. */
76911 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
76912 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
76913 }
76914
76915 /**
76916 @@ -675,7 +675,7 @@ int rcu_is_cpu_idle(void)
76917 int ret;
76918
76919 preempt_disable();
76920 - ret = (atomic_read(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
76921 + ret = (atomic_read_unchecked(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
76922 preempt_enable();
76923 return ret;
76924 }
76925 @@ -743,7 +743,7 @@ static int rcu_is_cpu_rrupt_from_idle(void)
76926 */
76927 static int dyntick_save_progress_counter(struct rcu_data *rdp)
76928 {
76929 - rdp->dynticks_snap = atomic_add_return(0, &rdp->dynticks->dynticks);
76930 + rdp->dynticks_snap = atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
76931 return (rdp->dynticks_snap & 0x1) == 0;
76932 }
76933
76934 @@ -758,7 +758,7 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp)
76935 unsigned int curr;
76936 unsigned int snap;
76937
76938 - curr = (unsigned int)atomic_add_return(0, &rdp->dynticks->dynticks);
76939 + curr = (unsigned int)atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
76940 snap = (unsigned int)rdp->dynticks_snap;
76941
76942 /*
76943 @@ -1698,7 +1698,7 @@ rcu_send_cbs_to_orphanage(int cpu, struct rcu_state *rsp,
76944 rsp->qlen += rdp->qlen;
76945 rdp->n_cbs_orphaned += rdp->qlen;
76946 rdp->qlen_lazy = 0;
76947 - ACCESS_ONCE(rdp->qlen) = 0;
76948 + ACCESS_ONCE_RW(rdp->qlen) = 0;
76949 }
76950
76951 /*
76952 @@ -1944,7 +1944,7 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp)
76953 }
76954 smp_mb(); /* List handling before counting for rcu_barrier(). */
76955 rdp->qlen_lazy -= count_lazy;
76956 - ACCESS_ONCE(rdp->qlen) -= count;
76957 + ACCESS_ONCE_RW(rdp->qlen) -= count;
76958 rdp->n_cbs_invoked += count;
76959
76960 /* Reinstate batch limit if we have worked down the excess. */
76961 @@ -2137,7 +2137,7 @@ __rcu_process_callbacks(struct rcu_state *rsp)
76962 /*
76963 * Do RCU core processing for the current CPU.
76964 */
76965 -static void rcu_process_callbacks(struct softirq_action *unused)
76966 +static void rcu_process_callbacks(void)
76967 {
76968 struct rcu_state *rsp;
76969
76970 @@ -2260,7 +2260,7 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
76971 local_irq_restore(flags);
76972 return;
76973 }
76974 - ACCESS_ONCE(rdp->qlen)++;
76975 + ACCESS_ONCE_RW(rdp->qlen)++;
76976 if (lazy)
76977 rdp->qlen_lazy++;
76978 else
76979 @@ -2469,11 +2469,11 @@ void synchronize_sched_expedited(void)
76980 * counter wrap on a 32-bit system. Quite a few more CPUs would of
76981 * course be required on a 64-bit system.
76982 */
76983 - if (ULONG_CMP_GE((ulong)atomic_long_read(&rsp->expedited_start),
76984 + if (ULONG_CMP_GE((ulong)atomic_long_read_unchecked(&rsp->expedited_start),
76985 (ulong)atomic_long_read(&rsp->expedited_done) +
76986 ULONG_MAX / 8)) {
76987 synchronize_sched();
76988 - atomic_long_inc(&rsp->expedited_wrap);
76989 + atomic_long_inc_unchecked(&rsp->expedited_wrap);
76990 return;
76991 }
76992
76993 @@ -2481,7 +2481,7 @@ void synchronize_sched_expedited(void)
76994 * Take a ticket. Note that atomic_inc_return() implies a
76995 * full memory barrier.
76996 */
76997 - snap = atomic_long_inc_return(&rsp->expedited_start);
76998 + snap = atomic_long_inc_return_unchecked(&rsp->expedited_start);
76999 firstsnap = snap;
77000 get_online_cpus();
77001 WARN_ON_ONCE(cpu_is_offline(raw_smp_processor_id()));
77002 @@ -2494,14 +2494,14 @@ void synchronize_sched_expedited(void)
77003 synchronize_sched_expedited_cpu_stop,
77004 NULL) == -EAGAIN) {
77005 put_online_cpus();
77006 - atomic_long_inc(&rsp->expedited_tryfail);
77007 + atomic_long_inc_unchecked(&rsp->expedited_tryfail);
77008
77009 /* Check to see if someone else did our work for us. */
77010 s = atomic_long_read(&rsp->expedited_done);
77011 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
77012 /* ensure test happens before caller kfree */
77013 smp_mb__before_atomic_inc(); /* ^^^ */
77014 - atomic_long_inc(&rsp->expedited_workdone1);
77015 + atomic_long_inc_unchecked(&rsp->expedited_workdone1);
77016 return;
77017 }
77018
77019 @@ -2510,7 +2510,7 @@ void synchronize_sched_expedited(void)
77020 udelay(trycount * num_online_cpus());
77021 } else {
77022 wait_rcu_gp(call_rcu_sched);
77023 - atomic_long_inc(&rsp->expedited_normal);
77024 + atomic_long_inc_unchecked(&rsp->expedited_normal);
77025 return;
77026 }
77027
77028 @@ -2519,7 +2519,7 @@ void synchronize_sched_expedited(void)
77029 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
77030 /* ensure test happens before caller kfree */
77031 smp_mb__before_atomic_inc(); /* ^^^ */
77032 - atomic_long_inc(&rsp->expedited_workdone2);
77033 + atomic_long_inc_unchecked(&rsp->expedited_workdone2);
77034 return;
77035 }
77036
77037 @@ -2531,10 +2531,10 @@ void synchronize_sched_expedited(void)
77038 * period works for us.
77039 */
77040 get_online_cpus();
77041 - snap = atomic_long_read(&rsp->expedited_start);
77042 + snap = atomic_long_read_unchecked(&rsp->expedited_start);
77043 smp_mb(); /* ensure read is before try_stop_cpus(). */
77044 }
77045 - atomic_long_inc(&rsp->expedited_stoppedcpus);
77046 + atomic_long_inc_unchecked(&rsp->expedited_stoppedcpus);
77047
77048 /*
77049 * Everyone up to our most recent fetch is covered by our grace
77050 @@ -2543,16 +2543,16 @@ void synchronize_sched_expedited(void)
77051 * than we did already did their update.
77052 */
77053 do {
77054 - atomic_long_inc(&rsp->expedited_done_tries);
77055 + atomic_long_inc_unchecked(&rsp->expedited_done_tries);
77056 s = atomic_long_read(&rsp->expedited_done);
77057 if (ULONG_CMP_GE((ulong)s, (ulong)snap)) {
77058 /* ensure test happens before caller kfree */
77059 smp_mb__before_atomic_inc(); /* ^^^ */
77060 - atomic_long_inc(&rsp->expedited_done_lost);
77061 + atomic_long_inc_unchecked(&rsp->expedited_done_lost);
77062 break;
77063 }
77064 } while (atomic_long_cmpxchg(&rsp->expedited_done, s, snap) != s);
77065 - atomic_long_inc(&rsp->expedited_done_exit);
77066 + atomic_long_inc_unchecked(&rsp->expedited_done_exit);
77067
77068 put_online_cpus();
77069 }
77070 @@ -2726,7 +2726,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
77071 * ACCESS_ONCE() to prevent the compiler from speculating
77072 * the increment to precede the early-exit check.
77073 */
77074 - ACCESS_ONCE(rsp->n_barrier_done)++;
77075 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
77076 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 1);
77077 _rcu_barrier_trace(rsp, "Inc1", -1, rsp->n_barrier_done);
77078 smp_mb(); /* Order ->n_barrier_done increment with below mechanism. */
77079 @@ -2776,7 +2776,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
77080
77081 /* Increment ->n_barrier_done to prevent duplicate work. */
77082 smp_mb(); /* Keep increment after above mechanism. */
77083 - ACCESS_ONCE(rsp->n_barrier_done)++;
77084 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
77085 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 0);
77086 _rcu_barrier_trace(rsp, "Inc2", -1, rsp->n_barrier_done);
77087 smp_mb(); /* Keep increment before caller's subsequent code. */
77088 @@ -2821,10 +2821,10 @@ rcu_boot_init_percpu_data(int cpu, struct rcu_state *rsp)
77089 rdp->grpmask = 1UL << (cpu - rdp->mynode->grplo);
77090 init_callback_list(rdp);
77091 rdp->qlen_lazy = 0;
77092 - ACCESS_ONCE(rdp->qlen) = 0;
77093 + ACCESS_ONCE_RW(rdp->qlen) = 0;
77094 rdp->dynticks = &per_cpu(rcu_dynticks, cpu);
77095 WARN_ON_ONCE(rdp->dynticks->dynticks_nesting != DYNTICK_TASK_EXIT_IDLE);
77096 - WARN_ON_ONCE(atomic_read(&rdp->dynticks->dynticks) != 1);
77097 + WARN_ON_ONCE(atomic_read_unchecked(&rdp->dynticks->dynticks) != 1);
77098 rdp->cpu = cpu;
77099 rdp->rsp = rsp;
77100 rcu_boot_init_nocb_percpu_data(rdp);
77101 @@ -2857,8 +2857,8 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptible)
77102 rdp->blimit = blimit;
77103 init_callback_list(rdp); /* Re-enable callbacks on this CPU. */
77104 rdp->dynticks->dynticks_nesting = DYNTICK_TASK_EXIT_IDLE;
77105 - atomic_set(&rdp->dynticks->dynticks,
77106 - (atomic_read(&rdp->dynticks->dynticks) & ~0x1) + 1);
77107 + atomic_set_unchecked(&rdp->dynticks->dynticks,
77108 + (atomic_read_unchecked(&rdp->dynticks->dynticks) & ~0x1) + 1);
77109 rcu_prepare_for_idle_init(cpu);
77110 raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */
77111
77112 diff --git a/kernel/rcutree.h b/kernel/rcutree.h
77113 index c896b50..c357252 100644
77114 --- a/kernel/rcutree.h
77115 +++ b/kernel/rcutree.h
77116 @@ -86,7 +86,7 @@ struct rcu_dynticks {
77117 long long dynticks_nesting; /* Track irq/process nesting level. */
77118 /* Process level is worth LLONG_MAX/2. */
77119 int dynticks_nmi_nesting; /* Track NMI nesting level. */
77120 - atomic_t dynticks; /* Even value for idle, else odd. */
77121 + atomic_unchecked_t dynticks;/* Even value for idle, else odd. */
77122 #ifdef CONFIG_RCU_FAST_NO_HZ
77123 int dyntick_drain; /* Prepare-for-idle state variable. */
77124 unsigned long dyntick_holdoff;
77125 @@ -416,17 +416,17 @@ struct rcu_state {
77126 /* _rcu_barrier(). */
77127 /* End of fields guarded by barrier_mutex. */
77128
77129 - atomic_long_t expedited_start; /* Starting ticket. */
77130 - atomic_long_t expedited_done; /* Done ticket. */
77131 - atomic_long_t expedited_wrap; /* # near-wrap incidents. */
77132 - atomic_long_t expedited_tryfail; /* # acquisition failures. */
77133 - atomic_long_t expedited_workdone1; /* # done by others #1. */
77134 - atomic_long_t expedited_workdone2; /* # done by others #2. */
77135 - atomic_long_t expedited_normal; /* # fallbacks to normal. */
77136 - atomic_long_t expedited_stoppedcpus; /* # successful stop_cpus. */
77137 - atomic_long_t expedited_done_tries; /* # tries to update _done. */
77138 - atomic_long_t expedited_done_lost; /* # times beaten to _done. */
77139 - atomic_long_t expedited_done_exit; /* # times exited _done loop. */
77140 + atomic_long_unchecked_t expedited_start; /* Starting ticket. */
77141 + atomic_long_t expedited_done; /* Done ticket. */
77142 + atomic_long_unchecked_t expedited_wrap; /* # near-wrap incidents. */
77143 + atomic_long_unchecked_t expedited_tryfail; /* # acquisition failures. */
77144 + atomic_long_unchecked_t expedited_workdone1; /* # done by others #1. */
77145 + atomic_long_unchecked_t expedited_workdone2; /* # done by others #2. */
77146 + atomic_long_unchecked_t expedited_normal; /* # fallbacks to normal. */
77147 + atomic_long_unchecked_t expedited_stoppedcpus; /* # successful stop_cpus. */
77148 + atomic_long_unchecked_t expedited_done_tries; /* # tries to update _done. */
77149 + atomic_long_unchecked_t expedited_done_lost; /* # times beaten to _done. */
77150 + atomic_long_unchecked_t expedited_done_exit; /* # times exited _done loop. */
77151
77152 unsigned long jiffies_force_qs; /* Time at which to invoke */
77153 /* force_quiescent_state(). */
77154 diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
77155 index c1cc7e1..f62e436 100644
77156 --- a/kernel/rcutree_plugin.h
77157 +++ b/kernel/rcutree_plugin.h
77158 @@ -892,7 +892,7 @@ void synchronize_rcu_expedited(void)
77159
77160 /* Clean up and exit. */
77161 smp_mb(); /* ensure expedited GP seen before counter increment. */
77162 - ACCESS_ONCE(sync_rcu_preempt_exp_count)++;
77163 + ACCESS_ONCE_RW(sync_rcu_preempt_exp_count)++;
77164 unlock_mb_ret:
77165 mutex_unlock(&sync_rcu_preempt_exp_mutex);
77166 mb_ret:
77167 @@ -1440,7 +1440,7 @@ static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu)
77168 free_cpumask_var(cm);
77169 }
77170
77171 -static struct smp_hotplug_thread rcu_cpu_thread_spec = {
77172 +static struct smp_hotplug_thread rcu_cpu_thread_spec __read_only = {
77173 .store = &rcu_cpu_kthread_task,
77174 .thread_should_run = rcu_cpu_kthread_should_run,
77175 .thread_fn = rcu_cpu_kthread,
77176 @@ -2072,7 +2072,7 @@ static void print_cpu_stall_info(struct rcu_state *rsp, int cpu)
77177 print_cpu_stall_fast_no_hz(fast_no_hz, cpu);
77178 printk(KERN_ERR "\t%d: (%lu %s) idle=%03x/%llx/%d %s\n",
77179 cpu, ticks_value, ticks_title,
77180 - atomic_read(&rdtp->dynticks) & 0xfff,
77181 + atomic_read_unchecked(&rdtp->dynticks) & 0xfff,
77182 rdtp->dynticks_nesting, rdtp->dynticks_nmi_nesting,
77183 fast_no_hz);
77184 }
77185 @@ -2192,7 +2192,7 @@ static void __call_rcu_nocb_enqueue(struct rcu_data *rdp,
77186
77187 /* Enqueue the callback on the nocb list and update counts. */
77188 old_rhpp = xchg(&rdp->nocb_tail, rhtp);
77189 - ACCESS_ONCE(*old_rhpp) = rhp;
77190 + ACCESS_ONCE_RW(*old_rhpp) = rhp;
77191 atomic_long_add(rhcount, &rdp->nocb_q_count);
77192 atomic_long_add(rhcount_lazy, &rdp->nocb_q_count_lazy);
77193
77194 @@ -2384,12 +2384,12 @@ static int rcu_nocb_kthread(void *arg)
77195 * Extract queued callbacks, update counts, and wait
77196 * for a grace period to elapse.
77197 */
77198 - ACCESS_ONCE(rdp->nocb_head) = NULL;
77199 + ACCESS_ONCE_RW(rdp->nocb_head) = NULL;
77200 tail = xchg(&rdp->nocb_tail, &rdp->nocb_head);
77201 c = atomic_long_xchg(&rdp->nocb_q_count, 0);
77202 cl = atomic_long_xchg(&rdp->nocb_q_count_lazy, 0);
77203 - ACCESS_ONCE(rdp->nocb_p_count) += c;
77204 - ACCESS_ONCE(rdp->nocb_p_count_lazy) += cl;
77205 + ACCESS_ONCE_RW(rdp->nocb_p_count) += c;
77206 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) += cl;
77207 wait_rcu_gp(rdp->rsp->call_remote);
77208
77209 /* Each pass through the following loop invokes a callback. */
77210 @@ -2411,8 +2411,8 @@ static int rcu_nocb_kthread(void *arg)
77211 list = next;
77212 }
77213 trace_rcu_batch_end(rdp->rsp->name, c, !!list, 0, 0, 1);
77214 - ACCESS_ONCE(rdp->nocb_p_count) -= c;
77215 - ACCESS_ONCE(rdp->nocb_p_count_lazy) -= cl;
77216 + ACCESS_ONCE_RW(rdp->nocb_p_count) -= c;
77217 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) -= cl;
77218 rdp->n_nocbs_invoked += c;
77219 }
77220 return 0;
77221 @@ -2438,7 +2438,7 @@ static void __init rcu_spawn_nocb_kthreads(struct rcu_state *rsp)
77222 rdp = per_cpu_ptr(rsp->rda, cpu);
77223 t = kthread_run(rcu_nocb_kthread, rdp, "rcuo%d", cpu);
77224 BUG_ON(IS_ERR(t));
77225 - ACCESS_ONCE(rdp->nocb_kthread) = t;
77226 + ACCESS_ONCE_RW(rdp->nocb_kthread) = t;
77227 }
77228 }
77229
77230 diff --git a/kernel/rcutree_trace.c b/kernel/rcutree_trace.c
77231 index 93f8e8f..cf812ae 100644
77232 --- a/kernel/rcutree_trace.c
77233 +++ b/kernel/rcutree_trace.c
77234 @@ -123,7 +123,7 @@ static void print_one_rcu_data(struct seq_file *m, struct rcu_data *rdp)
77235 ulong2long(rdp->completed), ulong2long(rdp->gpnum),
77236 rdp->passed_quiesce, rdp->qs_pending);
77237 seq_printf(m, " dt=%d/%llx/%d df=%lu",
77238 - atomic_read(&rdp->dynticks->dynticks),
77239 + atomic_read_unchecked(&rdp->dynticks->dynticks),
77240 rdp->dynticks->dynticks_nesting,
77241 rdp->dynticks->dynticks_nmi_nesting,
77242 rdp->dynticks_fqs);
77243 @@ -184,17 +184,17 @@ static int show_rcuexp(struct seq_file *m, void *v)
77244 struct rcu_state *rsp = (struct rcu_state *)m->private;
77245
77246 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",
77247 - atomic_long_read(&rsp->expedited_start),
77248 + atomic_long_read_unchecked(&rsp->expedited_start),
77249 atomic_long_read(&rsp->expedited_done),
77250 - atomic_long_read(&rsp->expedited_wrap),
77251 - atomic_long_read(&rsp->expedited_tryfail),
77252 - atomic_long_read(&rsp->expedited_workdone1),
77253 - atomic_long_read(&rsp->expedited_workdone2),
77254 - atomic_long_read(&rsp->expedited_normal),
77255 - atomic_long_read(&rsp->expedited_stoppedcpus),
77256 - atomic_long_read(&rsp->expedited_done_tries),
77257 - atomic_long_read(&rsp->expedited_done_lost),
77258 - atomic_long_read(&rsp->expedited_done_exit));
77259 + atomic_long_read_unchecked(&rsp->expedited_wrap),
77260 + atomic_long_read_unchecked(&rsp->expedited_tryfail),
77261 + atomic_long_read_unchecked(&rsp->expedited_workdone1),
77262 + atomic_long_read_unchecked(&rsp->expedited_workdone2),
77263 + atomic_long_read_unchecked(&rsp->expedited_normal),
77264 + atomic_long_read_unchecked(&rsp->expedited_stoppedcpus),
77265 + atomic_long_read_unchecked(&rsp->expedited_done_tries),
77266 + atomic_long_read_unchecked(&rsp->expedited_done_lost),
77267 + atomic_long_read_unchecked(&rsp->expedited_done_exit));
77268 return 0;
77269 }
77270
77271 diff --git a/kernel/resource.c b/kernel/resource.c
77272 index 73f35d4..4684fc4 100644
77273 --- a/kernel/resource.c
77274 +++ b/kernel/resource.c
77275 @@ -143,8 +143,18 @@ static const struct file_operations proc_iomem_operations = {
77276
77277 static int __init ioresources_init(void)
77278 {
77279 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
77280 +#ifdef CONFIG_GRKERNSEC_PROC_USER
77281 + proc_create("ioports", S_IRUSR, NULL, &proc_ioports_operations);
77282 + proc_create("iomem", S_IRUSR, NULL, &proc_iomem_operations);
77283 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
77284 + proc_create("ioports", S_IRUSR | S_IRGRP, NULL, &proc_ioports_operations);
77285 + proc_create("iomem", S_IRUSR | S_IRGRP, NULL, &proc_iomem_operations);
77286 +#endif
77287 +#else
77288 proc_create("ioports", 0, NULL, &proc_ioports_operations);
77289 proc_create("iomem", 0, NULL, &proc_iomem_operations);
77290 +#endif
77291 return 0;
77292 }
77293 __initcall(ioresources_init);
77294 diff --git a/kernel/rtmutex-tester.c b/kernel/rtmutex-tester.c
77295 index 7890b10..8b68605f 100644
77296 --- a/kernel/rtmutex-tester.c
77297 +++ b/kernel/rtmutex-tester.c
77298 @@ -21,7 +21,7 @@
77299 #define MAX_RT_TEST_MUTEXES 8
77300
77301 static spinlock_t rttest_lock;
77302 -static atomic_t rttest_event;
77303 +static atomic_unchecked_t rttest_event;
77304
77305 struct test_thread_data {
77306 int opcode;
77307 @@ -62,7 +62,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
77308
77309 case RTTEST_LOCKCONT:
77310 td->mutexes[td->opdata] = 1;
77311 - td->event = atomic_add_return(1, &rttest_event);
77312 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77313 return 0;
77314
77315 case RTTEST_RESET:
77316 @@ -75,7 +75,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
77317 return 0;
77318
77319 case RTTEST_RESETEVENT:
77320 - atomic_set(&rttest_event, 0);
77321 + atomic_set_unchecked(&rttest_event, 0);
77322 return 0;
77323
77324 default:
77325 @@ -92,9 +92,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
77326 return ret;
77327
77328 td->mutexes[id] = 1;
77329 - td->event = atomic_add_return(1, &rttest_event);
77330 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77331 rt_mutex_lock(&mutexes[id]);
77332 - td->event = atomic_add_return(1, &rttest_event);
77333 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77334 td->mutexes[id] = 4;
77335 return 0;
77336
77337 @@ -105,9 +105,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
77338 return ret;
77339
77340 td->mutexes[id] = 1;
77341 - td->event = atomic_add_return(1, &rttest_event);
77342 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77343 ret = rt_mutex_lock_interruptible(&mutexes[id], 0);
77344 - td->event = atomic_add_return(1, &rttest_event);
77345 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77346 td->mutexes[id] = ret ? 0 : 4;
77347 return ret ? -EINTR : 0;
77348
77349 @@ -116,9 +116,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
77350 if (id < 0 || id >= MAX_RT_TEST_MUTEXES || td->mutexes[id] != 4)
77351 return ret;
77352
77353 - td->event = atomic_add_return(1, &rttest_event);
77354 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77355 rt_mutex_unlock(&mutexes[id]);
77356 - td->event = atomic_add_return(1, &rttest_event);
77357 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77358 td->mutexes[id] = 0;
77359 return 0;
77360
77361 @@ -165,7 +165,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
77362 break;
77363
77364 td->mutexes[dat] = 2;
77365 - td->event = atomic_add_return(1, &rttest_event);
77366 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77367 break;
77368
77369 default:
77370 @@ -185,7 +185,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
77371 return;
77372
77373 td->mutexes[dat] = 3;
77374 - td->event = atomic_add_return(1, &rttest_event);
77375 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77376 break;
77377
77378 case RTTEST_LOCKNOWAIT:
77379 @@ -197,7 +197,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
77380 return;
77381
77382 td->mutexes[dat] = 1;
77383 - td->event = atomic_add_return(1, &rttest_event);
77384 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77385 return;
77386
77387 default:
77388 diff --git a/kernel/sched/auto_group.c b/kernel/sched/auto_group.c
77389 index 64de5f8..7735e12 100644
77390 --- a/kernel/sched/auto_group.c
77391 +++ b/kernel/sched/auto_group.c
77392 @@ -11,7 +11,7 @@
77393
77394 unsigned int __read_mostly sysctl_sched_autogroup_enabled = 1;
77395 static struct autogroup autogroup_default;
77396 -static atomic_t autogroup_seq_nr;
77397 +static atomic_unchecked_t autogroup_seq_nr;
77398
77399 void __init autogroup_init(struct task_struct *init_task)
77400 {
77401 @@ -81,7 +81,7 @@ static inline struct autogroup *autogroup_create(void)
77402
77403 kref_init(&ag->kref);
77404 init_rwsem(&ag->lock);
77405 - ag->id = atomic_inc_return(&autogroup_seq_nr);
77406 + ag->id = atomic_inc_return_unchecked(&autogroup_seq_nr);
77407 ag->tg = tg;
77408 #ifdef CONFIG_RT_GROUP_SCHED
77409 /*
77410 diff --git a/kernel/sched/core.c b/kernel/sched/core.c
77411 index 67d0465..4cf9361 100644
77412 --- a/kernel/sched/core.c
77413 +++ b/kernel/sched/core.c
77414 @@ -3406,7 +3406,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible);
77415 * The return value is -ERESTARTSYS if interrupted, 0 if timed out,
77416 * positive (at least 1, or number of jiffies left till timeout) if completed.
77417 */
77418 -long __sched
77419 +long __sched __intentional_overflow(-1)
77420 wait_for_completion_interruptible_timeout(struct completion *x,
77421 unsigned long timeout)
77422 {
77423 @@ -3423,7 +3423,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible_timeout);
77424 *
77425 * The return value is -ERESTARTSYS if interrupted, 0 if completed.
77426 */
77427 -int __sched wait_for_completion_killable(struct completion *x)
77428 +int __sched __intentional_overflow(-1) wait_for_completion_killable(struct completion *x)
77429 {
77430 long t = wait_for_common(x, MAX_SCHEDULE_TIMEOUT, TASK_KILLABLE);
77431 if (t == -ERESTARTSYS)
77432 @@ -3444,7 +3444,7 @@ EXPORT_SYMBOL(wait_for_completion_killable);
77433 * The return value is -ERESTARTSYS if interrupted, 0 if timed out,
77434 * positive (at least 1, or number of jiffies left till timeout) if completed.
77435 */
77436 -long __sched
77437 +long __sched __intentional_overflow(-1)
77438 wait_for_completion_killable_timeout(struct completion *x,
77439 unsigned long timeout)
77440 {
77441 @@ -3670,6 +3670,8 @@ int can_nice(const struct task_struct *p, const int nice)
77442 /* convert nice value [19,-20] to rlimit style value [1,40] */
77443 int nice_rlim = 20 - nice;
77444
77445 + gr_learn_resource(p, RLIMIT_NICE, nice_rlim, 1);
77446 +
77447 return (nice_rlim <= task_rlimit(p, RLIMIT_NICE) ||
77448 capable(CAP_SYS_NICE));
77449 }
77450 @@ -3703,7 +3705,8 @@ SYSCALL_DEFINE1(nice, int, increment)
77451 if (nice > 19)
77452 nice = 19;
77453
77454 - if (increment < 0 && !can_nice(current, nice))
77455 + if (increment < 0 && (!can_nice(current, nice) ||
77456 + gr_handle_chroot_nice()))
77457 return -EPERM;
77458
77459 retval = security_task_setnice(current, nice);
77460 @@ -3857,6 +3860,7 @@ recheck:
77461 unsigned long rlim_rtprio =
77462 task_rlimit(p, RLIMIT_RTPRIO);
77463
77464 + gr_learn_resource(p, RLIMIT_RTPRIO, param->sched_priority, 1);
77465 /* can't set/change the rt policy */
77466 if (policy != p->policy && !rlim_rtprio)
77467 return -EPERM;
77468 @@ -4954,7 +4958,7 @@ static void migrate_tasks(unsigned int dead_cpu)
77469
77470 #if defined(CONFIG_SCHED_DEBUG) && defined(CONFIG_SYSCTL)
77471
77472 -static struct ctl_table sd_ctl_dir[] = {
77473 +static ctl_table_no_const sd_ctl_dir[] __read_only = {
77474 {
77475 .procname = "sched_domain",
77476 .mode = 0555,
77477 @@ -4971,17 +4975,17 @@ static struct ctl_table sd_ctl_root[] = {
77478 {}
77479 };
77480
77481 -static struct ctl_table *sd_alloc_ctl_entry(int n)
77482 +static ctl_table_no_const *sd_alloc_ctl_entry(int n)
77483 {
77484 - struct ctl_table *entry =
77485 + ctl_table_no_const *entry =
77486 kcalloc(n, sizeof(struct ctl_table), GFP_KERNEL);
77487
77488 return entry;
77489 }
77490
77491 -static void sd_free_ctl_entry(struct ctl_table **tablep)
77492 +static void sd_free_ctl_entry(ctl_table_no_const *tablep)
77493 {
77494 - struct ctl_table *entry;
77495 + ctl_table_no_const *entry;
77496
77497 /*
77498 * In the intermediate directories, both the child directory and
77499 @@ -4989,22 +4993,25 @@ static void sd_free_ctl_entry(struct ctl_table **tablep)
77500 * will always be set. In the lowest directory the names are
77501 * static strings and all have proc handlers.
77502 */
77503 - for (entry = *tablep; entry->mode; entry++) {
77504 - if (entry->child)
77505 - sd_free_ctl_entry(&entry->child);
77506 + for (entry = tablep; entry->mode; entry++) {
77507 + if (entry->child) {
77508 + sd_free_ctl_entry(entry->child);
77509 + pax_open_kernel();
77510 + entry->child = NULL;
77511 + pax_close_kernel();
77512 + }
77513 if (entry->proc_handler == NULL)
77514 kfree(entry->procname);
77515 }
77516
77517 - kfree(*tablep);
77518 - *tablep = NULL;
77519 + kfree(tablep);
77520 }
77521
77522 static int min_load_idx = 0;
77523 static int max_load_idx = CPU_LOAD_IDX_MAX-1;
77524
77525 static void
77526 -set_table_entry(struct ctl_table *entry,
77527 +set_table_entry(ctl_table_no_const *entry,
77528 const char *procname, void *data, int maxlen,
77529 umode_t mode, proc_handler *proc_handler,
77530 bool load_idx)
77531 @@ -5024,7 +5031,7 @@ set_table_entry(struct ctl_table *entry,
77532 static struct ctl_table *
77533 sd_alloc_ctl_domain_table(struct sched_domain *sd)
77534 {
77535 - struct ctl_table *table = sd_alloc_ctl_entry(13);
77536 + ctl_table_no_const *table = sd_alloc_ctl_entry(13);
77537
77538 if (table == NULL)
77539 return NULL;
77540 @@ -5059,9 +5066,9 @@ sd_alloc_ctl_domain_table(struct sched_domain *sd)
77541 return table;
77542 }
77543
77544 -static ctl_table *sd_alloc_ctl_cpu_table(int cpu)
77545 +static ctl_table_no_const *sd_alloc_ctl_cpu_table(int cpu)
77546 {
77547 - struct ctl_table *entry, *table;
77548 + ctl_table_no_const *entry, *table;
77549 struct sched_domain *sd;
77550 int domain_num = 0, i;
77551 char buf[32];
77552 @@ -5088,11 +5095,13 @@ static struct ctl_table_header *sd_sysctl_header;
77553 static void register_sched_domain_sysctl(void)
77554 {
77555 int i, cpu_num = num_possible_cpus();
77556 - struct ctl_table *entry = sd_alloc_ctl_entry(cpu_num + 1);
77557 + ctl_table_no_const *entry = sd_alloc_ctl_entry(cpu_num + 1);
77558 char buf[32];
77559
77560 WARN_ON(sd_ctl_dir[0].child);
77561 + pax_open_kernel();
77562 sd_ctl_dir[0].child = entry;
77563 + pax_close_kernel();
77564
77565 if (entry == NULL)
77566 return;
77567 @@ -5115,8 +5124,12 @@ static void unregister_sched_domain_sysctl(void)
77568 if (sd_sysctl_header)
77569 unregister_sysctl_table(sd_sysctl_header);
77570 sd_sysctl_header = NULL;
77571 - if (sd_ctl_dir[0].child)
77572 - sd_free_ctl_entry(&sd_ctl_dir[0].child);
77573 + if (sd_ctl_dir[0].child) {
77574 + sd_free_ctl_entry(sd_ctl_dir[0].child);
77575 + pax_open_kernel();
77576 + sd_ctl_dir[0].child = NULL;
77577 + pax_close_kernel();
77578 + }
77579 }
77580 #else
77581 static void register_sched_domain_sysctl(void)
77582 @@ -5215,7 +5228,7 @@ migration_call(struct notifier_block *nfb, unsigned long action, void *hcpu)
77583 * happens before everything else. This has to be lower priority than
77584 * the notifier in the perf_event subsystem, though.
77585 */
77586 -static struct notifier_block __cpuinitdata migration_notifier = {
77587 +static struct notifier_block migration_notifier = {
77588 .notifier_call = migration_call,
77589 .priority = CPU_PRI_MIGRATION,
77590 };
77591 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
77592 index 7a33e59..2f7730c 100644
77593 --- a/kernel/sched/fair.c
77594 +++ b/kernel/sched/fair.c
77595 @@ -830,7 +830,7 @@ void task_numa_fault(int node, int pages, bool migrated)
77596
77597 static void reset_ptenuma_scan(struct task_struct *p)
77598 {
77599 - ACCESS_ONCE(p->mm->numa_scan_seq)++;
77600 + ACCESS_ONCE_RW(p->mm->numa_scan_seq)++;
77601 p->mm->numa_scan_offset = 0;
77602 }
77603
77604 @@ -5654,7 +5654,7 @@ static void nohz_idle_balance(int this_cpu, enum cpu_idle_type idle) { }
77605 * run_rebalance_domains is triggered when needed from the scheduler tick.
77606 * Also triggered for nohz idle balancing (with nohz_balancing_kick set).
77607 */
77608 -static void run_rebalance_domains(struct softirq_action *h)
77609 +static void run_rebalance_domains(void)
77610 {
77611 int this_cpu = smp_processor_id();
77612 struct rq *this_rq = cpu_rq(this_cpu);
77613 diff --git a/kernel/signal.c b/kernel/signal.c
77614 index 598dc06..471310a 100644
77615 --- a/kernel/signal.c
77616 +++ b/kernel/signal.c
77617 @@ -50,12 +50,12 @@ static struct kmem_cache *sigqueue_cachep;
77618
77619 int print_fatal_signals __read_mostly;
77620
77621 -static void __user *sig_handler(struct task_struct *t, int sig)
77622 +static __sighandler_t sig_handler(struct task_struct *t, int sig)
77623 {
77624 return t->sighand->action[sig - 1].sa.sa_handler;
77625 }
77626
77627 -static int sig_handler_ignored(void __user *handler, int sig)
77628 +static int sig_handler_ignored(__sighandler_t handler, int sig)
77629 {
77630 /* Is it explicitly or implicitly ignored? */
77631 return handler == SIG_IGN ||
77632 @@ -64,7 +64,7 @@ static int sig_handler_ignored(void __user *handler, int sig)
77633
77634 static int sig_task_ignored(struct task_struct *t, int sig, bool force)
77635 {
77636 - void __user *handler;
77637 + __sighandler_t handler;
77638
77639 handler = sig_handler(t, sig);
77640
77641 @@ -368,6 +368,9 @@ __sigqueue_alloc(int sig, struct task_struct *t, gfp_t flags, int override_rlimi
77642 atomic_inc(&user->sigpending);
77643 rcu_read_unlock();
77644
77645 + if (!override_rlimit)
77646 + gr_learn_resource(t, RLIMIT_SIGPENDING, atomic_read(&user->sigpending), 1);
77647 +
77648 if (override_rlimit ||
77649 atomic_read(&user->sigpending) <=
77650 task_rlimit(t, RLIMIT_SIGPENDING)) {
77651 @@ -495,7 +498,7 @@ flush_signal_handlers(struct task_struct *t, int force_default)
77652
77653 int unhandled_signal(struct task_struct *tsk, int sig)
77654 {
77655 - void __user *handler = tsk->sighand->action[sig-1].sa.sa_handler;
77656 + __sighandler_t handler = tsk->sighand->action[sig-1].sa.sa_handler;
77657 if (is_global_init(tsk))
77658 return 1;
77659 if (handler != SIG_IGN && handler != SIG_DFL)
77660 @@ -815,6 +818,13 @@ static int check_kill_permission(int sig, struct siginfo *info,
77661 }
77662 }
77663
77664 + /* allow glibc communication via tgkill to other threads in our
77665 + thread group */
77666 + if ((info == SEND_SIG_NOINFO || info->si_code != SI_TKILL ||
77667 + sig != (SIGRTMIN+1) || task_tgid_vnr(t) != info->si_pid)
77668 + && gr_handle_signal(t, sig))
77669 + return -EPERM;
77670 +
77671 return security_task_kill(t, info, sig, 0);
77672 }
77673
77674 @@ -1197,7 +1207,7 @@ __group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
77675 return send_signal(sig, info, p, 1);
77676 }
77677
77678 -static int
77679 +int
77680 specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t)
77681 {
77682 return send_signal(sig, info, t, 0);
77683 @@ -1234,6 +1244,7 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
77684 unsigned long int flags;
77685 int ret, blocked, ignored;
77686 struct k_sigaction *action;
77687 + int is_unhandled = 0;
77688
77689 spin_lock_irqsave(&t->sighand->siglock, flags);
77690 action = &t->sighand->action[sig-1];
77691 @@ -1248,9 +1259,18 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
77692 }
77693 if (action->sa.sa_handler == SIG_DFL)
77694 t->signal->flags &= ~SIGNAL_UNKILLABLE;
77695 + if (action->sa.sa_handler == SIG_IGN || action->sa.sa_handler == SIG_DFL)
77696 + is_unhandled = 1;
77697 ret = specific_send_sig_info(sig, info, t);
77698 spin_unlock_irqrestore(&t->sighand->siglock, flags);
77699
77700 + /* only deal with unhandled signals, java etc trigger SIGSEGV during
77701 + normal operation */
77702 + if (is_unhandled) {
77703 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, t);
77704 + gr_handle_crash(t, sig);
77705 + }
77706 +
77707 return ret;
77708 }
77709
77710 @@ -1317,8 +1337,11 @@ int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
77711 ret = check_kill_permission(sig, info, p);
77712 rcu_read_unlock();
77713
77714 - if (!ret && sig)
77715 + if (!ret && sig) {
77716 ret = do_send_sig_info(sig, info, p, true);
77717 + if (!ret)
77718 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, p);
77719 + }
77720
77721 return ret;
77722 }
77723 @@ -2923,7 +2946,15 @@ do_send_specific(pid_t tgid, pid_t pid, int sig, struct siginfo *info)
77724 int error = -ESRCH;
77725
77726 rcu_read_lock();
77727 - p = find_task_by_vpid(pid);
77728 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
77729 + /* allow glibc communication via tgkill to other threads in our
77730 + thread group */
77731 + if (grsec_enable_chroot_findtask && info->si_code == SI_TKILL &&
77732 + sig == (SIGRTMIN+1) && tgid == info->si_pid)
77733 + p = find_task_by_vpid_unrestricted(pid);
77734 + else
77735 +#endif
77736 + p = find_task_by_vpid(pid);
77737 if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) {
77738 error = check_kill_permission(sig, info, p);
77739 /*
77740 @@ -3237,8 +3268,8 @@ COMPAT_SYSCALL_DEFINE2(sigaltstack,
77741 }
77742 seg = get_fs();
77743 set_fs(KERNEL_DS);
77744 - ret = do_sigaltstack((stack_t __force __user *) (uss_ptr ? &uss : NULL),
77745 - (stack_t __force __user *) &uoss,
77746 + ret = do_sigaltstack((stack_t __force_user *) (uss_ptr ? &uss : NULL),
77747 + (stack_t __force_user *) &uoss,
77748 compat_user_stack_pointer());
77749 set_fs(seg);
77750 if (ret >= 0 && uoss_ptr) {
77751 diff --git a/kernel/smp.c b/kernel/smp.c
77752 index 8e451f3..8322029 100644
77753 --- a/kernel/smp.c
77754 +++ b/kernel/smp.c
77755 @@ -73,7 +73,7 @@ hotplug_cfd(struct notifier_block *nfb, unsigned long action, void *hcpu)
77756 return NOTIFY_OK;
77757 }
77758
77759 -static struct notifier_block __cpuinitdata hotplug_cfd_notifier = {
77760 +static struct notifier_block hotplug_cfd_notifier = {
77761 .notifier_call = hotplug_cfd,
77762 };
77763
77764 diff --git a/kernel/smpboot.c b/kernel/smpboot.c
77765 index 02fc5c9..e54c335 100644
77766 --- a/kernel/smpboot.c
77767 +++ b/kernel/smpboot.c
77768 @@ -288,7 +288,7 @@ int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread)
77769 }
77770 smpboot_unpark_thread(plug_thread, cpu);
77771 }
77772 - list_add(&plug_thread->list, &hotplug_threads);
77773 + pax_list_add(&plug_thread->list, &hotplug_threads);
77774 out:
77775 mutex_unlock(&smpboot_threads_lock);
77776 return ret;
77777 @@ -305,7 +305,7 @@ void smpboot_unregister_percpu_thread(struct smp_hotplug_thread *plug_thread)
77778 {
77779 get_online_cpus();
77780 mutex_lock(&smpboot_threads_lock);
77781 - list_del(&plug_thread->list);
77782 + pax_list_del(&plug_thread->list);
77783 smpboot_destroy_threads(plug_thread);
77784 mutex_unlock(&smpboot_threads_lock);
77785 put_online_cpus();
77786 diff --git a/kernel/softirq.c b/kernel/softirq.c
77787 index 14d7758..012121f 100644
77788 --- a/kernel/softirq.c
77789 +++ b/kernel/softirq.c
77790 @@ -53,11 +53,11 @@ irq_cpustat_t irq_stat[NR_CPUS] ____cacheline_aligned;
77791 EXPORT_SYMBOL(irq_stat);
77792 #endif
77793
77794 -static struct softirq_action softirq_vec[NR_SOFTIRQS] __cacheline_aligned_in_smp;
77795 +static struct softirq_action softirq_vec[NR_SOFTIRQS] __read_only __aligned(PAGE_SIZE);
77796
77797 DEFINE_PER_CPU(struct task_struct *, ksoftirqd);
77798
77799 -char *softirq_to_name[NR_SOFTIRQS] = {
77800 +const char * const softirq_to_name[NR_SOFTIRQS] = {
77801 "HI", "TIMER", "NET_TX", "NET_RX", "BLOCK", "BLOCK_IOPOLL",
77802 "TASKLET", "SCHED", "HRTIMER", "RCU"
77803 };
77804 @@ -244,7 +244,7 @@ restart:
77805 kstat_incr_softirqs_this_cpu(vec_nr);
77806
77807 trace_softirq_entry(vec_nr);
77808 - h->action(h);
77809 + h->action();
77810 trace_softirq_exit(vec_nr);
77811 if (unlikely(prev_count != preempt_count())) {
77812 printk(KERN_ERR "huh, entered softirq %u %s %p"
77813 @@ -389,7 +389,7 @@ void __raise_softirq_irqoff(unsigned int nr)
77814 or_softirq_pending(1UL << nr);
77815 }
77816
77817 -void open_softirq(int nr, void (*action)(struct softirq_action *))
77818 +void __init open_softirq(int nr, void (*action)(void))
77819 {
77820 softirq_vec[nr].action = action;
77821 }
77822 @@ -445,7 +445,7 @@ void __tasklet_hi_schedule_first(struct tasklet_struct *t)
77823
77824 EXPORT_SYMBOL(__tasklet_hi_schedule_first);
77825
77826 -static void tasklet_action(struct softirq_action *a)
77827 +static void tasklet_action(void)
77828 {
77829 struct tasklet_struct *list;
77830
77831 @@ -480,7 +480,7 @@ static void tasklet_action(struct softirq_action *a)
77832 }
77833 }
77834
77835 -static void tasklet_hi_action(struct softirq_action *a)
77836 +static void tasklet_hi_action(void)
77837 {
77838 struct tasklet_struct *list;
77839
77840 @@ -716,7 +716,7 @@ static int __cpuinit remote_softirq_cpu_notify(struct notifier_block *self,
77841 return NOTIFY_OK;
77842 }
77843
77844 -static struct notifier_block __cpuinitdata remote_softirq_cpu_notifier = {
77845 +static struct notifier_block remote_softirq_cpu_notifier = {
77846 .notifier_call = remote_softirq_cpu_notify,
77847 };
77848
77849 @@ -833,11 +833,11 @@ static int __cpuinit cpu_callback(struct notifier_block *nfb,
77850 return NOTIFY_OK;
77851 }
77852
77853 -static struct notifier_block __cpuinitdata cpu_nfb = {
77854 +static struct notifier_block cpu_nfb = {
77855 .notifier_call = cpu_callback
77856 };
77857
77858 -static struct smp_hotplug_thread softirq_threads = {
77859 +static struct smp_hotplug_thread softirq_threads __read_only = {
77860 .store = &ksoftirqd,
77861 .thread_should_run = ksoftirqd_should_run,
77862 .thread_fn = run_ksoftirqd,
77863 diff --git a/kernel/srcu.c b/kernel/srcu.c
77864 index 01d5ccb..cdcbee6 100644
77865 --- a/kernel/srcu.c
77866 +++ b/kernel/srcu.c
77867 @@ -300,9 +300,9 @@ int __srcu_read_lock(struct srcu_struct *sp)
77868
77869 idx = ACCESS_ONCE(sp->completed) & 0x1;
77870 preempt_disable();
77871 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
77872 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
77873 smp_mb(); /* B */ /* Avoid leaking the critical section. */
77874 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
77875 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
77876 preempt_enable();
77877 return idx;
77878 }
77879 diff --git a/kernel/sys.c b/kernel/sys.c
77880 index 0da73cf..a22106a 100644
77881 --- a/kernel/sys.c
77882 +++ b/kernel/sys.c
77883 @@ -158,6 +158,12 @@ static int set_one_prio(struct task_struct *p, int niceval, int error)
77884 error = -EACCES;
77885 goto out;
77886 }
77887 +
77888 + if (gr_handle_chroot_setpriority(p, niceval)) {
77889 + error = -EACCES;
77890 + goto out;
77891 + }
77892 +
77893 no_nice = security_task_setnice(p, niceval);
77894 if (no_nice) {
77895 error = no_nice;
77896 @@ -598,6 +604,9 @@ SYSCALL_DEFINE2(setregid, gid_t, rgid, gid_t, egid)
77897 goto error;
77898 }
77899
77900 + if (gr_check_group_change(new->gid, new->egid, INVALID_GID))
77901 + goto error;
77902 +
77903 if (rgid != (gid_t) -1 ||
77904 (egid != (gid_t) -1 && !gid_eq(kegid, old->gid)))
77905 new->sgid = new->egid;
77906 @@ -633,6 +642,10 @@ SYSCALL_DEFINE1(setgid, gid_t, gid)
77907 old = current_cred();
77908
77909 retval = -EPERM;
77910 +
77911 + if (gr_check_group_change(kgid, kgid, kgid))
77912 + goto error;
77913 +
77914 if (nsown_capable(CAP_SETGID))
77915 new->gid = new->egid = new->sgid = new->fsgid = kgid;
77916 else if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->sgid))
77917 @@ -650,7 +663,7 @@ error:
77918 /*
77919 * change the user struct in a credentials set to match the new UID
77920 */
77921 -static int set_user(struct cred *new)
77922 +int set_user(struct cred *new)
77923 {
77924 struct user_struct *new_user;
77925
77926 @@ -730,6 +743,9 @@ SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid)
77927 goto error;
77928 }
77929
77930 + if (gr_check_user_change(new->uid, new->euid, INVALID_UID))
77931 + goto error;
77932 +
77933 if (!uid_eq(new->uid, old->uid)) {
77934 retval = set_user(new);
77935 if (retval < 0)
77936 @@ -780,6 +796,12 @@ SYSCALL_DEFINE1(setuid, uid_t, uid)
77937 old = current_cred();
77938
77939 retval = -EPERM;
77940 +
77941 + if (gr_check_crash_uid(kuid))
77942 + goto error;
77943 + if (gr_check_user_change(kuid, kuid, kuid))
77944 + goto error;
77945 +
77946 if (nsown_capable(CAP_SETUID)) {
77947 new->suid = new->uid = kuid;
77948 if (!uid_eq(kuid, old->uid)) {
77949 @@ -849,6 +871,9 @@ SYSCALL_DEFINE3(setresuid, uid_t, ruid, uid_t, euid, uid_t, suid)
77950 goto error;
77951 }
77952
77953 + if (gr_check_user_change(kruid, keuid, INVALID_UID))
77954 + goto error;
77955 +
77956 if (ruid != (uid_t) -1) {
77957 new->uid = kruid;
77958 if (!uid_eq(kruid, old->uid)) {
77959 @@ -931,6 +956,9 @@ SYSCALL_DEFINE3(setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid)
77960 goto error;
77961 }
77962
77963 + if (gr_check_group_change(krgid, kegid, INVALID_GID))
77964 + goto error;
77965 +
77966 if (rgid != (gid_t) -1)
77967 new->gid = krgid;
77968 if (egid != (gid_t) -1)
77969 @@ -992,12 +1020,16 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
77970 uid_eq(kuid, old->suid) || uid_eq(kuid, old->fsuid) ||
77971 nsown_capable(CAP_SETUID)) {
77972 if (!uid_eq(kuid, old->fsuid)) {
77973 + if (gr_check_user_change(INVALID_UID, INVALID_UID, kuid))
77974 + goto error;
77975 +
77976 new->fsuid = kuid;
77977 if (security_task_fix_setuid(new, old, LSM_SETID_FS) == 0)
77978 goto change_okay;
77979 }
77980 }
77981
77982 +error:
77983 abort_creds(new);
77984 return old_fsuid;
77985
77986 @@ -1030,12 +1062,16 @@ SYSCALL_DEFINE1(setfsgid, gid_t, gid)
77987 if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->egid) ||
77988 gid_eq(kgid, old->sgid) || gid_eq(kgid, old->fsgid) ||
77989 nsown_capable(CAP_SETGID)) {
77990 + if (gr_check_group_change(INVALID_GID, INVALID_GID, kgid))
77991 + goto error;
77992 +
77993 if (!gid_eq(kgid, old->fsgid)) {
77994 new->fsgid = kgid;
77995 goto change_okay;
77996 }
77997 }
77998
77999 +error:
78000 abort_creds(new);
78001 return old_fsgid;
78002
78003 @@ -1343,19 +1379,19 @@ SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name)
78004 return -EFAULT;
78005
78006 down_read(&uts_sem);
78007 - error = __copy_to_user(&name->sysname, &utsname()->sysname,
78008 + error = __copy_to_user(name->sysname, &utsname()->sysname,
78009 __OLD_UTS_LEN);
78010 error |= __put_user(0, name->sysname + __OLD_UTS_LEN);
78011 - error |= __copy_to_user(&name->nodename, &utsname()->nodename,
78012 + error |= __copy_to_user(name->nodename, &utsname()->nodename,
78013 __OLD_UTS_LEN);
78014 error |= __put_user(0, name->nodename + __OLD_UTS_LEN);
78015 - error |= __copy_to_user(&name->release, &utsname()->release,
78016 + error |= __copy_to_user(name->release, &utsname()->release,
78017 __OLD_UTS_LEN);
78018 error |= __put_user(0, name->release + __OLD_UTS_LEN);
78019 - error |= __copy_to_user(&name->version, &utsname()->version,
78020 + error |= __copy_to_user(name->version, &utsname()->version,
78021 __OLD_UTS_LEN);
78022 error |= __put_user(0, name->version + __OLD_UTS_LEN);
78023 - error |= __copy_to_user(&name->machine, &utsname()->machine,
78024 + error |= __copy_to_user(name->machine, &utsname()->machine,
78025 __OLD_UTS_LEN);
78026 error |= __put_user(0, name->machine + __OLD_UTS_LEN);
78027 up_read(&uts_sem);
78028 @@ -1557,6 +1593,13 @@ int do_prlimit(struct task_struct *tsk, unsigned int resource,
78029 */
78030 new_rlim->rlim_cur = 1;
78031 }
78032 + /* Handle the case where a fork and setuid occur and then RLIMIT_NPROC
78033 + is changed to a lower value. Since tasks can be created by the same
78034 + user in between this limit change and an execve by this task, force
78035 + a recheck only for this task by setting PF_NPROC_EXCEEDED
78036 + */
78037 + if (resource == RLIMIT_NPROC)
78038 + tsk->flags |= PF_NPROC_EXCEEDED;
78039 }
78040 if (!retval) {
78041 if (old_rlim)
78042 diff --git a/kernel/sysctl.c b/kernel/sysctl.c
78043 index afc1dc6..5e28bbf 100644
78044 --- a/kernel/sysctl.c
78045 +++ b/kernel/sysctl.c
78046 @@ -93,7 +93,6 @@
78047
78048
78049 #if defined(CONFIG_SYSCTL)
78050 -
78051 /* External variables not in a header file. */
78052 extern int sysctl_overcommit_memory;
78053 extern int sysctl_overcommit_ratio;
78054 @@ -178,10 +177,8 @@ static int proc_taint(struct ctl_table *table, int write,
78055 void __user *buffer, size_t *lenp, loff_t *ppos);
78056 #endif
78057
78058 -#ifdef CONFIG_PRINTK
78059 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
78060 void __user *buffer, size_t *lenp, loff_t *ppos);
78061 -#endif
78062
78063 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
78064 void __user *buffer, size_t *lenp, loff_t *ppos);
78065 @@ -212,6 +209,8 @@ static int sysrq_sysctl_handler(ctl_table *table, int write,
78066
78067 #endif
78068
78069 +extern struct ctl_table grsecurity_table[];
78070 +
78071 static struct ctl_table kern_table[];
78072 static struct ctl_table vm_table[];
78073 static struct ctl_table fs_table[];
78074 @@ -226,6 +225,20 @@ extern struct ctl_table epoll_table[];
78075 int sysctl_legacy_va_layout;
78076 #endif
78077
78078 +#ifdef CONFIG_PAX_SOFTMODE
78079 +static ctl_table pax_table[] = {
78080 + {
78081 + .procname = "softmode",
78082 + .data = &pax_softmode,
78083 + .maxlen = sizeof(unsigned int),
78084 + .mode = 0600,
78085 + .proc_handler = &proc_dointvec,
78086 + },
78087 +
78088 + { }
78089 +};
78090 +#endif
78091 +
78092 /* The default sysctl tables: */
78093
78094 static struct ctl_table sysctl_base_table[] = {
78095 @@ -274,6 +287,22 @@ static int max_extfrag_threshold = 1000;
78096 #endif
78097
78098 static struct ctl_table kern_table[] = {
78099 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
78100 + {
78101 + .procname = "grsecurity",
78102 + .mode = 0500,
78103 + .child = grsecurity_table,
78104 + },
78105 +#endif
78106 +
78107 +#ifdef CONFIG_PAX_SOFTMODE
78108 + {
78109 + .procname = "pax",
78110 + .mode = 0500,
78111 + .child = pax_table,
78112 + },
78113 +#endif
78114 +
78115 {
78116 .procname = "sched_child_runs_first",
78117 .data = &sysctl_sched_child_runs_first,
78118 @@ -608,7 +637,7 @@ static struct ctl_table kern_table[] = {
78119 .data = &modprobe_path,
78120 .maxlen = KMOD_PATH_LEN,
78121 .mode = 0644,
78122 - .proc_handler = proc_dostring,
78123 + .proc_handler = proc_dostring_modpriv,
78124 },
78125 {
78126 .procname = "modules_disabled",
78127 @@ -775,16 +804,20 @@ static struct ctl_table kern_table[] = {
78128 .extra1 = &zero,
78129 .extra2 = &one,
78130 },
78131 +#endif
78132 {
78133 .procname = "kptr_restrict",
78134 .data = &kptr_restrict,
78135 .maxlen = sizeof(int),
78136 .mode = 0644,
78137 .proc_handler = proc_dointvec_minmax_sysadmin,
78138 +#ifdef CONFIG_GRKERNSEC_HIDESYM
78139 + .extra1 = &two,
78140 +#else
78141 .extra1 = &zero,
78142 +#endif
78143 .extra2 = &two,
78144 },
78145 -#endif
78146 {
78147 .procname = "ngroups_max",
78148 .data = &ngroups_max,
78149 @@ -1026,8 +1059,8 @@ static struct ctl_table kern_table[] = {
78150 */
78151 {
78152 .procname = "perf_event_paranoid",
78153 - .data = &sysctl_perf_event_paranoid,
78154 - .maxlen = sizeof(sysctl_perf_event_paranoid),
78155 + .data = &sysctl_perf_event_legitimately_concerned,
78156 + .maxlen = sizeof(sysctl_perf_event_legitimately_concerned),
78157 .mode = 0644,
78158 .proc_handler = proc_dointvec,
78159 },
78160 @@ -1283,6 +1316,13 @@ static struct ctl_table vm_table[] = {
78161 .proc_handler = proc_dointvec_minmax,
78162 .extra1 = &zero,
78163 },
78164 + {
78165 + .procname = "heap_stack_gap",
78166 + .data = &sysctl_heap_stack_gap,
78167 + .maxlen = sizeof(sysctl_heap_stack_gap),
78168 + .mode = 0644,
78169 + .proc_handler = proc_doulongvec_minmax,
78170 + },
78171 #else
78172 {
78173 .procname = "nr_trim_pages",
78174 @@ -1733,6 +1773,16 @@ int proc_dostring(struct ctl_table *table, int write,
78175 buffer, lenp, ppos);
78176 }
78177
78178 +int proc_dostring_modpriv(struct ctl_table *table, int write,
78179 + void __user *buffer, size_t *lenp, loff_t *ppos)
78180 +{
78181 + if (write && !capable(CAP_SYS_MODULE))
78182 + return -EPERM;
78183 +
78184 + return _proc_do_string(table->data, table->maxlen, write,
78185 + buffer, lenp, ppos);
78186 +}
78187 +
78188 static size_t proc_skip_spaces(char **buf)
78189 {
78190 size_t ret;
78191 @@ -1838,6 +1888,8 @@ static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
78192 len = strlen(tmp);
78193 if (len > *size)
78194 len = *size;
78195 + if (len > sizeof(tmp))
78196 + len = sizeof(tmp);
78197 if (copy_to_user(*buf, tmp, len))
78198 return -EFAULT;
78199 *size -= len;
78200 @@ -2002,7 +2054,7 @@ int proc_dointvec(struct ctl_table *table, int write,
78201 static int proc_taint(struct ctl_table *table, int write,
78202 void __user *buffer, size_t *lenp, loff_t *ppos)
78203 {
78204 - struct ctl_table t;
78205 + ctl_table_no_const t;
78206 unsigned long tmptaint = get_taint();
78207 int err;
78208
78209 @@ -2030,7 +2082,6 @@ static int proc_taint(struct ctl_table *table, int write,
78210 return err;
78211 }
78212
78213 -#ifdef CONFIG_PRINTK
78214 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
78215 void __user *buffer, size_t *lenp, loff_t *ppos)
78216 {
78217 @@ -2039,7 +2090,6 @@ static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
78218
78219 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
78220 }
78221 -#endif
78222
78223 struct do_proc_dointvec_minmax_conv_param {
78224 int *min;
78225 @@ -2186,8 +2236,11 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int
78226 *i = val;
78227 } else {
78228 val = convdiv * (*i) / convmul;
78229 - if (!first)
78230 + if (!first) {
78231 err = proc_put_char(&buffer, &left, '\t');
78232 + if (err)
78233 + break;
78234 + }
78235 err = proc_put_long(&buffer, &left, val, false);
78236 if (err)
78237 break;
78238 @@ -2579,6 +2632,12 @@ int proc_dostring(struct ctl_table *table, int write,
78239 return -ENOSYS;
78240 }
78241
78242 +int proc_dostring_modpriv(struct ctl_table *table, int write,
78243 + void __user *buffer, size_t *lenp, loff_t *ppos)
78244 +{
78245 + return -ENOSYS;
78246 +}
78247 +
78248 int proc_dointvec(struct ctl_table *table, int write,
78249 void __user *buffer, size_t *lenp, loff_t *ppos)
78250 {
78251 @@ -2635,5 +2694,6 @@ EXPORT_SYMBOL(proc_dointvec_minmax);
78252 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
78253 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
78254 EXPORT_SYMBOL(proc_dostring);
78255 +EXPORT_SYMBOL(proc_dostring_modpriv);
78256 EXPORT_SYMBOL(proc_doulongvec_minmax);
78257 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
78258 diff --git a/kernel/taskstats.c b/kernel/taskstats.c
78259 index 145bb4d..b2aa969 100644
78260 --- a/kernel/taskstats.c
78261 +++ b/kernel/taskstats.c
78262 @@ -28,9 +28,12 @@
78263 #include <linux/fs.h>
78264 #include <linux/file.h>
78265 #include <linux/pid_namespace.h>
78266 +#include <linux/grsecurity.h>
78267 #include <net/genetlink.h>
78268 #include <linux/atomic.h>
78269
78270 +extern int gr_is_taskstats_denied(int pid);
78271 +
78272 /*
78273 * Maximum length of a cpumask that can be specified in
78274 * the TASKSTATS_CMD_ATTR_REGISTER/DEREGISTER_CPUMASK attribute
78275 @@ -570,6 +573,9 @@ err:
78276
78277 static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info)
78278 {
78279 + if (gr_is_taskstats_denied(current->pid))
78280 + return -EACCES;
78281 +
78282 if (info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK])
78283 return cmd_attr_register_cpumask(info);
78284 else if (info->attrs[TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK])
78285 diff --git a/kernel/time.c b/kernel/time.c
78286 index f8342a4..288f13b 100644
78287 --- a/kernel/time.c
78288 +++ b/kernel/time.c
78289 @@ -171,6 +171,11 @@ int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz)
78290 return error;
78291
78292 if (tz) {
78293 + /* we log in do_settimeofday called below, so don't log twice
78294 + */
78295 + if (!tv)
78296 + gr_log_timechange();
78297 +
78298 sys_tz = *tz;
78299 update_vsyscall_tz();
78300 if (firsttime) {
78301 @@ -501,7 +506,7 @@ EXPORT_SYMBOL(usecs_to_jiffies);
78302 * The >> (NSEC_JIFFIE_SC - SEC_JIFFIE_SC) converts the scaled nsec
78303 * value to a scaled second value.
78304 */
78305 -unsigned long
78306 +unsigned long __intentional_overflow(-1)
78307 timespec_to_jiffies(const struct timespec *value)
78308 {
78309 unsigned long sec = value->tv_sec;
78310 diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
78311 index f11d83b..d016d91 100644
78312 --- a/kernel/time/alarmtimer.c
78313 +++ b/kernel/time/alarmtimer.c
78314 @@ -750,7 +750,7 @@ static int __init alarmtimer_init(void)
78315 struct platform_device *pdev;
78316 int error = 0;
78317 int i;
78318 - struct k_clock alarm_clock = {
78319 + static struct k_clock alarm_clock = {
78320 .clock_getres = alarm_clock_getres,
78321 .clock_get = alarm_clock_get,
78322 .timer_create = alarm_timer_create,
78323 diff --git a/kernel/time/tick-broadcast.c b/kernel/time/tick-broadcast.c
78324 index 90ad470..1814e9a 100644
78325 --- a/kernel/time/tick-broadcast.c
78326 +++ b/kernel/time/tick-broadcast.c
78327 @@ -138,7 +138,7 @@ int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu)
78328 * then clear the broadcast bit.
78329 */
78330 if (!(dev->features & CLOCK_EVT_FEAT_C3STOP)) {
78331 - int cpu = smp_processor_id();
78332 + cpu = smp_processor_id();
78333 cpumask_clear_cpu(cpu, tick_get_broadcast_mask());
78334 tick_broadcast_clear_oneshot(cpu);
78335 } else {
78336 diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
78337 index 9a0bc98..fceb7d0 100644
78338 --- a/kernel/time/timekeeping.c
78339 +++ b/kernel/time/timekeeping.c
78340 @@ -15,6 +15,7 @@
78341 #include <linux/init.h>
78342 #include <linux/mm.h>
78343 #include <linux/sched.h>
78344 +#include <linux/grsecurity.h>
78345 #include <linux/syscore_ops.h>
78346 #include <linux/clocksource.h>
78347 #include <linux/jiffies.h>
78348 @@ -448,6 +449,8 @@ int do_settimeofday(const struct timespec *tv)
78349 if (!timespec_valid_strict(tv))
78350 return -EINVAL;
78351
78352 + gr_log_timechange();
78353 +
78354 write_seqlock_irqsave(&tk->lock, flags);
78355
78356 timekeeping_forward_now(tk);
78357 diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
78358 index af5a7e9..715611a 100644
78359 --- a/kernel/time/timer_list.c
78360 +++ b/kernel/time/timer_list.c
78361 @@ -38,12 +38,16 @@ DECLARE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases);
78362
78363 static void print_name_offset(struct seq_file *m, void *sym)
78364 {
78365 +#ifdef CONFIG_GRKERNSEC_HIDESYM
78366 + SEQ_printf(m, "<%p>", NULL);
78367 +#else
78368 char symname[KSYM_NAME_LEN];
78369
78370 if (lookup_symbol_name((unsigned long)sym, symname) < 0)
78371 SEQ_printf(m, "<%pK>", sym);
78372 else
78373 SEQ_printf(m, "%s", symname);
78374 +#endif
78375 }
78376
78377 static void
78378 @@ -112,7 +116,11 @@ next_one:
78379 static void
78380 print_base(struct seq_file *m, struct hrtimer_clock_base *base, u64 now)
78381 {
78382 +#ifdef CONFIG_GRKERNSEC_HIDESYM
78383 + SEQ_printf(m, " .base: %p\n", NULL);
78384 +#else
78385 SEQ_printf(m, " .base: %pK\n", base);
78386 +#endif
78387 SEQ_printf(m, " .index: %d\n",
78388 base->index);
78389 SEQ_printf(m, " .resolution: %Lu nsecs\n",
78390 @@ -293,7 +301,11 @@ static int __init init_timer_list_procfs(void)
78391 {
78392 struct proc_dir_entry *pe;
78393
78394 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
78395 + pe = proc_create("timer_list", 0400, NULL, &timer_list_fops);
78396 +#else
78397 pe = proc_create("timer_list", 0444, NULL, &timer_list_fops);
78398 +#endif
78399 if (!pe)
78400 return -ENOMEM;
78401 return 0;
78402 diff --git a/kernel/time/timer_stats.c b/kernel/time/timer_stats.c
78403 index 0b537f2..40d6c20 100644
78404 --- a/kernel/time/timer_stats.c
78405 +++ b/kernel/time/timer_stats.c
78406 @@ -116,7 +116,7 @@ static ktime_t time_start, time_stop;
78407 static unsigned long nr_entries;
78408 static struct entry entries[MAX_ENTRIES];
78409
78410 -static atomic_t overflow_count;
78411 +static atomic_unchecked_t overflow_count;
78412
78413 /*
78414 * The entries are in a hash-table, for fast lookup:
78415 @@ -140,7 +140,7 @@ static void reset_entries(void)
78416 nr_entries = 0;
78417 memset(entries, 0, sizeof(entries));
78418 memset(tstat_hash_table, 0, sizeof(tstat_hash_table));
78419 - atomic_set(&overflow_count, 0);
78420 + atomic_set_unchecked(&overflow_count, 0);
78421 }
78422
78423 static struct entry *alloc_entry(void)
78424 @@ -261,7 +261,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
78425 if (likely(entry))
78426 entry->count++;
78427 else
78428 - atomic_inc(&overflow_count);
78429 + atomic_inc_unchecked(&overflow_count);
78430
78431 out_unlock:
78432 raw_spin_unlock_irqrestore(lock, flags);
78433 @@ -269,12 +269,16 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
78434
78435 static void print_name_offset(struct seq_file *m, unsigned long addr)
78436 {
78437 +#ifdef CONFIG_GRKERNSEC_HIDESYM
78438 + seq_printf(m, "<%p>", NULL);
78439 +#else
78440 char symname[KSYM_NAME_LEN];
78441
78442 if (lookup_symbol_name(addr, symname) < 0)
78443 - seq_printf(m, "<%p>", (void *)addr);
78444 + seq_printf(m, "<%pK>", (void *)addr);
78445 else
78446 seq_printf(m, "%s", symname);
78447 +#endif
78448 }
78449
78450 static int tstats_show(struct seq_file *m, void *v)
78451 @@ -300,9 +304,9 @@ static int tstats_show(struct seq_file *m, void *v)
78452
78453 seq_puts(m, "Timer Stats Version: v0.2\n");
78454 seq_printf(m, "Sample period: %ld.%03ld s\n", period.tv_sec, ms);
78455 - if (atomic_read(&overflow_count))
78456 + if (atomic_read_unchecked(&overflow_count))
78457 seq_printf(m, "Overflow: %d entries\n",
78458 - atomic_read(&overflow_count));
78459 + atomic_read_unchecked(&overflow_count));
78460
78461 for (i = 0; i < nr_entries; i++) {
78462 entry = entries + i;
78463 @@ -417,7 +421,11 @@ static int __init init_tstats_procfs(void)
78464 {
78465 struct proc_dir_entry *pe;
78466
78467 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
78468 + pe = proc_create("timer_stats", 0600, NULL, &tstats_fops);
78469 +#else
78470 pe = proc_create("timer_stats", 0644, NULL, &tstats_fops);
78471 +#endif
78472 if (!pe)
78473 return -ENOMEM;
78474 return 0;
78475 diff --git a/kernel/timer.c b/kernel/timer.c
78476 index 1b399c8..90e1849 100644
78477 --- a/kernel/timer.c
78478 +++ b/kernel/timer.c
78479 @@ -1363,7 +1363,7 @@ void update_process_times(int user_tick)
78480 /*
78481 * This function runs timers and the timer-tq in bottom half context.
78482 */
78483 -static void run_timer_softirq(struct softirq_action *h)
78484 +static void run_timer_softirq(void)
78485 {
78486 struct tvec_base *base = __this_cpu_read(tvec_bases);
78487
78488 @@ -1481,7 +1481,7 @@ static void process_timeout(unsigned long __data)
78489 *
78490 * In all cases the return value is guaranteed to be non-negative.
78491 */
78492 -signed long __sched schedule_timeout(signed long timeout)
78493 +signed long __sched __intentional_overflow(-1) schedule_timeout(signed long timeout)
78494 {
78495 struct timer_list timer;
78496 unsigned long expire;
78497 @@ -1772,7 +1772,7 @@ static int __cpuinit timer_cpu_notify(struct notifier_block *self,
78498 return NOTIFY_OK;
78499 }
78500
78501 -static struct notifier_block __cpuinitdata timers_nb = {
78502 +static struct notifier_block timers_nb = {
78503 .notifier_call = timer_cpu_notify,
78504 };
78505
78506 diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
78507 index 5a0f781..1497f95 100644
78508 --- a/kernel/trace/blktrace.c
78509 +++ b/kernel/trace/blktrace.c
78510 @@ -317,7 +317,7 @@ static ssize_t blk_dropped_read(struct file *filp, char __user *buffer,
78511 struct blk_trace *bt = filp->private_data;
78512 char buf[16];
78513
78514 - snprintf(buf, sizeof(buf), "%u\n", atomic_read(&bt->dropped));
78515 + snprintf(buf, sizeof(buf), "%u\n", atomic_read_unchecked(&bt->dropped));
78516
78517 return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
78518 }
78519 @@ -375,7 +375,7 @@ static int blk_subbuf_start_callback(struct rchan_buf *buf, void *subbuf,
78520 return 1;
78521
78522 bt = buf->chan->private_data;
78523 - atomic_inc(&bt->dropped);
78524 + atomic_inc_unchecked(&bt->dropped);
78525 return 0;
78526 }
78527
78528 @@ -476,7 +476,7 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
78529
78530 bt->dir = dir;
78531 bt->dev = dev;
78532 - atomic_set(&bt->dropped, 0);
78533 + atomic_set_unchecked(&bt->dropped, 0);
78534
78535 ret = -EIO;
78536 bt->dropped_file = debugfs_create_file("dropped", 0444, dir, bt,
78537 diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
78538 index 0a0e2a6..943495e 100644
78539 --- a/kernel/trace/ftrace.c
78540 +++ b/kernel/trace/ftrace.c
78541 @@ -1909,12 +1909,17 @@ ftrace_code_disable(struct module *mod, struct dyn_ftrace *rec)
78542 if (unlikely(ftrace_disabled))
78543 return 0;
78544
78545 + ret = ftrace_arch_code_modify_prepare();
78546 + FTRACE_WARN_ON(ret);
78547 + if (ret)
78548 + return 0;
78549 +
78550 ret = ftrace_make_nop(mod, rec, MCOUNT_ADDR);
78551 + FTRACE_WARN_ON(ftrace_arch_code_modify_post_process());
78552 if (ret) {
78553 ftrace_bug(ret, ip);
78554 - return 0;
78555 }
78556 - return 1;
78557 + return ret ? 0 : 1;
78558 }
78559
78560 /*
78561 @@ -2986,7 +2991,7 @@ static void ftrace_free_entry_rcu(struct rcu_head *rhp)
78562
78563 int
78564 register_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops,
78565 - void *data)
78566 + void *data)
78567 {
78568 struct ftrace_func_probe *entry;
78569 struct ftrace_page *pg;
78570 @@ -3854,8 +3859,10 @@ static int ftrace_process_locs(struct module *mod,
78571 if (!count)
78572 return 0;
78573
78574 + pax_open_kernel();
78575 sort(start, count, sizeof(*start),
78576 ftrace_cmp_ips, ftrace_swap_ips);
78577 + pax_close_kernel();
78578
78579 start_pg = ftrace_allocate_pages(count);
78580 if (!start_pg)
78581 @@ -4574,8 +4581,6 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,
78582 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
78583
78584 static int ftrace_graph_active;
78585 -static struct notifier_block ftrace_suspend_notifier;
78586 -
78587 int ftrace_graph_entry_stub(struct ftrace_graph_ent *trace)
78588 {
78589 return 0;
78590 @@ -4719,6 +4724,10 @@ ftrace_suspend_notifier_call(struct notifier_block *bl, unsigned long state,
78591 return NOTIFY_DONE;
78592 }
78593
78594 +static struct notifier_block ftrace_suspend_notifier = {
78595 + .notifier_call = ftrace_suspend_notifier_call
78596 +};
78597 +
78598 int register_ftrace_graph(trace_func_graph_ret_t retfunc,
78599 trace_func_graph_ent_t entryfunc)
78600 {
78601 @@ -4732,7 +4741,6 @@ int register_ftrace_graph(trace_func_graph_ret_t retfunc,
78602 goto out;
78603 }
78604
78605 - ftrace_suspend_notifier.notifier_call = ftrace_suspend_notifier_call;
78606 register_pm_notifier(&ftrace_suspend_notifier);
78607
78608 ftrace_graph_active++;
78609 diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
78610 index 6989df2..c2265cf 100644
78611 --- a/kernel/trace/ring_buffer.c
78612 +++ b/kernel/trace/ring_buffer.c
78613 @@ -349,9 +349,9 @@ struct buffer_data_page {
78614 */
78615 struct buffer_page {
78616 struct list_head list; /* list of buffer pages */
78617 - local_t write; /* index for next write */
78618 + local_unchecked_t write; /* index for next write */
78619 unsigned read; /* index for next read */
78620 - local_t entries; /* entries on this page */
78621 + local_unchecked_t entries; /* entries on this page */
78622 unsigned long real_end; /* real end of data */
78623 struct buffer_data_page *page; /* Actual data page */
78624 };
78625 @@ -464,8 +464,8 @@ struct ring_buffer_per_cpu {
78626 unsigned long last_overrun;
78627 local_t entries_bytes;
78628 local_t entries;
78629 - local_t overrun;
78630 - local_t commit_overrun;
78631 + local_unchecked_t overrun;
78632 + local_unchecked_t commit_overrun;
78633 local_t dropped_events;
78634 local_t committing;
78635 local_t commits;
78636 @@ -864,8 +864,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
78637 *
78638 * We add a counter to the write field to denote this.
78639 */
78640 - old_write = local_add_return(RB_WRITE_INTCNT, &next_page->write);
78641 - old_entries = local_add_return(RB_WRITE_INTCNT, &next_page->entries);
78642 + old_write = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->write);
78643 + old_entries = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->entries);
78644
78645 /*
78646 * Just make sure we have seen our old_write and synchronize
78647 @@ -893,8 +893,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
78648 * cmpxchg to only update if an interrupt did not already
78649 * do it for us. If the cmpxchg fails, we don't care.
78650 */
78651 - (void)local_cmpxchg(&next_page->write, old_write, val);
78652 - (void)local_cmpxchg(&next_page->entries, old_entries, eval);
78653 + (void)local_cmpxchg_unchecked(&next_page->write, old_write, val);
78654 + (void)local_cmpxchg_unchecked(&next_page->entries, old_entries, eval);
78655
78656 /*
78657 * No need to worry about races with clearing out the commit.
78658 @@ -1253,12 +1253,12 @@ static void rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer);
78659
78660 static inline unsigned long rb_page_entries(struct buffer_page *bpage)
78661 {
78662 - return local_read(&bpage->entries) & RB_WRITE_MASK;
78663 + return local_read_unchecked(&bpage->entries) & RB_WRITE_MASK;
78664 }
78665
78666 static inline unsigned long rb_page_write(struct buffer_page *bpage)
78667 {
78668 - return local_read(&bpage->write) & RB_WRITE_MASK;
78669 + return local_read_unchecked(&bpage->write) & RB_WRITE_MASK;
78670 }
78671
78672 static int
78673 @@ -1353,7 +1353,7 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned int nr_pages)
78674 * bytes consumed in ring buffer from here.
78675 * Increment overrun to account for the lost events.
78676 */
78677 - local_add(page_entries, &cpu_buffer->overrun);
78678 + local_add_unchecked(page_entries, &cpu_buffer->overrun);
78679 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
78680 }
78681
78682 @@ -1909,7 +1909,7 @@ rb_handle_head_page(struct ring_buffer_per_cpu *cpu_buffer,
78683 * it is our responsibility to update
78684 * the counters.
78685 */
78686 - local_add(entries, &cpu_buffer->overrun);
78687 + local_add_unchecked(entries, &cpu_buffer->overrun);
78688 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
78689
78690 /*
78691 @@ -2059,7 +2059,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
78692 if (tail == BUF_PAGE_SIZE)
78693 tail_page->real_end = 0;
78694
78695 - local_sub(length, &tail_page->write);
78696 + local_sub_unchecked(length, &tail_page->write);
78697 return;
78698 }
78699
78700 @@ -2094,7 +2094,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
78701 rb_event_set_padding(event);
78702
78703 /* Set the write back to the previous setting */
78704 - local_sub(length, &tail_page->write);
78705 + local_sub_unchecked(length, &tail_page->write);
78706 return;
78707 }
78708
78709 @@ -2106,7 +2106,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
78710
78711 /* Set write to end of buffer */
78712 length = (tail + length) - BUF_PAGE_SIZE;
78713 - local_sub(length, &tail_page->write);
78714 + local_sub_unchecked(length, &tail_page->write);
78715 }
78716
78717 /*
78718 @@ -2132,7 +2132,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
78719 * about it.
78720 */
78721 if (unlikely(next_page == commit_page)) {
78722 - local_inc(&cpu_buffer->commit_overrun);
78723 + local_inc_unchecked(&cpu_buffer->commit_overrun);
78724 goto out_reset;
78725 }
78726
78727 @@ -2188,7 +2188,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
78728 cpu_buffer->tail_page) &&
78729 (cpu_buffer->commit_page ==
78730 cpu_buffer->reader_page))) {
78731 - local_inc(&cpu_buffer->commit_overrun);
78732 + local_inc_unchecked(&cpu_buffer->commit_overrun);
78733 goto out_reset;
78734 }
78735 }
78736 @@ -2236,7 +2236,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
78737 length += RB_LEN_TIME_EXTEND;
78738
78739 tail_page = cpu_buffer->tail_page;
78740 - write = local_add_return(length, &tail_page->write);
78741 + write = local_add_return_unchecked(length, &tail_page->write);
78742
78743 /* set write to only the index of the write */
78744 write &= RB_WRITE_MASK;
78745 @@ -2253,7 +2253,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
78746 kmemcheck_annotate_bitfield(event, bitfield);
78747 rb_update_event(cpu_buffer, event, length, add_timestamp, delta);
78748
78749 - local_inc(&tail_page->entries);
78750 + local_inc_unchecked(&tail_page->entries);
78751
78752 /*
78753 * If this is the first commit on the page, then update
78754 @@ -2286,7 +2286,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
78755
78756 if (bpage->page == (void *)addr && rb_page_write(bpage) == old_index) {
78757 unsigned long write_mask =
78758 - local_read(&bpage->write) & ~RB_WRITE_MASK;
78759 + local_read_unchecked(&bpage->write) & ~RB_WRITE_MASK;
78760 unsigned long event_length = rb_event_length(event);
78761 /*
78762 * This is on the tail page. It is possible that
78763 @@ -2296,7 +2296,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
78764 */
78765 old_index += write_mask;
78766 new_index += write_mask;
78767 - index = local_cmpxchg(&bpage->write, old_index, new_index);
78768 + index = local_cmpxchg_unchecked(&bpage->write, old_index, new_index);
78769 if (index == old_index) {
78770 /* update counters */
78771 local_sub(event_length, &cpu_buffer->entries_bytes);
78772 @@ -2670,7 +2670,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
78773
78774 /* Do the likely case first */
78775 if (likely(bpage->page == (void *)addr)) {
78776 - local_dec(&bpage->entries);
78777 + local_dec_unchecked(&bpage->entries);
78778 return;
78779 }
78780
78781 @@ -2682,7 +2682,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
78782 start = bpage;
78783 do {
78784 if (bpage->page == (void *)addr) {
78785 - local_dec(&bpage->entries);
78786 + local_dec_unchecked(&bpage->entries);
78787 return;
78788 }
78789 rb_inc_page(cpu_buffer, &bpage);
78790 @@ -2964,7 +2964,7 @@ static inline unsigned long
78791 rb_num_of_entries(struct ring_buffer_per_cpu *cpu_buffer)
78792 {
78793 return local_read(&cpu_buffer->entries) -
78794 - (local_read(&cpu_buffer->overrun) + cpu_buffer->read);
78795 + (local_read_unchecked(&cpu_buffer->overrun) + cpu_buffer->read);
78796 }
78797
78798 /**
78799 @@ -3053,7 +3053,7 @@ unsigned long ring_buffer_overrun_cpu(struct ring_buffer *buffer, int cpu)
78800 return 0;
78801
78802 cpu_buffer = buffer->buffers[cpu];
78803 - ret = local_read(&cpu_buffer->overrun);
78804 + ret = local_read_unchecked(&cpu_buffer->overrun);
78805
78806 return ret;
78807 }
78808 @@ -3076,7 +3076,7 @@ ring_buffer_commit_overrun_cpu(struct ring_buffer *buffer, int cpu)
78809 return 0;
78810
78811 cpu_buffer = buffer->buffers[cpu];
78812 - ret = local_read(&cpu_buffer->commit_overrun);
78813 + ret = local_read_unchecked(&cpu_buffer->commit_overrun);
78814
78815 return ret;
78816 }
78817 @@ -3161,7 +3161,7 @@ unsigned long ring_buffer_overruns(struct ring_buffer *buffer)
78818 /* if you care about this being correct, lock the buffer */
78819 for_each_buffer_cpu(buffer, cpu) {
78820 cpu_buffer = buffer->buffers[cpu];
78821 - overruns += local_read(&cpu_buffer->overrun);
78822 + overruns += local_read_unchecked(&cpu_buffer->overrun);
78823 }
78824
78825 return overruns;
78826 @@ -3337,8 +3337,8 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
78827 /*
78828 * Reset the reader page to size zero.
78829 */
78830 - local_set(&cpu_buffer->reader_page->write, 0);
78831 - local_set(&cpu_buffer->reader_page->entries, 0);
78832 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
78833 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
78834 local_set(&cpu_buffer->reader_page->page->commit, 0);
78835 cpu_buffer->reader_page->real_end = 0;
78836
78837 @@ -3372,7 +3372,7 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
78838 * want to compare with the last_overrun.
78839 */
78840 smp_mb();
78841 - overwrite = local_read(&(cpu_buffer->overrun));
78842 + overwrite = local_read_unchecked(&(cpu_buffer->overrun));
78843
78844 /*
78845 * Here's the tricky part.
78846 @@ -3942,8 +3942,8 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
78847
78848 cpu_buffer->head_page
78849 = list_entry(cpu_buffer->pages, struct buffer_page, list);
78850 - local_set(&cpu_buffer->head_page->write, 0);
78851 - local_set(&cpu_buffer->head_page->entries, 0);
78852 + local_set_unchecked(&cpu_buffer->head_page->write, 0);
78853 + local_set_unchecked(&cpu_buffer->head_page->entries, 0);
78854 local_set(&cpu_buffer->head_page->page->commit, 0);
78855
78856 cpu_buffer->head_page->read = 0;
78857 @@ -3953,14 +3953,14 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
78858
78859 INIT_LIST_HEAD(&cpu_buffer->reader_page->list);
78860 INIT_LIST_HEAD(&cpu_buffer->new_pages);
78861 - local_set(&cpu_buffer->reader_page->write, 0);
78862 - local_set(&cpu_buffer->reader_page->entries, 0);
78863 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
78864 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
78865 local_set(&cpu_buffer->reader_page->page->commit, 0);
78866 cpu_buffer->reader_page->read = 0;
78867
78868 local_set(&cpu_buffer->entries_bytes, 0);
78869 - local_set(&cpu_buffer->overrun, 0);
78870 - local_set(&cpu_buffer->commit_overrun, 0);
78871 + local_set_unchecked(&cpu_buffer->overrun, 0);
78872 + local_set_unchecked(&cpu_buffer->commit_overrun, 0);
78873 local_set(&cpu_buffer->dropped_events, 0);
78874 local_set(&cpu_buffer->entries, 0);
78875 local_set(&cpu_buffer->committing, 0);
78876 @@ -4364,8 +4364,8 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
78877 rb_init_page(bpage);
78878 bpage = reader->page;
78879 reader->page = *data_page;
78880 - local_set(&reader->write, 0);
78881 - local_set(&reader->entries, 0);
78882 + local_set_unchecked(&reader->write, 0);
78883 + local_set_unchecked(&reader->entries, 0);
78884 reader->read = 0;
78885 *data_page = bpage;
78886
78887 diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
78888 index 3f28192..a29e8b0 100644
78889 --- a/kernel/trace/trace.c
78890 +++ b/kernel/trace/trace.c
78891 @@ -2893,7 +2893,7 @@ int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set)
78892 return 0;
78893 }
78894
78895 -int set_tracer_flag(unsigned int mask, int enabled)
78896 +int set_tracer_flag(unsigned long mask, int enabled)
78897 {
78898 /* do nothing if flag is already set */
78899 if (!!(trace_flags & mask) == !!enabled)
78900 @@ -4637,10 +4637,9 @@ static const struct file_operations tracing_dyn_info_fops = {
78901 };
78902 #endif
78903
78904 -static struct dentry *d_tracer;
78905 -
78906 struct dentry *tracing_init_dentry(void)
78907 {
78908 + static struct dentry *d_tracer;
78909 static int once;
78910
78911 if (d_tracer)
78912 @@ -4660,10 +4659,9 @@ struct dentry *tracing_init_dentry(void)
78913 return d_tracer;
78914 }
78915
78916 -static struct dentry *d_percpu;
78917 -
78918 static struct dentry *tracing_dentry_percpu(void)
78919 {
78920 + static struct dentry *d_percpu;
78921 static int once;
78922 struct dentry *d_tracer;
78923
78924 diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
78925 index 2081971..09f861e 100644
78926 --- a/kernel/trace/trace.h
78927 +++ b/kernel/trace/trace.h
78928 @@ -948,7 +948,7 @@ extern const char *__stop___trace_bprintk_fmt[];
78929 void trace_printk_init_buffers(void);
78930 void trace_printk_start_comm(void);
78931 int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set);
78932 -int set_tracer_flag(unsigned int mask, int enabled);
78933 +int set_tracer_flag(unsigned long mask, int enabled);
78934
78935 #undef FTRACE_ENTRY
78936 #define FTRACE_ENTRY(call, struct_name, id, tstruct, print, filter) \
78937 diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
78938 index 57e9b28..eebe41c 100644
78939 --- a/kernel/trace/trace_events.c
78940 +++ b/kernel/trace/trace_events.c
78941 @@ -1329,10 +1329,6 @@ static LIST_HEAD(ftrace_module_file_list);
78942 struct ftrace_module_file_ops {
78943 struct list_head list;
78944 struct module *mod;
78945 - struct file_operations id;
78946 - struct file_operations enable;
78947 - struct file_operations format;
78948 - struct file_operations filter;
78949 };
78950
78951 static struct ftrace_module_file_ops *
78952 @@ -1353,17 +1349,12 @@ trace_create_file_ops(struct module *mod)
78953
78954 file_ops->mod = mod;
78955
78956 - file_ops->id = ftrace_event_id_fops;
78957 - file_ops->id.owner = mod;
78958 -
78959 - file_ops->enable = ftrace_enable_fops;
78960 - file_ops->enable.owner = mod;
78961 -
78962 - file_ops->filter = ftrace_event_filter_fops;
78963 - file_ops->filter.owner = mod;
78964 -
78965 - file_ops->format = ftrace_event_format_fops;
78966 - file_ops->format.owner = mod;
78967 + pax_open_kernel();
78968 + mod->trace_id.owner = mod;
78969 + mod->trace_enable.owner = mod;
78970 + mod->trace_filter.owner = mod;
78971 + mod->trace_format.owner = mod;
78972 + pax_close_kernel();
78973
78974 list_add(&file_ops->list, &ftrace_module_file_list);
78975
78976 @@ -1387,8 +1378,8 @@ static void trace_module_add_events(struct module *mod)
78977
78978 for_each_event(call, start, end) {
78979 __trace_add_event_call(*call, mod,
78980 - &file_ops->id, &file_ops->enable,
78981 - &file_ops->filter, &file_ops->format);
78982 + &mod->trace_id, &mod->trace_enable,
78983 + &mod->trace_filter, &mod->trace_format);
78984 }
78985 }
78986
78987 diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c
78988 index fd3c8aa..5f324a6 100644
78989 --- a/kernel/trace/trace_mmiotrace.c
78990 +++ b/kernel/trace/trace_mmiotrace.c
78991 @@ -24,7 +24,7 @@ struct header_iter {
78992 static struct trace_array *mmio_trace_array;
78993 static bool overrun_detected;
78994 static unsigned long prev_overruns;
78995 -static atomic_t dropped_count;
78996 +static atomic_unchecked_t dropped_count;
78997
78998 static void mmio_reset_data(struct trace_array *tr)
78999 {
79000 @@ -127,7 +127,7 @@ static void mmio_close(struct trace_iterator *iter)
79001
79002 static unsigned long count_overruns(struct trace_iterator *iter)
79003 {
79004 - unsigned long cnt = atomic_xchg(&dropped_count, 0);
79005 + unsigned long cnt = atomic_xchg_unchecked(&dropped_count, 0);
79006 unsigned long over = ring_buffer_overruns(iter->tr->buffer);
79007
79008 if (over > prev_overruns)
79009 @@ -317,7 +317,7 @@ static void __trace_mmiotrace_rw(struct trace_array *tr,
79010 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_RW,
79011 sizeof(*entry), 0, pc);
79012 if (!event) {
79013 - atomic_inc(&dropped_count);
79014 + atomic_inc_unchecked(&dropped_count);
79015 return;
79016 }
79017 entry = ring_buffer_event_data(event);
79018 @@ -347,7 +347,7 @@ static void __trace_mmiotrace_map(struct trace_array *tr,
79019 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_MAP,
79020 sizeof(*entry), 0, pc);
79021 if (!event) {
79022 - atomic_inc(&dropped_count);
79023 + atomic_inc_unchecked(&dropped_count);
79024 return;
79025 }
79026 entry = ring_buffer_event_data(event);
79027 diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
79028 index 697e88d..1a79993 100644
79029 --- a/kernel/trace/trace_output.c
79030 +++ b/kernel/trace/trace_output.c
79031 @@ -278,7 +278,7 @@ int trace_seq_path(struct trace_seq *s, const struct path *path)
79032
79033 p = d_path(path, s->buffer + s->len, PAGE_SIZE - s->len);
79034 if (!IS_ERR(p)) {
79035 - p = mangle_path(s->buffer + s->len, p, "\n");
79036 + p = mangle_path(s->buffer + s->len, p, "\n\\");
79037 if (p) {
79038 s->len = p - s->buffer;
79039 return 1;
79040 @@ -851,14 +851,16 @@ int register_ftrace_event(struct trace_event *event)
79041 goto out;
79042 }
79043
79044 + pax_open_kernel();
79045 if (event->funcs->trace == NULL)
79046 - event->funcs->trace = trace_nop_print;
79047 + *(void **)&event->funcs->trace = trace_nop_print;
79048 if (event->funcs->raw == NULL)
79049 - event->funcs->raw = trace_nop_print;
79050 + *(void **)&event->funcs->raw = trace_nop_print;
79051 if (event->funcs->hex == NULL)
79052 - event->funcs->hex = trace_nop_print;
79053 + *(void **)&event->funcs->hex = trace_nop_print;
79054 if (event->funcs->binary == NULL)
79055 - event->funcs->binary = trace_nop_print;
79056 + *(void **)&event->funcs->binary = trace_nop_print;
79057 + pax_close_kernel();
79058
79059 key = event->type & (EVENT_HASHSIZE - 1);
79060
79061 diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
79062 index b20428c..4845a10 100644
79063 --- a/kernel/trace/trace_stack.c
79064 +++ b/kernel/trace/trace_stack.c
79065 @@ -68,7 +68,7 @@ check_stack(unsigned long ip, unsigned long *stack)
79066 return;
79067
79068 /* we do not handle interrupt stacks yet */
79069 - if (!object_is_on_stack(stack))
79070 + if (!object_starts_on_stack(stack))
79071 return;
79072
79073 local_irq_save(flags);
79074 diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
79075 index e134d8f..a018cdd 100644
79076 --- a/kernel/user_namespace.c
79077 +++ b/kernel/user_namespace.c
79078 @@ -853,7 +853,7 @@ static int userns_install(struct nsproxy *nsproxy, void *ns)
79079 if (atomic_read(&current->mm->mm_users) > 1)
79080 return -EINVAL;
79081
79082 - if (current->fs->users != 1)
79083 + if (atomic_read(&current->fs->users) != 1)
79084 return -EINVAL;
79085
79086 if (!ns_capable(user_ns, CAP_SYS_ADMIN))
79087 diff --git a/kernel/utsname_sysctl.c b/kernel/utsname_sysctl.c
79088 index 4f69f9a..7c6f8f8 100644
79089 --- a/kernel/utsname_sysctl.c
79090 +++ b/kernel/utsname_sysctl.c
79091 @@ -47,7 +47,7 @@ static void put_uts(ctl_table *table, int write, void *which)
79092 static int proc_do_uts_string(ctl_table *table, int write,
79093 void __user *buffer, size_t *lenp, loff_t *ppos)
79094 {
79095 - struct ctl_table uts_table;
79096 + ctl_table_no_const uts_table;
79097 int r;
79098 memcpy(&uts_table, table, sizeof(uts_table));
79099 uts_table.data = get_uts(table, write);
79100 diff --git a/kernel/watchdog.c b/kernel/watchdog.c
79101 index 4a94467..80a6f9c 100644
79102 --- a/kernel/watchdog.c
79103 +++ b/kernel/watchdog.c
79104 @@ -526,7 +526,7 @@ int proc_dowatchdog(struct ctl_table *table, int write,
79105 }
79106 #endif /* CONFIG_SYSCTL */
79107
79108 -static struct smp_hotplug_thread watchdog_threads = {
79109 +static struct smp_hotplug_thread watchdog_threads __read_only = {
79110 .store = &softlockup_watchdog,
79111 .thread_should_run = watchdog_should_run,
79112 .thread_fn = watchdog,
79113 diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
79114 index 28be08c..47bab92 100644
79115 --- a/lib/Kconfig.debug
79116 +++ b/lib/Kconfig.debug
79117 @@ -549,7 +549,7 @@ config DEBUG_MUTEXES
79118
79119 config DEBUG_LOCK_ALLOC
79120 bool "Lock debugging: detect incorrect freeing of live locks"
79121 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
79122 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
79123 select DEBUG_SPINLOCK
79124 select DEBUG_MUTEXES
79125 select LOCKDEP
79126 @@ -563,7 +563,7 @@ config DEBUG_LOCK_ALLOC
79127
79128 config PROVE_LOCKING
79129 bool "Lock debugging: prove locking correctness"
79130 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
79131 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
79132 select LOCKDEP
79133 select DEBUG_SPINLOCK
79134 select DEBUG_MUTEXES
79135 @@ -614,7 +614,7 @@ config LOCKDEP
79136
79137 config LOCK_STAT
79138 bool "Lock usage statistics"
79139 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
79140 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
79141 select LOCKDEP
79142 select DEBUG_SPINLOCK
79143 select DEBUG_MUTEXES
79144 @@ -1282,6 +1282,7 @@ config LATENCYTOP
79145 depends on DEBUG_KERNEL
79146 depends on STACKTRACE_SUPPORT
79147 depends on PROC_FS
79148 + depends on !GRKERNSEC_HIDESYM
79149 select FRAME_POINTER if !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM_UNWIND
79150 select KALLSYMS
79151 select KALLSYMS_ALL
79152 @@ -1310,7 +1311,7 @@ config INTERVAL_TREE_TEST
79153
79154 config PROVIDE_OHCI1394_DMA_INIT
79155 bool "Remote debugging over FireWire early on boot"
79156 - depends on PCI && X86
79157 + depends on PCI && X86 && !GRKERNSEC
79158 help
79159 If you want to debug problems which hang or crash the kernel early
79160 on boot and the crashing machine has a FireWire port, you can use
79161 @@ -1339,7 +1340,7 @@ config PROVIDE_OHCI1394_DMA_INIT
79162
79163 config FIREWIRE_OHCI_REMOTE_DMA
79164 bool "Remote debugging over FireWire with firewire-ohci"
79165 - depends on FIREWIRE_OHCI
79166 + depends on FIREWIRE_OHCI && !GRKERNSEC
79167 help
79168 This option lets you use the FireWire bus for remote debugging
79169 with help of the firewire-ohci driver. It enables unfiltered
79170 diff --git a/lib/Makefile b/lib/Makefile
79171 index 6e2cc56..9b13738 100644
79172 --- a/lib/Makefile
79173 +++ b/lib/Makefile
79174 @@ -47,7 +47,7 @@ obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o
79175
79176 obj-$(CONFIG_BTREE) += btree.o
79177 obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o
79178 -obj-$(CONFIG_DEBUG_LIST) += list_debug.o
79179 +obj-y += list_debug.o
79180 obj-$(CONFIG_DEBUG_OBJECTS) += debugobjects.o
79181
79182 ifneq ($(CONFIG_HAVE_DEC_LOCK),y)
79183 diff --git a/lib/bitmap.c b/lib/bitmap.c
79184 index 06f7e4f..f3cf2b0 100644
79185 --- a/lib/bitmap.c
79186 +++ b/lib/bitmap.c
79187 @@ -422,7 +422,7 @@ int __bitmap_parse(const char *buf, unsigned int buflen,
79188 {
79189 int c, old_c, totaldigits, ndigits, nchunks, nbits;
79190 u32 chunk;
79191 - const char __user __force *ubuf = (const char __user __force *)buf;
79192 + const char __user *ubuf = (const char __force_user *)buf;
79193
79194 bitmap_zero(maskp, nmaskbits);
79195
79196 @@ -507,7 +507,7 @@ int bitmap_parse_user(const char __user *ubuf,
79197 {
79198 if (!access_ok(VERIFY_READ, ubuf, ulen))
79199 return -EFAULT;
79200 - return __bitmap_parse((const char __force *)ubuf,
79201 + return __bitmap_parse((const char __force_kernel *)ubuf,
79202 ulen, 1, maskp, nmaskbits);
79203
79204 }
79205 @@ -598,7 +598,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
79206 {
79207 unsigned a, b;
79208 int c, old_c, totaldigits;
79209 - const char __user __force *ubuf = (const char __user __force *)buf;
79210 + const char __user *ubuf = (const char __force_user *)buf;
79211 int exp_digit, in_range;
79212
79213 totaldigits = c = 0;
79214 @@ -698,7 +698,7 @@ int bitmap_parselist_user(const char __user *ubuf,
79215 {
79216 if (!access_ok(VERIFY_READ, ubuf, ulen))
79217 return -EFAULT;
79218 - return __bitmap_parselist((const char __force *)ubuf,
79219 + return __bitmap_parselist((const char __force_kernel *)ubuf,
79220 ulen, 1, maskp, nmaskbits);
79221 }
79222 EXPORT_SYMBOL(bitmap_parselist_user);
79223 diff --git a/lib/bug.c b/lib/bug.c
79224 index 1686034..a9c00c8 100644
79225 --- a/lib/bug.c
79226 +++ b/lib/bug.c
79227 @@ -134,6 +134,8 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
79228 return BUG_TRAP_TYPE_NONE;
79229
79230 bug = find_bug(bugaddr);
79231 + if (!bug)
79232 + return BUG_TRAP_TYPE_NONE;
79233
79234 file = NULL;
79235 line = 0;
79236 diff --git a/lib/debugobjects.c b/lib/debugobjects.c
79237 index 37061ed..da83f48 100644
79238 --- a/lib/debugobjects.c
79239 +++ b/lib/debugobjects.c
79240 @@ -286,7 +286,7 @@ static void debug_object_is_on_stack(void *addr, int onstack)
79241 if (limit > 4)
79242 return;
79243
79244 - is_on_stack = object_is_on_stack(addr);
79245 + is_on_stack = object_starts_on_stack(addr);
79246 if (is_on_stack == onstack)
79247 return;
79248
79249 diff --git a/lib/devres.c b/lib/devres.c
79250 index 8235331..5881053 100644
79251 --- a/lib/devres.c
79252 +++ b/lib/devres.c
79253 @@ -81,7 +81,7 @@ EXPORT_SYMBOL(devm_ioremap_nocache);
79254 void devm_iounmap(struct device *dev, void __iomem *addr)
79255 {
79256 WARN_ON(devres_destroy(dev, devm_ioremap_release, devm_ioremap_match,
79257 - (void *)addr));
79258 + (void __force *)addr));
79259 iounmap(addr);
79260 }
79261 EXPORT_SYMBOL(devm_iounmap);
79262 @@ -224,7 +224,7 @@ void devm_ioport_unmap(struct device *dev, void __iomem *addr)
79263 {
79264 ioport_unmap(addr);
79265 WARN_ON(devres_destroy(dev, devm_ioport_map_release,
79266 - devm_ioport_map_match, (void *)addr));
79267 + devm_ioport_map_match, (void __force *)addr));
79268 }
79269 EXPORT_SYMBOL(devm_ioport_unmap);
79270 #endif /* CONFIG_HAS_IOPORT */
79271 diff --git a/lib/div64.c b/lib/div64.c
79272 index a163b6c..9618fa5 100644
79273 --- a/lib/div64.c
79274 +++ b/lib/div64.c
79275 @@ -59,7 +59,7 @@ uint32_t __attribute__((weak)) __div64_32(uint64_t *n, uint32_t base)
79276 EXPORT_SYMBOL(__div64_32);
79277
79278 #ifndef div_s64_rem
79279 -s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
79280 +s64 __intentional_overflow(-1) div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
79281 {
79282 u64 quotient;
79283
79284 @@ -90,7 +90,7 @@ EXPORT_SYMBOL(div_s64_rem);
79285 * 'http://www.hackersdelight.org/HDcode/newCode/divDouble.c.txt'
79286 */
79287 #ifndef div64_u64
79288 -u64 div64_u64(u64 dividend, u64 divisor)
79289 +u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor)
79290 {
79291 u32 high = divisor >> 32;
79292 u64 quot;
79293 diff --git a/lib/dma-debug.c b/lib/dma-debug.c
79294 index d87a17a..ac0d79a 100644
79295 --- a/lib/dma-debug.c
79296 +++ b/lib/dma-debug.c
79297 @@ -768,7 +768,7 @@ static int dma_debug_device_change(struct notifier_block *nb, unsigned long acti
79298
79299 void dma_debug_add_bus(struct bus_type *bus)
79300 {
79301 - struct notifier_block *nb;
79302 + notifier_block_no_const *nb;
79303
79304 if (global_disable)
79305 return;
79306 @@ -945,7 +945,7 @@ static void check_unmap(struct dma_debug_entry *ref)
79307
79308 static void check_for_stack(struct device *dev, void *addr)
79309 {
79310 - if (object_is_on_stack(addr))
79311 + if (object_starts_on_stack(addr))
79312 err_printk(dev, NULL, "DMA-API: device driver maps memory from"
79313 "stack [addr=%p]\n", addr);
79314 }
79315 diff --git a/lib/inflate.c b/lib/inflate.c
79316 index 013a761..c28f3fc 100644
79317 --- a/lib/inflate.c
79318 +++ b/lib/inflate.c
79319 @@ -269,7 +269,7 @@ static void free(void *where)
79320 malloc_ptr = free_mem_ptr;
79321 }
79322 #else
79323 -#define malloc(a) kmalloc(a, GFP_KERNEL)
79324 +#define malloc(a) kmalloc((a), GFP_KERNEL)
79325 #define free(a) kfree(a)
79326 #endif
79327
79328 diff --git a/lib/ioremap.c b/lib/ioremap.c
79329 index 0c9216c..863bd89 100644
79330 --- a/lib/ioremap.c
79331 +++ b/lib/ioremap.c
79332 @@ -38,7 +38,7 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr,
79333 unsigned long next;
79334
79335 phys_addr -= addr;
79336 - pmd = pmd_alloc(&init_mm, pud, addr);
79337 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
79338 if (!pmd)
79339 return -ENOMEM;
79340 do {
79341 @@ -56,7 +56,7 @@ static inline int ioremap_pud_range(pgd_t *pgd, unsigned long addr,
79342 unsigned long next;
79343
79344 phys_addr -= addr;
79345 - pud = pud_alloc(&init_mm, pgd, addr);
79346 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
79347 if (!pud)
79348 return -ENOMEM;
79349 do {
79350 diff --git a/lib/is_single_threaded.c b/lib/is_single_threaded.c
79351 index bd2bea9..6b3c95e 100644
79352 --- a/lib/is_single_threaded.c
79353 +++ b/lib/is_single_threaded.c
79354 @@ -22,6 +22,9 @@ bool current_is_single_threaded(void)
79355 struct task_struct *p, *t;
79356 bool ret;
79357
79358 + if (!mm)
79359 + return true;
79360 +
79361 if (atomic_read(&task->signal->live) != 1)
79362 return false;
79363
79364 diff --git a/lib/kobject.c b/lib/kobject.c
79365 index a654866..a4fd13d 100644
79366 --- a/lib/kobject.c
79367 +++ b/lib/kobject.c
79368 @@ -859,9 +859,9 @@ EXPORT_SYMBOL_GPL(kset_create_and_add);
79369
79370
79371 static DEFINE_SPINLOCK(kobj_ns_type_lock);
79372 -static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES];
79373 +static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES] __read_only;
79374
79375 -int kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
79376 +int __init kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
79377 {
79378 enum kobj_ns_type type = ops->type;
79379 int error;
79380 diff --git a/lib/list_debug.c b/lib/list_debug.c
79381 index c24c2f7..06e070b 100644
79382 --- a/lib/list_debug.c
79383 +++ b/lib/list_debug.c
79384 @@ -11,7 +11,9 @@
79385 #include <linux/bug.h>
79386 #include <linux/kernel.h>
79387 #include <linux/rculist.h>
79388 +#include <linux/mm.h>
79389
79390 +#ifdef CONFIG_DEBUG_LIST
79391 /*
79392 * Insert a new entry between two known consecutive entries.
79393 *
79394 @@ -19,21 +21,32 @@
79395 * the prev/next entries already!
79396 */
79397
79398 -void __list_add(struct list_head *new,
79399 - struct list_head *prev,
79400 - struct list_head *next)
79401 +static bool __list_add_debug(struct list_head *new,
79402 + struct list_head *prev,
79403 + struct list_head *next)
79404 {
79405 - WARN(next->prev != prev,
79406 + if (WARN(next->prev != prev,
79407 "list_add corruption. next->prev should be "
79408 "prev (%p), but was %p. (next=%p).\n",
79409 - prev, next->prev, next);
79410 - WARN(prev->next != next,
79411 + prev, next->prev, next) ||
79412 + WARN(prev->next != next,
79413 "list_add corruption. prev->next should be "
79414 "next (%p), but was %p. (prev=%p).\n",
79415 - next, prev->next, prev);
79416 - WARN(new == prev || new == next,
79417 - "list_add double add: new=%p, prev=%p, next=%p.\n",
79418 - new, prev, next);
79419 + next, prev->next, prev) ||
79420 + WARN(new == prev || new == next,
79421 + "list_add double add: new=%p, prev=%p, next=%p.\n",
79422 + new, prev, next))
79423 + return false;
79424 + return true;
79425 +}
79426 +
79427 +void __list_add(struct list_head *new,
79428 + struct list_head *prev,
79429 + struct list_head *next)
79430 +{
79431 + if (!__list_add_debug(new, prev, next))
79432 + return;
79433 +
79434 next->prev = new;
79435 new->next = next;
79436 new->prev = prev;
79437 @@ -41,7 +54,7 @@ void __list_add(struct list_head *new,
79438 }
79439 EXPORT_SYMBOL(__list_add);
79440
79441 -void __list_del_entry(struct list_head *entry)
79442 +static bool __list_del_entry_debug(struct list_head *entry)
79443 {
79444 struct list_head *prev, *next;
79445
79446 @@ -60,9 +73,16 @@ void __list_del_entry(struct list_head *entry)
79447 WARN(next->prev != entry,
79448 "list_del corruption. next->prev should be %p, "
79449 "but was %p\n", entry, next->prev))
79450 + return false;
79451 + return true;
79452 +}
79453 +
79454 +void __list_del_entry(struct list_head *entry)
79455 +{
79456 + if (!__list_del_entry_debug(entry))
79457 return;
79458
79459 - __list_del(prev, next);
79460 + __list_del(entry->prev, entry->next);
79461 }
79462 EXPORT_SYMBOL(__list_del_entry);
79463
79464 @@ -86,15 +106,85 @@ EXPORT_SYMBOL(list_del);
79465 void __list_add_rcu(struct list_head *new,
79466 struct list_head *prev, struct list_head *next)
79467 {
79468 - WARN(next->prev != prev,
79469 - "list_add_rcu corruption. next->prev should be prev (%p), but was %p. (next=%p).\n",
79470 - prev, next->prev, next);
79471 - WARN(prev->next != next,
79472 - "list_add_rcu corruption. prev->next should be next (%p), but was %p. (prev=%p).\n",
79473 - next, prev->next, prev);
79474 + if (!__list_add_debug(new, prev, next))
79475 + return;
79476 +
79477 new->next = next;
79478 new->prev = prev;
79479 rcu_assign_pointer(list_next_rcu(prev), new);
79480 next->prev = new;
79481 }
79482 EXPORT_SYMBOL(__list_add_rcu);
79483 +#endif
79484 +
79485 +void __pax_list_add(struct list_head *new, struct list_head *prev, struct list_head *next)
79486 +{
79487 +#ifdef CONFIG_DEBUG_LIST
79488 + if (!__list_add_debug(new, prev, next))
79489 + return;
79490 +#endif
79491 +
79492 + pax_open_kernel();
79493 + next->prev = new;
79494 + new->next = next;
79495 + new->prev = prev;
79496 + prev->next = new;
79497 + pax_close_kernel();
79498 +}
79499 +EXPORT_SYMBOL(__pax_list_add);
79500 +
79501 +void pax_list_del(struct list_head *entry)
79502 +{
79503 +#ifdef CONFIG_DEBUG_LIST
79504 + if (!__list_del_entry_debug(entry))
79505 + return;
79506 +#endif
79507 +
79508 + pax_open_kernel();
79509 + __list_del(entry->prev, entry->next);
79510 + entry->next = LIST_POISON1;
79511 + entry->prev = LIST_POISON2;
79512 + pax_close_kernel();
79513 +}
79514 +EXPORT_SYMBOL(pax_list_del);
79515 +
79516 +void pax_list_del_init(struct list_head *entry)
79517 +{
79518 + pax_open_kernel();
79519 + __list_del(entry->prev, entry->next);
79520 + INIT_LIST_HEAD(entry);
79521 + pax_close_kernel();
79522 +}
79523 +EXPORT_SYMBOL(pax_list_del_init);
79524 +
79525 +void __pax_list_add_rcu(struct list_head *new,
79526 + struct list_head *prev, struct list_head *next)
79527 +{
79528 +#ifdef CONFIG_DEBUG_LIST
79529 + if (!__list_add_debug(new, prev, next))
79530 + return;
79531 +#endif
79532 +
79533 + pax_open_kernel();
79534 + new->next = next;
79535 + new->prev = prev;
79536 + rcu_assign_pointer(list_next_rcu(prev), new);
79537 + next->prev = new;
79538 + pax_close_kernel();
79539 +}
79540 +EXPORT_SYMBOL(__pax_list_add_rcu);
79541 +
79542 +void pax_list_del_rcu(struct list_head *entry)
79543 +{
79544 +#ifdef CONFIG_DEBUG_LIST
79545 + if (!__list_del_entry_debug(entry))
79546 + return;
79547 +#endif
79548 +
79549 + pax_open_kernel();
79550 + __list_del(entry->prev, entry->next);
79551 + entry->next = LIST_POISON1;
79552 + entry->prev = LIST_POISON2;
79553 + pax_close_kernel();
79554 +}
79555 +EXPORT_SYMBOL(pax_list_del_rcu);
79556 diff --git a/lib/radix-tree.c b/lib/radix-tree.c
79557 index e796429..6e38f9f 100644
79558 --- a/lib/radix-tree.c
79559 +++ b/lib/radix-tree.c
79560 @@ -92,7 +92,7 @@ struct radix_tree_preload {
79561 int nr;
79562 struct radix_tree_node *nodes[RADIX_TREE_PRELOAD_SIZE];
79563 };
79564 -static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads) = { 0, };
79565 +static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads);
79566
79567 static inline void *ptr_to_indirect(void *ptr)
79568 {
79569 diff --git a/lib/strncpy_from_user.c b/lib/strncpy_from_user.c
79570 index bb2b201..46abaf9 100644
79571 --- a/lib/strncpy_from_user.c
79572 +++ b/lib/strncpy_from_user.c
79573 @@ -21,7 +21,7 @@
79574 */
79575 static inline long do_strncpy_from_user(char *dst, const char __user *src, long count, unsigned long max)
79576 {
79577 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
79578 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
79579 long res = 0;
79580
79581 /*
79582 diff --git a/lib/strnlen_user.c b/lib/strnlen_user.c
79583 index a28df52..3d55877 100644
79584 --- a/lib/strnlen_user.c
79585 +++ b/lib/strnlen_user.c
79586 @@ -26,7 +26,7 @@
79587 */
79588 static inline long do_strnlen_user(const char __user *src, unsigned long count, unsigned long max)
79589 {
79590 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
79591 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
79592 long align, res = 0;
79593 unsigned long c;
79594
79595 diff --git a/lib/swiotlb.c b/lib/swiotlb.c
79596 index d23762e..e21eab2 100644
79597 --- a/lib/swiotlb.c
79598 +++ b/lib/swiotlb.c
79599 @@ -664,7 +664,7 @@ EXPORT_SYMBOL(swiotlb_alloc_coherent);
79600
79601 void
79602 swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
79603 - dma_addr_t dev_addr)
79604 + dma_addr_t dev_addr, struct dma_attrs *attrs)
79605 {
79606 phys_addr_t paddr = dma_to_phys(hwdev, dev_addr);
79607
79608 diff --git a/lib/vsprintf.c b/lib/vsprintf.c
79609 index 0d62fd7..b7bc911 100644
79610 --- a/lib/vsprintf.c
79611 +++ b/lib/vsprintf.c
79612 @@ -16,6 +16,9 @@
79613 * - scnprintf and vscnprintf
79614 */
79615
79616 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79617 +#define __INCLUDED_BY_HIDESYM 1
79618 +#endif
79619 #include <stdarg.h>
79620 #include <linux/module.h> /* for KSYM_SYMBOL_LEN */
79621 #include <linux/types.h>
79622 @@ -974,7 +977,11 @@ char *netdev_feature_string(char *buf, char *end, const u8 *addr,
79623 return number(buf, end, *(const netdev_features_t *)addr, spec);
79624 }
79625
79626 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79627 +int kptr_restrict __read_mostly = 2;
79628 +#else
79629 int kptr_restrict __read_mostly;
79630 +#endif
79631
79632 /*
79633 * Show a '%p' thing. A kernel extension is that the '%p' is followed
79634 @@ -988,6 +995,8 @@ int kptr_restrict __read_mostly;
79635 * - 'S' For symbolic direct pointers with offset
79636 * - 's' For symbolic direct pointers without offset
79637 * - 'B' For backtraced symbolic direct pointers with offset
79638 + * - 'A' For symbolic direct pointers with offset approved for use with GRKERNSEC_HIDESYM
79639 + * - 'a' For symbolic direct pointers without offset approved for use with GRKERNSEC_HIDESYM
79640 * - 'R' For decoded struct resource, e.g., [mem 0x0-0x1f 64bit pref]
79641 * - 'r' For raw struct resource, e.g., [mem 0x0-0x1f flags 0x201]
79642 * - 'M' For a 6-byte MAC address, it prints the address in the
79643 @@ -1044,12 +1053,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
79644
79645 if (!ptr && *fmt != 'K') {
79646 /*
79647 - * Print (null) with the same width as a pointer so it makes
79648 + * Print (nil) with the same width as a pointer so it makes
79649 * tabular output look nice.
79650 */
79651 if (spec.field_width == -1)
79652 spec.field_width = default_width;
79653 - return string(buf, end, "(null)", spec);
79654 + return string(buf, end, "(nil)", spec);
79655 }
79656
79657 switch (*fmt) {
79658 @@ -1059,6 +1068,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
79659 /* Fallthrough */
79660 case 'S':
79661 case 's':
79662 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79663 + break;
79664 +#else
79665 + return symbol_string(buf, end, ptr, spec, *fmt);
79666 +#endif
79667 + case 'A':
79668 case 'B':
79669 return symbol_string(buf, end, ptr, spec, *fmt);
79670 case 'R':
79671 @@ -1099,6 +1114,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
79672 va_end(va);
79673 return buf;
79674 }
79675 + case 'P':
79676 + break;
79677 case 'K':
79678 /*
79679 * %pK cannot be used in IRQ context because its test
79680 @@ -1128,6 +1145,21 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
79681 return number(buf, end,
79682 (unsigned long long) *((phys_addr_t *)ptr), spec);
79683 }
79684 +
79685 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79686 + /* 'P' = approved pointers to copy to userland,
79687 + as in the /proc/kallsyms case, as we make it display nothing
79688 + for non-root users, and the real contents for root users
79689 + Also ignore 'K' pointers, since we force their NULLing for non-root users
79690 + above
79691 + */
79692 + if ((unsigned long)ptr > TASK_SIZE && *fmt != 'P' && *fmt != 'K' && is_usercopy_object(buf)) {
79693 + printk(KERN_ALERT "grsec: kernel infoleak detected! Please report this log to spender@grsecurity.net.\n");
79694 + dump_stack();
79695 + ptr = NULL;
79696 + }
79697 +#endif
79698 +
79699 spec.flags |= SMALL;
79700 if (spec.field_width == -1) {
79701 spec.field_width = default_width;
79702 @@ -1849,11 +1881,11 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
79703 typeof(type) value; \
79704 if (sizeof(type) == 8) { \
79705 args = PTR_ALIGN(args, sizeof(u32)); \
79706 - *(u32 *)&value = *(u32 *)args; \
79707 - *((u32 *)&value + 1) = *(u32 *)(args + 4); \
79708 + *(u32 *)&value = *(const u32 *)args; \
79709 + *((u32 *)&value + 1) = *(const u32 *)(args + 4); \
79710 } else { \
79711 args = PTR_ALIGN(args, sizeof(type)); \
79712 - value = *(typeof(type) *)args; \
79713 + value = *(const typeof(type) *)args; \
79714 } \
79715 args += sizeof(type); \
79716 value; \
79717 @@ -1916,7 +1948,7 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
79718 case FORMAT_TYPE_STR: {
79719 const char *str_arg = args;
79720 args += strlen(str_arg) + 1;
79721 - str = string(str, end, (char *)str_arg, spec);
79722 + str = string(str, end, str_arg, spec);
79723 break;
79724 }
79725
79726 diff --git a/localversion-grsec b/localversion-grsec
79727 new file mode 100644
79728 index 0000000..7cd6065
79729 --- /dev/null
79730 +++ b/localversion-grsec
79731 @@ -0,0 +1 @@
79732 +-grsec
79733 diff --git a/mm/Kconfig b/mm/Kconfig
79734 index 3bea74f..e821c99 100644
79735 --- a/mm/Kconfig
79736 +++ b/mm/Kconfig
79737 @@ -311,10 +311,10 @@ config KSM
79738 root has set /sys/kernel/mm/ksm/run to 1 (if CONFIG_SYSFS is set).
79739
79740 config DEFAULT_MMAP_MIN_ADDR
79741 - int "Low address space to protect from user allocation"
79742 + int "Low address space to protect from user allocation"
79743 depends on MMU
79744 - default 4096
79745 - help
79746 + default 65536
79747 + help
79748 This is the portion of low virtual memory which should be protected
79749 from userspace allocation. Keeping a user from writing to low pages
79750 can help reduce the impact of kernel NULL pointer bugs.
79751 @@ -345,7 +345,7 @@ config MEMORY_FAILURE
79752
79753 config HWPOISON_INJECT
79754 tristate "HWPoison pages injector"
79755 - depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS
79756 + depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS && !GRKERNSEC
79757 select PROC_PAGE_MONITOR
79758
79759 config NOMMU_INITIAL_TRIM_EXCESS
79760 diff --git a/mm/filemap.c b/mm/filemap.c
79761 index e1979fd..dda5120 100644
79762 --- a/mm/filemap.c
79763 +++ b/mm/filemap.c
79764 @@ -1748,7 +1748,7 @@ int generic_file_mmap(struct file * file, struct vm_area_struct * vma)
79765 struct address_space *mapping = file->f_mapping;
79766
79767 if (!mapping->a_ops->readpage)
79768 - return -ENOEXEC;
79769 + return -ENODEV;
79770 file_accessed(file);
79771 vma->vm_ops = &generic_file_vm_ops;
79772 return 0;
79773 @@ -2088,6 +2088,7 @@ inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count, i
79774 *pos = i_size_read(inode);
79775
79776 if (limit != RLIM_INFINITY) {
79777 + gr_learn_resource(current, RLIMIT_FSIZE,*pos, 0);
79778 if (*pos >= limit) {
79779 send_sig(SIGXFSZ, current, 0);
79780 return -EFBIG;
79781 diff --git a/mm/fremap.c b/mm/fremap.c
79782 index 87da359..3f41cb1 100644
79783 --- a/mm/fremap.c
79784 +++ b/mm/fremap.c
79785 @@ -158,6 +158,11 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
79786 retry:
79787 vma = find_vma(mm, start);
79788
79789 +#ifdef CONFIG_PAX_SEGMEXEC
79790 + if (vma && (mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_MAYEXEC))
79791 + goto out;
79792 +#endif
79793 +
79794 /*
79795 * Make sure the vma is shared, that it supports prefaulting,
79796 * and that the remapped range is valid and fully within
79797 diff --git a/mm/highmem.c b/mm/highmem.c
79798 index b32b70c..e512eb0 100644
79799 --- a/mm/highmem.c
79800 +++ b/mm/highmem.c
79801 @@ -138,8 +138,9 @@ static void flush_all_zero_pkmaps(void)
79802 * So no dangers, even with speculative execution.
79803 */
79804 page = pte_page(pkmap_page_table[i]);
79805 + pax_open_kernel();
79806 pte_clear(&init_mm, PKMAP_ADDR(i), &pkmap_page_table[i]);
79807 -
79808 + pax_close_kernel();
79809 set_page_address(page, NULL);
79810 need_flush = 1;
79811 }
79812 @@ -198,9 +199,11 @@ start:
79813 }
79814 }
79815 vaddr = PKMAP_ADDR(last_pkmap_nr);
79816 +
79817 + pax_open_kernel();
79818 set_pte_at(&init_mm, vaddr,
79819 &(pkmap_page_table[last_pkmap_nr]), mk_pte(page, kmap_prot));
79820 -
79821 + pax_close_kernel();
79822 pkmap_count[last_pkmap_nr] = 1;
79823 set_page_address(page, (void *)vaddr);
79824
79825 diff --git a/mm/hugetlb.c b/mm/hugetlb.c
79826 index 1a12f5b..a85b8fc 100644
79827 --- a/mm/hugetlb.c
79828 +++ b/mm/hugetlb.c
79829 @@ -2005,15 +2005,17 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
79830 struct hstate *h = &default_hstate;
79831 unsigned long tmp;
79832 int ret;
79833 + ctl_table_no_const hugetlb_table;
79834
79835 tmp = h->max_huge_pages;
79836
79837 if (write && h->order >= MAX_ORDER)
79838 return -EINVAL;
79839
79840 - table->data = &tmp;
79841 - table->maxlen = sizeof(unsigned long);
79842 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
79843 + hugetlb_table = *table;
79844 + hugetlb_table.data = &tmp;
79845 + hugetlb_table.maxlen = sizeof(unsigned long);
79846 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
79847 if (ret)
79848 goto out;
79849
79850 @@ -2070,15 +2072,17 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write,
79851 struct hstate *h = &default_hstate;
79852 unsigned long tmp;
79853 int ret;
79854 + ctl_table_no_const hugetlb_table;
79855
79856 tmp = h->nr_overcommit_huge_pages;
79857
79858 if (write && h->order >= MAX_ORDER)
79859 return -EINVAL;
79860
79861 - table->data = &tmp;
79862 - table->maxlen = sizeof(unsigned long);
79863 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
79864 + hugetlb_table = *table;
79865 + hugetlb_table.data = &tmp;
79866 + hugetlb_table.maxlen = sizeof(unsigned long);
79867 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
79868 if (ret)
79869 goto out;
79870
79871 @@ -2512,6 +2516,27 @@ static int unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,
79872 return 1;
79873 }
79874
79875 +#ifdef CONFIG_PAX_SEGMEXEC
79876 +static void pax_mirror_huge_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m)
79877 +{
79878 + struct mm_struct *mm = vma->vm_mm;
79879 + struct vm_area_struct *vma_m;
79880 + unsigned long address_m;
79881 + pte_t *ptep_m;
79882 +
79883 + vma_m = pax_find_mirror_vma(vma);
79884 + if (!vma_m)
79885 + return;
79886 +
79887 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
79888 + address_m = address + SEGMEXEC_TASK_SIZE;
79889 + ptep_m = huge_pte_offset(mm, address_m & HPAGE_MASK);
79890 + get_page(page_m);
79891 + hugepage_add_anon_rmap(page_m, vma_m, address_m);
79892 + set_huge_pte_at(mm, address_m, ptep_m, make_huge_pte(vma_m, page_m, 0));
79893 +}
79894 +#endif
79895 +
79896 /*
79897 * Hugetlb_cow() should be called with page lock of the original hugepage held.
79898 * Called with hugetlb_instantiation_mutex held and pte_page locked so we
79899 @@ -2630,6 +2655,11 @@ retry_avoidcopy:
79900 make_huge_pte(vma, new_page, 1));
79901 page_remove_rmap(old_page);
79902 hugepage_add_new_anon_rmap(new_page, vma, address);
79903 +
79904 +#ifdef CONFIG_PAX_SEGMEXEC
79905 + pax_mirror_huge_pte(vma, address, new_page);
79906 +#endif
79907 +
79908 /* Make the old page be freed below */
79909 new_page = old_page;
79910 }
79911 @@ -2788,6 +2818,10 @@ retry:
79912 && (vma->vm_flags & VM_SHARED)));
79913 set_huge_pte_at(mm, address, ptep, new_pte);
79914
79915 +#ifdef CONFIG_PAX_SEGMEXEC
79916 + pax_mirror_huge_pte(vma, address, page);
79917 +#endif
79918 +
79919 if ((flags & FAULT_FLAG_WRITE) && !(vma->vm_flags & VM_SHARED)) {
79920 /* Optimization, do the COW without a second fault */
79921 ret = hugetlb_cow(mm, vma, address, ptep, new_pte, page);
79922 @@ -2817,6 +2851,10 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
79923 static DEFINE_MUTEX(hugetlb_instantiation_mutex);
79924 struct hstate *h = hstate_vma(vma);
79925
79926 +#ifdef CONFIG_PAX_SEGMEXEC
79927 + struct vm_area_struct *vma_m;
79928 +#endif
79929 +
79930 address &= huge_page_mask(h);
79931
79932 ptep = huge_pte_offset(mm, address);
79933 @@ -2830,6 +2868,26 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
79934 VM_FAULT_SET_HINDEX(hstate_index(h));
79935 }
79936
79937 +#ifdef CONFIG_PAX_SEGMEXEC
79938 + vma_m = pax_find_mirror_vma(vma);
79939 + if (vma_m) {
79940 + unsigned long address_m;
79941 +
79942 + if (vma->vm_start > vma_m->vm_start) {
79943 + address_m = address;
79944 + address -= SEGMEXEC_TASK_SIZE;
79945 + vma = vma_m;
79946 + h = hstate_vma(vma);
79947 + } else
79948 + address_m = address + SEGMEXEC_TASK_SIZE;
79949 +
79950 + if (!huge_pte_alloc(mm, address_m, huge_page_size(h)))
79951 + return VM_FAULT_OOM;
79952 + address_m &= HPAGE_MASK;
79953 + unmap_hugepage_range(vma, address_m, address_m + HPAGE_SIZE, NULL);
79954 + }
79955 +#endif
79956 +
79957 ptep = huge_pte_alloc(mm, address, huge_page_size(h));
79958 if (!ptep)
79959 return VM_FAULT_OOM;
79960 diff --git a/mm/internal.h b/mm/internal.h
79961 index 8562de0..7fdfe92 100644
79962 --- a/mm/internal.h
79963 +++ b/mm/internal.h
79964 @@ -100,6 +100,7 @@ extern pmd_t *mm_find_pmd(struct mm_struct *mm, unsigned long address);
79965 * in mm/page_alloc.c
79966 */
79967 extern void __free_pages_bootmem(struct page *page, unsigned int order);
79968 +extern void free_compound_page(struct page *page);
79969 extern void prep_compound_page(struct page *page, unsigned long order);
79970 #ifdef CONFIG_MEMORY_FAILURE
79971 extern bool is_free_buddy_page(struct page *page);
79972 diff --git a/mm/kmemleak.c b/mm/kmemleak.c
79973 index c8d7f31..2dbeffd 100644
79974 --- a/mm/kmemleak.c
79975 +++ b/mm/kmemleak.c
79976 @@ -363,7 +363,7 @@ static void print_unreferenced(struct seq_file *seq,
79977
79978 for (i = 0; i < object->trace_len; i++) {
79979 void *ptr = (void *)object->trace[i];
79980 - seq_printf(seq, " [<%p>] %pS\n", ptr, ptr);
79981 + seq_printf(seq, " [<%pP>] %pA\n", ptr, ptr);
79982 }
79983 }
79984
79985 @@ -1851,7 +1851,7 @@ static int __init kmemleak_late_init(void)
79986 return -ENOMEM;
79987 }
79988
79989 - dentry = debugfs_create_file("kmemleak", S_IRUGO, NULL, NULL,
79990 + dentry = debugfs_create_file("kmemleak", S_IRUSR, NULL, NULL,
79991 &kmemleak_fops);
79992 if (!dentry)
79993 pr_warning("Failed to create the debugfs kmemleak file\n");
79994 diff --git a/mm/maccess.c b/mm/maccess.c
79995 index d53adf9..03a24bf 100644
79996 --- a/mm/maccess.c
79997 +++ b/mm/maccess.c
79998 @@ -26,7 +26,7 @@ long __probe_kernel_read(void *dst, const void *src, size_t size)
79999 set_fs(KERNEL_DS);
80000 pagefault_disable();
80001 ret = __copy_from_user_inatomic(dst,
80002 - (__force const void __user *)src, size);
80003 + (const void __force_user *)src, size);
80004 pagefault_enable();
80005 set_fs(old_fs);
80006
80007 @@ -53,7 +53,7 @@ long __probe_kernel_write(void *dst, const void *src, size_t size)
80008
80009 set_fs(KERNEL_DS);
80010 pagefault_disable();
80011 - ret = __copy_to_user_inatomic((__force void __user *)dst, src, size);
80012 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
80013 pagefault_enable();
80014 set_fs(old_fs);
80015
80016 diff --git a/mm/madvise.c b/mm/madvise.c
80017 index c58c94b..86ec14e 100644
80018 --- a/mm/madvise.c
80019 +++ b/mm/madvise.c
80020 @@ -51,6 +51,10 @@ static long madvise_behavior(struct vm_area_struct * vma,
80021 pgoff_t pgoff;
80022 unsigned long new_flags = vma->vm_flags;
80023
80024 +#ifdef CONFIG_PAX_SEGMEXEC
80025 + struct vm_area_struct *vma_m;
80026 +#endif
80027 +
80028 switch (behavior) {
80029 case MADV_NORMAL:
80030 new_flags = new_flags & ~VM_RAND_READ & ~VM_SEQ_READ;
80031 @@ -126,6 +130,13 @@ success:
80032 /*
80033 * vm_flags is protected by the mmap_sem held in write mode.
80034 */
80035 +
80036 +#ifdef CONFIG_PAX_SEGMEXEC
80037 + vma_m = pax_find_mirror_vma(vma);
80038 + if (vma_m)
80039 + vma_m->vm_flags = new_flags & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT);
80040 +#endif
80041 +
80042 vma->vm_flags = new_flags;
80043
80044 out:
80045 @@ -274,6 +285,11 @@ static long madvise_dontneed(struct vm_area_struct * vma,
80046 struct vm_area_struct ** prev,
80047 unsigned long start, unsigned long end)
80048 {
80049 +
80050 +#ifdef CONFIG_PAX_SEGMEXEC
80051 + struct vm_area_struct *vma_m;
80052 +#endif
80053 +
80054 *prev = vma;
80055 if (vma->vm_flags & (VM_LOCKED|VM_HUGETLB|VM_PFNMAP))
80056 return -EINVAL;
80057 @@ -286,6 +302,21 @@ static long madvise_dontneed(struct vm_area_struct * vma,
80058 zap_page_range(vma, start, end - start, &details);
80059 } else
80060 zap_page_range(vma, start, end - start, NULL);
80061 +
80062 +#ifdef CONFIG_PAX_SEGMEXEC
80063 + vma_m = pax_find_mirror_vma(vma);
80064 + if (vma_m) {
80065 + if (unlikely(vma->vm_flags & VM_NONLINEAR)) {
80066 + struct zap_details details = {
80067 + .nonlinear_vma = vma_m,
80068 + .last_index = ULONG_MAX,
80069 + };
80070 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, &details);
80071 + } else
80072 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, NULL);
80073 + }
80074 +#endif
80075 +
80076 return 0;
80077 }
80078
80079 @@ -491,6 +522,16 @@ SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior)
80080 if (end < start)
80081 goto out;
80082
80083 +#ifdef CONFIG_PAX_SEGMEXEC
80084 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
80085 + if (end > SEGMEXEC_TASK_SIZE)
80086 + goto out;
80087 + } else
80088 +#endif
80089 +
80090 + if (end > TASK_SIZE)
80091 + goto out;
80092 +
80093 error = 0;
80094 if (end == start)
80095 goto out;
80096 diff --git a/mm/memory-failure.c b/mm/memory-failure.c
80097 index df0694c..bc95539 100644
80098 --- a/mm/memory-failure.c
80099 +++ b/mm/memory-failure.c
80100 @@ -61,7 +61,7 @@ int sysctl_memory_failure_early_kill __read_mostly = 0;
80101
80102 int sysctl_memory_failure_recovery __read_mostly = 1;
80103
80104 -atomic_long_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
80105 +atomic_long_unchecked_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
80106
80107 #if defined(CONFIG_HWPOISON_INJECT) || defined(CONFIG_HWPOISON_INJECT_MODULE)
80108
80109 @@ -202,7 +202,7 @@ static int kill_proc(struct task_struct *t, unsigned long addr, int trapno,
80110 pfn, t->comm, t->pid);
80111 si.si_signo = SIGBUS;
80112 si.si_errno = 0;
80113 - si.si_addr = (void *)addr;
80114 + si.si_addr = (void __user *)addr;
80115 #ifdef __ARCH_SI_TRAPNO
80116 si.si_trapno = trapno;
80117 #endif
80118 @@ -760,7 +760,7 @@ static struct page_state {
80119 unsigned long res;
80120 char *msg;
80121 int (*action)(struct page *p, unsigned long pfn);
80122 -} error_states[] = {
80123 +} __do_const error_states[] = {
80124 { reserved, reserved, "reserved kernel", me_kernel },
80125 /*
80126 * free pages are specially detected outside this table:
80127 @@ -1051,7 +1051,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
80128 nr_pages = 1 << compound_order(hpage);
80129 else /* normal page or thp */
80130 nr_pages = 1;
80131 - atomic_long_add(nr_pages, &num_poisoned_pages);
80132 + atomic_long_add_unchecked(nr_pages, &num_poisoned_pages);
80133
80134 /*
80135 * We need/can do nothing about count=0 pages.
80136 @@ -1081,7 +1081,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
80137 if (!PageHWPoison(hpage)
80138 || (hwpoison_filter(p) && TestClearPageHWPoison(p))
80139 || (p != hpage && TestSetPageHWPoison(hpage))) {
80140 - atomic_long_sub(nr_pages, &num_poisoned_pages);
80141 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
80142 return 0;
80143 }
80144 set_page_hwpoison_huge_page(hpage);
80145 @@ -1148,7 +1148,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
80146 }
80147 if (hwpoison_filter(p)) {
80148 if (TestClearPageHWPoison(p))
80149 - atomic_long_sub(nr_pages, &num_poisoned_pages);
80150 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
80151 unlock_page(hpage);
80152 put_page(hpage);
80153 return 0;
80154 @@ -1350,7 +1350,7 @@ int unpoison_memory(unsigned long pfn)
80155 return 0;
80156 }
80157 if (TestClearPageHWPoison(p))
80158 - atomic_long_sub(nr_pages, &num_poisoned_pages);
80159 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
80160 pr_info("MCE: Software-unpoisoned free page %#lx\n", pfn);
80161 return 0;
80162 }
80163 @@ -1364,7 +1364,7 @@ int unpoison_memory(unsigned long pfn)
80164 */
80165 if (TestClearPageHWPoison(page)) {
80166 pr_info("MCE: Software-unpoisoned page %#lx\n", pfn);
80167 - atomic_long_sub(nr_pages, &num_poisoned_pages);
80168 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
80169 freeit = 1;
80170 if (PageHuge(page))
80171 clear_page_hwpoison_huge_page(page);
80172 @@ -1491,7 +1491,7 @@ static int soft_offline_huge_page(struct page *page, int flags)
80173 } else {
80174 set_page_hwpoison_huge_page(hpage);
80175 dequeue_hwpoisoned_huge_page(hpage);
80176 - atomic_long_add(1 << compound_trans_order(hpage),
80177 + atomic_long_add_unchecked(1 << compound_trans_order(hpage),
80178 &num_poisoned_pages);
80179 }
80180 /* keep elevated page count for bad page */
80181 @@ -1552,11 +1552,11 @@ int soft_offline_page(struct page *page, int flags)
80182 if (PageHuge(page)) {
80183 set_page_hwpoison_huge_page(hpage);
80184 dequeue_hwpoisoned_huge_page(hpage);
80185 - atomic_long_add(1 << compound_trans_order(hpage),
80186 + atomic_long_add_unchecked(1 << compound_trans_order(hpage),
80187 &num_poisoned_pages);
80188 } else {
80189 SetPageHWPoison(page);
80190 - atomic_long_inc(&num_poisoned_pages);
80191 + atomic_long_inc_unchecked(&num_poisoned_pages);
80192 }
80193 }
80194 /* keep elevated page count for bad page */
80195 @@ -1596,7 +1596,7 @@ static int __soft_offline_page(struct page *page, int flags)
80196 put_page(page);
80197 pr_info("soft_offline: %#lx: invalidated\n", pfn);
80198 SetPageHWPoison(page);
80199 - atomic_long_inc(&num_poisoned_pages);
80200 + atomic_long_inc_unchecked(&num_poisoned_pages);
80201 return 0;
80202 }
80203
80204 @@ -1626,7 +1626,7 @@ static int __soft_offline_page(struct page *page, int flags)
80205 ret = -EIO;
80206 } else {
80207 SetPageHWPoison(page);
80208 - atomic_long_inc(&num_poisoned_pages);
80209 + atomic_long_inc_unchecked(&num_poisoned_pages);
80210 }
80211 } else {
80212 pr_info("soft offline: %#lx: isolation failed: %d, page count %d, type %lx\n",
80213 diff --git a/mm/memory.c b/mm/memory.c
80214 index ba94dec..08ffe0d 100644
80215 --- a/mm/memory.c
80216 +++ b/mm/memory.c
80217 @@ -438,6 +438,7 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
80218 free_pte_range(tlb, pmd, addr);
80219 } while (pmd++, addr = next, addr != end);
80220
80221 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_PER_CPU_PGD)
80222 start &= PUD_MASK;
80223 if (start < floor)
80224 return;
80225 @@ -452,6 +453,8 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
80226 pmd = pmd_offset(pud, start);
80227 pud_clear(pud);
80228 pmd_free_tlb(tlb, pmd, start);
80229 +#endif
80230 +
80231 }
80232
80233 static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
80234 @@ -471,6 +474,7 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
80235 free_pmd_range(tlb, pud, addr, next, floor, ceiling);
80236 } while (pud++, addr = next, addr != end);
80237
80238 +#if !defined(CONFIG_X86_64) || !defined(CONFIG_PAX_PER_CPU_PGD)
80239 start &= PGDIR_MASK;
80240 if (start < floor)
80241 return;
80242 @@ -485,6 +489,8 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
80243 pud = pud_offset(pgd, start);
80244 pgd_clear(pgd);
80245 pud_free_tlb(tlb, pud, start);
80246 +#endif
80247 +
80248 }
80249
80250 /*
80251 @@ -1644,12 +1650,6 @@ no_page_table:
80252 return page;
80253 }
80254
80255 -static inline int stack_guard_page(struct vm_area_struct *vma, unsigned long addr)
80256 -{
80257 - return stack_guard_page_start(vma, addr) ||
80258 - stack_guard_page_end(vma, addr+PAGE_SIZE);
80259 -}
80260 -
80261 /**
80262 * __get_user_pages() - pin user pages in memory
80263 * @tsk: task_struct of target task
80264 @@ -1736,10 +1736,10 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
80265
80266 i = 0;
80267
80268 - do {
80269 + while (nr_pages) {
80270 struct vm_area_struct *vma;
80271
80272 - vma = find_extend_vma(mm, start);
80273 + vma = find_vma(mm, start);
80274 if (!vma && in_gate_area(mm, start)) {
80275 unsigned long pg = start & PAGE_MASK;
80276 pgd_t *pgd;
80277 @@ -1788,7 +1788,7 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
80278 goto next_page;
80279 }
80280
80281 - if (!vma ||
80282 + if (!vma || start < vma->vm_start ||
80283 (vma->vm_flags & (VM_IO | VM_PFNMAP)) ||
80284 !(vm_flags & vma->vm_flags))
80285 return i ? : -EFAULT;
80286 @@ -1817,11 +1817,6 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
80287 int ret;
80288 unsigned int fault_flags = 0;
80289
80290 - /* For mlock, just skip the stack guard page. */
80291 - if (foll_flags & FOLL_MLOCK) {
80292 - if (stack_guard_page(vma, start))
80293 - goto next_page;
80294 - }
80295 if (foll_flags & FOLL_WRITE)
80296 fault_flags |= FAULT_FLAG_WRITE;
80297 if (nonblocking)
80298 @@ -1901,7 +1896,7 @@ next_page:
80299 start += page_increm * PAGE_SIZE;
80300 nr_pages -= page_increm;
80301 } while (nr_pages && start < vma->vm_end);
80302 - } while (nr_pages);
80303 + }
80304 return i;
80305 }
80306 EXPORT_SYMBOL(__get_user_pages);
80307 @@ -2108,6 +2103,10 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr,
80308 page_add_file_rmap(page);
80309 set_pte_at(mm, addr, pte, mk_pte(page, prot));
80310
80311 +#ifdef CONFIG_PAX_SEGMEXEC
80312 + pax_mirror_file_pte(vma, addr, page, ptl);
80313 +#endif
80314 +
80315 retval = 0;
80316 pte_unmap_unlock(pte, ptl);
80317 return retval;
80318 @@ -2152,9 +2151,21 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr,
80319 if (!page_count(page))
80320 return -EINVAL;
80321 if (!(vma->vm_flags & VM_MIXEDMAP)) {
80322 +
80323 +#ifdef CONFIG_PAX_SEGMEXEC
80324 + struct vm_area_struct *vma_m;
80325 +#endif
80326 +
80327 BUG_ON(down_read_trylock(&vma->vm_mm->mmap_sem));
80328 BUG_ON(vma->vm_flags & VM_PFNMAP);
80329 vma->vm_flags |= VM_MIXEDMAP;
80330 +
80331 +#ifdef CONFIG_PAX_SEGMEXEC
80332 + vma_m = pax_find_mirror_vma(vma);
80333 + if (vma_m)
80334 + vma_m->vm_flags |= VM_MIXEDMAP;
80335 +#endif
80336 +
80337 }
80338 return insert_page(vma, addr, page, vma->vm_page_prot);
80339 }
80340 @@ -2237,6 +2248,7 @@ int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
80341 unsigned long pfn)
80342 {
80343 BUG_ON(!(vma->vm_flags & VM_MIXEDMAP));
80344 + BUG_ON(vma->vm_mirror);
80345
80346 if (addr < vma->vm_start || addr >= vma->vm_end)
80347 return -EFAULT;
80348 @@ -2484,7 +2496,9 @@ static int apply_to_pmd_range(struct mm_struct *mm, pud_t *pud,
80349
80350 BUG_ON(pud_huge(*pud));
80351
80352 - pmd = pmd_alloc(mm, pud, addr);
80353 + pmd = (mm == &init_mm) ?
80354 + pmd_alloc_kernel(mm, pud, addr) :
80355 + pmd_alloc(mm, pud, addr);
80356 if (!pmd)
80357 return -ENOMEM;
80358 do {
80359 @@ -2504,7 +2518,9 @@ static int apply_to_pud_range(struct mm_struct *mm, pgd_t *pgd,
80360 unsigned long next;
80361 int err;
80362
80363 - pud = pud_alloc(mm, pgd, addr);
80364 + pud = (mm == &init_mm) ?
80365 + pud_alloc_kernel(mm, pgd, addr) :
80366 + pud_alloc(mm, pgd, addr);
80367 if (!pud)
80368 return -ENOMEM;
80369 do {
80370 @@ -2592,6 +2608,186 @@ static inline void cow_user_page(struct page *dst, struct page *src, unsigned lo
80371 copy_user_highpage(dst, src, va, vma);
80372 }
80373
80374 +#ifdef CONFIG_PAX_SEGMEXEC
80375 +static void pax_unmap_mirror_pte(struct vm_area_struct *vma, unsigned long address, pmd_t *pmd)
80376 +{
80377 + struct mm_struct *mm = vma->vm_mm;
80378 + spinlock_t *ptl;
80379 + pte_t *pte, entry;
80380 +
80381 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
80382 + entry = *pte;
80383 + if (!pte_present(entry)) {
80384 + if (!pte_none(entry)) {
80385 + BUG_ON(pte_file(entry));
80386 + free_swap_and_cache(pte_to_swp_entry(entry));
80387 + pte_clear_not_present_full(mm, address, pte, 0);
80388 + }
80389 + } else {
80390 + struct page *page;
80391 +
80392 + flush_cache_page(vma, address, pte_pfn(entry));
80393 + entry = ptep_clear_flush(vma, address, pte);
80394 + BUG_ON(pte_dirty(entry));
80395 + page = vm_normal_page(vma, address, entry);
80396 + if (page) {
80397 + update_hiwater_rss(mm);
80398 + if (PageAnon(page))
80399 + dec_mm_counter_fast(mm, MM_ANONPAGES);
80400 + else
80401 + dec_mm_counter_fast(mm, MM_FILEPAGES);
80402 + page_remove_rmap(page);
80403 + page_cache_release(page);
80404 + }
80405 + }
80406 + pte_unmap_unlock(pte, ptl);
80407 +}
80408 +
80409 +/* PaX: if vma is mirrored, synchronize the mirror's PTE
80410 + *
80411 + * the ptl of the lower mapped page is held on entry and is not released on exit
80412 + * or inside to ensure atomic changes to the PTE states (swapout, mremap, munmap, etc)
80413 + */
80414 +static void pax_mirror_anon_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
80415 +{
80416 + struct mm_struct *mm = vma->vm_mm;
80417 + unsigned long address_m;
80418 + spinlock_t *ptl_m;
80419 + struct vm_area_struct *vma_m;
80420 + pmd_t *pmd_m;
80421 + pte_t *pte_m, entry_m;
80422 +
80423 + BUG_ON(!page_m || !PageAnon(page_m));
80424 +
80425 + vma_m = pax_find_mirror_vma(vma);
80426 + if (!vma_m)
80427 + return;
80428 +
80429 + BUG_ON(!PageLocked(page_m));
80430 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
80431 + address_m = address + SEGMEXEC_TASK_SIZE;
80432 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
80433 + pte_m = pte_offset_map(pmd_m, address_m);
80434 + ptl_m = pte_lockptr(mm, pmd_m);
80435 + if (ptl != ptl_m) {
80436 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
80437 + if (!pte_none(*pte_m))
80438 + goto out;
80439 + }
80440 +
80441 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
80442 + page_cache_get(page_m);
80443 + page_add_anon_rmap(page_m, vma_m, address_m);
80444 + inc_mm_counter_fast(mm, MM_ANONPAGES);
80445 + set_pte_at(mm, address_m, pte_m, entry_m);
80446 + update_mmu_cache(vma_m, address_m, pte_m);
80447 +out:
80448 + if (ptl != ptl_m)
80449 + spin_unlock(ptl_m);
80450 + pte_unmap(pte_m);
80451 + unlock_page(page_m);
80452 +}
80453 +
80454 +void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
80455 +{
80456 + struct mm_struct *mm = vma->vm_mm;
80457 + unsigned long address_m;
80458 + spinlock_t *ptl_m;
80459 + struct vm_area_struct *vma_m;
80460 + pmd_t *pmd_m;
80461 + pte_t *pte_m, entry_m;
80462 +
80463 + BUG_ON(!page_m || PageAnon(page_m));
80464 +
80465 + vma_m = pax_find_mirror_vma(vma);
80466 + if (!vma_m)
80467 + return;
80468 +
80469 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
80470 + address_m = address + SEGMEXEC_TASK_SIZE;
80471 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
80472 + pte_m = pte_offset_map(pmd_m, address_m);
80473 + ptl_m = pte_lockptr(mm, pmd_m);
80474 + if (ptl != ptl_m) {
80475 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
80476 + if (!pte_none(*pte_m))
80477 + goto out;
80478 + }
80479 +
80480 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
80481 + page_cache_get(page_m);
80482 + page_add_file_rmap(page_m);
80483 + inc_mm_counter_fast(mm, MM_FILEPAGES);
80484 + set_pte_at(mm, address_m, pte_m, entry_m);
80485 + update_mmu_cache(vma_m, address_m, pte_m);
80486 +out:
80487 + if (ptl != ptl_m)
80488 + spin_unlock(ptl_m);
80489 + pte_unmap(pte_m);
80490 +}
80491 +
80492 +static void pax_mirror_pfn_pte(struct vm_area_struct *vma, unsigned long address, unsigned long pfn_m, spinlock_t *ptl)
80493 +{
80494 + struct mm_struct *mm = vma->vm_mm;
80495 + unsigned long address_m;
80496 + spinlock_t *ptl_m;
80497 + struct vm_area_struct *vma_m;
80498 + pmd_t *pmd_m;
80499 + pte_t *pte_m, entry_m;
80500 +
80501 + vma_m = pax_find_mirror_vma(vma);
80502 + if (!vma_m)
80503 + return;
80504 +
80505 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
80506 + address_m = address + SEGMEXEC_TASK_SIZE;
80507 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
80508 + pte_m = pte_offset_map(pmd_m, address_m);
80509 + ptl_m = pte_lockptr(mm, pmd_m);
80510 + if (ptl != ptl_m) {
80511 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
80512 + if (!pte_none(*pte_m))
80513 + goto out;
80514 + }
80515 +
80516 + entry_m = pfn_pte(pfn_m, vma_m->vm_page_prot);
80517 + set_pte_at(mm, address_m, pte_m, entry_m);
80518 +out:
80519 + if (ptl != ptl_m)
80520 + spin_unlock(ptl_m);
80521 + pte_unmap(pte_m);
80522 +}
80523 +
80524 +static void pax_mirror_pte(struct vm_area_struct *vma, unsigned long address, pte_t *pte, pmd_t *pmd, spinlock_t *ptl)
80525 +{
80526 + struct page *page_m;
80527 + pte_t entry;
80528 +
80529 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC))
80530 + goto out;
80531 +
80532 + entry = *pte;
80533 + page_m = vm_normal_page(vma, address, entry);
80534 + if (!page_m)
80535 + pax_mirror_pfn_pte(vma, address, pte_pfn(entry), ptl);
80536 + else if (PageAnon(page_m)) {
80537 + if (pax_find_mirror_vma(vma)) {
80538 + pte_unmap_unlock(pte, ptl);
80539 + lock_page(page_m);
80540 + pte = pte_offset_map_lock(vma->vm_mm, pmd, address, &ptl);
80541 + if (pte_same(entry, *pte))
80542 + pax_mirror_anon_pte(vma, address, page_m, ptl);
80543 + else
80544 + unlock_page(page_m);
80545 + }
80546 + } else
80547 + pax_mirror_file_pte(vma, address, page_m, ptl);
80548 +
80549 +out:
80550 + pte_unmap_unlock(pte, ptl);
80551 +}
80552 +#endif
80553 +
80554 /*
80555 * This routine handles present pages, when users try to write
80556 * to a shared page. It is done by copying the page to a new address
80557 @@ -2808,6 +3004,12 @@ gotten:
80558 */
80559 page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
80560 if (likely(pte_same(*page_table, orig_pte))) {
80561 +
80562 +#ifdef CONFIG_PAX_SEGMEXEC
80563 + if (pax_find_mirror_vma(vma))
80564 + BUG_ON(!trylock_page(new_page));
80565 +#endif
80566 +
80567 if (old_page) {
80568 if (!PageAnon(old_page)) {
80569 dec_mm_counter_fast(mm, MM_FILEPAGES);
80570 @@ -2859,6 +3061,10 @@ gotten:
80571 page_remove_rmap(old_page);
80572 }
80573
80574 +#ifdef CONFIG_PAX_SEGMEXEC
80575 + pax_mirror_anon_pte(vma, address, new_page, ptl);
80576 +#endif
80577 +
80578 /* Free the old page.. */
80579 new_page = old_page;
80580 ret |= VM_FAULT_WRITE;
80581 @@ -3134,6 +3340,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
80582 swap_free(entry);
80583 if (vm_swap_full() || (vma->vm_flags & VM_LOCKED) || PageMlocked(page))
80584 try_to_free_swap(page);
80585 +
80586 +#ifdef CONFIG_PAX_SEGMEXEC
80587 + if ((flags & FAULT_FLAG_WRITE) || !pax_find_mirror_vma(vma))
80588 +#endif
80589 +
80590 unlock_page(page);
80591 if (page != swapcache) {
80592 /*
80593 @@ -3157,6 +3368,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
80594
80595 /* No need to invalidate - it was non-present before */
80596 update_mmu_cache(vma, address, page_table);
80597 +
80598 +#ifdef CONFIG_PAX_SEGMEXEC
80599 + pax_mirror_anon_pte(vma, address, page, ptl);
80600 +#endif
80601 +
80602 unlock:
80603 pte_unmap_unlock(page_table, ptl);
80604 out:
80605 @@ -3176,40 +3392,6 @@ out_release:
80606 }
80607
80608 /*
80609 - * This is like a special single-page "expand_{down|up}wards()",
80610 - * except we must first make sure that 'address{-|+}PAGE_SIZE'
80611 - * doesn't hit another vma.
80612 - */
80613 -static inline int check_stack_guard_page(struct vm_area_struct *vma, unsigned long address)
80614 -{
80615 - address &= PAGE_MASK;
80616 - if ((vma->vm_flags & VM_GROWSDOWN) && address == vma->vm_start) {
80617 - struct vm_area_struct *prev = vma->vm_prev;
80618 -
80619 - /*
80620 - * Is there a mapping abutting this one below?
80621 - *
80622 - * That's only ok if it's the same stack mapping
80623 - * that has gotten split..
80624 - */
80625 - if (prev && prev->vm_end == address)
80626 - return prev->vm_flags & VM_GROWSDOWN ? 0 : -ENOMEM;
80627 -
80628 - expand_downwards(vma, address - PAGE_SIZE);
80629 - }
80630 - if ((vma->vm_flags & VM_GROWSUP) && address + PAGE_SIZE == vma->vm_end) {
80631 - struct vm_area_struct *next = vma->vm_next;
80632 -
80633 - /* As VM_GROWSDOWN but s/below/above/ */
80634 - if (next && next->vm_start == address + PAGE_SIZE)
80635 - return next->vm_flags & VM_GROWSUP ? 0 : -ENOMEM;
80636 -
80637 - expand_upwards(vma, address + PAGE_SIZE);
80638 - }
80639 - return 0;
80640 -}
80641 -
80642 -/*
80643 * We enter with non-exclusive mmap_sem (to exclude vma changes,
80644 * but allow concurrent faults), and pte mapped but not yet locked.
80645 * We return with mmap_sem still held, but pte unmapped and unlocked.
80646 @@ -3218,27 +3400,23 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
80647 unsigned long address, pte_t *page_table, pmd_t *pmd,
80648 unsigned int flags)
80649 {
80650 - struct page *page;
80651 + struct page *page = NULL;
80652 spinlock_t *ptl;
80653 pte_t entry;
80654
80655 - pte_unmap(page_table);
80656 -
80657 - /* Check if we need to add a guard page to the stack */
80658 - if (check_stack_guard_page(vma, address) < 0)
80659 - return VM_FAULT_SIGBUS;
80660 -
80661 - /* Use the zero-page for reads */
80662 if (!(flags & FAULT_FLAG_WRITE)) {
80663 entry = pte_mkspecial(pfn_pte(my_zero_pfn(address),
80664 vma->vm_page_prot));
80665 - page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
80666 + ptl = pte_lockptr(mm, pmd);
80667 + spin_lock(ptl);
80668 if (!pte_none(*page_table))
80669 goto unlock;
80670 goto setpte;
80671 }
80672
80673 /* Allocate our own private page. */
80674 + pte_unmap(page_table);
80675 +
80676 if (unlikely(anon_vma_prepare(vma)))
80677 goto oom;
80678 page = alloc_zeroed_user_highpage_movable(vma, address);
80679 @@ -3257,6 +3435,11 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
80680 if (!pte_none(*page_table))
80681 goto release;
80682
80683 +#ifdef CONFIG_PAX_SEGMEXEC
80684 + if (pax_find_mirror_vma(vma))
80685 + BUG_ON(!trylock_page(page));
80686 +#endif
80687 +
80688 inc_mm_counter_fast(mm, MM_ANONPAGES);
80689 page_add_new_anon_rmap(page, vma, address);
80690 setpte:
80691 @@ -3264,6 +3447,12 @@ setpte:
80692
80693 /* No need to invalidate - it was non-present before */
80694 update_mmu_cache(vma, address, page_table);
80695 +
80696 +#ifdef CONFIG_PAX_SEGMEXEC
80697 + if (page)
80698 + pax_mirror_anon_pte(vma, address, page, ptl);
80699 +#endif
80700 +
80701 unlock:
80702 pte_unmap_unlock(page_table, ptl);
80703 return 0;
80704 @@ -3407,6 +3596,12 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
80705 */
80706 /* Only go through if we didn't race with anybody else... */
80707 if (likely(pte_same(*page_table, orig_pte))) {
80708 +
80709 +#ifdef CONFIG_PAX_SEGMEXEC
80710 + if (anon && pax_find_mirror_vma(vma))
80711 + BUG_ON(!trylock_page(page));
80712 +#endif
80713 +
80714 flush_icache_page(vma, page);
80715 entry = mk_pte(page, vma->vm_page_prot);
80716 if (flags & FAULT_FLAG_WRITE)
80717 @@ -3426,6 +3621,14 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
80718
80719 /* no need to invalidate: a not-present page won't be cached */
80720 update_mmu_cache(vma, address, page_table);
80721 +
80722 +#ifdef CONFIG_PAX_SEGMEXEC
80723 + if (anon)
80724 + pax_mirror_anon_pte(vma, address, page, ptl);
80725 + else
80726 + pax_mirror_file_pte(vma, address, page, ptl);
80727 +#endif
80728 +
80729 } else {
80730 if (cow_page)
80731 mem_cgroup_uncharge_page(cow_page);
80732 @@ -3747,6 +3950,12 @@ int handle_pte_fault(struct mm_struct *mm,
80733 if (flags & FAULT_FLAG_WRITE)
80734 flush_tlb_fix_spurious_fault(vma, address);
80735 }
80736 +
80737 +#ifdef CONFIG_PAX_SEGMEXEC
80738 + pax_mirror_pte(vma, address, pte, pmd, ptl);
80739 + return 0;
80740 +#endif
80741 +
80742 unlock:
80743 pte_unmap_unlock(pte, ptl);
80744 return 0;
80745 @@ -3763,6 +3972,10 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
80746 pmd_t *pmd;
80747 pte_t *pte;
80748
80749 +#ifdef CONFIG_PAX_SEGMEXEC
80750 + struct vm_area_struct *vma_m;
80751 +#endif
80752 +
80753 __set_current_state(TASK_RUNNING);
80754
80755 count_vm_event(PGFAULT);
80756 @@ -3774,6 +3987,34 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
80757 if (unlikely(is_vm_hugetlb_page(vma)))
80758 return hugetlb_fault(mm, vma, address, flags);
80759
80760 +#ifdef CONFIG_PAX_SEGMEXEC
80761 + vma_m = pax_find_mirror_vma(vma);
80762 + if (vma_m) {
80763 + unsigned long address_m;
80764 + pgd_t *pgd_m;
80765 + pud_t *pud_m;
80766 + pmd_t *pmd_m;
80767 +
80768 + if (vma->vm_start > vma_m->vm_start) {
80769 + address_m = address;
80770 + address -= SEGMEXEC_TASK_SIZE;
80771 + vma = vma_m;
80772 + } else
80773 + address_m = address + SEGMEXEC_TASK_SIZE;
80774 +
80775 + pgd_m = pgd_offset(mm, address_m);
80776 + pud_m = pud_alloc(mm, pgd_m, address_m);
80777 + if (!pud_m)
80778 + return VM_FAULT_OOM;
80779 + pmd_m = pmd_alloc(mm, pud_m, address_m);
80780 + if (!pmd_m)
80781 + return VM_FAULT_OOM;
80782 + if (!pmd_present(*pmd_m) && __pte_alloc(mm, vma_m, pmd_m, address_m))
80783 + return VM_FAULT_OOM;
80784 + pax_unmap_mirror_pte(vma_m, address_m, pmd_m);
80785 + }
80786 +#endif
80787 +
80788 retry:
80789 pgd = pgd_offset(mm, address);
80790 pud = pud_alloc(mm, pgd, address);
80791 @@ -3872,6 +4113,23 @@ int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
80792 spin_unlock(&mm->page_table_lock);
80793 return 0;
80794 }
80795 +
80796 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
80797 +{
80798 + pud_t *new = pud_alloc_one(mm, address);
80799 + if (!new)
80800 + return -ENOMEM;
80801 +
80802 + smp_wmb(); /* See comment in __pte_alloc */
80803 +
80804 + spin_lock(&mm->page_table_lock);
80805 + if (pgd_present(*pgd)) /* Another has populated it */
80806 + pud_free(mm, new);
80807 + else
80808 + pgd_populate_kernel(mm, pgd, new);
80809 + spin_unlock(&mm->page_table_lock);
80810 + return 0;
80811 +}
80812 #endif /* __PAGETABLE_PUD_FOLDED */
80813
80814 #ifndef __PAGETABLE_PMD_FOLDED
80815 @@ -3902,6 +4160,30 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
80816 spin_unlock(&mm->page_table_lock);
80817 return 0;
80818 }
80819 +
80820 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
80821 +{
80822 + pmd_t *new = pmd_alloc_one(mm, address);
80823 + if (!new)
80824 + return -ENOMEM;
80825 +
80826 + smp_wmb(); /* See comment in __pte_alloc */
80827 +
80828 + spin_lock(&mm->page_table_lock);
80829 +#ifndef __ARCH_HAS_4LEVEL_HACK
80830 + if (pud_present(*pud)) /* Another has populated it */
80831 + pmd_free(mm, new);
80832 + else
80833 + pud_populate_kernel(mm, pud, new);
80834 +#else
80835 + if (pgd_present(*pud)) /* Another has populated it */
80836 + pmd_free(mm, new);
80837 + else
80838 + pgd_populate_kernel(mm, pud, new);
80839 +#endif /* __ARCH_HAS_4LEVEL_HACK */
80840 + spin_unlock(&mm->page_table_lock);
80841 + return 0;
80842 +}
80843 #endif /* __PAGETABLE_PMD_FOLDED */
80844
80845 #if !defined(__HAVE_ARCH_GATE_AREA)
80846 @@ -3915,7 +4197,7 @@ static int __init gate_vma_init(void)
80847 gate_vma.vm_start = FIXADDR_USER_START;
80848 gate_vma.vm_end = FIXADDR_USER_END;
80849 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
80850 - gate_vma.vm_page_prot = __P101;
80851 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
80852
80853 return 0;
80854 }
80855 @@ -4049,8 +4331,8 @@ out:
80856 return ret;
80857 }
80858
80859 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
80860 - void *buf, int len, int write)
80861 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
80862 + void *buf, size_t len, int write)
80863 {
80864 resource_size_t phys_addr;
80865 unsigned long prot = 0;
80866 @@ -4075,8 +4357,8 @@ int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
80867 * Access another process' address space as given in mm. If non-NULL, use the
80868 * given task for page fault accounting.
80869 */
80870 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
80871 - unsigned long addr, void *buf, int len, int write)
80872 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
80873 + unsigned long addr, void *buf, size_t len, int write)
80874 {
80875 struct vm_area_struct *vma;
80876 void *old_buf = buf;
80877 @@ -4084,7 +4366,7 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
80878 down_read(&mm->mmap_sem);
80879 /* ignore errors, just check how much was successfully transferred */
80880 while (len) {
80881 - int bytes, ret, offset;
80882 + ssize_t bytes, ret, offset;
80883 void *maddr;
80884 struct page *page = NULL;
80885
80886 @@ -4143,8 +4425,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
80887 *
80888 * The caller must hold a reference on @mm.
80889 */
80890 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
80891 - void *buf, int len, int write)
80892 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
80893 + void *buf, size_t len, int write)
80894 {
80895 return __access_remote_vm(NULL, mm, addr, buf, len, write);
80896 }
80897 @@ -4154,11 +4436,11 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
80898 * Source/target buffer must be kernel space,
80899 * Do not walk the page table directly, use get_user_pages
80900 */
80901 -int access_process_vm(struct task_struct *tsk, unsigned long addr,
80902 - void *buf, int len, int write)
80903 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr,
80904 + void *buf, size_t len, int write)
80905 {
80906 struct mm_struct *mm;
80907 - int ret;
80908 + ssize_t ret;
80909
80910 mm = get_task_mm(tsk);
80911 if (!mm)
80912 diff --git a/mm/mempolicy.c b/mm/mempolicy.c
80913 index 7431001..0f8344e 100644
80914 --- a/mm/mempolicy.c
80915 +++ b/mm/mempolicy.c
80916 @@ -708,6 +708,10 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
80917 unsigned long vmstart;
80918 unsigned long vmend;
80919
80920 +#ifdef CONFIG_PAX_SEGMEXEC
80921 + struct vm_area_struct *vma_m;
80922 +#endif
80923 +
80924 vma = find_vma(mm, start);
80925 if (!vma || vma->vm_start > start)
80926 return -EFAULT;
80927 @@ -744,9 +748,20 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
80928 if (err)
80929 goto out;
80930 }
80931 +
80932 err = vma_replace_policy(vma, new_pol);
80933 if (err)
80934 goto out;
80935 +
80936 +#ifdef CONFIG_PAX_SEGMEXEC
80937 + vma_m = pax_find_mirror_vma(vma);
80938 + if (vma_m) {
80939 + err = vma_replace_policy(vma_m, new_pol);
80940 + if (err)
80941 + goto out;
80942 + }
80943 +#endif
80944 +
80945 }
80946
80947 out:
80948 @@ -1202,6 +1217,17 @@ static long do_mbind(unsigned long start, unsigned long len,
80949
80950 if (end < start)
80951 return -EINVAL;
80952 +
80953 +#ifdef CONFIG_PAX_SEGMEXEC
80954 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
80955 + if (end > SEGMEXEC_TASK_SIZE)
80956 + return -EINVAL;
80957 + } else
80958 +#endif
80959 +
80960 + if (end > TASK_SIZE)
80961 + return -EINVAL;
80962 +
80963 if (end == start)
80964 return 0;
80965
80966 @@ -1430,8 +1456,7 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
80967 */
80968 tcred = __task_cred(task);
80969 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
80970 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
80971 - !capable(CAP_SYS_NICE)) {
80972 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
80973 rcu_read_unlock();
80974 err = -EPERM;
80975 goto out_put;
80976 @@ -1462,6 +1487,15 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
80977 goto out;
80978 }
80979
80980 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
80981 + if (mm != current->mm &&
80982 + (mm->pax_flags & MF_PAX_RANDMMAP || mm->pax_flags & MF_PAX_SEGMEXEC)) {
80983 + mmput(mm);
80984 + err = -EPERM;
80985 + goto out;
80986 + }
80987 +#endif
80988 +
80989 err = do_migrate_pages(mm, old, new,
80990 capable(CAP_SYS_NICE) ? MPOL_MF_MOVE_ALL : MPOL_MF_MOVE);
80991
80992 diff --git a/mm/migrate.c b/mm/migrate.c
80993 index 3bbaf5d..299b0e9 100644
80994 --- a/mm/migrate.c
80995 +++ b/mm/migrate.c
80996 @@ -1382,8 +1382,7 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
80997 */
80998 tcred = __task_cred(task);
80999 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
81000 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
81001 - !capable(CAP_SYS_NICE)) {
81002 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
81003 rcu_read_unlock();
81004 err = -EPERM;
81005 goto out;
81006 diff --git a/mm/mlock.c b/mm/mlock.c
81007 index 79b7cf7..c60424f 100644
81008 --- a/mm/mlock.c
81009 +++ b/mm/mlock.c
81010 @@ -13,6 +13,7 @@
81011 #include <linux/pagemap.h>
81012 #include <linux/mempolicy.h>
81013 #include <linux/syscalls.h>
81014 +#include <linux/security.h>
81015 #include <linux/sched.h>
81016 #include <linux/export.h>
81017 #include <linux/rmap.h>
81018 @@ -334,7 +335,7 @@ static int do_mlock(unsigned long start, size_t len, int on)
81019 {
81020 unsigned long nstart, end, tmp;
81021 struct vm_area_struct * vma, * prev;
81022 - int error;
81023 + int error = 0;
81024
81025 VM_BUG_ON(start & ~PAGE_MASK);
81026 VM_BUG_ON(len != PAGE_ALIGN(len));
81027 @@ -343,6 +344,9 @@ static int do_mlock(unsigned long start, size_t len, int on)
81028 return -EINVAL;
81029 if (end == start)
81030 return 0;
81031 + if (end > TASK_SIZE)
81032 + return -EINVAL;
81033 +
81034 vma = find_vma(current->mm, start);
81035 if (!vma || vma->vm_start > start)
81036 return -ENOMEM;
81037 @@ -354,6 +358,11 @@ static int do_mlock(unsigned long start, size_t len, int on)
81038 for (nstart = start ; ; ) {
81039 vm_flags_t newflags;
81040
81041 +#ifdef CONFIG_PAX_SEGMEXEC
81042 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
81043 + break;
81044 +#endif
81045 +
81046 /* Here we know that vma->vm_start <= nstart < vma->vm_end. */
81047
81048 newflags = vma->vm_flags & ~VM_LOCKED;
81049 @@ -466,6 +475,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
81050 lock_limit >>= PAGE_SHIFT;
81051
81052 /* check against resource limits */
81053 + gr_learn_resource(current, RLIMIT_MEMLOCK, (current->mm->locked_vm << PAGE_SHIFT) + len, 1);
81054 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
81055 error = do_mlock(start, len, 1);
81056 up_write(&current->mm->mmap_sem);
81057 @@ -500,6 +510,12 @@ static int do_mlockall(int flags)
81058 for (vma = current->mm->mmap; vma ; vma = prev->vm_next) {
81059 vm_flags_t newflags;
81060
81061 +#ifdef CONFIG_PAX_SEGMEXEC
81062 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
81063 + break;
81064 +#endif
81065 +
81066 + BUG_ON(vma->vm_end > TASK_SIZE);
81067 newflags = vma->vm_flags & ~VM_LOCKED;
81068 if (flags & MCL_CURRENT)
81069 newflags |= VM_LOCKED;
81070 @@ -532,6 +548,7 @@ SYSCALL_DEFINE1(mlockall, int, flags)
81071 lock_limit >>= PAGE_SHIFT;
81072
81073 ret = -ENOMEM;
81074 + gr_learn_resource(current, RLIMIT_MEMLOCK, current->mm->total_vm << PAGE_SHIFT, 1);
81075 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
81076 capable(CAP_IPC_LOCK))
81077 ret = do_mlockall(flags);
81078 diff --git a/mm/mmap.c b/mm/mmap.c
81079 index 0dceed8..671951c 100644
81080 --- a/mm/mmap.c
81081 +++ b/mm/mmap.c
81082 @@ -33,6 +33,7 @@
81083 #include <linux/uprobes.h>
81084 #include <linux/rbtree_augmented.h>
81085 #include <linux/sched/sysctl.h>
81086 +#include <linux/random.h>
81087
81088 #include <asm/uaccess.h>
81089 #include <asm/cacheflush.h>
81090 @@ -49,6 +50,16 @@
81091 #define arch_rebalance_pgtables(addr, len) (addr)
81092 #endif
81093
81094 +static inline void verify_mm_writelocked(struct mm_struct *mm)
81095 +{
81096 +#if defined(CONFIG_DEBUG_VM) || defined(CONFIG_PAX)
81097 + if (unlikely(down_read_trylock(&mm->mmap_sem))) {
81098 + up_read(&mm->mmap_sem);
81099 + BUG();
81100 + }
81101 +#endif
81102 +}
81103 +
81104 static void unmap_region(struct mm_struct *mm,
81105 struct vm_area_struct *vma, struct vm_area_struct *prev,
81106 unsigned long start, unsigned long end);
81107 @@ -68,22 +79,32 @@ static void unmap_region(struct mm_struct *mm,
81108 * x: (no) no x: (no) yes x: (no) yes x: (yes) yes
81109 *
81110 */
81111 -pgprot_t protection_map[16] = {
81112 +pgprot_t protection_map[16] __read_only = {
81113 __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111,
81114 __S000, __S001, __S010, __S011, __S100, __S101, __S110, __S111
81115 };
81116
81117 -pgprot_t vm_get_page_prot(unsigned long vm_flags)
81118 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
81119 {
81120 - return __pgprot(pgprot_val(protection_map[vm_flags &
81121 + pgprot_t prot = __pgprot(pgprot_val(protection_map[vm_flags &
81122 (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]) |
81123 pgprot_val(arch_vm_get_page_prot(vm_flags)));
81124 +
81125 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
81126 + if (!(__supported_pte_mask & _PAGE_NX) &&
81127 + (vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC &&
81128 + (vm_flags & (VM_READ | VM_WRITE)))
81129 + prot = __pgprot(pte_val(pte_exprotect(__pte(pgprot_val(prot)))));
81130 +#endif
81131 +
81132 + return prot;
81133 }
81134 EXPORT_SYMBOL(vm_get_page_prot);
81135
81136 int sysctl_overcommit_memory __read_mostly = OVERCOMMIT_GUESS; /* heuristic overcommit */
81137 int sysctl_overcommit_ratio __read_mostly = 50; /* default is 50% */
81138 int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT;
81139 +unsigned long sysctl_heap_stack_gap __read_mostly = 64*1024;
81140 /*
81141 * Make sure vm_committed_as in one cacheline and not cacheline shared with
81142 * other variables. It can be updated by several CPUs frequently.
81143 @@ -239,6 +260,7 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma)
81144 struct vm_area_struct *next = vma->vm_next;
81145
81146 might_sleep();
81147 + BUG_ON(vma->vm_mirror);
81148 if (vma->vm_ops && vma->vm_ops->close)
81149 vma->vm_ops->close(vma);
81150 if (vma->vm_file)
81151 @@ -283,6 +305,7 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
81152 * not page aligned -Ram Gupta
81153 */
81154 rlim = rlimit(RLIMIT_DATA);
81155 + gr_learn_resource(current, RLIMIT_DATA, (brk - mm->start_brk) + (mm->end_data - mm->start_data), 1);
81156 if (rlim < RLIM_INFINITY && (brk - mm->start_brk) +
81157 (mm->end_data - mm->start_data) > rlim)
81158 goto out;
81159 @@ -897,6 +920,12 @@ static int
81160 can_vma_merge_before(struct vm_area_struct *vma, unsigned long vm_flags,
81161 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
81162 {
81163 +
81164 +#ifdef CONFIG_PAX_SEGMEXEC
81165 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_start == SEGMEXEC_TASK_SIZE)
81166 + return 0;
81167 +#endif
81168 +
81169 if (is_mergeable_vma(vma, file, vm_flags) &&
81170 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
81171 if (vma->vm_pgoff == vm_pgoff)
81172 @@ -916,6 +945,12 @@ static int
81173 can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
81174 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
81175 {
81176 +
81177 +#ifdef CONFIG_PAX_SEGMEXEC
81178 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end == SEGMEXEC_TASK_SIZE)
81179 + return 0;
81180 +#endif
81181 +
81182 if (is_mergeable_vma(vma, file, vm_flags) &&
81183 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
81184 pgoff_t vm_pglen;
81185 @@ -958,13 +993,20 @@ can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
81186 struct vm_area_struct *vma_merge(struct mm_struct *mm,
81187 struct vm_area_struct *prev, unsigned long addr,
81188 unsigned long end, unsigned long vm_flags,
81189 - struct anon_vma *anon_vma, struct file *file,
81190 + struct anon_vma *anon_vma, struct file *file,
81191 pgoff_t pgoff, struct mempolicy *policy)
81192 {
81193 pgoff_t pglen = (end - addr) >> PAGE_SHIFT;
81194 struct vm_area_struct *area, *next;
81195 int err;
81196
81197 +#ifdef CONFIG_PAX_SEGMEXEC
81198 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE, end_m = end + SEGMEXEC_TASK_SIZE;
81199 + struct vm_area_struct *area_m = NULL, *next_m = NULL, *prev_m = NULL;
81200 +
81201 + BUG_ON((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE < end);
81202 +#endif
81203 +
81204 /*
81205 * We later require that vma->vm_flags == vm_flags,
81206 * so this tests vma->vm_flags & VM_SPECIAL, too.
81207 @@ -980,6 +1022,15 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
81208 if (next && next->vm_end == end) /* cases 6, 7, 8 */
81209 next = next->vm_next;
81210
81211 +#ifdef CONFIG_PAX_SEGMEXEC
81212 + if (prev)
81213 + prev_m = pax_find_mirror_vma(prev);
81214 + if (area)
81215 + area_m = pax_find_mirror_vma(area);
81216 + if (next)
81217 + next_m = pax_find_mirror_vma(next);
81218 +#endif
81219 +
81220 /*
81221 * Can it merge with the predecessor?
81222 */
81223 @@ -999,9 +1050,24 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
81224 /* cases 1, 6 */
81225 err = vma_adjust(prev, prev->vm_start,
81226 next->vm_end, prev->vm_pgoff, NULL);
81227 - } else /* cases 2, 5, 7 */
81228 +
81229 +#ifdef CONFIG_PAX_SEGMEXEC
81230 + if (!err && prev_m)
81231 + err = vma_adjust(prev_m, prev_m->vm_start,
81232 + next_m->vm_end, prev_m->vm_pgoff, NULL);
81233 +#endif
81234 +
81235 + } else { /* cases 2, 5, 7 */
81236 err = vma_adjust(prev, prev->vm_start,
81237 end, prev->vm_pgoff, NULL);
81238 +
81239 +#ifdef CONFIG_PAX_SEGMEXEC
81240 + if (!err && prev_m)
81241 + err = vma_adjust(prev_m, prev_m->vm_start,
81242 + end_m, prev_m->vm_pgoff, NULL);
81243 +#endif
81244 +
81245 + }
81246 if (err)
81247 return NULL;
81248 khugepaged_enter_vma_merge(prev);
81249 @@ -1015,12 +1081,27 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
81250 mpol_equal(policy, vma_policy(next)) &&
81251 can_vma_merge_before(next, vm_flags,
81252 anon_vma, file, pgoff+pglen)) {
81253 - if (prev && addr < prev->vm_end) /* case 4 */
81254 + if (prev && addr < prev->vm_end) { /* case 4 */
81255 err = vma_adjust(prev, prev->vm_start,
81256 addr, prev->vm_pgoff, NULL);
81257 - else /* cases 3, 8 */
81258 +
81259 +#ifdef CONFIG_PAX_SEGMEXEC
81260 + if (!err && prev_m)
81261 + err = vma_adjust(prev_m, prev_m->vm_start,
81262 + addr_m, prev_m->vm_pgoff, NULL);
81263 +#endif
81264 +
81265 + } else { /* cases 3, 8 */
81266 err = vma_adjust(area, addr, next->vm_end,
81267 next->vm_pgoff - pglen, NULL);
81268 +
81269 +#ifdef CONFIG_PAX_SEGMEXEC
81270 + if (!err && area_m)
81271 + err = vma_adjust(area_m, addr_m, next_m->vm_end,
81272 + next_m->vm_pgoff - pglen, NULL);
81273 +#endif
81274 +
81275 + }
81276 if (err)
81277 return NULL;
81278 khugepaged_enter_vma_merge(area);
81279 @@ -1129,8 +1210,10 @@ none:
81280 void vm_stat_account(struct mm_struct *mm, unsigned long flags,
81281 struct file *file, long pages)
81282 {
81283 - const unsigned long stack_flags
81284 - = VM_STACK_FLAGS & (VM_GROWSUP|VM_GROWSDOWN);
81285 +
81286 +#ifdef CONFIG_PAX_RANDMMAP
81287 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
81288 +#endif
81289
81290 mm->total_vm += pages;
81291
81292 @@ -1138,7 +1221,7 @@ void vm_stat_account(struct mm_struct *mm, unsigned long flags,
81293 mm->shared_vm += pages;
81294 if ((flags & (VM_EXEC|VM_WRITE)) == VM_EXEC)
81295 mm->exec_vm += pages;
81296 - } else if (flags & stack_flags)
81297 + } else if (flags & (VM_GROWSUP|VM_GROWSDOWN))
81298 mm->stack_vm += pages;
81299 }
81300 #endif /* CONFIG_PROC_FS */
81301 @@ -1177,7 +1260,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
81302 * (the exception is when the underlying filesystem is noexec
81303 * mounted, in which case we dont add PROT_EXEC.)
81304 */
81305 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
81306 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
81307 if (!(file && (file->f_path.mnt->mnt_flags & MNT_NOEXEC)))
81308 prot |= PROT_EXEC;
81309
81310 @@ -1203,7 +1286,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
81311 /* Obtain the address to map to. we verify (or select) it and ensure
81312 * that it represents a valid section of the address space.
81313 */
81314 - addr = get_unmapped_area(file, addr, len, pgoff, flags);
81315 + addr = get_unmapped_area(file, addr, len, pgoff, flags | ((prot & PROT_EXEC) ? MAP_EXECUTABLE : 0));
81316 if (addr & ~PAGE_MASK)
81317 return addr;
81318
81319 @@ -1214,6 +1297,36 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
81320 vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags) |
81321 mm->def_flags | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
81322
81323 +#ifdef CONFIG_PAX_MPROTECT
81324 + if (mm->pax_flags & MF_PAX_MPROTECT) {
81325 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
81326 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC)) {
81327 + gr_log_rwxmmap(file);
81328 +
81329 +#ifdef CONFIG_PAX_EMUPLT
81330 + vm_flags &= ~VM_EXEC;
81331 +#else
81332 + return -EPERM;
81333 +#endif
81334 +
81335 + }
81336 +
81337 + if (!(vm_flags & VM_EXEC))
81338 + vm_flags &= ~VM_MAYEXEC;
81339 +#else
81340 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
81341 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
81342 +#endif
81343 + else
81344 + vm_flags &= ~VM_MAYWRITE;
81345 + }
81346 +#endif
81347 +
81348 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
81349 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && file)
81350 + vm_flags &= ~VM_PAGEEXEC;
81351 +#endif
81352 +
81353 if (flags & MAP_LOCKED)
81354 if (!can_do_mlock())
81355 return -EPERM;
81356 @@ -1225,6 +1338,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
81357 locked += mm->locked_vm;
81358 lock_limit = rlimit(RLIMIT_MEMLOCK);
81359 lock_limit >>= PAGE_SHIFT;
81360 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
81361 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
81362 return -EAGAIN;
81363 }
81364 @@ -1305,6 +1419,9 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
81365 vm_flags |= VM_NORESERVE;
81366 }
81367
81368 + if (!gr_acl_handle_mmap(file, prot))
81369 + return -EACCES;
81370 +
81371 addr = mmap_region(file, addr, len, vm_flags, pgoff);
81372 if (!IS_ERR_VALUE(addr) &&
81373 ((vm_flags & VM_LOCKED) ||
81374 @@ -1396,7 +1513,7 @@ int vma_wants_writenotify(struct vm_area_struct *vma)
81375 vm_flags_t vm_flags = vma->vm_flags;
81376
81377 /* If it was private or non-writable, the write bit is already clear */
81378 - if ((vm_flags & (VM_WRITE|VM_SHARED)) != ((VM_WRITE|VM_SHARED)))
81379 + if ((vm_flags & (VM_WRITE|VM_SHARED)) != (VM_WRITE|VM_SHARED))
81380 return 0;
81381
81382 /* The backer wishes to know when pages are first written to? */
81383 @@ -1444,16 +1561,30 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
81384 unsigned long charged = 0;
81385 struct inode *inode = file ? file_inode(file) : NULL;
81386
81387 +#ifdef CONFIG_PAX_SEGMEXEC
81388 + struct vm_area_struct *vma_m = NULL;
81389 +#endif
81390 +
81391 + /*
81392 + * mm->mmap_sem is required to protect against another thread
81393 + * changing the mappings in case we sleep.
81394 + */
81395 + verify_mm_writelocked(mm);
81396 +
81397 /* Clear old maps */
81398 error = -ENOMEM;
81399 -munmap_back:
81400 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
81401 if (do_munmap(mm, addr, len))
81402 return -ENOMEM;
81403 - goto munmap_back;
81404 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
81405 }
81406
81407 /* Check against address space limit. */
81408 +
81409 +#ifdef CONFIG_PAX_RANDMMAP
81410 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (vm_flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
81411 +#endif
81412 +
81413 if (!may_expand_vm(mm, len >> PAGE_SHIFT))
81414 return -ENOMEM;
81415
81416 @@ -1485,6 +1616,16 @@ munmap_back:
81417 goto unacct_error;
81418 }
81419
81420 +#ifdef CONFIG_PAX_SEGMEXEC
81421 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vm_flags & VM_EXEC)) {
81422 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
81423 + if (!vma_m) {
81424 + error = -ENOMEM;
81425 + goto free_vma;
81426 + }
81427 + }
81428 +#endif
81429 +
81430 vma->vm_mm = mm;
81431 vma->vm_start = addr;
81432 vma->vm_end = addr + len;
81433 @@ -1509,6 +1650,13 @@ munmap_back:
81434 if (error)
81435 goto unmap_and_free_vma;
81436
81437 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
81438 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && !(vma->vm_flags & VM_SPECIAL)) {
81439 + vma->vm_flags |= VM_PAGEEXEC;
81440 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
81441 + }
81442 +#endif
81443 +
81444 /* Can addr have changed??
81445 *
81446 * Answer: Yes, several device drivers can do it in their
81447 @@ -1547,6 +1695,11 @@ munmap_back:
81448 vma_link(mm, vma, prev, rb_link, rb_parent);
81449 file = vma->vm_file;
81450
81451 +#ifdef CONFIG_PAX_SEGMEXEC
81452 + if (vma_m)
81453 + BUG_ON(pax_mirror_vma(vma_m, vma));
81454 +#endif
81455 +
81456 /* Once vma denies write, undo our temporary denial count */
81457 if (correct_wcount)
81458 atomic_inc(&inode->i_writecount);
81459 @@ -1554,6 +1707,7 @@ out:
81460 perf_event_mmap(vma);
81461
81462 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
81463 + track_exec_limit(mm, addr, addr + len, vm_flags);
81464 if (vm_flags & VM_LOCKED) {
81465 if (!((vm_flags & VM_SPECIAL) || is_vm_hugetlb_page(vma) ||
81466 vma == get_gate_vma(current->mm)))
81467 @@ -1577,6 +1731,12 @@ unmap_and_free_vma:
81468 unmap_region(mm, vma, prev, vma->vm_start, vma->vm_end);
81469 charged = 0;
81470 free_vma:
81471 +
81472 +#ifdef CONFIG_PAX_SEGMEXEC
81473 + if (vma_m)
81474 + kmem_cache_free(vm_area_cachep, vma_m);
81475 +#endif
81476 +
81477 kmem_cache_free(vm_area_cachep, vma);
81478 unacct_error:
81479 if (charged)
81480 @@ -1584,6 +1744,62 @@ unacct_error:
81481 return error;
81482 }
81483
81484 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
81485 +unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
81486 +{
81487 + if ((mm->pax_flags & MF_PAX_RANDMMAP) && !filp && (flags & MAP_STACK))
81488 + return (random32() & 0xFF) << PAGE_SHIFT;
81489 +
81490 + return 0;
81491 +}
81492 +#endif
81493 +
81494 +bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset)
81495 +{
81496 + if (!vma) {
81497 +#ifdef CONFIG_STACK_GROWSUP
81498 + if (addr > sysctl_heap_stack_gap)
81499 + vma = find_vma(current->mm, addr - sysctl_heap_stack_gap);
81500 + else
81501 + vma = find_vma(current->mm, 0);
81502 + if (vma && (vma->vm_flags & VM_GROWSUP))
81503 + return false;
81504 +#endif
81505 + return true;
81506 + }
81507 +
81508 + if (addr + len > vma->vm_start)
81509 + return false;
81510 +
81511 + if (vma->vm_flags & VM_GROWSDOWN)
81512 + return sysctl_heap_stack_gap <= vma->vm_start - addr - len;
81513 +#ifdef CONFIG_STACK_GROWSUP
81514 + else if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP))
81515 + return addr - vma->vm_prev->vm_end <= sysctl_heap_stack_gap;
81516 +#endif
81517 + else if (offset)
81518 + return offset <= vma->vm_start - addr - len;
81519 +
81520 + return true;
81521 +}
81522 +
81523 +unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset)
81524 +{
81525 + if (vma->vm_start < len)
81526 + return -ENOMEM;
81527 +
81528 + if (!(vma->vm_flags & VM_GROWSDOWN)) {
81529 + if (offset <= vma->vm_start - len)
81530 + return vma->vm_start - len - offset;
81531 + else
81532 + return -ENOMEM;
81533 + }
81534 +
81535 + if (sysctl_heap_stack_gap <= vma->vm_start - len)
81536 + return vma->vm_start - len - sysctl_heap_stack_gap;
81537 + return -ENOMEM;
81538 +}
81539 +
81540 unsigned long unmapped_area(struct vm_unmapped_area_info *info)
81541 {
81542 /*
81543 @@ -1803,6 +2019,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
81544 struct mm_struct *mm = current->mm;
81545 struct vm_area_struct *vma;
81546 struct vm_unmapped_area_info info;
81547 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
81548
81549 if (len > TASK_SIZE)
81550 return -ENOMEM;
81551 @@ -1810,29 +2027,45 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
81552 if (flags & MAP_FIXED)
81553 return addr;
81554
81555 +#ifdef CONFIG_PAX_RANDMMAP
81556 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
81557 +#endif
81558 +
81559 if (addr) {
81560 addr = PAGE_ALIGN(addr);
81561 vma = find_vma(mm, addr);
81562 - if (TASK_SIZE - len >= addr &&
81563 - (!vma || addr + len <= vma->vm_start))
81564 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
81565 return addr;
81566 }
81567
81568 info.flags = 0;
81569 info.length = len;
81570 info.low_limit = TASK_UNMAPPED_BASE;
81571 +
81572 +#ifdef CONFIG_PAX_RANDMMAP
81573 + if (mm->pax_flags & MF_PAX_RANDMMAP)
81574 + info.low_limit += mm->delta_mmap;
81575 +#endif
81576 +
81577 info.high_limit = TASK_SIZE;
81578 info.align_mask = 0;
81579 + info.threadstack_offset = offset;
81580 return vm_unmapped_area(&info);
81581 }
81582 #endif
81583
81584 void arch_unmap_area(struct mm_struct *mm, unsigned long addr)
81585 {
81586 +
81587 +#ifdef CONFIG_PAX_SEGMEXEC
81588 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE <= addr)
81589 + return;
81590 +#endif
81591 +
81592 /*
81593 * Is this a new hole at the lowest possible address?
81594 */
81595 - if (addr >= TASK_UNMAPPED_BASE && addr < mm->free_area_cache)
81596 + if (addr >= mm->mmap_base && addr < mm->free_area_cache)
81597 mm->free_area_cache = addr;
81598 }
81599
81600 @@ -1850,6 +2083,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
81601 struct mm_struct *mm = current->mm;
81602 unsigned long addr = addr0;
81603 struct vm_unmapped_area_info info;
81604 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
81605
81606 /* requested length too big for entire address space */
81607 if (len > TASK_SIZE)
81608 @@ -1858,12 +2092,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
81609 if (flags & MAP_FIXED)
81610 return addr;
81611
81612 +#ifdef CONFIG_PAX_RANDMMAP
81613 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
81614 +#endif
81615 +
81616 /* requesting a specific address */
81617 if (addr) {
81618 addr = PAGE_ALIGN(addr);
81619 vma = find_vma(mm, addr);
81620 - if (TASK_SIZE - len >= addr &&
81621 - (!vma || addr + len <= vma->vm_start))
81622 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
81623 return addr;
81624 }
81625
81626 @@ -1872,6 +2109,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
81627 info.low_limit = PAGE_SIZE;
81628 info.high_limit = mm->mmap_base;
81629 info.align_mask = 0;
81630 + info.threadstack_offset = offset;
81631 addr = vm_unmapped_area(&info);
81632
81633 /*
81634 @@ -1884,6 +2122,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
81635 VM_BUG_ON(addr != -ENOMEM);
81636 info.flags = 0;
81637 info.low_limit = TASK_UNMAPPED_BASE;
81638 +
81639 +#ifdef CONFIG_PAX_RANDMMAP
81640 + if (mm->pax_flags & MF_PAX_RANDMMAP)
81641 + info.low_limit += mm->delta_mmap;
81642 +#endif
81643 +
81644 info.high_limit = TASK_SIZE;
81645 addr = vm_unmapped_area(&info);
81646 }
81647 @@ -1894,6 +2138,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
81648
81649 void arch_unmap_area_topdown(struct mm_struct *mm, unsigned long addr)
81650 {
81651 +
81652 +#ifdef CONFIG_PAX_SEGMEXEC
81653 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE <= addr)
81654 + return;
81655 +#endif
81656 +
81657 /*
81658 * Is this a new hole at the highest possible address?
81659 */
81660 @@ -1901,8 +2151,10 @@ void arch_unmap_area_topdown(struct mm_struct *mm, unsigned long addr)
81661 mm->free_area_cache = addr;
81662
81663 /* dont allow allocations above current base */
81664 - if (mm->free_area_cache > mm->mmap_base)
81665 + if (mm->free_area_cache > mm->mmap_base) {
81666 mm->free_area_cache = mm->mmap_base;
81667 + mm->cached_hole_size = ~0UL;
81668 + }
81669 }
81670
81671 unsigned long
81672 @@ -2001,6 +2253,28 @@ find_vma_prev(struct mm_struct *mm, unsigned long addr,
81673 return vma;
81674 }
81675
81676 +#ifdef CONFIG_PAX_SEGMEXEC
81677 +struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma)
81678 +{
81679 + struct vm_area_struct *vma_m;
81680 +
81681 + BUG_ON(!vma || vma->vm_start >= vma->vm_end);
81682 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC)) {
81683 + BUG_ON(vma->vm_mirror);
81684 + return NULL;
81685 + }
81686 + BUG_ON(vma->vm_start < SEGMEXEC_TASK_SIZE && SEGMEXEC_TASK_SIZE < vma->vm_end);
81687 + vma_m = vma->vm_mirror;
81688 + BUG_ON(!vma_m || vma_m->vm_mirror != vma);
81689 + BUG_ON(vma->vm_file != vma_m->vm_file);
81690 + BUG_ON(vma->vm_end - vma->vm_start != vma_m->vm_end - vma_m->vm_start);
81691 + BUG_ON(vma->vm_pgoff != vma_m->vm_pgoff);
81692 + BUG_ON(vma->anon_vma != vma_m->anon_vma && vma->anon_vma->root != vma_m->anon_vma->root);
81693 + BUG_ON((vma->vm_flags ^ vma_m->vm_flags) & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED));
81694 + return vma_m;
81695 +}
81696 +#endif
81697 +
81698 /*
81699 * Verify that the stack growth is acceptable and
81700 * update accounting. This is shared with both the
81701 @@ -2017,6 +2291,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
81702 return -ENOMEM;
81703
81704 /* Stack limit test */
81705 + gr_learn_resource(current, RLIMIT_STACK, size, 1);
81706 if (size > ACCESS_ONCE(rlim[RLIMIT_STACK].rlim_cur))
81707 return -ENOMEM;
81708
81709 @@ -2027,6 +2302,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
81710 locked = mm->locked_vm + grow;
81711 limit = ACCESS_ONCE(rlim[RLIMIT_MEMLOCK].rlim_cur);
81712 limit >>= PAGE_SHIFT;
81713 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
81714 if (locked > limit && !capable(CAP_IPC_LOCK))
81715 return -ENOMEM;
81716 }
81717 @@ -2056,37 +2332,48 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
81718 * PA-RISC uses this for its stack; IA64 for its Register Backing Store.
81719 * vma is the last one with address > vma->vm_end. Have to extend vma.
81720 */
81721 +#ifndef CONFIG_IA64
81722 +static
81723 +#endif
81724 int expand_upwards(struct vm_area_struct *vma, unsigned long address)
81725 {
81726 int error;
81727 + bool locknext;
81728
81729 if (!(vma->vm_flags & VM_GROWSUP))
81730 return -EFAULT;
81731
81732 + /* Also guard against wrapping around to address 0. */
81733 + if (address < PAGE_ALIGN(address+1))
81734 + address = PAGE_ALIGN(address+1);
81735 + else
81736 + return -ENOMEM;
81737 +
81738 /*
81739 * We must make sure the anon_vma is allocated
81740 * so that the anon_vma locking is not a noop.
81741 */
81742 if (unlikely(anon_vma_prepare(vma)))
81743 return -ENOMEM;
81744 + locknext = vma->vm_next && (vma->vm_next->vm_flags & VM_GROWSDOWN);
81745 + if (locknext && anon_vma_prepare(vma->vm_next))
81746 + return -ENOMEM;
81747 vma_lock_anon_vma(vma);
81748 + if (locknext)
81749 + vma_lock_anon_vma(vma->vm_next);
81750
81751 /*
81752 * vma->vm_start/vm_end cannot change under us because the caller
81753 * is required to hold the mmap_sem in read mode. We need the
81754 - * anon_vma lock to serialize against concurrent expand_stacks.
81755 - * Also guard against wrapping around to address 0.
81756 + * anon_vma locks to serialize against concurrent expand_stacks
81757 + * and expand_upwards.
81758 */
81759 - if (address < PAGE_ALIGN(address+4))
81760 - address = PAGE_ALIGN(address+4);
81761 - else {
81762 - vma_unlock_anon_vma(vma);
81763 - return -ENOMEM;
81764 - }
81765 error = 0;
81766
81767 /* Somebody else might have raced and expanded it already */
81768 - if (address > vma->vm_end) {
81769 + 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)
81770 + error = -ENOMEM;
81771 + else if (address > vma->vm_end && (!locknext || vma->vm_next->vm_start >= address)) {
81772 unsigned long size, grow;
81773
81774 size = address - vma->vm_start;
81775 @@ -2121,6 +2408,8 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
81776 }
81777 }
81778 }
81779 + if (locknext)
81780 + vma_unlock_anon_vma(vma->vm_next);
81781 vma_unlock_anon_vma(vma);
81782 khugepaged_enter_vma_merge(vma);
81783 validate_mm(vma->vm_mm);
81784 @@ -2135,6 +2424,8 @@ int expand_downwards(struct vm_area_struct *vma,
81785 unsigned long address)
81786 {
81787 int error;
81788 + bool lockprev = false;
81789 + struct vm_area_struct *prev;
81790
81791 /*
81792 * We must make sure the anon_vma is allocated
81793 @@ -2148,6 +2439,15 @@ int expand_downwards(struct vm_area_struct *vma,
81794 if (error)
81795 return error;
81796
81797 + prev = vma->vm_prev;
81798 +#if defined(CONFIG_STACK_GROWSUP) || defined(CONFIG_IA64)
81799 + lockprev = prev && (prev->vm_flags & VM_GROWSUP);
81800 +#endif
81801 + if (lockprev && anon_vma_prepare(prev))
81802 + return -ENOMEM;
81803 + if (lockprev)
81804 + vma_lock_anon_vma(prev);
81805 +
81806 vma_lock_anon_vma(vma);
81807
81808 /*
81809 @@ -2157,9 +2457,17 @@ int expand_downwards(struct vm_area_struct *vma,
81810 */
81811
81812 /* Somebody else might have raced and expanded it already */
81813 - if (address < vma->vm_start) {
81814 + if (prev && (prev->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)) && address - prev->vm_end < sysctl_heap_stack_gap)
81815 + error = -ENOMEM;
81816 + else if (address < vma->vm_start && (!lockprev || prev->vm_end <= address)) {
81817 unsigned long size, grow;
81818
81819 +#ifdef CONFIG_PAX_SEGMEXEC
81820 + struct vm_area_struct *vma_m;
81821 +
81822 + vma_m = pax_find_mirror_vma(vma);
81823 +#endif
81824 +
81825 size = vma->vm_end - address;
81826 grow = (vma->vm_start - address) >> PAGE_SHIFT;
81827
81828 @@ -2184,6 +2492,18 @@ int expand_downwards(struct vm_area_struct *vma,
81829 vma->vm_pgoff -= grow;
81830 anon_vma_interval_tree_post_update_vma(vma);
81831 vma_gap_update(vma);
81832 + track_exec_limit(vma->vm_mm, vma->vm_start, vma->vm_end, vma->vm_flags);
81833 +
81834 +#ifdef CONFIG_PAX_SEGMEXEC
81835 + if (vma_m) {
81836 + anon_vma_interval_tree_pre_update_vma(vma_m);
81837 + vma_m->vm_start -= grow << PAGE_SHIFT;
81838 + vma_m->vm_pgoff -= grow;
81839 + anon_vma_interval_tree_post_update_vma(vma_m);
81840 + vma_gap_update(vma_m);
81841 + }
81842 +#endif
81843 +
81844 spin_unlock(&vma->vm_mm->page_table_lock);
81845
81846 perf_event_mmap(vma);
81847 @@ -2288,6 +2608,13 @@ static void remove_vma_list(struct mm_struct *mm, struct vm_area_struct *vma)
81848 do {
81849 long nrpages = vma_pages(vma);
81850
81851 +#ifdef CONFIG_PAX_SEGMEXEC
81852 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE)) {
81853 + vma = remove_vma(vma);
81854 + continue;
81855 + }
81856 +#endif
81857 +
81858 if (vma->vm_flags & VM_ACCOUNT)
81859 nr_accounted += nrpages;
81860 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
81861 @@ -2333,6 +2660,16 @@ detach_vmas_to_be_unmapped(struct mm_struct *mm, struct vm_area_struct *vma,
81862 insertion_point = (prev ? &prev->vm_next : &mm->mmap);
81863 vma->vm_prev = NULL;
81864 do {
81865 +
81866 +#ifdef CONFIG_PAX_SEGMEXEC
81867 + if (vma->vm_mirror) {
81868 + BUG_ON(!vma->vm_mirror->vm_mirror || vma->vm_mirror->vm_mirror != vma);
81869 + vma->vm_mirror->vm_mirror = NULL;
81870 + vma->vm_mirror->vm_flags &= ~VM_EXEC;
81871 + vma->vm_mirror = NULL;
81872 + }
81873 +#endif
81874 +
81875 vma_rb_erase(vma, &mm->mm_rb);
81876 mm->map_count--;
81877 tail_vma = vma;
81878 @@ -2364,14 +2701,33 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
81879 struct vm_area_struct *new;
81880 int err = -ENOMEM;
81881
81882 +#ifdef CONFIG_PAX_SEGMEXEC
81883 + struct vm_area_struct *vma_m, *new_m = NULL;
81884 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE;
81885 +#endif
81886 +
81887 if (is_vm_hugetlb_page(vma) && (addr &
81888 ~(huge_page_mask(hstate_vma(vma)))))
81889 return -EINVAL;
81890
81891 +#ifdef CONFIG_PAX_SEGMEXEC
81892 + vma_m = pax_find_mirror_vma(vma);
81893 +#endif
81894 +
81895 new = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
81896 if (!new)
81897 goto out_err;
81898
81899 +#ifdef CONFIG_PAX_SEGMEXEC
81900 + if (vma_m) {
81901 + new_m = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
81902 + if (!new_m) {
81903 + kmem_cache_free(vm_area_cachep, new);
81904 + goto out_err;
81905 + }
81906 + }
81907 +#endif
81908 +
81909 /* most fields are the same, copy all, and then fixup */
81910 *new = *vma;
81911
81912 @@ -2384,6 +2740,22 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
81913 new->vm_pgoff += ((addr - vma->vm_start) >> PAGE_SHIFT);
81914 }
81915
81916 +#ifdef CONFIG_PAX_SEGMEXEC
81917 + if (vma_m) {
81918 + *new_m = *vma_m;
81919 + INIT_LIST_HEAD(&new_m->anon_vma_chain);
81920 + new_m->vm_mirror = new;
81921 + new->vm_mirror = new_m;
81922 +
81923 + if (new_below)
81924 + new_m->vm_end = addr_m;
81925 + else {
81926 + new_m->vm_start = addr_m;
81927 + new_m->vm_pgoff += ((addr_m - vma_m->vm_start) >> PAGE_SHIFT);
81928 + }
81929 + }
81930 +#endif
81931 +
81932 pol = mpol_dup(vma_policy(vma));
81933 if (IS_ERR(pol)) {
81934 err = PTR_ERR(pol);
81935 @@ -2406,6 +2778,36 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
81936 else
81937 err = vma_adjust(vma, vma->vm_start, addr, vma->vm_pgoff, new);
81938
81939 +#ifdef CONFIG_PAX_SEGMEXEC
81940 + if (!err && vma_m) {
81941 + if (anon_vma_clone(new_m, vma_m))
81942 + goto out_free_mpol;
81943 +
81944 + mpol_get(pol);
81945 + vma_set_policy(new_m, pol);
81946 +
81947 + if (new_m->vm_file)
81948 + get_file(new_m->vm_file);
81949 +
81950 + if (new_m->vm_ops && new_m->vm_ops->open)
81951 + new_m->vm_ops->open(new_m);
81952 +
81953 + if (new_below)
81954 + err = vma_adjust(vma_m, addr_m, vma_m->vm_end, vma_m->vm_pgoff +
81955 + ((addr_m - new_m->vm_start) >> PAGE_SHIFT), new_m);
81956 + else
81957 + err = vma_adjust(vma_m, vma_m->vm_start, addr_m, vma_m->vm_pgoff, new_m);
81958 +
81959 + if (err) {
81960 + if (new_m->vm_ops && new_m->vm_ops->close)
81961 + new_m->vm_ops->close(new_m);
81962 + if (new_m->vm_file)
81963 + fput(new_m->vm_file);
81964 + mpol_put(pol);
81965 + }
81966 + }
81967 +#endif
81968 +
81969 /* Success. */
81970 if (!err)
81971 return 0;
81972 @@ -2415,10 +2817,18 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
81973 new->vm_ops->close(new);
81974 if (new->vm_file)
81975 fput(new->vm_file);
81976 - unlink_anon_vmas(new);
81977 out_free_mpol:
81978 mpol_put(pol);
81979 out_free_vma:
81980 +
81981 +#ifdef CONFIG_PAX_SEGMEXEC
81982 + if (new_m) {
81983 + unlink_anon_vmas(new_m);
81984 + kmem_cache_free(vm_area_cachep, new_m);
81985 + }
81986 +#endif
81987 +
81988 + unlink_anon_vmas(new);
81989 kmem_cache_free(vm_area_cachep, new);
81990 out_err:
81991 return err;
81992 @@ -2431,6 +2841,15 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
81993 int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
81994 unsigned long addr, int new_below)
81995 {
81996 +
81997 +#ifdef CONFIG_PAX_SEGMEXEC
81998 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
81999 + BUG_ON(vma->vm_end > SEGMEXEC_TASK_SIZE);
82000 + if (mm->map_count >= sysctl_max_map_count-1)
82001 + return -ENOMEM;
82002 + } else
82003 +#endif
82004 +
82005 if (mm->map_count >= sysctl_max_map_count)
82006 return -ENOMEM;
82007
82008 @@ -2442,11 +2861,30 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
82009 * work. This now handles partial unmappings.
82010 * Jeremy Fitzhardinge <jeremy@goop.org>
82011 */
82012 +#ifdef CONFIG_PAX_SEGMEXEC
82013 int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
82014 {
82015 + int ret = __do_munmap(mm, start, len);
82016 + if (ret || !(mm->pax_flags & MF_PAX_SEGMEXEC))
82017 + return ret;
82018 +
82019 + return __do_munmap(mm, start + SEGMEXEC_TASK_SIZE, len);
82020 +}
82021 +
82022 +int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
82023 +#else
82024 +int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
82025 +#endif
82026 +{
82027 unsigned long end;
82028 struct vm_area_struct *vma, *prev, *last;
82029
82030 + /*
82031 + * mm->mmap_sem is required to protect against another thread
82032 + * changing the mappings in case we sleep.
82033 + */
82034 + verify_mm_writelocked(mm);
82035 +
82036 if ((start & ~PAGE_MASK) || start > TASK_SIZE || len > TASK_SIZE-start)
82037 return -EINVAL;
82038
82039 @@ -2521,6 +2959,8 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
82040 /* Fix up all other VM information */
82041 remove_vma_list(mm, vma);
82042
82043 + track_exec_limit(mm, start, end, 0UL);
82044 +
82045 return 0;
82046 }
82047
82048 @@ -2529,6 +2969,13 @@ int vm_munmap(unsigned long start, size_t len)
82049 int ret;
82050 struct mm_struct *mm = current->mm;
82051
82052 +
82053 +#ifdef CONFIG_PAX_SEGMEXEC
82054 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) &&
82055 + (len > SEGMEXEC_TASK_SIZE || start > SEGMEXEC_TASK_SIZE-len))
82056 + return -EINVAL;
82057 +#endif
82058 +
82059 down_write(&mm->mmap_sem);
82060 ret = do_munmap(mm, start, len);
82061 up_write(&mm->mmap_sem);
82062 @@ -2542,16 +2989,6 @@ SYSCALL_DEFINE2(munmap, unsigned long, addr, size_t, len)
82063 return vm_munmap(addr, len);
82064 }
82065
82066 -static inline void verify_mm_writelocked(struct mm_struct *mm)
82067 -{
82068 -#ifdef CONFIG_DEBUG_VM
82069 - if (unlikely(down_read_trylock(&mm->mmap_sem))) {
82070 - WARN_ON(1);
82071 - up_read(&mm->mmap_sem);
82072 - }
82073 -#endif
82074 -}
82075 -
82076 /*
82077 * this is really a simplified "do_mmap". it only handles
82078 * anonymous maps. eventually we may be able to do some
82079 @@ -2565,6 +3002,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
82080 struct rb_node ** rb_link, * rb_parent;
82081 pgoff_t pgoff = addr >> PAGE_SHIFT;
82082 int error;
82083 + unsigned long charged;
82084
82085 len = PAGE_ALIGN(len);
82086 if (!len)
82087 @@ -2572,16 +3010,30 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
82088
82089 flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
82090
82091 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
82092 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
82093 + flags &= ~VM_EXEC;
82094 +
82095 +#ifdef CONFIG_PAX_MPROTECT
82096 + if (mm->pax_flags & MF_PAX_MPROTECT)
82097 + flags &= ~VM_MAYEXEC;
82098 +#endif
82099 +
82100 + }
82101 +#endif
82102 +
82103 error = get_unmapped_area(NULL, addr, len, 0, MAP_FIXED);
82104 if (error & ~PAGE_MASK)
82105 return error;
82106
82107 + charged = len >> PAGE_SHIFT;
82108 +
82109 /*
82110 * mlock MCL_FUTURE?
82111 */
82112 if (mm->def_flags & VM_LOCKED) {
82113 unsigned long locked, lock_limit;
82114 - locked = len >> PAGE_SHIFT;
82115 + locked = charged;
82116 locked += mm->locked_vm;
82117 lock_limit = rlimit(RLIMIT_MEMLOCK);
82118 lock_limit >>= PAGE_SHIFT;
82119 @@ -2598,21 +3050,20 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
82120 /*
82121 * Clear old maps. this also does some error checking for us
82122 */
82123 - munmap_back:
82124 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
82125 if (do_munmap(mm, addr, len))
82126 return -ENOMEM;
82127 - goto munmap_back;
82128 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
82129 }
82130
82131 /* Check against address space limits *after* clearing old maps... */
82132 - if (!may_expand_vm(mm, len >> PAGE_SHIFT))
82133 + if (!may_expand_vm(mm, charged))
82134 return -ENOMEM;
82135
82136 if (mm->map_count > sysctl_max_map_count)
82137 return -ENOMEM;
82138
82139 - if (security_vm_enough_memory_mm(mm, len >> PAGE_SHIFT))
82140 + if (security_vm_enough_memory_mm(mm, charged))
82141 return -ENOMEM;
82142
82143 /* Can we just expand an old private anonymous mapping? */
82144 @@ -2626,7 +3077,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
82145 */
82146 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
82147 if (!vma) {
82148 - vm_unacct_memory(len >> PAGE_SHIFT);
82149 + vm_unacct_memory(charged);
82150 return -ENOMEM;
82151 }
82152
82153 @@ -2640,9 +3091,10 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
82154 vma_link(mm, vma, prev, rb_link, rb_parent);
82155 out:
82156 perf_event_mmap(vma);
82157 - mm->total_vm += len >> PAGE_SHIFT;
82158 + mm->total_vm += charged;
82159 if (flags & VM_LOCKED)
82160 - mm->locked_vm += (len >> PAGE_SHIFT);
82161 + mm->locked_vm += charged;
82162 + track_exec_limit(mm, addr, addr + len, flags);
82163 return addr;
82164 }
82165
82166 @@ -2704,6 +3156,7 @@ void exit_mmap(struct mm_struct *mm)
82167 while (vma) {
82168 if (vma->vm_flags & VM_ACCOUNT)
82169 nr_accounted += vma_pages(vma);
82170 + vma->vm_mirror = NULL;
82171 vma = remove_vma(vma);
82172 }
82173 vm_unacct_memory(nr_accounted);
82174 @@ -2720,6 +3173,13 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
82175 struct vm_area_struct *prev;
82176 struct rb_node **rb_link, *rb_parent;
82177
82178 +#ifdef CONFIG_PAX_SEGMEXEC
82179 + struct vm_area_struct *vma_m = NULL;
82180 +#endif
82181 +
82182 + if (security_mmap_addr(vma->vm_start))
82183 + return -EPERM;
82184 +
82185 /*
82186 * The vm_pgoff of a purely anonymous vma should be irrelevant
82187 * until its first write fault, when page's anon_vma and index
82188 @@ -2743,7 +3203,21 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
82189 security_vm_enough_memory_mm(mm, vma_pages(vma)))
82190 return -ENOMEM;
82191
82192 +#ifdef CONFIG_PAX_SEGMEXEC
82193 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_EXEC)) {
82194 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
82195 + if (!vma_m)
82196 + return -ENOMEM;
82197 + }
82198 +#endif
82199 +
82200 vma_link(mm, vma, prev, rb_link, rb_parent);
82201 +
82202 +#ifdef CONFIG_PAX_SEGMEXEC
82203 + if (vma_m)
82204 + BUG_ON(pax_mirror_vma(vma_m, vma));
82205 +#endif
82206 +
82207 return 0;
82208 }
82209
82210 @@ -2763,6 +3237,8 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
82211 struct mempolicy *pol;
82212 bool faulted_in_anon_vma = true;
82213
82214 + BUG_ON(vma->vm_mirror);
82215 +
82216 /*
82217 * If anonymous vma has not yet been faulted, update new pgoff
82218 * to match new location, to increase its chance of merging.
82219 @@ -2829,6 +3305,39 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
82220 return NULL;
82221 }
82222
82223 +#ifdef CONFIG_PAX_SEGMEXEC
82224 +long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma)
82225 +{
82226 + struct vm_area_struct *prev_m;
82227 + struct rb_node **rb_link_m, *rb_parent_m;
82228 + struct mempolicy *pol_m;
82229 +
82230 + BUG_ON(!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC));
82231 + BUG_ON(vma->vm_mirror || vma_m->vm_mirror);
82232 + BUG_ON(!mpol_equal(vma_policy(vma), vma_policy(vma_m)));
82233 + *vma_m = *vma;
82234 + INIT_LIST_HEAD(&vma_m->anon_vma_chain);
82235 + if (anon_vma_clone(vma_m, vma))
82236 + return -ENOMEM;
82237 + pol_m = vma_policy(vma_m);
82238 + mpol_get(pol_m);
82239 + vma_set_policy(vma_m, pol_m);
82240 + vma_m->vm_start += SEGMEXEC_TASK_SIZE;
82241 + vma_m->vm_end += SEGMEXEC_TASK_SIZE;
82242 + vma_m->vm_flags &= ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED);
82243 + vma_m->vm_page_prot = vm_get_page_prot(vma_m->vm_flags);
82244 + if (vma_m->vm_file)
82245 + get_file(vma_m->vm_file);
82246 + if (vma_m->vm_ops && vma_m->vm_ops->open)
82247 + vma_m->vm_ops->open(vma_m);
82248 + BUG_ON(find_vma_links(vma->vm_mm, vma_m->vm_start, vma_m->vm_end, &prev_m, &rb_link_m, &rb_parent_m));
82249 + vma_link(vma->vm_mm, vma_m, prev_m, rb_link_m, rb_parent_m);
82250 + vma_m->vm_mirror = vma;
82251 + vma->vm_mirror = vma_m;
82252 + return 0;
82253 +}
82254 +#endif
82255 +
82256 /*
82257 * Return true if the calling process may expand its vm space by the passed
82258 * number of pages
82259 @@ -2840,6 +3349,7 @@ int may_expand_vm(struct mm_struct *mm, unsigned long npages)
82260
82261 lim = rlimit(RLIMIT_AS) >> PAGE_SHIFT;
82262
82263 + gr_learn_resource(current, RLIMIT_AS, (cur + npages) << PAGE_SHIFT, 1);
82264 if (cur + npages > lim)
82265 return 0;
82266 return 1;
82267 @@ -2910,6 +3420,22 @@ int install_special_mapping(struct mm_struct *mm,
82268 vma->vm_start = addr;
82269 vma->vm_end = addr + len;
82270
82271 +#ifdef CONFIG_PAX_MPROTECT
82272 + if (mm->pax_flags & MF_PAX_MPROTECT) {
82273 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
82274 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC))
82275 + return -EPERM;
82276 + if (!(vm_flags & VM_EXEC))
82277 + vm_flags &= ~VM_MAYEXEC;
82278 +#else
82279 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
82280 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
82281 +#endif
82282 + else
82283 + vm_flags &= ~VM_MAYWRITE;
82284 + }
82285 +#endif
82286 +
82287 vma->vm_flags = vm_flags | mm->def_flags | VM_DONTEXPAND;
82288 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
82289
82290 diff --git a/mm/mprotect.c b/mm/mprotect.c
82291 index 94722a4..07d9926 100644
82292 --- a/mm/mprotect.c
82293 +++ b/mm/mprotect.c
82294 @@ -23,10 +23,18 @@
82295 #include <linux/mmu_notifier.h>
82296 #include <linux/migrate.h>
82297 #include <linux/perf_event.h>
82298 +#include <linux/sched/sysctl.h>
82299 +
82300 +#ifdef CONFIG_PAX_MPROTECT
82301 +#include <linux/elf.h>
82302 +#include <linux/binfmts.h>
82303 +#endif
82304 +
82305 #include <asm/uaccess.h>
82306 #include <asm/pgtable.h>
82307 #include <asm/cacheflush.h>
82308 #include <asm/tlbflush.h>
82309 +#include <asm/mmu_context.h>
82310
82311 #ifndef pgprot_modify
82312 static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
82313 @@ -233,6 +241,48 @@ unsigned long change_protection(struct vm_area_struct *vma, unsigned long start,
82314 return pages;
82315 }
82316
82317 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
82318 +/* called while holding the mmap semaphor for writing except stack expansion */
82319 +void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot)
82320 +{
82321 + unsigned long oldlimit, newlimit = 0UL;
82322 +
82323 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || (__supported_pte_mask & _PAGE_NX))
82324 + return;
82325 +
82326 + spin_lock(&mm->page_table_lock);
82327 + oldlimit = mm->context.user_cs_limit;
82328 + if ((prot & VM_EXEC) && oldlimit < end)
82329 + /* USER_CS limit moved up */
82330 + newlimit = end;
82331 + else if (!(prot & VM_EXEC) && start < oldlimit && oldlimit <= end)
82332 + /* USER_CS limit moved down */
82333 + newlimit = start;
82334 +
82335 + if (newlimit) {
82336 + mm->context.user_cs_limit = newlimit;
82337 +
82338 +#ifdef CONFIG_SMP
82339 + wmb();
82340 + cpus_clear(mm->context.cpu_user_cs_mask);
82341 + cpu_set(smp_processor_id(), mm->context.cpu_user_cs_mask);
82342 +#endif
82343 +
82344 + set_user_cs(mm->context.user_cs_base, mm->context.user_cs_limit, smp_processor_id());
82345 + }
82346 + spin_unlock(&mm->page_table_lock);
82347 + if (newlimit == end) {
82348 + struct vm_area_struct *vma = find_vma(mm, oldlimit);
82349 +
82350 + for (; vma && vma->vm_start < end; vma = vma->vm_next)
82351 + if (is_vm_hugetlb_page(vma))
82352 + hugetlb_change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot);
82353 + else
82354 + change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot, vma_wants_writenotify(vma), 0);
82355 + }
82356 +}
82357 +#endif
82358 +
82359 int
82360 mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
82361 unsigned long start, unsigned long end, unsigned long newflags)
82362 @@ -245,11 +295,29 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
82363 int error;
82364 int dirty_accountable = 0;
82365
82366 +#ifdef CONFIG_PAX_SEGMEXEC
82367 + struct vm_area_struct *vma_m = NULL;
82368 + unsigned long start_m, end_m;
82369 +
82370 + start_m = start + SEGMEXEC_TASK_SIZE;
82371 + end_m = end + SEGMEXEC_TASK_SIZE;
82372 +#endif
82373 +
82374 if (newflags == oldflags) {
82375 *pprev = vma;
82376 return 0;
82377 }
82378
82379 + if (newflags & (VM_READ | VM_WRITE | VM_EXEC)) {
82380 + struct vm_area_struct *prev = vma->vm_prev, *next = vma->vm_next;
82381 +
82382 + if (next && (next->vm_flags & VM_GROWSDOWN) && sysctl_heap_stack_gap > next->vm_start - end)
82383 + return -ENOMEM;
82384 +
82385 + if (prev && (prev->vm_flags & VM_GROWSUP) && sysctl_heap_stack_gap > start - prev->vm_end)
82386 + return -ENOMEM;
82387 + }
82388 +
82389 /*
82390 * If we make a private mapping writable we increase our commit;
82391 * but (without finer accounting) cannot reduce our commit if we
82392 @@ -266,6 +334,42 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
82393 }
82394 }
82395
82396 +#ifdef CONFIG_PAX_SEGMEXEC
82397 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && ((oldflags ^ newflags) & VM_EXEC)) {
82398 + if (start != vma->vm_start) {
82399 + error = split_vma(mm, vma, start, 1);
82400 + if (error)
82401 + goto fail;
82402 + BUG_ON(!*pprev || (*pprev)->vm_next == vma);
82403 + *pprev = (*pprev)->vm_next;
82404 + }
82405 +
82406 + if (end != vma->vm_end) {
82407 + error = split_vma(mm, vma, end, 0);
82408 + if (error)
82409 + goto fail;
82410 + }
82411 +
82412 + if (pax_find_mirror_vma(vma)) {
82413 + error = __do_munmap(mm, start_m, end_m - start_m);
82414 + if (error)
82415 + goto fail;
82416 + } else {
82417 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
82418 + if (!vma_m) {
82419 + error = -ENOMEM;
82420 + goto fail;
82421 + }
82422 + vma->vm_flags = newflags;
82423 + error = pax_mirror_vma(vma_m, vma);
82424 + if (error) {
82425 + vma->vm_flags = oldflags;
82426 + goto fail;
82427 + }
82428 + }
82429 + }
82430 +#endif
82431 +
82432 /*
82433 * First try to merge with previous and/or next vma.
82434 */
82435 @@ -296,9 +400,21 @@ success:
82436 * vm_flags and vm_page_prot are protected by the mmap_sem
82437 * held in write mode.
82438 */
82439 +
82440 +#ifdef CONFIG_PAX_SEGMEXEC
82441 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (newflags & VM_EXEC) && ((vma->vm_flags ^ newflags) & VM_READ))
82442 + pax_find_mirror_vma(vma)->vm_flags ^= VM_READ;
82443 +#endif
82444 +
82445 vma->vm_flags = newflags;
82446 +
82447 +#ifdef CONFIG_PAX_MPROTECT
82448 + if (mm->binfmt && mm->binfmt->handle_mprotect)
82449 + mm->binfmt->handle_mprotect(vma, newflags);
82450 +#endif
82451 +
82452 vma->vm_page_prot = pgprot_modify(vma->vm_page_prot,
82453 - vm_get_page_prot(newflags));
82454 + vm_get_page_prot(vma->vm_flags));
82455
82456 if (vma_wants_writenotify(vma)) {
82457 vma->vm_page_prot = vm_get_page_prot(newflags & ~VM_SHARED);
82458 @@ -337,6 +453,17 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
82459 end = start + len;
82460 if (end <= start)
82461 return -ENOMEM;
82462 +
82463 +#ifdef CONFIG_PAX_SEGMEXEC
82464 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
82465 + if (end > SEGMEXEC_TASK_SIZE)
82466 + return -EINVAL;
82467 + } else
82468 +#endif
82469 +
82470 + if (end > TASK_SIZE)
82471 + return -EINVAL;
82472 +
82473 if (!arch_validate_prot(prot))
82474 return -EINVAL;
82475
82476 @@ -344,7 +471,7 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
82477 /*
82478 * Does the application expect PROT_READ to imply PROT_EXEC:
82479 */
82480 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
82481 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
82482 prot |= PROT_EXEC;
82483
82484 vm_flags = calc_vm_prot_bits(prot);
82485 @@ -376,6 +503,11 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
82486 if (start > vma->vm_start)
82487 prev = vma;
82488
82489 +#ifdef CONFIG_PAX_MPROTECT
82490 + if (current->mm->binfmt && current->mm->binfmt->handle_mprotect)
82491 + current->mm->binfmt->handle_mprotect(vma, vm_flags);
82492 +#endif
82493 +
82494 for (nstart = start ; ; ) {
82495 unsigned long newflags;
82496
82497 @@ -386,6 +518,14 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
82498
82499 /* newflags >> 4 shift VM_MAY% in place of VM_% */
82500 if ((newflags & ~(newflags >> 4)) & (VM_READ | VM_WRITE | VM_EXEC)) {
82501 + if (prot & (PROT_WRITE | PROT_EXEC))
82502 + gr_log_rwxmprotect(vma->vm_file);
82503 +
82504 + error = -EACCES;
82505 + goto out;
82506 + }
82507 +
82508 + if (!gr_acl_handle_mprotect(vma->vm_file, prot)) {
82509 error = -EACCES;
82510 goto out;
82511 }
82512 @@ -400,6 +540,9 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
82513 error = mprotect_fixup(vma, &prev, nstart, tmp, newflags);
82514 if (error)
82515 goto out;
82516 +
82517 + track_exec_limit(current->mm, nstart, tmp, vm_flags);
82518 +
82519 nstart = tmp;
82520
82521 if (nstart < prev->vm_end)
82522 diff --git a/mm/mremap.c b/mm/mremap.c
82523 index 463a257..c0c7a92 100644
82524 --- a/mm/mremap.c
82525 +++ b/mm/mremap.c
82526 @@ -126,6 +126,12 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd,
82527 continue;
82528 pte = ptep_get_and_clear(mm, old_addr, old_pte);
82529 pte = move_pte(pte, new_vma->vm_page_prot, old_addr, new_addr);
82530 +
82531 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
82532 + if (!(__supported_pte_mask & _PAGE_NX) && (new_vma->vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC)
82533 + pte = pte_exprotect(pte);
82534 +#endif
82535 +
82536 set_pte_at(mm, new_addr, new_pte, pte);
82537 }
82538
82539 @@ -318,6 +324,11 @@ static struct vm_area_struct *vma_to_resize(unsigned long addr,
82540 if (is_vm_hugetlb_page(vma))
82541 goto Einval;
82542
82543 +#ifdef CONFIG_PAX_SEGMEXEC
82544 + if (pax_find_mirror_vma(vma))
82545 + goto Einval;
82546 +#endif
82547 +
82548 /* We can't remap across vm area boundaries */
82549 if (old_len > vma->vm_end - addr)
82550 goto Efault;
82551 @@ -373,20 +384,25 @@ static unsigned long mremap_to(unsigned long addr, unsigned long old_len,
82552 unsigned long ret = -EINVAL;
82553 unsigned long charged = 0;
82554 unsigned long map_flags;
82555 + unsigned long pax_task_size = TASK_SIZE;
82556
82557 if (new_addr & ~PAGE_MASK)
82558 goto out;
82559
82560 - if (new_len > TASK_SIZE || new_addr > TASK_SIZE - new_len)
82561 +#ifdef CONFIG_PAX_SEGMEXEC
82562 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
82563 + pax_task_size = SEGMEXEC_TASK_SIZE;
82564 +#endif
82565 +
82566 + pax_task_size -= PAGE_SIZE;
82567 +
82568 + if (new_len > TASK_SIZE || new_addr > pax_task_size - new_len)
82569 goto out;
82570
82571 /* Check if the location we're moving into overlaps the
82572 * old location at all, and fail if it does.
82573 */
82574 - if ((new_addr <= addr) && (new_addr+new_len) > addr)
82575 - goto out;
82576 -
82577 - if ((addr <= new_addr) && (addr+old_len) > new_addr)
82578 + if (addr + old_len > new_addr && new_addr + new_len > addr)
82579 goto out;
82580
82581 ret = do_munmap(mm, new_addr, new_len);
82582 @@ -455,6 +471,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
82583 unsigned long ret = -EINVAL;
82584 unsigned long charged = 0;
82585 bool locked = false;
82586 + unsigned long pax_task_size = TASK_SIZE;
82587
82588 down_write(&current->mm->mmap_sem);
82589
82590 @@ -475,6 +492,17 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
82591 if (!new_len)
82592 goto out;
82593
82594 +#ifdef CONFIG_PAX_SEGMEXEC
82595 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
82596 + pax_task_size = SEGMEXEC_TASK_SIZE;
82597 +#endif
82598 +
82599 + pax_task_size -= PAGE_SIZE;
82600 +
82601 + if (new_len > pax_task_size || addr > pax_task_size-new_len ||
82602 + old_len > pax_task_size || addr > pax_task_size-old_len)
82603 + goto out;
82604 +
82605 if (flags & MREMAP_FIXED) {
82606 if (flags & MREMAP_MAYMOVE)
82607 ret = mremap_to(addr, old_len, new_addr, new_len,
82608 @@ -524,6 +552,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
82609 new_addr = addr;
82610 }
82611 ret = addr;
82612 + track_exec_limit(vma->vm_mm, vma->vm_start, addr + new_len, vma->vm_flags);
82613 goto out;
82614 }
82615 }
82616 @@ -547,7 +576,12 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
82617 goto out;
82618 }
82619
82620 + map_flags = vma->vm_flags;
82621 ret = move_vma(vma, addr, old_len, new_len, new_addr, &locked);
82622 + if (!(ret & ~PAGE_MASK)) {
82623 + track_exec_limit(current->mm, addr, addr + old_len, 0UL);
82624 + track_exec_limit(current->mm, new_addr, new_addr + new_len, map_flags);
82625 + }
82626 }
82627 out:
82628 if (ret & ~PAGE_MASK)
82629 diff --git a/mm/nommu.c b/mm/nommu.c
82630 index e001768..9b52b30 100644
82631 --- a/mm/nommu.c
82632 +++ b/mm/nommu.c
82633 @@ -63,7 +63,6 @@ int sysctl_overcommit_memory = OVERCOMMIT_GUESS; /* heuristic overcommit */
82634 int sysctl_overcommit_ratio = 50; /* default is 50% */
82635 int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT;
82636 int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS;
82637 -int heap_stack_gap = 0;
82638
82639 atomic_long_t mmap_pages_allocated;
82640
82641 @@ -841,15 +840,6 @@ struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
82642 EXPORT_SYMBOL(find_vma);
82643
82644 /*
82645 - * find a VMA
82646 - * - we don't extend stack VMAs under NOMMU conditions
82647 - */
82648 -struct vm_area_struct *find_extend_vma(struct mm_struct *mm, unsigned long addr)
82649 -{
82650 - return find_vma(mm, addr);
82651 -}
82652 -
82653 -/*
82654 * expand a stack to a given address
82655 * - not supported under NOMMU conditions
82656 */
82657 @@ -1560,6 +1550,7 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
82658
82659 /* most fields are the same, copy all, and then fixup */
82660 *new = *vma;
82661 + INIT_LIST_HEAD(&new->anon_vma_chain);
82662 *region = *vma->vm_region;
82663 new->vm_region = region;
82664
82665 @@ -1992,8 +1983,8 @@ int generic_file_remap_pages(struct vm_area_struct *vma, unsigned long addr,
82666 }
82667 EXPORT_SYMBOL(generic_file_remap_pages);
82668
82669 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
82670 - unsigned long addr, void *buf, int len, int write)
82671 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
82672 + unsigned long addr, void *buf, size_t len, int write)
82673 {
82674 struct vm_area_struct *vma;
82675
82676 @@ -2034,8 +2025,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
82677 *
82678 * The caller must hold a reference on @mm.
82679 */
82680 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
82681 - void *buf, int len, int write)
82682 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
82683 + void *buf, size_t len, int write)
82684 {
82685 return __access_remote_vm(NULL, mm, addr, buf, len, write);
82686 }
82687 @@ -2044,7 +2035,7 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
82688 * Access another process' address space.
82689 * - source/target buffer must be kernel space
82690 */
82691 -int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write)
82692 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write)
82693 {
82694 struct mm_struct *mm;
82695
82696 diff --git a/mm/page-writeback.c b/mm/page-writeback.c
82697 index efe6814..64b4701 100644
82698 --- a/mm/page-writeback.c
82699 +++ b/mm/page-writeback.c
82700 @@ -659,7 +659,7 @@ unsigned long bdi_dirty_limit(struct backing_dev_info *bdi, unsigned long dirty)
82701 * card's bdi_dirty may rush to many times higher than bdi_setpoint.
82702 * - the bdi dirty thresh drops quickly due to change of JBOD workload
82703 */
82704 -static unsigned long bdi_position_ratio(struct backing_dev_info *bdi,
82705 +static unsigned long __intentional_overflow(-1) bdi_position_ratio(struct backing_dev_info *bdi,
82706 unsigned long thresh,
82707 unsigned long bg_thresh,
82708 unsigned long dirty,
82709 @@ -1634,7 +1634,7 @@ ratelimit_handler(struct notifier_block *self, unsigned long action,
82710 }
82711 }
82712
82713 -static struct notifier_block __cpuinitdata ratelimit_nb = {
82714 +static struct notifier_block ratelimit_nb = {
82715 .notifier_call = ratelimit_handler,
82716 .next = NULL,
82717 };
82718 diff --git a/mm/page_alloc.c b/mm/page_alloc.c
82719 index 8fcced7..ebcd481 100644
82720 --- a/mm/page_alloc.c
82721 +++ b/mm/page_alloc.c
82722 @@ -59,6 +59,7 @@
82723 #include <linux/migrate.h>
82724 #include <linux/page-debug-flags.h>
82725 #include <linux/sched/rt.h>
82726 +#include <linux/random.h>
82727
82728 #include <asm/tlbflush.h>
82729 #include <asm/div64.h>
82730 @@ -344,7 +345,7 @@ out:
82731 * This usage means that zero-order pages may not be compound.
82732 */
82733
82734 -static void free_compound_page(struct page *page)
82735 +void free_compound_page(struct page *page)
82736 {
82737 __free_pages_ok(page, compound_order(page));
82738 }
82739 @@ -701,6 +702,10 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
82740 int i;
82741 int bad = 0;
82742
82743 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
82744 + unsigned long index = 1UL << order;
82745 +#endif
82746 +
82747 trace_mm_page_free(page, order);
82748 kmemcheck_free_shadow(page, order);
82749
82750 @@ -716,6 +721,12 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
82751 debug_check_no_obj_freed(page_address(page),
82752 PAGE_SIZE << order);
82753 }
82754 +
82755 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
82756 + for (; index; --index)
82757 + sanitize_highpage(page + index - 1);
82758 +#endif
82759 +
82760 arch_free_page(page, order);
82761 kernel_map_pages(page, 1 << order, 0);
82762
82763 @@ -738,6 +749,19 @@ static void __free_pages_ok(struct page *page, unsigned int order)
82764 local_irq_restore(flags);
82765 }
82766
82767 +#ifdef CONFIG_PAX_LATENT_ENTROPY
82768 +bool __meminitdata extra_latent_entropy;
82769 +
82770 +static int __init setup_pax_extra_latent_entropy(char *str)
82771 +{
82772 + extra_latent_entropy = true;
82773 + return 0;
82774 +}
82775 +early_param("pax_extra_latent_entropy", setup_pax_extra_latent_entropy);
82776 +
82777 +volatile u64 latent_entropy;
82778 +#endif
82779 +
82780 /*
82781 * Read access to zone->managed_pages is safe because it's unsigned long,
82782 * but we still need to serialize writers. Currently all callers of
82783 @@ -760,6 +784,19 @@ void __meminit __free_pages_bootmem(struct page *page, unsigned int order)
82784 set_page_count(p, 0);
82785 }
82786
82787 +#ifdef CONFIG_PAX_LATENT_ENTROPY
82788 + if (extra_latent_entropy && !PageHighMem(page) && page_to_pfn(page) < 0x100000) {
82789 + u64 hash = 0;
82790 + size_t index, end = PAGE_SIZE * nr_pages / sizeof hash;
82791 + const u64 *data = lowmem_page_address(page);
82792 +
82793 + for (index = 0; index < end; index++)
82794 + hash ^= hash + data[index];
82795 + latent_entropy ^= hash;
82796 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
82797 + }
82798 +#endif
82799 +
82800 page_zone(page)->managed_pages += 1 << order;
82801 set_page_refcounted(page);
82802 __free_pages(page, order);
82803 @@ -869,8 +906,10 @@ static int prep_new_page(struct page *page, int order, gfp_t gfp_flags)
82804 arch_alloc_page(page, order);
82805 kernel_map_pages(page, 1 << order, 1);
82806
82807 +#ifndef CONFIG_PAX_MEMORY_SANITIZE
82808 if (gfp_flags & __GFP_ZERO)
82809 prep_zero_page(page, order, gfp_flags);
82810 +#endif
82811
82812 if (order && (gfp_flags & __GFP_COMP))
82813 prep_compound_page(page, order);
82814 diff --git a/mm/percpu.c b/mm/percpu.c
82815 index 8c8e08f..73a5cda 100644
82816 --- a/mm/percpu.c
82817 +++ b/mm/percpu.c
82818 @@ -122,7 +122,7 @@ static unsigned int pcpu_low_unit_cpu __read_mostly;
82819 static unsigned int pcpu_high_unit_cpu __read_mostly;
82820
82821 /* the address of the first chunk which starts with the kernel static area */
82822 -void *pcpu_base_addr __read_mostly;
82823 +void *pcpu_base_addr __read_only;
82824 EXPORT_SYMBOL_GPL(pcpu_base_addr);
82825
82826 static const int *pcpu_unit_map __read_mostly; /* cpu -> unit */
82827 diff --git a/mm/process_vm_access.c b/mm/process_vm_access.c
82828 index fd26d04..0cea1b0 100644
82829 --- a/mm/process_vm_access.c
82830 +++ b/mm/process_vm_access.c
82831 @@ -13,6 +13,7 @@
82832 #include <linux/uio.h>
82833 #include <linux/sched.h>
82834 #include <linux/highmem.h>
82835 +#include <linux/security.h>
82836 #include <linux/ptrace.h>
82837 #include <linux/slab.h>
82838 #include <linux/syscalls.h>
82839 @@ -258,19 +259,19 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
82840 size_t iov_l_curr_offset = 0;
82841 ssize_t iov_len;
82842
82843 + return -ENOSYS; // PaX: until properly audited
82844 +
82845 /*
82846 * Work out how many pages of struct pages we're going to need
82847 * when eventually calling get_user_pages
82848 */
82849 for (i = 0; i < riovcnt; i++) {
82850 iov_len = rvec[i].iov_len;
82851 - if (iov_len > 0) {
82852 - nr_pages_iov = ((unsigned long)rvec[i].iov_base
82853 - + iov_len)
82854 - / PAGE_SIZE - (unsigned long)rvec[i].iov_base
82855 - / PAGE_SIZE + 1;
82856 - nr_pages = max(nr_pages, nr_pages_iov);
82857 - }
82858 + if (iov_len <= 0)
82859 + continue;
82860 + nr_pages_iov = ((unsigned long)rvec[i].iov_base + iov_len) / PAGE_SIZE -
82861 + (unsigned long)rvec[i].iov_base / PAGE_SIZE + 1;
82862 + nr_pages = max(nr_pages, nr_pages_iov);
82863 }
82864
82865 if (nr_pages == 0)
82866 @@ -298,6 +299,11 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
82867 goto free_proc_pages;
82868 }
82869
82870 + if (gr_handle_ptrace(task, vm_write ? PTRACE_POKETEXT : PTRACE_ATTACH)) {
82871 + rc = -EPERM;
82872 + goto put_task_struct;
82873 + }
82874 +
82875 mm = mm_access(task, PTRACE_MODE_ATTACH);
82876 if (!mm || IS_ERR(mm)) {
82877 rc = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH;
82878 diff --git a/mm/rmap.c b/mm/rmap.c
82879 index 807c96b..0e05279 100644
82880 --- a/mm/rmap.c
82881 +++ b/mm/rmap.c
82882 @@ -163,6 +163,10 @@ int anon_vma_prepare(struct vm_area_struct *vma)
82883 struct anon_vma *anon_vma = vma->anon_vma;
82884 struct anon_vma_chain *avc;
82885
82886 +#ifdef CONFIG_PAX_SEGMEXEC
82887 + struct anon_vma_chain *avc_m = NULL;
82888 +#endif
82889 +
82890 might_sleep();
82891 if (unlikely(!anon_vma)) {
82892 struct mm_struct *mm = vma->vm_mm;
82893 @@ -172,6 +176,12 @@ int anon_vma_prepare(struct vm_area_struct *vma)
82894 if (!avc)
82895 goto out_enomem;
82896
82897 +#ifdef CONFIG_PAX_SEGMEXEC
82898 + avc_m = anon_vma_chain_alloc(GFP_KERNEL);
82899 + if (!avc_m)
82900 + goto out_enomem_free_avc;
82901 +#endif
82902 +
82903 anon_vma = find_mergeable_anon_vma(vma);
82904 allocated = NULL;
82905 if (!anon_vma) {
82906 @@ -185,6 +195,18 @@ int anon_vma_prepare(struct vm_area_struct *vma)
82907 /* page_table_lock to protect against threads */
82908 spin_lock(&mm->page_table_lock);
82909 if (likely(!vma->anon_vma)) {
82910 +
82911 +#ifdef CONFIG_PAX_SEGMEXEC
82912 + struct vm_area_struct *vma_m = pax_find_mirror_vma(vma);
82913 +
82914 + if (vma_m) {
82915 + BUG_ON(vma_m->anon_vma);
82916 + vma_m->anon_vma = anon_vma;
82917 + anon_vma_chain_link(vma_m, avc_m, anon_vma);
82918 + avc_m = NULL;
82919 + }
82920 +#endif
82921 +
82922 vma->anon_vma = anon_vma;
82923 anon_vma_chain_link(vma, avc, anon_vma);
82924 allocated = NULL;
82925 @@ -195,12 +217,24 @@ int anon_vma_prepare(struct vm_area_struct *vma)
82926
82927 if (unlikely(allocated))
82928 put_anon_vma(allocated);
82929 +
82930 +#ifdef CONFIG_PAX_SEGMEXEC
82931 + if (unlikely(avc_m))
82932 + anon_vma_chain_free(avc_m);
82933 +#endif
82934 +
82935 if (unlikely(avc))
82936 anon_vma_chain_free(avc);
82937 }
82938 return 0;
82939
82940 out_enomem_free_avc:
82941 +
82942 +#ifdef CONFIG_PAX_SEGMEXEC
82943 + if (avc_m)
82944 + anon_vma_chain_free(avc_m);
82945 +#endif
82946 +
82947 anon_vma_chain_free(avc);
82948 out_enomem:
82949 return -ENOMEM;
82950 @@ -236,7 +270,7 @@ static inline void unlock_anon_vma_root(struct anon_vma *root)
82951 * Attach the anon_vmas from src to dst.
82952 * Returns 0 on success, -ENOMEM on failure.
82953 */
82954 -int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
82955 +int anon_vma_clone(struct vm_area_struct *dst, const struct vm_area_struct *src)
82956 {
82957 struct anon_vma_chain *avc, *pavc;
82958 struct anon_vma *root = NULL;
82959 @@ -269,7 +303,7 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
82960 * the corresponding VMA in the parent process is attached to.
82961 * Returns 0 on success, non-zero on failure.
82962 */
82963 -int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
82964 +int anon_vma_fork(struct vm_area_struct *vma, const struct vm_area_struct *pvma)
82965 {
82966 struct anon_vma_chain *avc;
82967 struct anon_vma *anon_vma;
82968 diff --git a/mm/shmem.c b/mm/shmem.c
82969 index 1c44af7..cefe9a6 100644
82970 --- a/mm/shmem.c
82971 +++ b/mm/shmem.c
82972 @@ -31,7 +31,7 @@
82973 #include <linux/export.h>
82974 #include <linux/swap.h>
82975
82976 -static struct vfsmount *shm_mnt;
82977 +struct vfsmount *shm_mnt;
82978
82979 #ifdef CONFIG_SHMEM
82980 /*
82981 @@ -75,7 +75,7 @@ static struct vfsmount *shm_mnt;
82982 #define BOGO_DIRENT_SIZE 20
82983
82984 /* Symlink up to this size is kmalloc'ed instead of using a swappable page */
82985 -#define SHORT_SYMLINK_LEN 128
82986 +#define SHORT_SYMLINK_LEN 64
82987
82988 /*
82989 * shmem_fallocate and shmem_writepage communicate via inode->i_private
82990 @@ -2201,6 +2201,11 @@ static const struct xattr_handler *shmem_xattr_handlers[] = {
82991 static int shmem_xattr_validate(const char *name)
82992 {
82993 struct { const char *prefix; size_t len; } arr[] = {
82994 +
82995 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
82996 + { XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN},
82997 +#endif
82998 +
82999 { XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN },
83000 { XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN }
83001 };
83002 @@ -2256,6 +2261,15 @@ static int shmem_setxattr(struct dentry *dentry, const char *name,
83003 if (err)
83004 return err;
83005
83006 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
83007 + if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) {
83008 + if (strcmp(name, XATTR_NAME_PAX_FLAGS))
83009 + return -EOPNOTSUPP;
83010 + if (size > 8)
83011 + return -EINVAL;
83012 + }
83013 +#endif
83014 +
83015 return simple_xattr_set(&info->xattrs, name, value, size, flags);
83016 }
83017
83018 @@ -2568,8 +2582,7 @@ int shmem_fill_super(struct super_block *sb, void *data, int silent)
83019 int err = -ENOMEM;
83020
83021 /* Round up to L1_CACHE_BYTES to resist false sharing */
83022 - sbinfo = kzalloc(max((int)sizeof(struct shmem_sb_info),
83023 - L1_CACHE_BYTES), GFP_KERNEL);
83024 + sbinfo = kzalloc(max(sizeof(struct shmem_sb_info), L1_CACHE_BYTES), GFP_KERNEL);
83025 if (!sbinfo)
83026 return -ENOMEM;
83027
83028 diff --git a/mm/slab.c b/mm/slab.c
83029 index 856e4a1..fafb820 100644
83030 --- a/mm/slab.c
83031 +++ b/mm/slab.c
83032 @@ -306,7 +306,7 @@ struct kmem_list3 {
83033 * Need this for bootstrapping a per node allocator.
83034 */
83035 #define NUM_INIT_LISTS (3 * MAX_NUMNODES)
83036 -static struct kmem_list3 __initdata initkmem_list3[NUM_INIT_LISTS];
83037 +static struct kmem_list3 initkmem_list3[NUM_INIT_LISTS];
83038 #define CACHE_CACHE 0
83039 #define SIZE_AC MAX_NUMNODES
83040 #define SIZE_L3 (2 * MAX_NUMNODES)
83041 @@ -407,10 +407,10 @@ static void kmem_list3_init(struct kmem_list3 *parent)
83042 if ((x)->max_freeable < i) \
83043 (x)->max_freeable = i; \
83044 } while (0)
83045 -#define STATS_INC_ALLOCHIT(x) atomic_inc(&(x)->allochit)
83046 -#define STATS_INC_ALLOCMISS(x) atomic_inc(&(x)->allocmiss)
83047 -#define STATS_INC_FREEHIT(x) atomic_inc(&(x)->freehit)
83048 -#define STATS_INC_FREEMISS(x) atomic_inc(&(x)->freemiss)
83049 +#define STATS_INC_ALLOCHIT(x) atomic_inc_unchecked(&(x)->allochit)
83050 +#define STATS_INC_ALLOCMISS(x) atomic_inc_unchecked(&(x)->allocmiss)
83051 +#define STATS_INC_FREEHIT(x) atomic_inc_unchecked(&(x)->freehit)
83052 +#define STATS_INC_FREEMISS(x) atomic_inc_unchecked(&(x)->freemiss)
83053 #else
83054 #define STATS_INC_ACTIVE(x) do { } while (0)
83055 #define STATS_DEC_ACTIVE(x) do { } while (0)
83056 @@ -518,7 +518,7 @@ static inline void *index_to_obj(struct kmem_cache *cache, struct slab *slab,
83057 * reciprocal_divide(offset, cache->reciprocal_buffer_size)
83058 */
83059 static inline unsigned int obj_to_index(const struct kmem_cache *cache,
83060 - const struct slab *slab, void *obj)
83061 + const struct slab *slab, const void *obj)
83062 {
83063 u32 offset = (obj - slab->s_mem);
83064 return reciprocal_divide(offset, cache->reciprocal_buffer_size);
83065 @@ -539,12 +539,13 @@ EXPORT_SYMBOL(malloc_sizes);
83066 struct cache_names {
83067 char *name;
83068 char *name_dma;
83069 + char *name_usercopy;
83070 };
83071
83072 static struct cache_names __initdata cache_names[] = {
83073 -#define CACHE(x) { .name = "size-" #x, .name_dma = "size-" #x "(DMA)" },
83074 +#define CACHE(x) { .name = "size-" #x, .name_dma = "size-" #x "(DMA)", .name_usercopy = "size-" #x "(USERCOPY)" },
83075 #include <linux/kmalloc_sizes.h>
83076 - {NULL,}
83077 + {NULL}
83078 #undef CACHE
83079 };
83080
83081 @@ -729,6 +730,12 @@ static inline struct kmem_cache *__find_general_cachep(size_t size,
83082 if (unlikely(gfpflags & GFP_DMA))
83083 return csizep->cs_dmacachep;
83084 #endif
83085 +
83086 +#ifdef CONFIG_PAX_USERCOPY_SLABS
83087 + if (unlikely(gfpflags & GFP_USERCOPY))
83088 + return csizep->cs_usercopycachep;
83089 +#endif
83090 +
83091 return csizep->cs_cachep;
83092 }
83093
83094 @@ -1482,7 +1489,7 @@ static int __cpuinit cpuup_callback(struct notifier_block *nfb,
83095 return notifier_from_errno(err);
83096 }
83097
83098 -static struct notifier_block __cpuinitdata cpucache_notifier = {
83099 +static struct notifier_block cpucache_notifier = {
83100 &cpuup_callback, NULL, 0
83101 };
83102
83103 @@ -1667,12 +1674,12 @@ void __init kmem_cache_init(void)
83104 */
83105
83106 sizes[INDEX_AC].cs_cachep = create_kmalloc_cache(names[INDEX_AC].name,
83107 - sizes[INDEX_AC].cs_size, ARCH_KMALLOC_FLAGS);
83108 + sizes[INDEX_AC].cs_size, ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
83109
83110 if (INDEX_AC != INDEX_L3)
83111 sizes[INDEX_L3].cs_cachep =
83112 create_kmalloc_cache(names[INDEX_L3].name,
83113 - sizes[INDEX_L3].cs_size, ARCH_KMALLOC_FLAGS);
83114 + sizes[INDEX_L3].cs_size, ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
83115
83116 slab_early_init = 0;
83117
83118 @@ -1686,13 +1693,20 @@ void __init kmem_cache_init(void)
83119 */
83120 if (!sizes->cs_cachep)
83121 sizes->cs_cachep = create_kmalloc_cache(names->name,
83122 - sizes->cs_size, ARCH_KMALLOC_FLAGS);
83123 + sizes->cs_size, ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
83124
83125 #ifdef CONFIG_ZONE_DMA
83126 sizes->cs_dmacachep = create_kmalloc_cache(
83127 names->name_dma, sizes->cs_size,
83128 SLAB_CACHE_DMA|ARCH_KMALLOC_FLAGS);
83129 #endif
83130 +
83131 +#ifdef CONFIG_PAX_USERCOPY_SLABS
83132 + sizes->cs_usercopycachep = create_kmalloc_cache(
83133 + names->name_usercopy, sizes->cs_size,
83134 + ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
83135 +#endif
83136 +
83137 sizes++;
83138 names++;
83139 }
83140 @@ -3924,6 +3938,7 @@ void kfree(const void *objp)
83141
83142 if (unlikely(ZERO_OR_NULL_PTR(objp)))
83143 return;
83144 + VM_BUG_ON(!virt_addr_valid(objp));
83145 local_irq_save(flags);
83146 kfree_debugcheck(objp);
83147 c = virt_to_cache(objp);
83148 @@ -4365,10 +4380,10 @@ void slabinfo_show_stats(struct seq_file *m, struct kmem_cache *cachep)
83149 }
83150 /* cpu stats */
83151 {
83152 - unsigned long allochit = atomic_read(&cachep->allochit);
83153 - unsigned long allocmiss = atomic_read(&cachep->allocmiss);
83154 - unsigned long freehit = atomic_read(&cachep->freehit);
83155 - unsigned long freemiss = atomic_read(&cachep->freemiss);
83156 + unsigned long allochit = atomic_read_unchecked(&cachep->allochit);
83157 + unsigned long allocmiss = atomic_read_unchecked(&cachep->allocmiss);
83158 + unsigned long freehit = atomic_read_unchecked(&cachep->freehit);
83159 + unsigned long freemiss = atomic_read_unchecked(&cachep->freemiss);
83160
83161 seq_printf(m, " : cpustat %6lu %6lu %6lu %6lu",
83162 allochit, allocmiss, freehit, freemiss);
83163 @@ -4600,13 +4615,71 @@ static const struct file_operations proc_slabstats_operations = {
83164 static int __init slab_proc_init(void)
83165 {
83166 #ifdef CONFIG_DEBUG_SLAB_LEAK
83167 - proc_create("slab_allocators", 0, NULL, &proc_slabstats_operations);
83168 + proc_create("slab_allocators", S_IRUSR, NULL, &proc_slabstats_operations);
83169 #endif
83170 return 0;
83171 }
83172 module_init(slab_proc_init);
83173 #endif
83174
83175 +bool is_usercopy_object(const void *ptr)
83176 +{
83177 + struct page *page;
83178 + struct kmem_cache *cachep;
83179 +
83180 + if (ZERO_OR_NULL_PTR(ptr))
83181 + return false;
83182 +
83183 + if (!slab_is_available())
83184 + return false;
83185 +
83186 + if (!virt_addr_valid(ptr))
83187 + return false;
83188 +
83189 + page = virt_to_head_page(ptr);
83190 +
83191 + if (!PageSlab(page))
83192 + return false;
83193 +
83194 + cachep = page->slab_cache;
83195 + return cachep->flags & SLAB_USERCOPY;
83196 +}
83197 +
83198 +#ifdef CONFIG_PAX_USERCOPY
83199 +const char *check_heap_object(const void *ptr, unsigned long n)
83200 +{
83201 + struct page *page;
83202 + struct kmem_cache *cachep;
83203 + struct slab *slabp;
83204 + unsigned int objnr;
83205 + unsigned long offset;
83206 +
83207 + if (ZERO_OR_NULL_PTR(ptr))
83208 + return "<null>";
83209 +
83210 + if (!virt_addr_valid(ptr))
83211 + return NULL;
83212 +
83213 + page = virt_to_head_page(ptr);
83214 +
83215 + if (!PageSlab(page))
83216 + return NULL;
83217 +
83218 + cachep = page->slab_cache;
83219 + if (!(cachep->flags & SLAB_USERCOPY))
83220 + return cachep->name;
83221 +
83222 + slabp = page->slab_page;
83223 + objnr = obj_to_index(cachep, slabp, ptr);
83224 + BUG_ON(objnr >= cachep->num);
83225 + offset = ptr - index_to_obj(cachep, slabp, objnr) - obj_offset(cachep);
83226 + if (offset <= cachep->object_size && n <= cachep->object_size - offset)
83227 + return NULL;
83228 +
83229 + return cachep->name;
83230 +}
83231 +#endif
83232 +
83233 /**
83234 * ksize - get the actual amount of memory allocated for a given object
83235 * @objp: Pointer to the object
83236 diff --git a/mm/slab.h b/mm/slab.h
83237 index 34a98d6..73633d1 100644
83238 --- a/mm/slab.h
83239 +++ b/mm/slab.h
83240 @@ -58,7 +58,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
83241
83242 /* Legal flag mask for kmem_cache_create(), for various configurations */
83243 #define SLAB_CORE_FLAGS (SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA | SLAB_PANIC | \
83244 - SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS )
83245 + SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS | SLAB_USERCOPY)
83246
83247 #if defined(CONFIG_DEBUG_SLAB)
83248 #define SLAB_DEBUG_FLAGS (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER)
83249 @@ -220,6 +220,9 @@ static inline struct kmem_cache *cache_from_obj(struct kmem_cache *s, void *x)
83250 return s;
83251
83252 page = virt_to_head_page(x);
83253 +
83254 + BUG_ON(!PageSlab(page));
83255 +
83256 cachep = page->slab_cache;
83257 if (slab_equal_or_root(cachep, s))
83258 return cachep;
83259 diff --git a/mm/slab_common.c b/mm/slab_common.c
83260 index 3f3cd97..93b0236 100644
83261 --- a/mm/slab_common.c
83262 +++ b/mm/slab_common.c
83263 @@ -22,7 +22,7 @@
83264
83265 #include "slab.h"
83266
83267 -enum slab_state slab_state;
83268 +enum slab_state slab_state __read_only;
83269 LIST_HEAD(slab_caches);
83270 DEFINE_MUTEX(slab_mutex);
83271 struct kmem_cache *kmem_cache;
83272 @@ -209,7 +209,7 @@ kmem_cache_create_memcg(struct mem_cgroup *memcg, const char *name, size_t size,
83273
83274 err = __kmem_cache_create(s, flags);
83275 if (!err) {
83276 - s->refcount = 1;
83277 + atomic_set(&s->refcount, 1);
83278 list_add(&s->list, &slab_caches);
83279 memcg_cache_list_add(memcg, s);
83280 } else {
83281 @@ -255,8 +255,7 @@ void kmem_cache_destroy(struct kmem_cache *s)
83282
83283 get_online_cpus();
83284 mutex_lock(&slab_mutex);
83285 - s->refcount--;
83286 - if (!s->refcount) {
83287 + if (atomic_dec_and_test(&s->refcount)) {
83288 list_del(&s->list);
83289
83290 if (!__kmem_cache_shutdown(s)) {
83291 @@ -302,7 +301,7 @@ void __init create_boot_cache(struct kmem_cache *s, const char *name, size_t siz
83292 panic("Creation of kmalloc slab %s size=%zd failed. Reason %d\n",
83293 name, size, err);
83294
83295 - s->refcount = -1; /* Exempt from merging for now */
83296 + atomic_set(&s->refcount, -1); /* Exempt from merging for now */
83297 }
83298
83299 struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
83300 @@ -315,7 +314,7 @@ struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
83301
83302 create_boot_cache(s, name, size, flags);
83303 list_add(&s->list, &slab_caches);
83304 - s->refcount = 1;
83305 + atomic_set(&s->refcount, 1);
83306 return s;
83307 }
83308
83309 diff --git a/mm/slob.c b/mm/slob.c
83310 index eeed4a0..6ee34ec 100644
83311 --- a/mm/slob.c
83312 +++ b/mm/slob.c
83313 @@ -157,7 +157,7 @@ static void set_slob(slob_t *s, slobidx_t size, slob_t *next)
83314 /*
83315 * Return the size of a slob block.
83316 */
83317 -static slobidx_t slob_units(slob_t *s)
83318 +static slobidx_t slob_units(const slob_t *s)
83319 {
83320 if (s->units > 0)
83321 return s->units;
83322 @@ -167,7 +167,7 @@ static slobidx_t slob_units(slob_t *s)
83323 /*
83324 * Return the next free slob block pointer after this one.
83325 */
83326 -static slob_t *slob_next(slob_t *s)
83327 +static slob_t *slob_next(const slob_t *s)
83328 {
83329 slob_t *base = (slob_t *)((unsigned long)s & PAGE_MASK);
83330 slobidx_t next;
83331 @@ -182,14 +182,14 @@ static slob_t *slob_next(slob_t *s)
83332 /*
83333 * Returns true if s is the last free block in its page.
83334 */
83335 -static int slob_last(slob_t *s)
83336 +static int slob_last(const slob_t *s)
83337 {
83338 return !((unsigned long)slob_next(s) & ~PAGE_MASK);
83339 }
83340
83341 -static void *slob_new_pages(gfp_t gfp, int order, int node)
83342 +static struct page *slob_new_pages(gfp_t gfp, unsigned int order, int node)
83343 {
83344 - void *page;
83345 + struct page *page;
83346
83347 #ifdef CONFIG_NUMA
83348 if (node != NUMA_NO_NODE)
83349 @@ -201,14 +201,18 @@ static void *slob_new_pages(gfp_t gfp, int order, int node)
83350 if (!page)
83351 return NULL;
83352
83353 - return page_address(page);
83354 + __SetPageSlab(page);
83355 + return page;
83356 }
83357
83358 -static void slob_free_pages(void *b, int order)
83359 +static void slob_free_pages(struct page *sp, int order)
83360 {
83361 if (current->reclaim_state)
83362 current->reclaim_state->reclaimed_slab += 1 << order;
83363 - free_pages((unsigned long)b, order);
83364 + __ClearPageSlab(sp);
83365 + reset_page_mapcount(sp);
83366 + sp->private = 0;
83367 + __free_pages(sp, order);
83368 }
83369
83370 /*
83371 @@ -313,15 +317,15 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
83372
83373 /* Not enough space: must allocate a new page */
83374 if (!b) {
83375 - b = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
83376 - if (!b)
83377 + sp = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
83378 + if (!sp)
83379 return NULL;
83380 - sp = virt_to_page(b);
83381 - __SetPageSlab(sp);
83382 + b = page_address(sp);
83383
83384 spin_lock_irqsave(&slob_lock, flags);
83385 sp->units = SLOB_UNITS(PAGE_SIZE);
83386 sp->freelist = b;
83387 + sp->private = 0;
83388 INIT_LIST_HEAD(&sp->list);
83389 set_slob(b, SLOB_UNITS(PAGE_SIZE), b + SLOB_UNITS(PAGE_SIZE));
83390 set_slob_page_free(sp, slob_list);
83391 @@ -359,9 +363,7 @@ static void slob_free(void *block, int size)
83392 if (slob_page_free(sp))
83393 clear_slob_page_free(sp);
83394 spin_unlock_irqrestore(&slob_lock, flags);
83395 - __ClearPageSlab(sp);
83396 - page_mapcount_reset(sp);
83397 - slob_free_pages(b, 0);
83398 + slob_free_pages(sp, 0);
83399 return;
83400 }
83401
83402 @@ -424,11 +426,10 @@ out:
83403 */
83404
83405 static __always_inline void *
83406 -__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
83407 +__do_kmalloc_node_align(size_t size, gfp_t gfp, int node, unsigned long caller, int align)
83408 {
83409 - unsigned int *m;
83410 - int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
83411 - void *ret;
83412 + slob_t *m;
83413 + void *ret = NULL;
83414
83415 gfp &= gfp_allowed_mask;
83416
83417 @@ -442,23 +443,41 @@ __do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
83418
83419 if (!m)
83420 return NULL;
83421 - *m = size;
83422 + BUILD_BUG_ON(ARCH_KMALLOC_MINALIGN < 2 * SLOB_UNIT);
83423 + BUILD_BUG_ON(ARCH_SLAB_MINALIGN < 2 * SLOB_UNIT);
83424 + m[0].units = size;
83425 + m[1].units = align;
83426 ret = (void *)m + align;
83427
83428 trace_kmalloc_node(caller, ret,
83429 size, size + align, gfp, node);
83430 } else {
83431 unsigned int order = get_order(size);
83432 + struct page *page;
83433
83434 if (likely(order))
83435 gfp |= __GFP_COMP;
83436 - ret = slob_new_pages(gfp, order, node);
83437 + page = slob_new_pages(gfp, order, node);
83438 + if (page) {
83439 + ret = page_address(page);
83440 + page->private = size;
83441 + }
83442
83443 trace_kmalloc_node(caller, ret,
83444 size, PAGE_SIZE << order, gfp, node);
83445 }
83446
83447 - kmemleak_alloc(ret, size, 1, gfp);
83448 + return ret;
83449 +}
83450 +
83451 +static __always_inline void *
83452 +__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
83453 +{
83454 + int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
83455 + void *ret = __do_kmalloc_node_align(size, gfp, node, caller, align);
83456 +
83457 + if (!ZERO_OR_NULL_PTR(ret))
83458 + kmemleak_alloc(ret, size, 1, gfp);
83459 return ret;
83460 }
83461
83462 @@ -493,34 +512,112 @@ void kfree(const void *block)
83463 return;
83464 kmemleak_free(block);
83465
83466 + VM_BUG_ON(!virt_addr_valid(block));
83467 sp = virt_to_page(block);
83468 - if (PageSlab(sp)) {
83469 + VM_BUG_ON(!PageSlab(sp));
83470 + if (!sp->private) {
83471 int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
83472 - unsigned int *m = (unsigned int *)(block - align);
83473 - slob_free(m, *m + align);
83474 - } else
83475 + slob_t *m = (slob_t *)(block - align);
83476 + slob_free(m, m[0].units + align);
83477 + } else {
83478 + __ClearPageSlab(sp);
83479 + reset_page_mapcount(sp);
83480 + sp->private = 0;
83481 __free_pages(sp, compound_order(sp));
83482 + }
83483 }
83484 EXPORT_SYMBOL(kfree);
83485
83486 +bool is_usercopy_object(const void *ptr)
83487 +{
83488 + if (!slab_is_available())
83489 + return false;
83490 +
83491 + // PAX: TODO
83492 +
83493 + return false;
83494 +}
83495 +
83496 +#ifdef CONFIG_PAX_USERCOPY
83497 +const char *check_heap_object(const void *ptr, unsigned long n)
83498 +{
83499 + struct page *page;
83500 + const slob_t *free;
83501 + const void *base;
83502 + unsigned long flags;
83503 +
83504 + if (ZERO_OR_NULL_PTR(ptr))
83505 + return "<null>";
83506 +
83507 + if (!virt_addr_valid(ptr))
83508 + return NULL;
83509 +
83510 + page = virt_to_head_page(ptr);
83511 + if (!PageSlab(page))
83512 + return NULL;
83513 +
83514 + if (page->private) {
83515 + base = page;
83516 + if (base <= ptr && n <= page->private - (ptr - base))
83517 + return NULL;
83518 + return "<slob>";
83519 + }
83520 +
83521 + /* some tricky double walking to find the chunk */
83522 + spin_lock_irqsave(&slob_lock, flags);
83523 + base = (void *)((unsigned long)ptr & PAGE_MASK);
83524 + free = page->freelist;
83525 +
83526 + while (!slob_last(free) && (void *)free <= ptr) {
83527 + base = free + slob_units(free);
83528 + free = slob_next(free);
83529 + }
83530 +
83531 + while (base < (void *)free) {
83532 + slobidx_t m = ((slob_t *)base)[0].units, align = ((slob_t *)base)[1].units;
83533 + int size = SLOB_UNIT * SLOB_UNITS(m + align);
83534 + int offset;
83535 +
83536 + if (ptr < base + align)
83537 + break;
83538 +
83539 + offset = ptr - base - align;
83540 + if (offset >= m) {
83541 + base += size;
83542 + continue;
83543 + }
83544 +
83545 + if (n > m - offset)
83546 + break;
83547 +
83548 + spin_unlock_irqrestore(&slob_lock, flags);
83549 + return NULL;
83550 + }
83551 +
83552 + spin_unlock_irqrestore(&slob_lock, flags);
83553 + return "<slob>";
83554 +}
83555 +#endif
83556 +
83557 /* can't use ksize for kmem_cache_alloc memory, only kmalloc */
83558 size_t ksize(const void *block)
83559 {
83560 struct page *sp;
83561 int align;
83562 - unsigned int *m;
83563 + slob_t *m;
83564
83565 BUG_ON(!block);
83566 if (unlikely(block == ZERO_SIZE_PTR))
83567 return 0;
83568
83569 sp = virt_to_page(block);
83570 - if (unlikely(!PageSlab(sp)))
83571 - return PAGE_SIZE << compound_order(sp);
83572 + VM_BUG_ON(!PageSlab(sp));
83573 + if (sp->private)
83574 + return sp->private;
83575
83576 align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
83577 - m = (unsigned int *)(block - align);
83578 - return SLOB_UNITS(*m) * SLOB_UNIT;
83579 + m = (slob_t *)(block - align);
83580 + return SLOB_UNITS(m[0].units) * SLOB_UNIT;
83581 }
83582 EXPORT_SYMBOL(ksize);
83583
83584 @@ -536,23 +633,33 @@ int __kmem_cache_create(struct kmem_cache *c, unsigned long flags)
83585
83586 void *kmem_cache_alloc_node(struct kmem_cache *c, gfp_t flags, int node)
83587 {
83588 - void *b;
83589 + void *b = NULL;
83590
83591 flags &= gfp_allowed_mask;
83592
83593 lockdep_trace_alloc(flags);
83594
83595 +#ifdef CONFIG_PAX_USERCOPY_SLABS
83596 + b = __do_kmalloc_node_align(c->size, flags, node, _RET_IP_, c->align);
83597 +#else
83598 if (c->size < PAGE_SIZE) {
83599 b = slob_alloc(c->size, flags, c->align, node);
83600 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
83601 SLOB_UNITS(c->size) * SLOB_UNIT,
83602 flags, node);
83603 } else {
83604 - b = slob_new_pages(flags, get_order(c->size), node);
83605 + struct page *sp;
83606 +
83607 + sp = slob_new_pages(flags, get_order(c->size), node);
83608 + if (sp) {
83609 + b = page_address(sp);
83610 + sp->private = c->size;
83611 + }
83612 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
83613 PAGE_SIZE << get_order(c->size),
83614 flags, node);
83615 }
83616 +#endif
83617
83618 if (c->ctor)
83619 c->ctor(b);
83620 @@ -564,10 +671,14 @@ EXPORT_SYMBOL(kmem_cache_alloc_node);
83621
83622 static void __kmem_cache_free(void *b, int size)
83623 {
83624 - if (size < PAGE_SIZE)
83625 + struct page *sp;
83626 +
83627 + sp = virt_to_page(b);
83628 + BUG_ON(!PageSlab(sp));
83629 + if (!sp->private)
83630 slob_free(b, size);
83631 else
83632 - slob_free_pages(b, get_order(size));
83633 + slob_free_pages(sp, get_order(size));
83634 }
83635
83636 static void kmem_rcu_free(struct rcu_head *head)
83637 @@ -580,17 +691,31 @@ static void kmem_rcu_free(struct rcu_head *head)
83638
83639 void kmem_cache_free(struct kmem_cache *c, void *b)
83640 {
83641 + int size = c->size;
83642 +
83643 +#ifdef CONFIG_PAX_USERCOPY_SLABS
83644 + if (size + c->align < PAGE_SIZE) {
83645 + size += c->align;
83646 + b -= c->align;
83647 + }
83648 +#endif
83649 +
83650 kmemleak_free_recursive(b, c->flags);
83651 if (unlikely(c->flags & SLAB_DESTROY_BY_RCU)) {
83652 struct slob_rcu *slob_rcu;
83653 - slob_rcu = b + (c->size - sizeof(struct slob_rcu));
83654 - slob_rcu->size = c->size;
83655 + slob_rcu = b + (size - sizeof(struct slob_rcu));
83656 + slob_rcu->size = size;
83657 call_rcu(&slob_rcu->head, kmem_rcu_free);
83658 } else {
83659 - __kmem_cache_free(b, c->size);
83660 + __kmem_cache_free(b, size);
83661 }
83662
83663 +#ifdef CONFIG_PAX_USERCOPY_SLABS
83664 + trace_kfree(_RET_IP_, b);
83665 +#else
83666 trace_kmem_cache_free(_RET_IP_, b);
83667 +#endif
83668 +
83669 }
83670 EXPORT_SYMBOL(kmem_cache_free);
83671
83672 diff --git a/mm/slub.c b/mm/slub.c
83673 index 4aec537..a64753d 100644
83674 --- a/mm/slub.c
83675 +++ b/mm/slub.c
83676 @@ -197,7 +197,7 @@ struct track {
83677
83678 enum track_item { TRACK_ALLOC, TRACK_FREE };
83679
83680 -#ifdef CONFIG_SYSFS
83681 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
83682 static int sysfs_slab_add(struct kmem_cache *);
83683 static int sysfs_slab_alias(struct kmem_cache *, const char *);
83684 static void sysfs_slab_remove(struct kmem_cache *);
83685 @@ -518,7 +518,7 @@ static void print_track(const char *s, struct track *t)
83686 if (!t->addr)
83687 return;
83688
83689 - printk(KERN_ERR "INFO: %s in %pS age=%lu cpu=%u pid=%d\n",
83690 + printk(KERN_ERR "INFO: %s in %pA age=%lu cpu=%u pid=%d\n",
83691 s, (void *)t->addr, jiffies - t->when, t->cpu, t->pid);
83692 #ifdef CONFIG_STACKTRACE
83693 {
83694 @@ -2653,7 +2653,7 @@ static int slub_min_objects;
83695 * Merge control. If this is set then no merging of slab caches will occur.
83696 * (Could be removed. This was introduced to pacify the merge skeptics.)
83697 */
83698 -static int slub_nomerge;
83699 +static int slub_nomerge = 1;
83700
83701 /*
83702 * Calculate the order of allocation given an slab object size.
83703 @@ -3181,6 +3181,10 @@ EXPORT_SYMBOL(kmalloc_caches);
83704 static struct kmem_cache *kmalloc_dma_caches[SLUB_PAGE_SHIFT];
83705 #endif
83706
83707 +#ifdef CONFIG_PAX_USERCOPY_SLABS
83708 +static struct kmem_cache *kmalloc_usercopy_caches[SLUB_PAGE_SHIFT];
83709 +#endif
83710 +
83711 static int __init setup_slub_min_order(char *str)
83712 {
83713 get_option(&str, &slub_min_order);
83714 @@ -3272,6 +3276,13 @@ static struct kmem_cache *get_slab(size_t size, gfp_t flags)
83715 return kmalloc_dma_caches[index];
83716
83717 #endif
83718 +
83719 +#ifdef CONFIG_PAX_USERCOPY_SLABS
83720 + if (flags & SLAB_USERCOPY)
83721 + return kmalloc_usercopy_caches[index];
83722 +
83723 +#endif
83724 +
83725 return kmalloc_caches[index];
83726 }
83727
83728 @@ -3340,6 +3351,59 @@ void *__kmalloc_node(size_t size, gfp_t flags, int node)
83729 EXPORT_SYMBOL(__kmalloc_node);
83730 #endif
83731
83732 +bool is_usercopy_object(const void *ptr)
83733 +{
83734 + struct page *page;
83735 + struct kmem_cache *s;
83736 +
83737 + if (ZERO_OR_NULL_PTR(ptr))
83738 + return false;
83739 +
83740 + if (!slab_is_available())
83741 + return false;
83742 +
83743 + if (!virt_addr_valid(ptr))
83744 + return false;
83745 +
83746 + page = virt_to_head_page(ptr);
83747 +
83748 + if (!PageSlab(page))
83749 + return false;
83750 +
83751 + s = page->slab_cache;
83752 + return s->flags & SLAB_USERCOPY;
83753 +}
83754 +
83755 +#ifdef CONFIG_PAX_USERCOPY
83756 +const char *check_heap_object(const void *ptr, unsigned long n)
83757 +{
83758 + struct page *page;
83759 + struct kmem_cache *s;
83760 + unsigned long offset;
83761 +
83762 + if (ZERO_OR_NULL_PTR(ptr))
83763 + return "<null>";
83764 +
83765 + if (!virt_addr_valid(ptr))
83766 + return NULL;
83767 +
83768 + page = virt_to_head_page(ptr);
83769 +
83770 + if (!PageSlab(page))
83771 + return NULL;
83772 +
83773 + s = page->slab_cache;
83774 + if (!(s->flags & SLAB_USERCOPY))
83775 + return s->name;
83776 +
83777 + offset = (ptr - page_address(page)) % s->size;
83778 + if (offset <= s->object_size && n <= s->object_size - offset)
83779 + return NULL;
83780 +
83781 + return s->name;
83782 +}
83783 +#endif
83784 +
83785 size_t ksize(const void *object)
83786 {
83787 struct page *page;
83788 @@ -3404,6 +3468,7 @@ void kfree(const void *x)
83789 if (unlikely(ZERO_OR_NULL_PTR(x)))
83790 return;
83791
83792 + VM_BUG_ON(!virt_addr_valid(x));
83793 page = virt_to_head_page(x);
83794 if (unlikely(!PageSlab(page))) {
83795 BUG_ON(!PageCompound(page));
83796 @@ -3712,17 +3777,17 @@ void __init kmem_cache_init(void)
83797
83798 /* Caches that are not of the two-to-the-power-of size */
83799 if (KMALLOC_MIN_SIZE <= 32) {
83800 - kmalloc_caches[1] = create_kmalloc_cache("kmalloc-96", 96, 0);
83801 + kmalloc_caches[1] = create_kmalloc_cache("kmalloc-96", 96, SLAB_USERCOPY);
83802 caches++;
83803 }
83804
83805 if (KMALLOC_MIN_SIZE <= 64) {
83806 - kmalloc_caches[2] = create_kmalloc_cache("kmalloc-192", 192, 0);
83807 + kmalloc_caches[2] = create_kmalloc_cache("kmalloc-192", 192, SLAB_USERCOPY);
83808 caches++;
83809 }
83810
83811 for (i = KMALLOC_SHIFT_LOW; i < SLUB_PAGE_SHIFT; i++) {
83812 - kmalloc_caches[i] = create_kmalloc_cache("kmalloc", 1 << i, 0);
83813 + kmalloc_caches[i] = create_kmalloc_cache("kmalloc", 1 << i, SLAB_USERCOPY);
83814 caches++;
83815 }
83816
83817 @@ -3764,6 +3829,22 @@ void __init kmem_cache_init(void)
83818 }
83819 }
83820 #endif
83821 +
83822 +#ifdef CONFIG_PAX_USERCOPY_SLABS
83823 + for (i = 0; i < SLUB_PAGE_SHIFT; i++) {
83824 + struct kmem_cache *s = kmalloc_caches[i];
83825 +
83826 + if (s && s->size) {
83827 + char *name = kasprintf(GFP_NOWAIT,
83828 + "usercopy-kmalloc-%d", s->object_size);
83829 +
83830 + BUG_ON(!name);
83831 + kmalloc_usercopy_caches[i] = create_kmalloc_cache(name,
83832 + s->object_size, SLAB_USERCOPY);
83833 + }
83834 + }
83835 +#endif
83836 +
83837 printk(KERN_INFO
83838 "SLUB: Genslabs=%d, HWalign=%d, Order=%d-%d, MinObjects=%d,"
83839 " CPUs=%d, Nodes=%d\n",
83840 @@ -3790,7 +3871,7 @@ static int slab_unmergeable(struct kmem_cache *s)
83841 /*
83842 * We may have set a slab to be unmergeable during bootstrap.
83843 */
83844 - if (s->refcount < 0)
83845 + if (atomic_read(&s->refcount) < 0)
83846 return 1;
83847
83848 return 0;
83849 @@ -3848,7 +3929,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
83850
83851 s = find_mergeable(memcg, size, align, flags, name, ctor);
83852 if (s) {
83853 - s->refcount++;
83854 + atomic_inc(&s->refcount);
83855 /*
83856 * Adjust the object sizes so that we clear
83857 * the complete object on kzalloc.
83858 @@ -3857,7 +3938,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
83859 s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *)));
83860
83861 if (sysfs_slab_alias(s, name)) {
83862 - s->refcount--;
83863 + atomic_dec(&s->refcount);
83864 s = NULL;
83865 }
83866 }
83867 @@ -3919,7 +4000,7 @@ static int __cpuinit slab_cpuup_callback(struct notifier_block *nfb,
83868 return NOTIFY_OK;
83869 }
83870
83871 -static struct notifier_block __cpuinitdata slab_notifier = {
83872 +static struct notifier_block slab_notifier = {
83873 .notifier_call = slab_cpuup_callback
83874 };
83875
83876 @@ -3977,7 +4058,7 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,
83877 }
83878 #endif
83879
83880 -#ifdef CONFIG_SYSFS
83881 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
83882 static int count_inuse(struct page *page)
83883 {
83884 return page->inuse;
83885 @@ -4364,12 +4445,12 @@ static void resiliency_test(void)
83886 validate_slab_cache(kmalloc_caches[9]);
83887 }
83888 #else
83889 -#ifdef CONFIG_SYSFS
83890 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
83891 static void resiliency_test(void) {};
83892 #endif
83893 #endif
83894
83895 -#ifdef CONFIG_SYSFS
83896 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
83897 enum slab_stat_type {
83898 SL_ALL, /* All slabs */
83899 SL_PARTIAL, /* Only partially allocated slabs */
83900 @@ -4613,7 +4694,7 @@ SLAB_ATTR_RO(ctor);
83901
83902 static ssize_t aliases_show(struct kmem_cache *s, char *buf)
83903 {
83904 - return sprintf(buf, "%d\n", s->refcount - 1);
83905 + return sprintf(buf, "%d\n", atomic_read(&s->refcount) - 1);
83906 }
83907 SLAB_ATTR_RO(aliases);
83908
83909 @@ -5266,6 +5347,7 @@ static char *create_unique_id(struct kmem_cache *s)
83910 return name;
83911 }
83912
83913 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
83914 static int sysfs_slab_add(struct kmem_cache *s)
83915 {
83916 int err;
83917 @@ -5323,6 +5405,7 @@ static void sysfs_slab_remove(struct kmem_cache *s)
83918 kobject_del(&s->kobj);
83919 kobject_put(&s->kobj);
83920 }
83921 +#endif
83922
83923 /*
83924 * Need to buffer aliases during bootup until sysfs becomes
83925 @@ -5336,6 +5419,7 @@ struct saved_alias {
83926
83927 static struct saved_alias *alias_list;
83928
83929 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
83930 static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
83931 {
83932 struct saved_alias *al;
83933 @@ -5358,6 +5442,7 @@ static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
83934 alias_list = al;
83935 return 0;
83936 }
83937 +#endif
83938
83939 static int __init slab_sysfs_init(void)
83940 {
83941 diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c
83942 index 1b7e22a..3fcd4f3 100644
83943 --- a/mm/sparse-vmemmap.c
83944 +++ b/mm/sparse-vmemmap.c
83945 @@ -128,7 +128,7 @@ pud_t * __meminit vmemmap_pud_populate(pgd_t *pgd, unsigned long addr, int node)
83946 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
83947 if (!p)
83948 return NULL;
83949 - pud_populate(&init_mm, pud, p);
83950 + pud_populate_kernel(&init_mm, pud, p);
83951 }
83952 return pud;
83953 }
83954 @@ -140,7 +140,7 @@ pgd_t * __meminit vmemmap_pgd_populate(unsigned long addr, int node)
83955 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
83956 if (!p)
83957 return NULL;
83958 - pgd_populate(&init_mm, pgd, p);
83959 + pgd_populate_kernel(&init_mm, pgd, p);
83960 }
83961 return pgd;
83962 }
83963 diff --git a/mm/sparse.c b/mm/sparse.c
83964 index 7ca6dc8..6472aa1 100644
83965 --- a/mm/sparse.c
83966 +++ b/mm/sparse.c
83967 @@ -783,7 +783,7 @@ static void clear_hwpoisoned_pages(struct page *memmap, int nr_pages)
83968
83969 for (i = 0; i < PAGES_PER_SECTION; i++) {
83970 if (PageHWPoison(&memmap[i])) {
83971 - atomic_long_sub(1, &num_poisoned_pages);
83972 + atomic_long_sub_unchecked(1, &num_poisoned_pages);
83973 ClearPageHWPoison(&memmap[i]);
83974 }
83975 }
83976 diff --git a/mm/swap.c b/mm/swap.c
83977 index 8a529a0..154ef26 100644
83978 --- a/mm/swap.c
83979 +++ b/mm/swap.c
83980 @@ -30,6 +30,7 @@
83981 #include <linux/backing-dev.h>
83982 #include <linux/memcontrol.h>
83983 #include <linux/gfp.h>
83984 +#include <linux/hugetlb.h>
83985
83986 #include "internal.h"
83987
83988 @@ -72,6 +73,8 @@ static void __put_compound_page(struct page *page)
83989
83990 __page_cache_release(page);
83991 dtor = get_compound_page_dtor(page);
83992 + if (!PageHuge(page))
83993 + BUG_ON(dtor != free_compound_page);
83994 (*dtor)(page);
83995 }
83996
83997 diff --git a/mm/swapfile.c b/mm/swapfile.c
83998 index a1f7772..9e982ac 100644
83999 --- a/mm/swapfile.c
84000 +++ b/mm/swapfile.c
84001 @@ -66,7 +66,7 @@ static DEFINE_MUTEX(swapon_mutex);
84002
84003 static DECLARE_WAIT_QUEUE_HEAD(proc_poll_wait);
84004 /* Activity counter to indicate that a swapon or swapoff has occurred */
84005 -static atomic_t proc_poll_event = ATOMIC_INIT(0);
84006 +static atomic_unchecked_t proc_poll_event = ATOMIC_INIT(0);
84007
84008 static inline unsigned char swap_count(unsigned char ent)
84009 {
84010 @@ -1683,7 +1683,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
84011 }
84012 filp_close(swap_file, NULL);
84013 err = 0;
84014 - atomic_inc(&proc_poll_event);
84015 + atomic_inc_unchecked(&proc_poll_event);
84016 wake_up_interruptible(&proc_poll_wait);
84017
84018 out_dput:
84019 @@ -1700,8 +1700,8 @@ static unsigned swaps_poll(struct file *file, poll_table *wait)
84020
84021 poll_wait(file, &proc_poll_wait, wait);
84022
84023 - if (seq->poll_event != atomic_read(&proc_poll_event)) {
84024 - seq->poll_event = atomic_read(&proc_poll_event);
84025 + if (seq->poll_event != atomic_read_unchecked(&proc_poll_event)) {
84026 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
84027 return POLLIN | POLLRDNORM | POLLERR | POLLPRI;
84028 }
84029
84030 @@ -1799,7 +1799,7 @@ static int swaps_open(struct inode *inode, struct file *file)
84031 return ret;
84032
84033 seq = file->private_data;
84034 - seq->poll_event = atomic_read(&proc_poll_event);
84035 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
84036 return 0;
84037 }
84038
84039 @@ -2142,7 +2142,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
84040 (frontswap_map) ? "FS" : "");
84041
84042 mutex_unlock(&swapon_mutex);
84043 - atomic_inc(&proc_poll_event);
84044 + atomic_inc_unchecked(&proc_poll_event);
84045 wake_up_interruptible(&proc_poll_wait);
84046
84047 if (S_ISREG(inode->i_mode))
84048 diff --git a/mm/util.c b/mm/util.c
84049 index ab1424d..7c5bd5a 100644
84050 --- a/mm/util.c
84051 +++ b/mm/util.c
84052 @@ -294,6 +294,12 @@ done:
84053 void arch_pick_mmap_layout(struct mm_struct *mm)
84054 {
84055 mm->mmap_base = TASK_UNMAPPED_BASE;
84056 +
84057 +#ifdef CONFIG_PAX_RANDMMAP
84058 + if (mm->pax_flags & MF_PAX_RANDMMAP)
84059 + mm->mmap_base += mm->delta_mmap;
84060 +#endif
84061 +
84062 mm->get_unmapped_area = arch_get_unmapped_area;
84063 mm->unmap_area = arch_unmap_area;
84064 }
84065 diff --git a/mm/vmalloc.c b/mm/vmalloc.c
84066 index 0f751f2..ef398a0 100644
84067 --- a/mm/vmalloc.c
84068 +++ b/mm/vmalloc.c
84069 @@ -39,8 +39,19 @@ static void vunmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end)
84070
84071 pte = pte_offset_kernel(pmd, addr);
84072 do {
84073 - pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
84074 - WARN_ON(!pte_none(ptent) && !pte_present(ptent));
84075 +
84076 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
84077 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr < (unsigned long)MODULES_EXEC_END) {
84078 + BUG_ON(!pte_exec(*pte));
84079 + set_pte_at(&init_mm, addr, pte, pfn_pte(__pa(addr) >> PAGE_SHIFT, PAGE_KERNEL_EXEC));
84080 + continue;
84081 + }
84082 +#endif
84083 +
84084 + {
84085 + pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
84086 + WARN_ON(!pte_none(ptent) && !pte_present(ptent));
84087 + }
84088 } while (pte++, addr += PAGE_SIZE, addr != end);
84089 }
84090
84091 @@ -100,16 +111,29 @@ static int vmap_pte_range(pmd_t *pmd, unsigned long addr,
84092 pte = pte_alloc_kernel(pmd, addr);
84093 if (!pte)
84094 return -ENOMEM;
84095 +
84096 + pax_open_kernel();
84097 do {
84098 struct page *page = pages[*nr];
84099
84100 - if (WARN_ON(!pte_none(*pte)))
84101 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
84102 + if (pgprot_val(prot) & _PAGE_NX)
84103 +#endif
84104 +
84105 + if (!pte_none(*pte)) {
84106 + pax_close_kernel();
84107 + WARN_ON(1);
84108 return -EBUSY;
84109 - if (WARN_ON(!page))
84110 + }
84111 + if (!page) {
84112 + pax_close_kernel();
84113 + WARN_ON(1);
84114 return -ENOMEM;
84115 + }
84116 set_pte_at(&init_mm, addr, pte, mk_pte(page, prot));
84117 (*nr)++;
84118 } while (pte++, addr += PAGE_SIZE, addr != end);
84119 + pax_close_kernel();
84120 return 0;
84121 }
84122
84123 @@ -119,7 +143,7 @@ static int vmap_pmd_range(pud_t *pud, unsigned long addr,
84124 pmd_t *pmd;
84125 unsigned long next;
84126
84127 - pmd = pmd_alloc(&init_mm, pud, addr);
84128 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
84129 if (!pmd)
84130 return -ENOMEM;
84131 do {
84132 @@ -136,7 +160,7 @@ static int vmap_pud_range(pgd_t *pgd, unsigned long addr,
84133 pud_t *pud;
84134 unsigned long next;
84135
84136 - pud = pud_alloc(&init_mm, pgd, addr);
84137 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
84138 if (!pud)
84139 return -ENOMEM;
84140 do {
84141 @@ -191,11 +215,20 @@ int is_vmalloc_or_module_addr(const void *x)
84142 * and fall back on vmalloc() if that fails. Others
84143 * just put it in the vmalloc space.
84144 */
84145 -#if defined(CONFIG_MODULES) && defined(MODULES_VADDR)
84146 +#ifdef CONFIG_MODULES
84147 +#ifdef MODULES_VADDR
84148 unsigned long addr = (unsigned long)x;
84149 if (addr >= MODULES_VADDR && addr < MODULES_END)
84150 return 1;
84151 #endif
84152 +
84153 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
84154 + if (x >= (const void *)MODULES_EXEC_VADDR && x < (const void *)MODULES_EXEC_END)
84155 + return 1;
84156 +#endif
84157 +
84158 +#endif
84159 +
84160 return is_vmalloc_addr(x);
84161 }
84162
84163 @@ -216,8 +249,14 @@ struct page *vmalloc_to_page(const void *vmalloc_addr)
84164
84165 if (!pgd_none(*pgd)) {
84166 pud_t *pud = pud_offset(pgd, addr);
84167 +#ifdef CONFIG_X86
84168 + if (!pud_large(*pud))
84169 +#endif
84170 if (!pud_none(*pud)) {
84171 pmd_t *pmd = pmd_offset(pud, addr);
84172 +#ifdef CONFIG_X86
84173 + if (!pmd_large(*pmd))
84174 +#endif
84175 if (!pmd_none(*pmd)) {
84176 pte_t *ptep, pte;
84177
84178 @@ -329,7 +368,7 @@ static void purge_vmap_area_lazy(void);
84179 * Allocate a region of KVA of the specified size and alignment, within the
84180 * vstart and vend.
84181 */
84182 -static struct vmap_area *alloc_vmap_area(unsigned long size,
84183 +static __size_overflow(1) struct vmap_area *alloc_vmap_area(unsigned long size,
84184 unsigned long align,
84185 unsigned long vstart, unsigned long vend,
84186 int node, gfp_t gfp_mask)
84187 @@ -1328,6 +1367,16 @@ static struct vm_struct *__get_vm_area_node(unsigned long size,
84188 struct vm_struct *area;
84189
84190 BUG_ON(in_interrupt());
84191 +
84192 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
84193 + if (flags & VM_KERNEXEC) {
84194 + if (start != VMALLOC_START || end != VMALLOC_END)
84195 + return NULL;
84196 + start = (unsigned long)MODULES_EXEC_VADDR;
84197 + end = (unsigned long)MODULES_EXEC_END;
84198 + }
84199 +#endif
84200 +
84201 if (flags & VM_IOREMAP) {
84202 int bit = fls(size);
84203
84204 @@ -1569,6 +1618,11 @@ void *vmap(struct page **pages, unsigned int count,
84205 if (count > totalram_pages)
84206 return NULL;
84207
84208 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
84209 + if (!(pgprot_val(prot) & _PAGE_NX))
84210 + flags |= VM_KERNEXEC;
84211 +#endif
84212 +
84213 area = get_vm_area_caller((count << PAGE_SHIFT), flags,
84214 __builtin_return_address(0));
84215 if (!area)
84216 @@ -1670,6 +1724,13 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
84217 if (!size || (size >> PAGE_SHIFT) > totalram_pages)
84218 goto fail;
84219
84220 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
84221 + if (!(pgprot_val(prot) & _PAGE_NX))
84222 + area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNLIST | VM_KERNEXEC,
84223 + VMALLOC_START, VMALLOC_END, node, gfp_mask, caller);
84224 + else
84225 +#endif
84226 +
84227 area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNLIST,
84228 start, end, node, gfp_mask, caller);
84229 if (!area)
84230 @@ -1845,10 +1906,9 @@ EXPORT_SYMBOL(vzalloc_node);
84231 * For tight control over page level allocator and protection flags
84232 * use __vmalloc() instead.
84233 */
84234 -
84235 void *vmalloc_exec(unsigned long size)
84236 {
84237 - return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
84238 + return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL_EXEC,
84239 NUMA_NO_NODE, __builtin_return_address(0));
84240 }
84241
84242 @@ -2139,6 +2199,8 @@ int remap_vmalloc_range(struct vm_area_struct *vma, void *addr,
84243 unsigned long uaddr = vma->vm_start;
84244 unsigned long usize = vma->vm_end - vma->vm_start;
84245
84246 + BUG_ON(vma->vm_mirror);
84247 +
84248 if ((PAGE_SIZE-1) & (unsigned long)addr)
84249 return -EINVAL;
84250
84251 @@ -2578,7 +2640,11 @@ static int s_show(struct seq_file *m, void *p)
84252 v->addr, v->addr + v->size, v->size);
84253
84254 if (v->caller)
84255 +#ifdef CONFIG_GRKERNSEC_HIDESYM
84256 + seq_printf(m, " %pK", v->caller);
84257 +#else
84258 seq_printf(m, " %pS", v->caller);
84259 +#endif
84260
84261 if (v->nr_pages)
84262 seq_printf(m, " pages=%d", v->nr_pages);
84263 diff --git a/mm/vmstat.c b/mm/vmstat.c
84264 index e1d8ed1..253fa3c 100644
84265 --- a/mm/vmstat.c
84266 +++ b/mm/vmstat.c
84267 @@ -78,7 +78,7 @@ void vm_events_fold_cpu(int cpu)
84268 *
84269 * vm_stat contains the global counters
84270 */
84271 -atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
84272 +atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
84273 EXPORT_SYMBOL(vm_stat);
84274
84275 #ifdef CONFIG_SMP
84276 @@ -454,7 +454,7 @@ void refresh_cpu_vm_stats(int cpu)
84277 v = p->vm_stat_diff[i];
84278 p->vm_stat_diff[i] = 0;
84279 local_irq_restore(flags);
84280 - atomic_long_add(v, &zone->vm_stat[i]);
84281 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
84282 global_diff[i] += v;
84283 #ifdef CONFIG_NUMA
84284 /* 3 seconds idle till flush */
84285 @@ -492,7 +492,7 @@ void refresh_cpu_vm_stats(int cpu)
84286
84287 for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
84288 if (global_diff[i])
84289 - atomic_long_add(global_diff[i], &vm_stat[i]);
84290 + atomic_long_add_unchecked(global_diff[i], &vm_stat[i]);
84291 }
84292
84293 void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
84294 @@ -503,8 +503,8 @@ void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
84295 if (pset->vm_stat_diff[i]) {
84296 int v = pset->vm_stat_diff[i];
84297 pset->vm_stat_diff[i] = 0;
84298 - atomic_long_add(v, &zone->vm_stat[i]);
84299 - atomic_long_add(v, &vm_stat[i]);
84300 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
84301 + atomic_long_add_unchecked(v, &vm_stat[i]);
84302 }
84303 }
84304 #endif
84305 @@ -1224,7 +1224,7 @@ static int __cpuinit vmstat_cpuup_callback(struct notifier_block *nfb,
84306 return NOTIFY_OK;
84307 }
84308
84309 -static struct notifier_block __cpuinitdata vmstat_notifier =
84310 +static struct notifier_block vmstat_notifier =
84311 { &vmstat_cpuup_callback, NULL, 0 };
84312 #endif
84313
84314 @@ -1239,10 +1239,20 @@ static int __init setup_vmstat(void)
84315 start_cpu_timer(cpu);
84316 #endif
84317 #ifdef CONFIG_PROC_FS
84318 - proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations);
84319 - proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops);
84320 - proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations);
84321 - proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations);
84322 + {
84323 + mode_t gr_mode = S_IRUGO;
84324 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
84325 + gr_mode = S_IRUSR;
84326 +#endif
84327 + proc_create("buddyinfo", gr_mode, NULL, &fragmentation_file_operations);
84328 + proc_create("pagetypeinfo", gr_mode, NULL, &pagetypeinfo_file_ops);
84329 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
84330 + proc_create("vmstat", gr_mode | S_IRGRP, NULL, &proc_vmstat_file_operations);
84331 +#else
84332 + proc_create("vmstat", gr_mode, NULL, &proc_vmstat_file_operations);
84333 +#endif
84334 + proc_create("zoneinfo", gr_mode, NULL, &proc_zoneinfo_file_operations);
84335 + }
84336 #endif
84337 return 0;
84338 }
84339 diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
84340 index 85addcd..c429a13 100644
84341 --- a/net/8021q/vlan.c
84342 +++ b/net/8021q/vlan.c
84343 @@ -114,6 +114,13 @@ void unregister_vlan_dev(struct net_device *dev, struct list_head *head)
84344 if (vlan_id)
84345 vlan_vid_del(real_dev, vlan_id);
84346
84347 + /* Take it out of our own structures, but be sure to interlock with
84348 + * HW accelerating devices or SW vlan input packet processing if
84349 + * VLAN is not 0 (leave it there for 802.1p).
84350 + */
84351 + if (vlan_id)
84352 + vlan_vid_del(real_dev, vlan_id);
84353 +
84354 /* Get rid of the vlan's reference to real_dev */
84355 dev_put(real_dev);
84356 }
84357 @@ -496,7 +503,7 @@ out:
84358 return NOTIFY_DONE;
84359 }
84360
84361 -static struct notifier_block vlan_notifier_block __read_mostly = {
84362 +static struct notifier_block vlan_notifier_block = {
84363 .notifier_call = vlan_device_event,
84364 };
84365
84366 @@ -571,8 +578,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
84367 err = -EPERM;
84368 if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
84369 break;
84370 - if ((args.u.name_type >= 0) &&
84371 - (args.u.name_type < VLAN_NAME_TYPE_HIGHEST)) {
84372 + if (args.u.name_type < VLAN_NAME_TYPE_HIGHEST) {
84373 struct vlan_net *vn;
84374
84375 vn = net_generic(net, vlan_net_id);
84376 diff --git a/net/9p/mod.c b/net/9p/mod.c
84377 index 6ab36ae..6f1841b 100644
84378 --- a/net/9p/mod.c
84379 +++ b/net/9p/mod.c
84380 @@ -84,7 +84,7 @@ static LIST_HEAD(v9fs_trans_list);
84381 void v9fs_register_trans(struct p9_trans_module *m)
84382 {
84383 spin_lock(&v9fs_trans_lock);
84384 - list_add_tail(&m->list, &v9fs_trans_list);
84385 + pax_list_add_tail((struct list_head *)&m->list, &v9fs_trans_list);
84386 spin_unlock(&v9fs_trans_lock);
84387 }
84388 EXPORT_SYMBOL(v9fs_register_trans);
84389 @@ -97,7 +97,7 @@ EXPORT_SYMBOL(v9fs_register_trans);
84390 void v9fs_unregister_trans(struct p9_trans_module *m)
84391 {
84392 spin_lock(&v9fs_trans_lock);
84393 - list_del_init(&m->list);
84394 + pax_list_del_init((struct list_head *)&m->list);
84395 spin_unlock(&v9fs_trans_lock);
84396 }
84397 EXPORT_SYMBOL(v9fs_unregister_trans);
84398 diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
84399 index 02efb25..41541a9 100644
84400 --- a/net/9p/trans_fd.c
84401 +++ b/net/9p/trans_fd.c
84402 @@ -425,7 +425,7 @@ static int p9_fd_write(struct p9_client *client, void *v, int len)
84403 oldfs = get_fs();
84404 set_fs(get_ds());
84405 /* The cast to a user pointer is valid due to the set_fs() */
84406 - ret = vfs_write(ts->wr, (__force void __user *)v, len, &ts->wr->f_pos);
84407 + ret = vfs_write(ts->wr, (void __force_user *)v, len, &ts->wr->f_pos);
84408 set_fs(oldfs);
84409
84410 if (ret <= 0 && ret != -ERESTARTSYS && ret != -EAGAIN)
84411 diff --git a/net/atm/atm_misc.c b/net/atm/atm_misc.c
84412 index 876fbe8..8bbea9f 100644
84413 --- a/net/atm/atm_misc.c
84414 +++ b/net/atm/atm_misc.c
84415 @@ -17,7 +17,7 @@ int atm_charge(struct atm_vcc *vcc, int truesize)
84416 if (atomic_read(&sk_atm(vcc)->sk_rmem_alloc) <= sk_atm(vcc)->sk_rcvbuf)
84417 return 1;
84418 atm_return(vcc, truesize);
84419 - atomic_inc(&vcc->stats->rx_drop);
84420 + atomic_inc_unchecked(&vcc->stats->rx_drop);
84421 return 0;
84422 }
84423 EXPORT_SYMBOL(atm_charge);
84424 @@ -39,7 +39,7 @@ struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc, int pdu_size,
84425 }
84426 }
84427 atm_return(vcc, guess);
84428 - atomic_inc(&vcc->stats->rx_drop);
84429 + atomic_inc_unchecked(&vcc->stats->rx_drop);
84430 return NULL;
84431 }
84432 EXPORT_SYMBOL(atm_alloc_charge);
84433 @@ -86,7 +86,7 @@ EXPORT_SYMBOL(atm_pcr_goal);
84434
84435 void sonet_copy_stats(struct k_sonet_stats *from, struct sonet_stats *to)
84436 {
84437 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
84438 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
84439 __SONET_ITEMS
84440 #undef __HANDLE_ITEM
84441 }
84442 @@ -94,7 +94,7 @@ EXPORT_SYMBOL(sonet_copy_stats);
84443
84444 void sonet_subtract_stats(struct k_sonet_stats *from, struct sonet_stats *to)
84445 {
84446 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
84447 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i,&from->i)
84448 __SONET_ITEMS
84449 #undef __HANDLE_ITEM
84450 }
84451 diff --git a/net/atm/lec.h b/net/atm/lec.h
84452 index a86aff9..3a0d6f6 100644
84453 --- a/net/atm/lec.h
84454 +++ b/net/atm/lec.h
84455 @@ -48,7 +48,7 @@ struct lane2_ops {
84456 const u8 *tlvs, u32 sizeoftlvs);
84457 void (*associate_indicator) (struct net_device *dev, const u8 *mac_addr,
84458 const u8 *tlvs, u32 sizeoftlvs);
84459 -};
84460 +} __no_const;
84461
84462 /*
84463 * ATM LAN Emulation supports both LLC & Dix Ethernet EtherType
84464 diff --git a/net/atm/proc.c b/net/atm/proc.c
84465 index 6ac35ff..ac0e136 100644
84466 --- a/net/atm/proc.c
84467 +++ b/net/atm/proc.c
84468 @@ -45,9 +45,9 @@ static void add_stats(struct seq_file *seq, const char *aal,
84469 const struct k_atm_aal_stats *stats)
84470 {
84471 seq_printf(seq, "%s ( %d %d %d %d %d )", aal,
84472 - atomic_read(&stats->tx), atomic_read(&stats->tx_err),
84473 - atomic_read(&stats->rx), atomic_read(&stats->rx_err),
84474 - atomic_read(&stats->rx_drop));
84475 + atomic_read_unchecked(&stats->tx),atomic_read_unchecked(&stats->tx_err),
84476 + atomic_read_unchecked(&stats->rx),atomic_read_unchecked(&stats->rx_err),
84477 + atomic_read_unchecked(&stats->rx_drop));
84478 }
84479
84480 static void atm_dev_info(struct seq_file *seq, const struct atm_dev *dev)
84481 diff --git a/net/atm/resources.c b/net/atm/resources.c
84482 index 0447d5d..3cf4728 100644
84483 --- a/net/atm/resources.c
84484 +++ b/net/atm/resources.c
84485 @@ -160,7 +160,7 @@ EXPORT_SYMBOL(atm_dev_deregister);
84486 static void copy_aal_stats(struct k_atm_aal_stats *from,
84487 struct atm_aal_stats *to)
84488 {
84489 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
84490 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
84491 __AAL_STAT_ITEMS
84492 #undef __HANDLE_ITEM
84493 }
84494 @@ -168,7 +168,7 @@ static void copy_aal_stats(struct k_atm_aal_stats *from,
84495 static void subtract_aal_stats(struct k_atm_aal_stats *from,
84496 struct atm_aal_stats *to)
84497 {
84498 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
84499 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i, &from->i)
84500 __AAL_STAT_ITEMS
84501 #undef __HANDLE_ITEM
84502 }
84503 diff --git a/net/ax25/sysctl_net_ax25.c b/net/ax25/sysctl_net_ax25.c
84504 index d5744b7..506bae3 100644
84505 --- a/net/ax25/sysctl_net_ax25.c
84506 +++ b/net/ax25/sysctl_net_ax25.c
84507 @@ -152,7 +152,7 @@ int ax25_register_dev_sysctl(ax25_dev *ax25_dev)
84508 {
84509 char path[sizeof("net/ax25/") + IFNAMSIZ];
84510 int k;
84511 - struct ctl_table *table;
84512 + ctl_table_no_const *table;
84513
84514 table = kmemdup(ax25_param_table, sizeof(ax25_param_table), GFP_KERNEL);
84515 if (!table)
84516 diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
84517 index a5bb0a7..e1d8b97 100644
84518 --- a/net/batman-adv/bat_iv_ogm.c
84519 +++ b/net/batman-adv/bat_iv_ogm.c
84520 @@ -63,7 +63,7 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
84521
84522 /* randomize initial seqno to avoid collision */
84523 get_random_bytes(&random_seqno, sizeof(random_seqno));
84524 - atomic_set(&hard_iface->bat_iv.ogm_seqno, random_seqno);
84525 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, random_seqno);
84526
84527 hard_iface->bat_iv.ogm_buff_len = BATADV_OGM_HLEN;
84528 ogm_buff = kmalloc(hard_iface->bat_iv.ogm_buff_len, GFP_ATOMIC);
84529 @@ -611,9 +611,9 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
84530 batadv_ogm_packet = (struct batadv_ogm_packet *)(*ogm_buff);
84531
84532 /* change sequence number to network order */
84533 - seqno = (uint32_t)atomic_read(&hard_iface->bat_iv.ogm_seqno);
84534 + seqno = (uint32_t)atomic_read_unchecked(&hard_iface->bat_iv.ogm_seqno);
84535 batadv_ogm_packet->seqno = htonl(seqno);
84536 - atomic_inc(&hard_iface->bat_iv.ogm_seqno);
84537 + atomic_inc_unchecked(&hard_iface->bat_iv.ogm_seqno);
84538
84539 batadv_ogm_packet->ttvn = atomic_read(&bat_priv->tt.vn);
84540 batadv_ogm_packet->tt_crc = htons(bat_priv->tt.local_crc);
84541 @@ -1013,7 +1013,7 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
84542 return;
84543
84544 /* could be changed by schedule_own_packet() */
84545 - if_incoming_seqno = atomic_read(&if_incoming->bat_iv.ogm_seqno);
84546 + if_incoming_seqno = atomic_read_unchecked(&if_incoming->bat_iv.ogm_seqno);
84547
84548 if (batadv_ogm_packet->flags & BATADV_DIRECTLINK)
84549 has_directlink_flag = 1;
84550 diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
84551 index 368219e..53f56f9 100644
84552 --- a/net/batman-adv/hard-interface.c
84553 +++ b/net/batman-adv/hard-interface.c
84554 @@ -370,7 +370,7 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
84555 hard_iface->batman_adv_ptype.dev = hard_iface->net_dev;
84556 dev_add_pack(&hard_iface->batman_adv_ptype);
84557
84558 - atomic_set(&hard_iface->frag_seqno, 1);
84559 + atomic_set_unchecked(&hard_iface->frag_seqno, 1);
84560 batadv_info(hard_iface->soft_iface, "Adding interface: %s\n",
84561 hard_iface->net_dev->name);
84562
84563 @@ -514,7 +514,7 @@ batadv_hardif_add_interface(struct net_device *net_dev)
84564 /* This can't be called via a bat_priv callback because
84565 * we have no bat_priv yet.
84566 */
84567 - atomic_set(&hard_iface->bat_iv.ogm_seqno, 1);
84568 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, 1);
84569 hard_iface->bat_iv.ogm_buff = NULL;
84570
84571 return hard_iface;
84572 diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
84573 index 2711e87..4ca48fa 100644
84574 --- a/net/batman-adv/soft-interface.c
84575 +++ b/net/batman-adv/soft-interface.c
84576 @@ -252,7 +252,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
84577 primary_if->net_dev->dev_addr, ETH_ALEN);
84578
84579 /* set broadcast sequence number */
84580 - seqno = atomic_inc_return(&bat_priv->bcast_seqno);
84581 + seqno = atomic_inc_return_unchecked(&bat_priv->bcast_seqno);
84582 bcast_packet->seqno = htonl(seqno);
84583
84584 batadv_add_bcast_packet_to_list(bat_priv, skb, brd_delay);
84585 @@ -527,7 +527,7 @@ struct net_device *batadv_softif_create(const char *name)
84586 atomic_set(&bat_priv->batman_queue_left, BATADV_BATMAN_QUEUE_LEN);
84587
84588 atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE);
84589 - atomic_set(&bat_priv->bcast_seqno, 1);
84590 + atomic_set_unchecked(&bat_priv->bcast_seqno, 1);
84591 atomic_set(&bat_priv->tt.vn, 0);
84592 atomic_set(&bat_priv->tt.local_changes, 0);
84593 atomic_set(&bat_priv->tt.ogm_append_cnt, 0);
84594 diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
84595 index 4cd87a0..348e705 100644
84596 --- a/net/batman-adv/types.h
84597 +++ b/net/batman-adv/types.h
84598 @@ -51,7 +51,7 @@
84599 struct batadv_hard_iface_bat_iv {
84600 unsigned char *ogm_buff;
84601 int ogm_buff_len;
84602 - atomic_t ogm_seqno;
84603 + atomic_unchecked_t ogm_seqno;
84604 };
84605
84606 /**
84607 @@ -75,7 +75,7 @@ struct batadv_hard_iface {
84608 int16_t if_num;
84609 char if_status;
84610 struct net_device *net_dev;
84611 - atomic_t frag_seqno;
84612 + atomic_unchecked_t frag_seqno;
84613 struct kobject *hardif_obj;
84614 atomic_t refcount;
84615 struct packet_type batman_adv_ptype;
84616 @@ -495,7 +495,7 @@ struct batadv_priv {
84617 #ifdef CONFIG_BATMAN_ADV_DEBUG
84618 atomic_t log_level;
84619 #endif
84620 - atomic_t bcast_seqno;
84621 + atomic_unchecked_t bcast_seqno;
84622 atomic_t bcast_queue_left;
84623 atomic_t batman_queue_left;
84624 char num_ifaces;
84625 diff --git a/net/batman-adv/unicast.c b/net/batman-adv/unicast.c
84626 index 50e079f..49ce2d2 100644
84627 --- a/net/batman-adv/unicast.c
84628 +++ b/net/batman-adv/unicast.c
84629 @@ -270,7 +270,7 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct batadv_priv *bat_priv,
84630 frag1->flags = BATADV_UNI_FRAG_HEAD | large_tail;
84631 frag2->flags = large_tail;
84632
84633 - seqno = atomic_add_return(2, &hard_iface->frag_seqno);
84634 + seqno = atomic_add_return_unchecked(2, &hard_iface->frag_seqno);
84635 frag1->seqno = htons(seqno - 1);
84636 frag2->seqno = htons(seqno);
84637
84638 diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
84639 index 6a93614..1415549 100644
84640 --- a/net/bluetooth/hci_sock.c
84641 +++ b/net/bluetooth/hci_sock.c
84642 @@ -929,7 +929,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname,
84643 uf.event_mask[1] = *((u32 *) f->event_mask + 1);
84644 }
84645
84646 - len = min_t(unsigned int, len, sizeof(uf));
84647 + len = min((size_t)len, sizeof(uf));
84648 if (copy_from_user(&uf, optval, len)) {
84649 err = -EFAULT;
84650 break;
84651 diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
84652 index 7c7e932..7a7815d 100644
84653 --- a/net/bluetooth/l2cap_core.c
84654 +++ b/net/bluetooth/l2cap_core.c
84655 @@ -3395,8 +3395,10 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len,
84656 break;
84657
84658 case L2CAP_CONF_RFC:
84659 - if (olen == sizeof(rfc))
84660 - memcpy(&rfc, (void *)val, olen);
84661 + if (olen != sizeof(rfc))
84662 + break;
84663 +
84664 + memcpy(&rfc, (void *)val, olen);
84665
84666 if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state) &&
84667 rfc.mode != chan->mode)
84668 diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
84669 index 1bcfb84..dad9f98 100644
84670 --- a/net/bluetooth/l2cap_sock.c
84671 +++ b/net/bluetooth/l2cap_sock.c
84672 @@ -479,7 +479,8 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
84673 struct sock *sk = sock->sk;
84674 struct l2cap_chan *chan = l2cap_pi(sk)->chan;
84675 struct l2cap_options opts;
84676 - int len, err = 0;
84677 + int err = 0;
84678 + size_t len = optlen;
84679 u32 opt;
84680
84681 BT_DBG("sk %p", sk);
84682 @@ -501,7 +502,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
84683 opts.max_tx = chan->max_tx;
84684 opts.txwin_size = chan->tx_win;
84685
84686 - len = min_t(unsigned int, sizeof(opts), optlen);
84687 + len = min(sizeof(opts), len);
84688 if (copy_from_user((char *) &opts, optval, len)) {
84689 err = -EFAULT;
84690 break;
84691 @@ -581,7 +582,8 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
84692 struct bt_security sec;
84693 struct bt_power pwr;
84694 struct l2cap_conn *conn;
84695 - int len, err = 0;
84696 + int err = 0;
84697 + size_t len = optlen;
84698 u32 opt;
84699
84700 BT_DBG("sk %p", sk);
84701 @@ -604,7 +606,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
84702
84703 sec.level = BT_SECURITY_LOW;
84704
84705 - len = min_t(unsigned int, sizeof(sec), optlen);
84706 + len = min(sizeof(sec), len);
84707 if (copy_from_user((char *) &sec, optval, len)) {
84708 err = -EFAULT;
84709 break;
84710 @@ -701,7 +703,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
84711
84712 pwr.force_active = BT_POWER_FORCE_ACTIVE_ON;
84713
84714 - len = min_t(unsigned int, sizeof(pwr), optlen);
84715 + len = min(sizeof(pwr), len);
84716 if (copy_from_user((char *) &pwr, optval, len)) {
84717 err = -EFAULT;
84718 break;
84719 diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
84720 index 7c9224b..381009e 100644
84721 --- a/net/bluetooth/rfcomm/sock.c
84722 +++ b/net/bluetooth/rfcomm/sock.c
84723 @@ -666,7 +666,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
84724 struct sock *sk = sock->sk;
84725 struct bt_security sec;
84726 int err = 0;
84727 - size_t len;
84728 + size_t len = optlen;
84729 u32 opt;
84730
84731 BT_DBG("sk %p", sk);
84732 @@ -688,7 +688,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
84733
84734 sec.level = BT_SECURITY_LOW;
84735
84736 - len = min_t(unsigned int, sizeof(sec), optlen);
84737 + len = min(sizeof(sec), len);
84738 if (copy_from_user((char *) &sec, optval, len)) {
84739 err = -EFAULT;
84740 break;
84741 diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
84742 index b6e44ad..5b0d514 100644
84743 --- a/net/bluetooth/rfcomm/tty.c
84744 +++ b/net/bluetooth/rfcomm/tty.c
84745 @@ -309,7 +309,7 @@ static void rfcomm_dev_del(struct rfcomm_dev *dev)
84746 BUG_ON(test_and_set_bit(RFCOMM_TTY_RELEASED, &dev->flags));
84747
84748 spin_lock_irqsave(&dev->port.lock, flags);
84749 - if (dev->port.count > 0) {
84750 + if (atomic_read(&dev->port.count) > 0) {
84751 spin_unlock_irqrestore(&dev->port.lock, flags);
84752 return;
84753 }
84754 @@ -659,10 +659,10 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp)
84755 return -ENODEV;
84756
84757 BT_DBG("dev %p dst %pMR channel %d opened %d", dev, &dev->dst,
84758 - dev->channel, dev->port.count);
84759 + dev->channel, atomic_read(&dev->port.count));
84760
84761 spin_lock_irqsave(&dev->port.lock, flags);
84762 - if (++dev->port.count > 1) {
84763 + if (atomic_inc_return(&dev->port.count) > 1) {
84764 spin_unlock_irqrestore(&dev->port.lock, flags);
84765 return 0;
84766 }
84767 @@ -727,10 +727,10 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp)
84768 return;
84769
84770 BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc,
84771 - dev->port.count);
84772 + atomic_read(&dev->port.count));
84773
84774 spin_lock_irqsave(&dev->port.lock, flags);
84775 - if (!--dev->port.count) {
84776 + if (!atomic_dec_return(&dev->port.count)) {
84777 spin_unlock_irqrestore(&dev->port.lock, flags);
84778 if (dev->tty_dev->parent)
84779 device_move(dev->tty_dev, NULL, DPM_ORDER_DEV_LAST);
84780 diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
84781 index 8d493c9..3849e49 100644
84782 --- a/net/bridge/netfilter/ebtables.c
84783 +++ b/net/bridge/netfilter/ebtables.c
84784 @@ -1525,7 +1525,7 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
84785 tmp.valid_hooks = t->table->valid_hooks;
84786 }
84787 mutex_unlock(&ebt_mutex);
84788 - if (copy_to_user(user, &tmp, *len) != 0){
84789 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0){
84790 BUGPRINT("c2u Didn't work\n");
84791 ret = -EFAULT;
84792 break;
84793 @@ -2331,7 +2331,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
84794 goto out;
84795 tmp.valid_hooks = t->valid_hooks;
84796
84797 - if (copy_to_user(user, &tmp, *len) != 0) {
84798 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
84799 ret = -EFAULT;
84800 break;
84801 }
84802 @@ -2342,7 +2342,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
84803 tmp.entries_size = t->table->entries_size;
84804 tmp.valid_hooks = t->table->valid_hooks;
84805
84806 - if (copy_to_user(user, &tmp, *len) != 0) {
84807 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
84808 ret = -EFAULT;
84809 break;
84810 }
84811 diff --git a/net/caif/cfctrl.c b/net/caif/cfctrl.c
84812 index a376ec1..1fbd6be 100644
84813 --- a/net/caif/cfctrl.c
84814 +++ b/net/caif/cfctrl.c
84815 @@ -10,6 +10,7 @@
84816 #include <linux/spinlock.h>
84817 #include <linux/slab.h>
84818 #include <linux/pkt_sched.h>
84819 +#include <linux/sched.h>
84820 #include <net/caif/caif_layer.h>
84821 #include <net/caif/cfpkt.h>
84822 #include <net/caif/cfctrl.h>
84823 @@ -43,8 +44,8 @@ struct cflayer *cfctrl_create(void)
84824 memset(&dev_info, 0, sizeof(dev_info));
84825 dev_info.id = 0xff;
84826 cfsrvl_init(&this->serv, 0, &dev_info, false);
84827 - atomic_set(&this->req_seq_no, 1);
84828 - atomic_set(&this->rsp_seq_no, 1);
84829 + atomic_set_unchecked(&this->req_seq_no, 1);
84830 + atomic_set_unchecked(&this->rsp_seq_no, 1);
84831 this->serv.layer.receive = cfctrl_recv;
84832 sprintf(this->serv.layer.name, "ctrl");
84833 this->serv.layer.ctrlcmd = cfctrl_ctrlcmd;
84834 @@ -130,8 +131,8 @@ static void cfctrl_insert_req(struct cfctrl *ctrl,
84835 struct cfctrl_request_info *req)
84836 {
84837 spin_lock_bh(&ctrl->info_list_lock);
84838 - atomic_inc(&ctrl->req_seq_no);
84839 - req->sequence_no = atomic_read(&ctrl->req_seq_no);
84840 + atomic_inc_unchecked(&ctrl->req_seq_no);
84841 + req->sequence_no = atomic_read_unchecked(&ctrl->req_seq_no);
84842 list_add_tail(&req->list, &ctrl->list);
84843 spin_unlock_bh(&ctrl->info_list_lock);
84844 }
84845 @@ -149,7 +150,7 @@ static struct cfctrl_request_info *cfctrl_remove_req(struct cfctrl *ctrl,
84846 if (p != first)
84847 pr_warn("Requests are not received in order\n");
84848
84849 - atomic_set(&ctrl->rsp_seq_no,
84850 + atomic_set_unchecked(&ctrl->rsp_seq_no,
84851 p->sequence_no);
84852 list_del(&p->list);
84853 goto out;
84854 diff --git a/net/can/af_can.c b/net/can/af_can.c
84855 index c48e522..1223690 100644
84856 --- a/net/can/af_can.c
84857 +++ b/net/can/af_can.c
84858 @@ -870,7 +870,7 @@ static const struct net_proto_family can_family_ops = {
84859 };
84860
84861 /* notifier block for netdevice event */
84862 -static struct notifier_block can_netdev_notifier __read_mostly = {
84863 +static struct notifier_block can_netdev_notifier = {
84864 .notifier_call = can_notifier,
84865 };
84866
84867 diff --git a/net/can/gw.c b/net/can/gw.c
84868 index 117814a..ad4fb73 100644
84869 --- a/net/can/gw.c
84870 +++ b/net/can/gw.c
84871 @@ -80,7 +80,6 @@ MODULE_PARM_DESC(max_hops,
84872 "default: " __stringify(CGW_DEFAULT_HOPS) ")");
84873
84874 static HLIST_HEAD(cgw_list);
84875 -static struct notifier_block notifier;
84876
84877 static struct kmem_cache *cgw_cache __read_mostly;
84878
84879 @@ -928,6 +927,10 @@ static int cgw_remove_job(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
84880 return err;
84881 }
84882
84883 +static struct notifier_block notifier = {
84884 + .notifier_call = cgw_notifier
84885 +};
84886 +
84887 static __init int cgw_module_init(void)
84888 {
84889 /* sanitize given module parameter */
84890 @@ -943,7 +946,6 @@ static __init int cgw_module_init(void)
84891 return -ENOMEM;
84892
84893 /* set notifier */
84894 - notifier.notifier_call = cgw_notifier;
84895 register_netdevice_notifier(&notifier);
84896
84897 if (__rtnl_register(PF_CAN, RTM_GETROUTE, NULL, cgw_dump_jobs, NULL)) {
84898 diff --git a/net/compat.c b/net/compat.c
84899 index 79ae884..17c5c09 100644
84900 --- a/net/compat.c
84901 +++ b/net/compat.c
84902 @@ -71,9 +71,9 @@ int get_compat_msghdr(struct msghdr *kmsg, struct compat_msghdr __user *umsg)
84903 __get_user(kmsg->msg_controllen, &umsg->msg_controllen) ||
84904 __get_user(kmsg->msg_flags, &umsg->msg_flags))
84905 return -EFAULT;
84906 - kmsg->msg_name = compat_ptr(tmp1);
84907 - kmsg->msg_iov = compat_ptr(tmp2);
84908 - kmsg->msg_control = compat_ptr(tmp3);
84909 + kmsg->msg_name = (void __force_kernel *)compat_ptr(tmp1);
84910 + kmsg->msg_iov = (void __force_kernel *)compat_ptr(tmp2);
84911 + kmsg->msg_control = (void __force_kernel *)compat_ptr(tmp3);
84912 return 0;
84913 }
84914
84915 @@ -85,7 +85,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
84916
84917 if (kern_msg->msg_namelen) {
84918 if (mode == VERIFY_READ) {
84919 - int err = move_addr_to_kernel(kern_msg->msg_name,
84920 + int err = move_addr_to_kernel((void __force_user *)kern_msg->msg_name,
84921 kern_msg->msg_namelen,
84922 kern_address);
84923 if (err < 0)
84924 @@ -96,7 +96,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
84925 kern_msg->msg_name = NULL;
84926
84927 tot_len = iov_from_user_compat_to_kern(kern_iov,
84928 - (struct compat_iovec __user *)kern_msg->msg_iov,
84929 + (struct compat_iovec __force_user *)kern_msg->msg_iov,
84930 kern_msg->msg_iovlen);
84931 if (tot_len >= 0)
84932 kern_msg->msg_iov = kern_iov;
84933 @@ -116,20 +116,20 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
84934
84935 #define CMSG_COMPAT_FIRSTHDR(msg) \
84936 (((msg)->msg_controllen) >= sizeof(struct compat_cmsghdr) ? \
84937 - (struct compat_cmsghdr __user *)((msg)->msg_control) : \
84938 + (struct compat_cmsghdr __force_user *)((msg)->msg_control) : \
84939 (struct compat_cmsghdr __user *)NULL)
84940
84941 #define CMSG_COMPAT_OK(ucmlen, ucmsg, mhdr) \
84942 ((ucmlen) >= sizeof(struct compat_cmsghdr) && \
84943 (ucmlen) <= (unsigned long) \
84944 ((mhdr)->msg_controllen - \
84945 - ((char *)(ucmsg) - (char *)(mhdr)->msg_control)))
84946 + ((char __force_kernel *)(ucmsg) - (char *)(mhdr)->msg_control)))
84947
84948 static inline struct compat_cmsghdr __user *cmsg_compat_nxthdr(struct msghdr *msg,
84949 struct compat_cmsghdr __user *cmsg, int cmsg_len)
84950 {
84951 char __user *ptr = (char __user *)cmsg + CMSG_COMPAT_ALIGN(cmsg_len);
84952 - if ((unsigned long)(ptr + 1 - (char __user *)msg->msg_control) >
84953 + if ((unsigned long)(ptr + 1 - (char __force_user *)msg->msg_control) >
84954 msg->msg_controllen)
84955 return NULL;
84956 return (struct compat_cmsghdr __user *)ptr;
84957 @@ -219,7 +219,7 @@ Efault:
84958
84959 int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *data)
84960 {
84961 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
84962 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
84963 struct compat_cmsghdr cmhdr;
84964 struct compat_timeval ctv;
84965 struct compat_timespec cts[3];
84966 @@ -275,7 +275,7 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
84967
84968 void scm_detach_fds_compat(struct msghdr *kmsg, struct scm_cookie *scm)
84969 {
84970 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
84971 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
84972 int fdmax = (kmsg->msg_controllen - sizeof(struct compat_cmsghdr)) / sizeof(int);
84973 int fdnum = scm->fp->count;
84974 struct file **fp = scm->fp->fp;
84975 @@ -363,7 +363,7 @@ static int do_set_sock_timeout(struct socket *sock, int level,
84976 return -EFAULT;
84977 old_fs = get_fs();
84978 set_fs(KERNEL_DS);
84979 - err = sock_setsockopt(sock, level, optname, (char *)&ktime, sizeof(ktime));
84980 + err = sock_setsockopt(sock, level, optname, (char __force_user *)&ktime, sizeof(ktime));
84981 set_fs(old_fs);
84982
84983 return err;
84984 @@ -424,7 +424,7 @@ static int do_get_sock_timeout(struct socket *sock, int level, int optname,
84985 len = sizeof(ktime);
84986 old_fs = get_fs();
84987 set_fs(KERNEL_DS);
84988 - err = sock_getsockopt(sock, level, optname, (char *) &ktime, &len);
84989 + err = sock_getsockopt(sock, level, optname, (char __force_user *) &ktime, (int __force_user *)&len);
84990 set_fs(old_fs);
84991
84992 if (!err) {
84993 @@ -567,7 +567,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
84994 case MCAST_JOIN_GROUP:
84995 case MCAST_LEAVE_GROUP:
84996 {
84997 - struct compat_group_req __user *gr32 = (void *)optval;
84998 + struct compat_group_req __user *gr32 = (void __user *)optval;
84999 struct group_req __user *kgr =
85000 compat_alloc_user_space(sizeof(struct group_req));
85001 u32 interface;
85002 @@ -588,7 +588,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
85003 case MCAST_BLOCK_SOURCE:
85004 case MCAST_UNBLOCK_SOURCE:
85005 {
85006 - struct compat_group_source_req __user *gsr32 = (void *)optval;
85007 + struct compat_group_source_req __user *gsr32 = (void __user *)optval;
85008 struct group_source_req __user *kgsr = compat_alloc_user_space(
85009 sizeof(struct group_source_req));
85010 u32 interface;
85011 @@ -609,7 +609,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
85012 }
85013 case MCAST_MSFILTER:
85014 {
85015 - struct compat_group_filter __user *gf32 = (void *)optval;
85016 + struct compat_group_filter __user *gf32 = (void __user *)optval;
85017 struct group_filter __user *kgf;
85018 u32 interface, fmode, numsrc;
85019
85020 @@ -647,7 +647,7 @@ int compat_mc_getsockopt(struct sock *sock, int level, int optname,
85021 char __user *optval, int __user *optlen,
85022 int (*getsockopt)(struct sock *, int, int, char __user *, int __user *))
85023 {
85024 - struct compat_group_filter __user *gf32 = (void *)optval;
85025 + struct compat_group_filter __user *gf32 = (void __user *)optval;
85026 struct group_filter __user *kgf;
85027 int __user *koptlen;
85028 u32 interface, fmode, numsrc;
85029 @@ -796,7 +796,7 @@ asmlinkage long compat_sys_socketcall(int call, u32 __user *args)
85030
85031 if (call < SYS_SOCKET || call > SYS_SENDMMSG)
85032 return -EINVAL;
85033 - if (copy_from_user(a, args, nas[call]))
85034 + if (nas[call] > sizeof a || copy_from_user(a, args, nas[call]))
85035 return -EFAULT;
85036 a0 = a[0];
85037 a1 = a[1];
85038 diff --git a/net/core/datagram.c b/net/core/datagram.c
85039 index 368f9c3..f82d4a3 100644
85040 --- a/net/core/datagram.c
85041 +++ b/net/core/datagram.c
85042 @@ -289,7 +289,7 @@ int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags)
85043 }
85044
85045 kfree_skb(skb);
85046 - atomic_inc(&sk->sk_drops);
85047 + atomic_inc_unchecked(&sk->sk_drops);
85048 sk_mem_reclaim_partial(sk);
85049
85050 return err;
85051 diff --git a/net/core/dev.c b/net/core/dev.c
85052 index 9a278e9..15f2b9e 100644
85053 --- a/net/core/dev.c
85054 +++ b/net/core/dev.c
85055 @@ -1617,7 +1617,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
85056 {
85057 if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) {
85058 if (skb_copy_ubufs(skb, GFP_ATOMIC)) {
85059 - atomic_long_inc(&dev->rx_dropped);
85060 + atomic_long_inc_unchecked(&dev->rx_dropped);
85061 kfree_skb(skb);
85062 return NET_RX_DROP;
85063 }
85064 @@ -1626,7 +1626,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
85065 skb_orphan(skb);
85066
85067 if (unlikely(!is_skb_forwardable(dev, skb))) {
85068 - atomic_long_inc(&dev->rx_dropped);
85069 + atomic_long_inc_unchecked(&dev->rx_dropped);
85070 kfree_skb(skb);
85071 return NET_RX_DROP;
85072 }
85073 @@ -2351,7 +2351,7 @@ static int illegal_highdma(struct net_device *dev, struct sk_buff *skb)
85074
85075 struct dev_gso_cb {
85076 void (*destructor)(struct sk_buff *skb);
85077 -};
85078 +} __no_const;
85079
85080 #define DEV_GSO_CB(skb) ((struct dev_gso_cb *)(skb)->cb)
85081
85082 @@ -3093,7 +3093,7 @@ enqueue:
85083
85084 local_irq_restore(flags);
85085
85086 - atomic_long_inc(&skb->dev->rx_dropped);
85087 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
85088 kfree_skb(skb);
85089 return NET_RX_DROP;
85090 }
85091 @@ -3165,7 +3165,7 @@ int netif_rx_ni(struct sk_buff *skb)
85092 }
85093 EXPORT_SYMBOL(netif_rx_ni);
85094
85095 -static void net_tx_action(struct softirq_action *h)
85096 +static void net_tx_action(void)
85097 {
85098 struct softnet_data *sd = &__get_cpu_var(softnet_data);
85099
85100 @@ -3490,7 +3490,7 @@ ncls:
85101 ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
85102 } else {
85103 drop:
85104 - atomic_long_inc(&skb->dev->rx_dropped);
85105 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
85106 kfree_skb(skb);
85107 /* Jamal, now you will not able to escape explaining
85108 * me how you were going to use this. :-)
85109 @@ -4095,7 +4095,7 @@ void netif_napi_del(struct napi_struct *napi)
85110 }
85111 EXPORT_SYMBOL(netif_napi_del);
85112
85113 -static void net_rx_action(struct softirq_action *h)
85114 +static void net_rx_action(void)
85115 {
85116 struct softnet_data *sd = &__get_cpu_var(softnet_data);
85117 unsigned long time_limit = jiffies + 2;
85118 @@ -5522,7 +5522,7 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
85119 } else {
85120 netdev_stats_to_stats64(storage, &dev->stats);
85121 }
85122 - storage->rx_dropped += atomic_long_read(&dev->rx_dropped);
85123 + storage->rx_dropped += atomic_long_read_unchecked(&dev->rx_dropped);
85124 return storage;
85125 }
85126 EXPORT_SYMBOL(dev_get_stats);
85127 diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c
85128 index 6cc0481..59cfb00 100644
85129 --- a/net/core/dev_ioctl.c
85130 +++ b/net/core/dev_ioctl.c
85131 @@ -376,9 +376,13 @@ void dev_load(struct net *net, const char *name)
85132 if (no_module && capable(CAP_NET_ADMIN))
85133 no_module = request_module("netdev-%s", name);
85134 if (no_module && capable(CAP_SYS_MODULE)) {
85135 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
85136 + ___request_module(true, "grsec_modharden_netdev", "%s", name);
85137 +#else
85138 if (!request_module("%s", name))
85139 pr_warn("Loading kernel module for a network device with CAP_SYS_MODULE (deprecated). Use CAP_NET_ADMIN and alias netdev-%s instead.\n",
85140 name);
85141 +#endif
85142 }
85143 }
85144 EXPORT_SYMBOL(dev_load);
85145 diff --git a/net/core/flow.c b/net/core/flow.c
85146 index 2bfd081..53c6058 100644
85147 --- a/net/core/flow.c
85148 +++ b/net/core/flow.c
85149 @@ -61,7 +61,7 @@ struct flow_cache {
85150 struct timer_list rnd_timer;
85151 };
85152
85153 -atomic_t flow_cache_genid = ATOMIC_INIT(0);
85154 +atomic_unchecked_t flow_cache_genid = ATOMIC_INIT(0);
85155 EXPORT_SYMBOL(flow_cache_genid);
85156 static struct flow_cache flow_cache_global;
85157 static struct kmem_cache *flow_cachep __read_mostly;
85158 @@ -86,7 +86,7 @@ static void flow_cache_new_hashrnd(unsigned long arg)
85159
85160 static int flow_entry_valid(struct flow_cache_entry *fle)
85161 {
85162 - if (atomic_read(&flow_cache_genid) != fle->genid)
85163 + if (atomic_read_unchecked(&flow_cache_genid) != fle->genid)
85164 return 0;
85165 if (fle->object && !fle->object->ops->check(fle->object))
85166 return 0;
85167 @@ -258,7 +258,7 @@ flow_cache_lookup(struct net *net, const struct flowi *key, u16 family, u8 dir,
85168 hlist_add_head(&fle->u.hlist, &fcp->hash_table[hash]);
85169 fcp->hash_count++;
85170 }
85171 - } else if (likely(fle->genid == atomic_read(&flow_cache_genid))) {
85172 + } else if (likely(fle->genid == atomic_read_unchecked(&flow_cache_genid))) {
85173 flo = fle->object;
85174 if (!flo)
85175 goto ret_object;
85176 @@ -279,7 +279,7 @@ nocache:
85177 }
85178 flo = resolver(net, key, family, dir, flo, ctx);
85179 if (fle) {
85180 - fle->genid = atomic_read(&flow_cache_genid);
85181 + fle->genid = atomic_read_unchecked(&flow_cache_genid);
85182 if (!IS_ERR(flo))
85183 fle->object = flo;
85184 else
85185 diff --git a/net/core/iovec.c b/net/core/iovec.c
85186 index 7e7aeb0..2a998cb 100644
85187 --- a/net/core/iovec.c
85188 +++ b/net/core/iovec.c
85189 @@ -42,7 +42,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
85190 if (m->msg_namelen) {
85191 if (mode == VERIFY_READ) {
85192 void __user *namep;
85193 - namep = (void __user __force *) m->msg_name;
85194 + namep = (void __force_user *) m->msg_name;
85195 err = move_addr_to_kernel(namep, m->msg_namelen,
85196 address);
85197 if (err < 0)
85198 @@ -54,7 +54,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
85199 }
85200
85201 size = m->msg_iovlen * sizeof(struct iovec);
85202 - if (copy_from_user(iov, (void __user __force *) m->msg_iov, size))
85203 + if (copy_from_user(iov, (void __force_user *) m->msg_iov, size))
85204 return -EFAULT;
85205
85206 m->msg_iov = iov;
85207 diff --git a/net/core/neighbour.c b/net/core/neighbour.c
85208 index 3863b8f..85c99a6 100644
85209 --- a/net/core/neighbour.c
85210 +++ b/net/core/neighbour.c
85211 @@ -2778,7 +2778,7 @@ static int proc_unres_qlen(ctl_table *ctl, int write, void __user *buffer,
85212 size_t *lenp, loff_t *ppos)
85213 {
85214 int size, ret;
85215 - ctl_table tmp = *ctl;
85216 + ctl_table_no_const tmp = *ctl;
85217
85218 tmp.extra1 = &zero;
85219 tmp.extra2 = &unres_qlen_max;
85220 diff --git a/net/core/net-procfs.c b/net/core/net-procfs.c
85221 index 3174f19..5810985 100644
85222 --- a/net/core/net-procfs.c
85223 +++ b/net/core/net-procfs.c
85224 @@ -271,8 +271,13 @@ static int ptype_seq_show(struct seq_file *seq, void *v)
85225 else
85226 seq_printf(seq, "%04x", ntohs(pt->type));
85227
85228 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85229 + seq_printf(seq, " %-8s %pF\n",
85230 + pt->dev ? pt->dev->name : "", NULL);
85231 +#else
85232 seq_printf(seq, " %-8s %pF\n",
85233 pt->dev ? pt->dev->name : "", pt->func);
85234 +#endif
85235 }
85236
85237 return 0;
85238 diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
85239 index 7427ab5..389f411 100644
85240 --- a/net/core/net-sysfs.c
85241 +++ b/net/core/net-sysfs.c
85242 @@ -1321,7 +1321,7 @@ void netdev_class_remove_file(struct class_attribute *class_attr)
85243 }
85244 EXPORT_SYMBOL(netdev_class_remove_file);
85245
85246 -int netdev_kobject_init(void)
85247 +int __init netdev_kobject_init(void)
85248 {
85249 kobj_ns_type_register(&net_ns_type_operations);
85250 return class_register(&net_class);
85251 diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
85252 index 80e271d..2980cc2 100644
85253 --- a/net/core/net_namespace.c
85254 +++ b/net/core/net_namespace.c
85255 @@ -442,7 +442,7 @@ static int __register_pernet_operations(struct list_head *list,
85256 int error;
85257 LIST_HEAD(net_exit_list);
85258
85259 - list_add_tail(&ops->list, list);
85260 + pax_list_add_tail((struct list_head *)&ops->list, list);
85261 if (ops->init || (ops->id && ops->size)) {
85262 for_each_net(net) {
85263 error = ops_init(ops, net);
85264 @@ -455,7 +455,7 @@ static int __register_pernet_operations(struct list_head *list,
85265
85266 out_undo:
85267 /* If I have an error cleanup all namespaces I initialized */
85268 - list_del(&ops->list);
85269 + pax_list_del((struct list_head *)&ops->list);
85270 ops_exit_list(ops, &net_exit_list);
85271 ops_free_list(ops, &net_exit_list);
85272 return error;
85273 @@ -466,7 +466,7 @@ static void __unregister_pernet_operations(struct pernet_operations *ops)
85274 struct net *net;
85275 LIST_HEAD(net_exit_list);
85276
85277 - list_del(&ops->list);
85278 + pax_list_del((struct list_head *)&ops->list);
85279 for_each_net(net)
85280 list_add_tail(&net->exit_list, &net_exit_list);
85281 ops_exit_list(ops, &net_exit_list);
85282 @@ -600,7 +600,7 @@ int register_pernet_device(struct pernet_operations *ops)
85283 mutex_lock(&net_mutex);
85284 error = register_pernet_operations(&pernet_list, ops);
85285 if (!error && (first_device == &pernet_list))
85286 - first_device = &ops->list;
85287 + first_device = (struct list_head *)&ops->list;
85288 mutex_unlock(&net_mutex);
85289 return error;
85290 }
85291 diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
85292 index 23854b5..ff4fda4 100644
85293 --- a/net/core/rtnetlink.c
85294 +++ b/net/core/rtnetlink.c
85295 @@ -58,7 +58,7 @@ struct rtnl_link {
85296 rtnl_doit_func doit;
85297 rtnl_dumpit_func dumpit;
85298 rtnl_calcit_func calcit;
85299 -};
85300 +} __no_const;
85301
85302 static DEFINE_MUTEX(rtnl_mutex);
85303
85304 @@ -299,10 +299,13 @@ int __rtnl_link_register(struct rtnl_link_ops *ops)
85305 if (rtnl_link_ops_get(ops->kind))
85306 return -EEXIST;
85307
85308 - if (!ops->dellink)
85309 - ops->dellink = unregister_netdevice_queue;
85310 + if (!ops->dellink) {
85311 + pax_open_kernel();
85312 + *(void **)&ops->dellink = unregister_netdevice_queue;
85313 + pax_close_kernel();
85314 + }
85315
85316 - list_add_tail(&ops->list, &link_ops);
85317 + pax_list_add_tail((struct list_head *)&ops->list, &link_ops);
85318 return 0;
85319 }
85320 EXPORT_SYMBOL_GPL(__rtnl_link_register);
85321 @@ -349,7 +352,7 @@ void __rtnl_link_unregister(struct rtnl_link_ops *ops)
85322 for_each_net(net) {
85323 __rtnl_kill_links(net, ops);
85324 }
85325 - list_del(&ops->list);
85326 + pax_list_del((struct list_head *)&ops->list);
85327 }
85328 EXPORT_SYMBOL_GPL(__rtnl_link_unregister);
85329
85330 diff --git a/net/core/scm.c b/net/core/scm.c
85331 index 2dc6cda..2159524 100644
85332 --- a/net/core/scm.c
85333 +++ b/net/core/scm.c
85334 @@ -226,7 +226,7 @@ EXPORT_SYMBOL(__scm_send);
85335 int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
85336 {
85337 struct cmsghdr __user *cm
85338 - = (__force struct cmsghdr __user *)msg->msg_control;
85339 + = (struct cmsghdr __force_user *)msg->msg_control;
85340 struct cmsghdr cmhdr;
85341 int cmlen = CMSG_LEN(len);
85342 int err;
85343 @@ -249,7 +249,7 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
85344 err = -EFAULT;
85345 if (copy_to_user(cm, &cmhdr, sizeof cmhdr))
85346 goto out;
85347 - if (copy_to_user(CMSG_DATA(cm), data, cmlen - sizeof(struct cmsghdr)))
85348 + if (copy_to_user((void __force_user *)CMSG_DATA((void __force_kernel *)cm), data, cmlen - sizeof(struct cmsghdr)))
85349 goto out;
85350 cmlen = CMSG_SPACE(len);
85351 if (msg->msg_controllen < cmlen)
85352 @@ -265,7 +265,7 @@ EXPORT_SYMBOL(put_cmsg);
85353 void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
85354 {
85355 struct cmsghdr __user *cm
85356 - = (__force struct cmsghdr __user*)msg->msg_control;
85357 + = (struct cmsghdr __force_user *)msg->msg_control;
85358
85359 int fdmax = 0;
85360 int fdnum = scm->fp->count;
85361 @@ -285,7 +285,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
85362 if (fdnum < fdmax)
85363 fdmax = fdnum;
85364
85365 - for (i=0, cmfptr=(__force int __user *)CMSG_DATA(cm); i<fdmax;
85366 + for (i=0, cmfptr=(int __force_user *)CMSG_DATA((void __force_kernel *)cm); i<fdmax;
85367 i++, cmfptr++)
85368 {
85369 struct socket *sock;
85370 diff --git a/net/core/secure_seq.c b/net/core/secure_seq.c
85371 index e61a8bb..6a2f13c 100644
85372 --- a/net/core/secure_seq.c
85373 +++ b/net/core/secure_seq.c
85374 @@ -12,12 +12,10 @@
85375
85376 static u32 net_secret[MD5_MESSAGE_BYTES / 4] ____cacheline_aligned;
85377
85378 -static int __init net_secret_init(void)
85379 +void net_secret_init(void)
85380 {
85381 get_random_bytes(net_secret, sizeof(net_secret));
85382 - return 0;
85383 }
85384 -late_initcall(net_secret_init);
85385
85386 #ifdef CONFIG_INET
85387 static u32 seq_scale(u32 seq)
85388 diff --git a/net/core/sock.c b/net/core/sock.c
85389 index 1432266..1a0d4a1 100644
85390 --- a/net/core/sock.c
85391 +++ b/net/core/sock.c
85392 @@ -390,7 +390,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
85393 struct sk_buff_head *list = &sk->sk_receive_queue;
85394
85395 if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf) {
85396 - atomic_inc(&sk->sk_drops);
85397 + atomic_inc_unchecked(&sk->sk_drops);
85398 trace_sock_rcvqueue_full(sk, skb);
85399 return -ENOMEM;
85400 }
85401 @@ -400,7 +400,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
85402 return err;
85403
85404 if (!sk_rmem_schedule(sk, skb, skb->truesize)) {
85405 - atomic_inc(&sk->sk_drops);
85406 + atomic_inc_unchecked(&sk->sk_drops);
85407 return -ENOBUFS;
85408 }
85409
85410 @@ -420,7 +420,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
85411 skb_dst_force(skb);
85412
85413 spin_lock_irqsave(&list->lock, flags);
85414 - skb->dropcount = atomic_read(&sk->sk_drops);
85415 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
85416 __skb_queue_tail(list, skb);
85417 spin_unlock_irqrestore(&list->lock, flags);
85418
85419 @@ -440,7 +440,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
85420 skb->dev = NULL;
85421
85422 if (sk_rcvqueues_full(sk, skb, sk->sk_rcvbuf)) {
85423 - atomic_inc(&sk->sk_drops);
85424 + atomic_inc_unchecked(&sk->sk_drops);
85425 goto discard_and_relse;
85426 }
85427 if (nested)
85428 @@ -458,7 +458,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
85429 mutex_release(&sk->sk_lock.dep_map, 1, _RET_IP_);
85430 } else if (sk_add_backlog(sk, skb, sk->sk_rcvbuf)) {
85431 bh_unlock_sock(sk);
85432 - atomic_inc(&sk->sk_drops);
85433 + atomic_inc_unchecked(&sk->sk_drops);
85434 goto discard_and_relse;
85435 }
85436
85437 @@ -942,12 +942,12 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
85438 struct timeval tm;
85439 } v;
85440
85441 - int lv = sizeof(int);
85442 - int len;
85443 + unsigned int lv = sizeof(int);
85444 + unsigned int len;
85445
85446 if (get_user(len, optlen))
85447 return -EFAULT;
85448 - if (len < 0)
85449 + if (len > INT_MAX)
85450 return -EINVAL;
85451
85452 memset(&v, 0, sizeof(v));
85453 @@ -1099,11 +1099,11 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
85454
85455 case SO_PEERNAME:
85456 {
85457 - char address[128];
85458 + char address[_K_SS_MAXSIZE];
85459
85460 if (sock->ops->getname(sock, (struct sockaddr *)address, &lv, 2))
85461 return -ENOTCONN;
85462 - if (lv < len)
85463 + if (lv < len || sizeof address < len)
85464 return -EINVAL;
85465 if (copy_to_user(optval, address, len))
85466 return -EFAULT;
85467 @@ -1166,7 +1166,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
85468
85469 if (len > lv)
85470 len = lv;
85471 - if (copy_to_user(optval, &v, len))
85472 + if (len > sizeof(v) || copy_to_user(optval, &v, len))
85473 return -EFAULT;
85474 lenout:
85475 if (put_user(len, optlen))
85476 @@ -2284,7 +2284,7 @@ void sock_init_data(struct socket *sock, struct sock *sk)
85477 */
85478 smp_wmb();
85479 atomic_set(&sk->sk_refcnt, 1);
85480 - atomic_set(&sk->sk_drops, 0);
85481 + atomic_set_unchecked(&sk->sk_drops, 0);
85482 }
85483 EXPORT_SYMBOL(sock_init_data);
85484
85485 diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c
85486 index a29e90c..922399c 100644
85487 --- a/net/core/sock_diag.c
85488 +++ b/net/core/sock_diag.c
85489 @@ -9,26 +9,33 @@
85490 #include <linux/inet_diag.h>
85491 #include <linux/sock_diag.h>
85492
85493 -static const struct sock_diag_handler *sock_diag_handlers[AF_MAX];
85494 +static const struct sock_diag_handler *sock_diag_handlers[AF_MAX] __read_only;
85495 static int (*inet_rcv_compat)(struct sk_buff *skb, struct nlmsghdr *nlh);
85496 static DEFINE_MUTEX(sock_diag_table_mutex);
85497
85498 int sock_diag_check_cookie(void *sk, __u32 *cookie)
85499 {
85500 +#ifndef CONFIG_GRKERNSEC_HIDESYM
85501 if ((cookie[0] != INET_DIAG_NOCOOKIE ||
85502 cookie[1] != INET_DIAG_NOCOOKIE) &&
85503 ((u32)(unsigned long)sk != cookie[0] ||
85504 (u32)((((unsigned long)sk) >> 31) >> 1) != cookie[1]))
85505 return -ESTALE;
85506 else
85507 +#endif
85508 return 0;
85509 }
85510 EXPORT_SYMBOL_GPL(sock_diag_check_cookie);
85511
85512 void sock_diag_save_cookie(void *sk, __u32 *cookie)
85513 {
85514 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85515 + cookie[0] = 0;
85516 + cookie[1] = 0;
85517 +#else
85518 cookie[0] = (u32)(unsigned long)sk;
85519 cookie[1] = (u32)(((unsigned long)sk >> 31) >> 1);
85520 +#endif
85521 }
85522 EXPORT_SYMBOL_GPL(sock_diag_save_cookie);
85523
85524 @@ -75,8 +82,11 @@ int sock_diag_register(const struct sock_diag_handler *hndl)
85525 mutex_lock(&sock_diag_table_mutex);
85526 if (sock_diag_handlers[hndl->family])
85527 err = -EBUSY;
85528 - else
85529 + else {
85530 + pax_open_kernel();
85531 sock_diag_handlers[hndl->family] = hndl;
85532 + pax_close_kernel();
85533 + }
85534 mutex_unlock(&sock_diag_table_mutex);
85535
85536 return err;
85537 @@ -92,7 +102,9 @@ void sock_diag_unregister(const struct sock_diag_handler *hnld)
85538
85539 mutex_lock(&sock_diag_table_mutex);
85540 BUG_ON(sock_diag_handlers[family] != hnld);
85541 + pax_open_kernel();
85542 sock_diag_handlers[family] = NULL;
85543 + pax_close_kernel();
85544 mutex_unlock(&sock_diag_table_mutex);
85545 }
85546 EXPORT_SYMBOL_GPL(sock_diag_unregister);
85547 diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
85548 index cfdb46a..cef55e1 100644
85549 --- a/net/core/sysctl_net_core.c
85550 +++ b/net/core/sysctl_net_core.c
85551 @@ -28,7 +28,7 @@ static int rps_sock_flow_sysctl(ctl_table *table, int write,
85552 {
85553 unsigned int orig_size, size;
85554 int ret, i;
85555 - ctl_table tmp = {
85556 + ctl_table_no_const tmp = {
85557 .data = &size,
85558 .maxlen = sizeof(size),
85559 .mode = table->mode
85560 @@ -211,13 +211,12 @@ static struct ctl_table netns_core_table[] = {
85561
85562 static __net_init int sysctl_core_net_init(struct net *net)
85563 {
85564 - struct ctl_table *tbl;
85565 + ctl_table_no_const *tbl = NULL;
85566
85567 net->core.sysctl_somaxconn = SOMAXCONN;
85568
85569 - tbl = netns_core_table;
85570 if (!net_eq(net, &init_net)) {
85571 - tbl = kmemdup(tbl, sizeof(netns_core_table), GFP_KERNEL);
85572 + tbl = kmemdup(netns_core_table, sizeof(netns_core_table), GFP_KERNEL);
85573 if (tbl == NULL)
85574 goto err_dup;
85575
85576 @@ -227,17 +226,16 @@ static __net_init int sysctl_core_net_init(struct net *net)
85577 if (net->user_ns != &init_user_ns) {
85578 tbl[0].procname = NULL;
85579 }
85580 - }
85581 -
85582 - net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
85583 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
85584 + } else
85585 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", netns_core_table);
85586 if (net->core.sysctl_hdr == NULL)
85587 goto err_reg;
85588
85589 return 0;
85590
85591 err_reg:
85592 - if (tbl != netns_core_table)
85593 - kfree(tbl);
85594 + kfree(tbl);
85595 err_dup:
85596 return -ENOMEM;
85597 }
85598 @@ -252,7 +250,7 @@ static __net_exit void sysctl_core_net_exit(struct net *net)
85599 kfree(tbl);
85600 }
85601
85602 -static __net_initdata struct pernet_operations sysctl_core_ops = {
85603 +static __net_initconst struct pernet_operations sysctl_core_ops = {
85604 .init = sysctl_core_net_init,
85605 .exit = sysctl_core_net_exit,
85606 };
85607 diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
85608 index c21f200..bc4565b 100644
85609 --- a/net/decnet/af_decnet.c
85610 +++ b/net/decnet/af_decnet.c
85611 @@ -465,6 +465,7 @@ static struct proto dn_proto = {
85612 .sysctl_rmem = sysctl_decnet_rmem,
85613 .max_header = DN_MAX_NSP_DATA_HEADER + 64,
85614 .obj_size = sizeof(struct dn_sock),
85615 + .slab_flags = SLAB_USERCOPY,
85616 };
85617
85618 static struct sock *dn_alloc_sock(struct net *net, struct socket *sock, gfp_t gfp)
85619 diff --git a/net/decnet/sysctl_net_decnet.c b/net/decnet/sysctl_net_decnet.c
85620 index a55eecc..dd8428c 100644
85621 --- a/net/decnet/sysctl_net_decnet.c
85622 +++ b/net/decnet/sysctl_net_decnet.c
85623 @@ -174,7 +174,7 @@ static int dn_node_address_handler(ctl_table *table, int write,
85624
85625 if (len > *lenp) len = *lenp;
85626
85627 - if (copy_to_user(buffer, addr, len))
85628 + if (len > sizeof addr || copy_to_user(buffer, addr, len))
85629 return -EFAULT;
85630
85631 *lenp = len;
85632 @@ -237,7 +237,7 @@ static int dn_def_dev_handler(ctl_table *table, int write,
85633
85634 if (len > *lenp) len = *lenp;
85635
85636 - if (copy_to_user(buffer, devname, len))
85637 + if (len > sizeof devname || copy_to_user(buffer, devname, len))
85638 return -EFAULT;
85639
85640 *lenp = len;
85641 diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
85642 index c929d9c..df10cde 100644
85643 --- a/net/ipv4/af_inet.c
85644 +++ b/net/ipv4/af_inet.c
85645 @@ -115,6 +115,7 @@
85646 #include <net/inet_common.h>
85647 #include <net/xfrm.h>
85648 #include <net/net_namespace.h>
85649 +#include <net/secure_seq.h>
85650 #ifdef CONFIG_IP_MROUTE
85651 #include <linux/mroute.h>
85652 #endif
85653 @@ -263,8 +264,10 @@ void build_ehash_secret(void)
85654 get_random_bytes(&rnd, sizeof(rnd));
85655 } while (rnd == 0);
85656
85657 - if (cmpxchg(&inet_ehash_secret, 0, rnd) == 0)
85658 + if (cmpxchg(&inet_ehash_secret, 0, rnd) == 0) {
85659 get_random_bytes(&ipv6_hash_secret, sizeof(ipv6_hash_secret));
85660 + net_secret_init();
85661 + }
85662 }
85663 EXPORT_SYMBOL(build_ehash_secret);
85664
85665 @@ -1699,13 +1702,9 @@ static int __init inet_init(void)
85666
85667 BUILD_BUG_ON(sizeof(struct inet_skb_parm) > FIELD_SIZEOF(struct sk_buff, cb));
85668
85669 - sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
85670 - if (!sysctl_local_reserved_ports)
85671 - goto out;
85672 -
85673 rc = proto_register(&tcp_prot, 1);
85674 if (rc)
85675 - goto out_free_reserved_ports;
85676 + goto out;
85677
85678 rc = proto_register(&udp_prot, 1);
85679 if (rc)
85680 @@ -1814,8 +1813,6 @@ out_unregister_udp_proto:
85681 proto_unregister(&udp_prot);
85682 out_unregister_tcp_proto:
85683 proto_unregister(&tcp_prot);
85684 -out_free_reserved_ports:
85685 - kfree(sysctl_local_reserved_ports);
85686 goto out;
85687 }
85688
85689 diff --git a/net/ipv4/ah4.c b/net/ipv4/ah4.c
85690 index 2e7f194..0fa4d6d 100644
85691 --- a/net/ipv4/ah4.c
85692 +++ b/net/ipv4/ah4.c
85693 @@ -420,7 +420,7 @@ static void ah4_err(struct sk_buff *skb, u32 info)
85694 return;
85695
85696 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
85697 - atomic_inc(&flow_cache_genid);
85698 + atomic_inc_unchecked(&flow_cache_genid);
85699 rt_genid_bump(net);
85700
85701 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_AH, 0);
85702 diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
85703 index c6287cd..e9bc96a 100644
85704 --- a/net/ipv4/devinet.c
85705 +++ b/net/ipv4/devinet.c
85706 @@ -1992,7 +1992,7 @@ static int ipv4_doint_and_flush(ctl_table *ctl, int write,
85707 #define DEVINET_SYSCTL_FLUSHING_ENTRY(attr, name) \
85708 DEVINET_SYSCTL_COMPLEX_ENTRY(attr, name, ipv4_doint_and_flush)
85709
85710 -static struct devinet_sysctl_table {
85711 +static const struct devinet_sysctl_table {
85712 struct ctl_table_header *sysctl_header;
85713 struct ctl_table devinet_vars[__IPV4_DEVCONF_MAX];
85714 } devinet_sysctl = {
85715 @@ -2110,7 +2110,7 @@ static __net_init int devinet_init_net(struct net *net)
85716 int err;
85717 struct ipv4_devconf *all, *dflt;
85718 #ifdef CONFIG_SYSCTL
85719 - struct ctl_table *tbl = ctl_forward_entry;
85720 + ctl_table_no_const *tbl = NULL;
85721 struct ctl_table_header *forw_hdr;
85722 #endif
85723
85724 @@ -2128,7 +2128,7 @@ static __net_init int devinet_init_net(struct net *net)
85725 goto err_alloc_dflt;
85726
85727 #ifdef CONFIG_SYSCTL
85728 - tbl = kmemdup(tbl, sizeof(ctl_forward_entry), GFP_KERNEL);
85729 + tbl = kmemdup(ctl_forward_entry, sizeof(ctl_forward_entry), GFP_KERNEL);
85730 if (tbl == NULL)
85731 goto err_alloc_ctl;
85732
85733 @@ -2148,7 +2148,10 @@ static __net_init int devinet_init_net(struct net *net)
85734 goto err_reg_dflt;
85735
85736 err = -ENOMEM;
85737 - forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
85738 + if (!net_eq(net, &init_net))
85739 + forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
85740 + else
85741 + forw_hdr = register_net_sysctl(net, "net/ipv4", ctl_forward_entry);
85742 if (forw_hdr == NULL)
85743 goto err_reg_ctl;
85744 net->ipv4.forw_hdr = forw_hdr;
85745 @@ -2164,8 +2167,7 @@ err_reg_ctl:
85746 err_reg_dflt:
85747 __devinet_sysctl_unregister(all);
85748 err_reg_all:
85749 - if (tbl != ctl_forward_entry)
85750 - kfree(tbl);
85751 + kfree(tbl);
85752 err_alloc_ctl:
85753 #endif
85754 if (dflt != &ipv4_devconf_dflt)
85755 diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c
85756 index 4cfe34d..a6ba66e 100644
85757 --- a/net/ipv4/esp4.c
85758 +++ b/net/ipv4/esp4.c
85759 @@ -503,7 +503,7 @@ static void esp4_err(struct sk_buff *skb, u32 info)
85760 return;
85761
85762 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
85763 - atomic_inc(&flow_cache_genid);
85764 + atomic_inc_unchecked(&flow_cache_genid);
85765 rt_genid_bump(net);
85766
85767 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_ESP, 0);
85768 diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
85769 index eb4bb12..ee4ec7d 100644
85770 --- a/net/ipv4/fib_frontend.c
85771 +++ b/net/ipv4/fib_frontend.c
85772 @@ -1017,12 +1017,12 @@ static int fib_inetaddr_event(struct notifier_block *this, unsigned long event,
85773 #ifdef CONFIG_IP_ROUTE_MULTIPATH
85774 fib_sync_up(dev);
85775 #endif
85776 - atomic_inc(&net->ipv4.dev_addr_genid);
85777 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
85778 rt_cache_flush(dev_net(dev));
85779 break;
85780 case NETDEV_DOWN:
85781 fib_del_ifaddr(ifa, NULL);
85782 - atomic_inc(&net->ipv4.dev_addr_genid);
85783 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
85784 if (ifa->ifa_dev->ifa_list == NULL) {
85785 /* Last address was deleted from this interface.
85786 * Disable IP.
85787 @@ -1058,7 +1058,7 @@ static int fib_netdev_event(struct notifier_block *this, unsigned long event, vo
85788 #ifdef CONFIG_IP_ROUTE_MULTIPATH
85789 fib_sync_up(dev);
85790 #endif
85791 - atomic_inc(&net->ipv4.dev_addr_genid);
85792 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
85793 rt_cache_flush(net);
85794 break;
85795 case NETDEV_DOWN:
85796 diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
85797 index 8f6cb7a..34507f9 100644
85798 --- a/net/ipv4/fib_semantics.c
85799 +++ b/net/ipv4/fib_semantics.c
85800 @@ -765,7 +765,7 @@ __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh)
85801 nh->nh_saddr = inet_select_addr(nh->nh_dev,
85802 nh->nh_gw,
85803 nh->nh_parent->fib_scope);
85804 - nh->nh_saddr_genid = atomic_read(&net->ipv4.dev_addr_genid);
85805 + nh->nh_saddr_genid = atomic_read_unchecked(&net->ipv4.dev_addr_genid);
85806
85807 return nh->nh_saddr;
85808 }
85809 diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
85810 index 786d97a..1889c0d 100644
85811 --- a/net/ipv4/inet_connection_sock.c
85812 +++ b/net/ipv4/inet_connection_sock.c
85813 @@ -37,7 +37,7 @@ struct local_ports sysctl_local_ports __read_mostly = {
85814 .range = { 32768, 61000 },
85815 };
85816
85817 -unsigned long *sysctl_local_reserved_ports;
85818 +unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
85819 EXPORT_SYMBOL(sysctl_local_reserved_ports);
85820
85821 void inet_get_local_port_range(int *low, int *high)
85822 diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
85823 index 6af375a..c493c74 100644
85824 --- a/net/ipv4/inet_hashtables.c
85825 +++ b/net/ipv4/inet_hashtables.c
85826 @@ -18,12 +18,15 @@
85827 #include <linux/sched.h>
85828 #include <linux/slab.h>
85829 #include <linux/wait.h>
85830 +#include <linux/security.h>
85831
85832 #include <net/inet_connection_sock.h>
85833 #include <net/inet_hashtables.h>
85834 #include <net/secure_seq.h>
85835 #include <net/ip.h>
85836
85837 +extern void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet);
85838 +
85839 /*
85840 * Allocate and initialize a new local port bind bucket.
85841 * The bindhash mutex for snum's hash chain must be held here.
85842 @@ -554,6 +557,8 @@ ok:
85843 twrefcnt += inet_twsk_bind_unhash(tw, hinfo);
85844 spin_unlock(&head->lock);
85845
85846 + gr_update_task_in_ip_table(current, inet_sk(sk));
85847 +
85848 if (tw) {
85849 inet_twsk_deschedule(tw, death_row);
85850 while (twrefcnt) {
85851 diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
85852 index 000e3d2..5472da3 100644
85853 --- a/net/ipv4/inetpeer.c
85854 +++ b/net/ipv4/inetpeer.c
85855 @@ -503,8 +503,8 @@ relookup:
85856 if (p) {
85857 p->daddr = *daddr;
85858 atomic_set(&p->refcnt, 1);
85859 - atomic_set(&p->rid, 0);
85860 - atomic_set(&p->ip_id_count,
85861 + atomic_set_unchecked(&p->rid, 0);
85862 + atomic_set_unchecked(&p->ip_id_count,
85863 (daddr->family == AF_INET) ?
85864 secure_ip_id(daddr->addr.a4) :
85865 secure_ipv6_id(daddr->addr.a6));
85866 diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
85867 index 52c273e..579060b 100644
85868 --- a/net/ipv4/ip_fragment.c
85869 +++ b/net/ipv4/ip_fragment.c
85870 @@ -311,7 +311,7 @@ static inline int ip_frag_too_far(struct ipq *qp)
85871 return 0;
85872
85873 start = qp->rid;
85874 - end = atomic_inc_return(&peer->rid);
85875 + end = atomic_inc_return_unchecked(&peer->rid);
85876 qp->rid = end;
85877
85878 rc = qp->q.fragments && (end - start) > max;
85879 @@ -788,12 +788,11 @@ static struct ctl_table ip4_frags_ctl_table[] = {
85880
85881 static int __net_init ip4_frags_ns_ctl_register(struct net *net)
85882 {
85883 - struct ctl_table *table;
85884 + ctl_table_no_const *table = NULL;
85885 struct ctl_table_header *hdr;
85886
85887 - table = ip4_frags_ns_ctl_table;
85888 if (!net_eq(net, &init_net)) {
85889 - table = kmemdup(table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
85890 + table = kmemdup(ip4_frags_ns_ctl_table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
85891 if (table == NULL)
85892 goto err_alloc;
85893
85894 @@ -804,9 +803,10 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
85895 /* Don't export sysctls to unprivileged users */
85896 if (net->user_ns != &init_user_ns)
85897 table[0].procname = NULL;
85898 - }
85899 + hdr = register_net_sysctl(net, "net/ipv4", table);
85900 + } else
85901 + hdr = register_net_sysctl(net, "net/ipv4", ip4_frags_ns_ctl_table);
85902
85903 - hdr = register_net_sysctl(net, "net/ipv4", table);
85904 if (hdr == NULL)
85905 goto err_reg;
85906
85907 @@ -814,8 +814,7 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
85908 return 0;
85909
85910 err_reg:
85911 - if (!net_eq(net, &init_net))
85912 - kfree(table);
85913 + kfree(table);
85914 err_alloc:
85915 return -ENOMEM;
85916 }
85917 diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
85918 index 91d66db..4af7d99 100644
85919 --- a/net/ipv4/ip_gre.c
85920 +++ b/net/ipv4/ip_gre.c
85921 @@ -124,7 +124,7 @@ static bool log_ecn_error = true;
85922 module_param(log_ecn_error, bool, 0644);
85923 MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
85924
85925 -static struct rtnl_link_ops ipgre_link_ops __read_mostly;
85926 +static struct rtnl_link_ops ipgre_link_ops;
85927 static int ipgre_tunnel_init(struct net_device *dev);
85928 static void ipgre_tunnel_setup(struct net_device *dev);
85929 static int ipgre_tunnel_bind_dev(struct net_device *dev);
85930 @@ -1823,7 +1823,7 @@ static const struct nla_policy ipgre_policy[IFLA_GRE_MAX + 1] = {
85931 [IFLA_GRE_PMTUDISC] = { .type = NLA_U8 },
85932 };
85933
85934 -static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
85935 +static struct rtnl_link_ops ipgre_link_ops = {
85936 .kind = "gre",
85937 .maxtype = IFLA_GRE_MAX,
85938 .policy = ipgre_policy,
85939 @@ -1836,7 +1836,7 @@ static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
85940 .fill_info = ipgre_fill_info,
85941 };
85942
85943 -static struct rtnl_link_ops ipgre_tap_ops __read_mostly = {
85944 +static struct rtnl_link_ops ipgre_tap_ops = {
85945 .kind = "gretap",
85946 .maxtype = IFLA_GRE_MAX,
85947 .policy = ipgre_policy,
85948 diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
85949 index d9c4f11..02b82dbc 100644
85950 --- a/net/ipv4/ip_sockglue.c
85951 +++ b/net/ipv4/ip_sockglue.c
85952 @@ -1152,7 +1152,8 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
85953 len = min_t(unsigned int, len, opt->optlen);
85954 if (put_user(len, optlen))
85955 return -EFAULT;
85956 - if (copy_to_user(optval, opt->__data, len))
85957 + if ((len > (sizeof(optbuf) - sizeof(struct ip_options))) ||
85958 + copy_to_user(optval, opt->__data, len))
85959 return -EFAULT;
85960 return 0;
85961 }
85962 @@ -1283,7 +1284,7 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
85963 if (sk->sk_type != SOCK_STREAM)
85964 return -ENOPROTOOPT;
85965
85966 - msg.msg_control = optval;
85967 + msg.msg_control = (void __force_kernel *)optval;
85968 msg.msg_controllen = len;
85969 msg.msg_flags = flags;
85970
85971 diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
85972 index c3a4233..1412161 100644
85973 --- a/net/ipv4/ip_vti.c
85974 +++ b/net/ipv4/ip_vti.c
85975 @@ -47,7 +47,7 @@
85976 #define HASH_SIZE 16
85977 #define HASH(addr) (((__force u32)addr^((__force u32)addr>>4))&(HASH_SIZE-1))
85978
85979 -static struct rtnl_link_ops vti_link_ops __read_mostly;
85980 +static struct rtnl_link_ops vti_link_ops;
85981
85982 static int vti_net_id __read_mostly;
85983 struct vti_net {
85984 @@ -886,7 +886,7 @@ static const struct nla_policy vti_policy[IFLA_VTI_MAX + 1] = {
85985 [IFLA_VTI_REMOTE] = { .len = FIELD_SIZEOF(struct iphdr, daddr) },
85986 };
85987
85988 -static struct rtnl_link_ops vti_link_ops __read_mostly = {
85989 +static struct rtnl_link_ops vti_link_ops = {
85990 .kind = "vti",
85991 .maxtype = IFLA_VTI_MAX,
85992 .policy = vti_policy,
85993 diff --git a/net/ipv4/ipcomp.c b/net/ipv4/ipcomp.c
85994 index f01d1b1..8fe03ad 100644
85995 --- a/net/ipv4/ipcomp.c
85996 +++ b/net/ipv4/ipcomp.c
85997 @@ -48,7 +48,7 @@ static void ipcomp4_err(struct sk_buff *skb, u32 info)
85998 return;
85999
86000 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
86001 - atomic_inc(&flow_cache_genid);
86002 + atomic_inc_unchecked(&flow_cache_genid);
86003 rt_genid_bump(net);
86004
86005 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_COMP, 0);
86006 diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
86007 index bf6c5cf..ab2e9c6 100644
86008 --- a/net/ipv4/ipconfig.c
86009 +++ b/net/ipv4/ipconfig.c
86010 @@ -323,7 +323,7 @@ static int __init ic_devinet_ioctl(unsigned int cmd, struct ifreq *arg)
86011
86012 mm_segment_t oldfs = get_fs();
86013 set_fs(get_ds());
86014 - res = devinet_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
86015 + res = devinet_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
86016 set_fs(oldfs);
86017 return res;
86018 }
86019 @@ -334,7 +334,7 @@ static int __init ic_dev_ioctl(unsigned int cmd, struct ifreq *arg)
86020
86021 mm_segment_t oldfs = get_fs();
86022 set_fs(get_ds());
86023 - res = dev_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
86024 + res = dev_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
86025 set_fs(oldfs);
86026 return res;
86027 }
86028 @@ -345,7 +345,7 @@ static int __init ic_route_ioctl(unsigned int cmd, struct rtentry *arg)
86029
86030 mm_segment_t oldfs = get_fs();
86031 set_fs(get_ds());
86032 - res = ip_rt_ioctl(&init_net, cmd, (void __user *) arg);
86033 + res = ip_rt_ioctl(&init_net, cmd, (void __force_user *) arg);
86034 set_fs(oldfs);
86035 return res;
86036 }
86037 diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
86038 index 8f024d4..8b3500c 100644
86039 --- a/net/ipv4/ipip.c
86040 +++ b/net/ipv4/ipip.c
86041 @@ -138,7 +138,7 @@ struct ipip_net {
86042 static int ipip_tunnel_init(struct net_device *dev);
86043 static void ipip_tunnel_setup(struct net_device *dev);
86044 static void ipip_dev_free(struct net_device *dev);
86045 -static struct rtnl_link_ops ipip_link_ops __read_mostly;
86046 +static struct rtnl_link_ops ipip_link_ops;
86047
86048 static struct rtnl_link_stats64 *ipip_get_stats64(struct net_device *dev,
86049 struct rtnl_link_stats64 *tot)
86050 @@ -974,7 +974,7 @@ static const struct nla_policy ipip_policy[IFLA_IPTUN_MAX + 1] = {
86051 [IFLA_IPTUN_PMTUDISC] = { .type = NLA_U8 },
86052 };
86053
86054 -static struct rtnl_link_ops ipip_link_ops __read_mostly = {
86055 +static struct rtnl_link_ops ipip_link_ops = {
86056 .kind = "ipip",
86057 .maxtype = IFLA_IPTUN_MAX,
86058 .policy = ipip_policy,
86059 diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
86060 index 7dc6a97..229c61b 100644
86061 --- a/net/ipv4/netfilter/arp_tables.c
86062 +++ b/net/ipv4/netfilter/arp_tables.c
86063 @@ -879,14 +879,14 @@ static int compat_table_info(const struct xt_table_info *info,
86064 #endif
86065
86066 static int get_info(struct net *net, void __user *user,
86067 - const int *len, int compat)
86068 + int len, int compat)
86069 {
86070 char name[XT_TABLE_MAXNAMELEN];
86071 struct xt_table *t;
86072 int ret;
86073
86074 - if (*len != sizeof(struct arpt_getinfo)) {
86075 - duprintf("length %u != %Zu\n", *len,
86076 + if (len != sizeof(struct arpt_getinfo)) {
86077 + duprintf("length %u != %Zu\n", len,
86078 sizeof(struct arpt_getinfo));
86079 return -EINVAL;
86080 }
86081 @@ -923,7 +923,7 @@ static int get_info(struct net *net, void __user *user,
86082 info.size = private->size;
86083 strcpy(info.name, name);
86084
86085 - if (copy_to_user(user, &info, *len) != 0)
86086 + if (copy_to_user(user, &info, len) != 0)
86087 ret = -EFAULT;
86088 else
86089 ret = 0;
86090 @@ -1682,7 +1682,7 @@ static int compat_do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user,
86091
86092 switch (cmd) {
86093 case ARPT_SO_GET_INFO:
86094 - ret = get_info(sock_net(sk), user, len, 1);
86095 + ret = get_info(sock_net(sk), user, *len, 1);
86096 break;
86097 case ARPT_SO_GET_ENTRIES:
86098 ret = compat_get_entries(sock_net(sk), user, len);
86099 @@ -1727,7 +1727,7 @@ static int do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len
86100
86101 switch (cmd) {
86102 case ARPT_SO_GET_INFO:
86103 - ret = get_info(sock_net(sk), user, len, 0);
86104 + ret = get_info(sock_net(sk), user, *len, 0);
86105 break;
86106
86107 case ARPT_SO_GET_ENTRIES:
86108 diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
86109 index 3efcf87..5247916 100644
86110 --- a/net/ipv4/netfilter/ip_tables.c
86111 +++ b/net/ipv4/netfilter/ip_tables.c
86112 @@ -1068,14 +1068,14 @@ static int compat_table_info(const struct xt_table_info *info,
86113 #endif
86114
86115 static int get_info(struct net *net, void __user *user,
86116 - const int *len, int compat)
86117 + int len, int compat)
86118 {
86119 char name[XT_TABLE_MAXNAMELEN];
86120 struct xt_table *t;
86121 int ret;
86122
86123 - if (*len != sizeof(struct ipt_getinfo)) {
86124 - duprintf("length %u != %zu\n", *len,
86125 + if (len != sizeof(struct ipt_getinfo)) {
86126 + duprintf("length %u != %zu\n", len,
86127 sizeof(struct ipt_getinfo));
86128 return -EINVAL;
86129 }
86130 @@ -1112,7 +1112,7 @@ static int get_info(struct net *net, void __user *user,
86131 info.size = private->size;
86132 strcpy(info.name, name);
86133
86134 - if (copy_to_user(user, &info, *len) != 0)
86135 + if (copy_to_user(user, &info, len) != 0)
86136 ret = -EFAULT;
86137 else
86138 ret = 0;
86139 @@ -1966,7 +1966,7 @@ compat_do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
86140
86141 switch (cmd) {
86142 case IPT_SO_GET_INFO:
86143 - ret = get_info(sock_net(sk), user, len, 1);
86144 + ret = get_info(sock_net(sk), user, *len, 1);
86145 break;
86146 case IPT_SO_GET_ENTRIES:
86147 ret = compat_get_entries(sock_net(sk), user, len);
86148 @@ -2013,7 +2013,7 @@ do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
86149
86150 switch (cmd) {
86151 case IPT_SO_GET_INFO:
86152 - ret = get_info(sock_net(sk), user, len, 0);
86153 + ret = get_info(sock_net(sk), user, *len, 0);
86154 break;
86155
86156 case IPT_SO_GET_ENTRIES:
86157 diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
86158 index 2e91006..f084394 100644
86159 --- a/net/ipv4/ping.c
86160 +++ b/net/ipv4/ping.c
86161 @@ -844,7 +844,7 @@ static void ping_format_sock(struct sock *sp, struct seq_file *f,
86162 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
86163 0, sock_i_ino(sp),
86164 atomic_read(&sp->sk_refcnt), sp,
86165 - atomic_read(&sp->sk_drops), len);
86166 + atomic_read_unchecked(&sp->sk_drops), len);
86167 }
86168
86169 static int ping_seq_show(struct seq_file *seq, void *v)
86170 diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
86171 index dd44e0a..06dcca4 100644
86172 --- a/net/ipv4/raw.c
86173 +++ b/net/ipv4/raw.c
86174 @@ -309,7 +309,7 @@ static int raw_rcv_skb(struct sock *sk, struct sk_buff *skb)
86175 int raw_rcv(struct sock *sk, struct sk_buff *skb)
86176 {
86177 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) {
86178 - atomic_inc(&sk->sk_drops);
86179 + atomic_inc_unchecked(&sk->sk_drops);
86180 kfree_skb(skb);
86181 return NET_RX_DROP;
86182 }
86183 @@ -745,16 +745,20 @@ static int raw_init(struct sock *sk)
86184
86185 static int raw_seticmpfilter(struct sock *sk, char __user *optval, int optlen)
86186 {
86187 + struct icmp_filter filter;
86188 +
86189 if (optlen > sizeof(struct icmp_filter))
86190 optlen = sizeof(struct icmp_filter);
86191 - if (copy_from_user(&raw_sk(sk)->filter, optval, optlen))
86192 + if (copy_from_user(&filter, optval, optlen))
86193 return -EFAULT;
86194 + raw_sk(sk)->filter = filter;
86195 return 0;
86196 }
86197
86198 static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *optlen)
86199 {
86200 int len, ret = -EFAULT;
86201 + struct icmp_filter filter;
86202
86203 if (get_user(len, optlen))
86204 goto out;
86205 @@ -764,8 +768,8 @@ static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *o
86206 if (len > sizeof(struct icmp_filter))
86207 len = sizeof(struct icmp_filter);
86208 ret = -EFAULT;
86209 - if (put_user(len, optlen) ||
86210 - copy_to_user(optval, &raw_sk(sk)->filter, len))
86211 + filter = raw_sk(sk)->filter;
86212 + if (put_user(len, optlen) || len > sizeof filter || copy_to_user(optval, &filter, len))
86213 goto out;
86214 ret = 0;
86215 out: return ret;
86216 @@ -994,7 +998,7 @@ static void raw_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
86217 0, 0L, 0,
86218 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
86219 0, sock_i_ino(sp),
86220 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
86221 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
86222 }
86223
86224 static int raw_seq_show(struct seq_file *seq, void *v)
86225 diff --git a/net/ipv4/route.c b/net/ipv4/route.c
86226 index 6e28514..5e1b055 100644
86227 --- a/net/ipv4/route.c
86228 +++ b/net/ipv4/route.c
86229 @@ -2553,34 +2553,34 @@ static struct ctl_table ipv4_route_flush_table[] = {
86230 .maxlen = sizeof(int),
86231 .mode = 0200,
86232 .proc_handler = ipv4_sysctl_rtcache_flush,
86233 + .extra1 = &init_net,
86234 },
86235 { },
86236 };
86237
86238 static __net_init int sysctl_route_net_init(struct net *net)
86239 {
86240 - struct ctl_table *tbl;
86241 + ctl_table_no_const *tbl = NULL;
86242
86243 - tbl = ipv4_route_flush_table;
86244 if (!net_eq(net, &init_net)) {
86245 - tbl = kmemdup(tbl, sizeof(ipv4_route_flush_table), GFP_KERNEL);
86246 + tbl = kmemdup(ipv4_route_flush_table, sizeof(ipv4_route_flush_table), GFP_KERNEL);
86247 if (tbl == NULL)
86248 goto err_dup;
86249
86250 /* Don't export sysctls to unprivileged users */
86251 if (net->user_ns != &init_user_ns)
86252 tbl[0].procname = NULL;
86253 - }
86254 - tbl[0].extra1 = net;
86255 + tbl[0].extra1 = net;
86256 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
86257 + } else
86258 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", ipv4_route_flush_table);
86259
86260 - net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
86261 if (net->ipv4.route_hdr == NULL)
86262 goto err_reg;
86263 return 0;
86264
86265 err_reg:
86266 - if (tbl != ipv4_route_flush_table)
86267 - kfree(tbl);
86268 + kfree(tbl);
86269 err_dup:
86270 return -ENOMEM;
86271 }
86272 @@ -2603,7 +2603,7 @@ static __net_initdata struct pernet_operations sysctl_route_ops = {
86273
86274 static __net_init int rt_genid_init(struct net *net)
86275 {
86276 - atomic_set(&net->rt_genid, 0);
86277 + atomic_set_unchecked(&net->rt_genid, 0);
86278 get_random_bytes(&net->ipv4.dev_addr_genid,
86279 sizeof(net->ipv4.dev_addr_genid));
86280 return 0;
86281 diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
86282 index 960fd29..d55bf64 100644
86283 --- a/net/ipv4/sysctl_net_ipv4.c
86284 +++ b/net/ipv4/sysctl_net_ipv4.c
86285 @@ -55,7 +55,7 @@ static int ipv4_local_port_range(ctl_table *table, int write,
86286 {
86287 int ret;
86288 int range[2];
86289 - ctl_table tmp = {
86290 + ctl_table_no_const tmp = {
86291 .data = &range,
86292 .maxlen = sizeof(range),
86293 .mode = table->mode,
86294 @@ -108,7 +108,7 @@ static int ipv4_ping_group_range(ctl_table *table, int write,
86295 int ret;
86296 gid_t urange[2];
86297 kgid_t low, high;
86298 - ctl_table tmp = {
86299 + ctl_table_no_const tmp = {
86300 .data = &urange,
86301 .maxlen = sizeof(urange),
86302 .mode = table->mode,
86303 @@ -139,7 +139,7 @@ static int proc_tcp_congestion_control(ctl_table *ctl, int write,
86304 void __user *buffer, size_t *lenp, loff_t *ppos)
86305 {
86306 char val[TCP_CA_NAME_MAX];
86307 - ctl_table tbl = {
86308 + ctl_table_no_const tbl = {
86309 .data = val,
86310 .maxlen = TCP_CA_NAME_MAX,
86311 };
86312 @@ -158,7 +158,7 @@ static int proc_tcp_available_congestion_control(ctl_table *ctl,
86313 void __user *buffer, size_t *lenp,
86314 loff_t *ppos)
86315 {
86316 - ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
86317 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX, };
86318 int ret;
86319
86320 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
86321 @@ -175,7 +175,7 @@ static int proc_allowed_congestion_control(ctl_table *ctl,
86322 void __user *buffer, size_t *lenp,
86323 loff_t *ppos)
86324 {
86325 - ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
86326 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX };
86327 int ret;
86328
86329 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
86330 @@ -201,15 +201,17 @@ static int ipv4_tcp_mem(ctl_table *ctl, int write,
86331 struct mem_cgroup *memcg;
86332 #endif
86333
86334 - ctl_table tmp = {
86335 + ctl_table_no_const tmp = {
86336 .data = &vec,
86337 .maxlen = sizeof(vec),
86338 .mode = ctl->mode,
86339 };
86340
86341 if (!write) {
86342 - ctl->data = &net->ipv4.sysctl_tcp_mem;
86343 - return proc_doulongvec_minmax(ctl, write, buffer, lenp, ppos);
86344 + ctl_table_no_const tcp_mem = *ctl;
86345 +
86346 + tcp_mem.data = &net->ipv4.sysctl_tcp_mem;
86347 + return proc_doulongvec_minmax(&tcp_mem, write, buffer, lenp, ppos);
86348 }
86349
86350 ret = proc_doulongvec_minmax(&tmp, write, buffer, lenp, ppos);
86351 @@ -236,7 +238,7 @@ static int ipv4_tcp_mem(ctl_table *ctl, int write,
86352 static int proc_tcp_fastopen_key(ctl_table *ctl, int write, void __user *buffer,
86353 size_t *lenp, loff_t *ppos)
86354 {
86355 - ctl_table tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
86356 + ctl_table_no_const tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
86357 struct tcp_fastopen_context *ctxt;
86358 int ret;
86359 u32 user_key[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */
86360 @@ -477,7 +479,7 @@ static struct ctl_table ipv4_table[] = {
86361 },
86362 {
86363 .procname = "ip_local_reserved_ports",
86364 - .data = NULL, /* initialized in sysctl_ipv4_init */
86365 + .data = sysctl_local_reserved_ports,
86366 .maxlen = 65536,
86367 .mode = 0644,
86368 .proc_handler = proc_do_large_bitmap,
86369 @@ -856,11 +858,10 @@ static struct ctl_table ipv4_net_table[] = {
86370
86371 static __net_init int ipv4_sysctl_init_net(struct net *net)
86372 {
86373 - struct ctl_table *table;
86374 + ctl_table_no_const *table = NULL;
86375
86376 - table = ipv4_net_table;
86377 if (!net_eq(net, &init_net)) {
86378 - table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
86379 + table = kmemdup(ipv4_net_table, sizeof(ipv4_net_table), GFP_KERNEL);
86380 if (table == NULL)
86381 goto err_alloc;
86382
86383 @@ -895,15 +896,17 @@ static __net_init int ipv4_sysctl_init_net(struct net *net)
86384
86385 tcp_init_mem(net);
86386
86387 - net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
86388 + if (!net_eq(net, &init_net))
86389 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
86390 + else
86391 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", ipv4_net_table);
86392 if (net->ipv4.ipv4_hdr == NULL)
86393 goto err_reg;
86394
86395 return 0;
86396
86397 err_reg:
86398 - if (!net_eq(net, &init_net))
86399 - kfree(table);
86400 + kfree(table);
86401 err_alloc:
86402 return -ENOMEM;
86403 }
86404 @@ -925,16 +928,6 @@ static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
86405 static __init int sysctl_ipv4_init(void)
86406 {
86407 struct ctl_table_header *hdr;
86408 - struct ctl_table *i;
86409 -
86410 - for (i = ipv4_table; i->procname; i++) {
86411 - if (strcmp(i->procname, "ip_local_reserved_ports") == 0) {
86412 - i->data = sysctl_local_reserved_ports;
86413 - break;
86414 - }
86415 - }
86416 - if (!i->procname)
86417 - return -EINVAL;
86418
86419 hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
86420 if (hdr == NULL)
86421 diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
86422 index 13b9c08..d33a8d0 100644
86423 --- a/net/ipv4/tcp_input.c
86424 +++ b/net/ipv4/tcp_input.c
86425 @@ -4724,7 +4724,7 @@ static struct sk_buff *tcp_collapse_one(struct sock *sk, struct sk_buff *skb,
86426 * simplifies code)
86427 */
86428 static void
86429 -tcp_collapse(struct sock *sk, struct sk_buff_head *list,
86430 +__intentional_overflow(5,6) tcp_collapse(struct sock *sk, struct sk_buff_head *list,
86431 struct sk_buff *head, struct sk_buff *tail,
86432 u32 start, u32 end)
86433 {
86434 @@ -5838,6 +5838,7 @@ discard:
86435 tcp_paws_reject(&tp->rx_opt, 0))
86436 goto discard_and_undo;
86437
86438 +#ifndef CONFIG_GRKERNSEC_NO_SIMULT_CONNECT
86439 if (th->syn) {
86440 /* We see SYN without ACK. It is attempt of
86441 * simultaneous connect with crossed SYNs.
86442 @@ -5888,6 +5889,7 @@ discard:
86443 goto discard;
86444 #endif
86445 }
86446 +#endif
86447 /* "fifth, if neither of the SYN or RST bits is set then
86448 * drop the segment and return."
86449 */
86450 @@ -5932,7 +5934,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
86451 goto discard;
86452
86453 if (th->syn) {
86454 - if (th->fin)
86455 + if (th->fin || th->urg || th->psh)
86456 goto discard;
86457 if (icsk->icsk_af_ops->conn_request(sk, skb) < 0)
86458 return 1;
86459 diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
86460 index d09203c..fd5cc91 100644
86461 --- a/net/ipv4/tcp_ipv4.c
86462 +++ b/net/ipv4/tcp_ipv4.c
86463 @@ -90,6 +90,10 @@ int sysctl_tcp_low_latency __read_mostly;
86464 EXPORT_SYMBOL(sysctl_tcp_low_latency);
86465
86466
86467 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86468 +extern int grsec_enable_blackhole;
86469 +#endif
86470 +
86471 #ifdef CONFIG_TCP_MD5SIG
86472 static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,
86473 __be32 daddr, __be32 saddr, const struct tcphdr *th);
86474 @@ -1897,6 +1901,9 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
86475 return 0;
86476
86477 reset:
86478 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86479 + if (!grsec_enable_blackhole)
86480 +#endif
86481 tcp_v4_send_reset(rsk, skb);
86482 discard:
86483 kfree_skb(skb);
86484 @@ -1996,12 +2003,19 @@ int tcp_v4_rcv(struct sk_buff *skb)
86485 TCP_SKB_CB(skb)->sacked = 0;
86486
86487 sk = __inet_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
86488 - if (!sk)
86489 + if (!sk) {
86490 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86491 + ret = 1;
86492 +#endif
86493 goto no_tcp_socket;
86494 -
86495 + }
86496 process:
86497 - if (sk->sk_state == TCP_TIME_WAIT)
86498 + if (sk->sk_state == TCP_TIME_WAIT) {
86499 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86500 + ret = 2;
86501 +#endif
86502 goto do_time_wait;
86503 + }
86504
86505 if (unlikely(iph->ttl < inet_sk(sk)->min_ttl)) {
86506 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
86507 @@ -2052,6 +2066,10 @@ no_tcp_socket:
86508 bad_packet:
86509 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
86510 } else {
86511 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86512 + if (!grsec_enable_blackhole || (ret == 1 &&
86513 + (skb->dev->flags & IFF_LOOPBACK)))
86514 +#endif
86515 tcp_v4_send_reset(NULL, skb);
86516 }
86517
86518 diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
86519 index 2f672e7..b8895e9 100644
86520 --- a/net/ipv4/tcp_minisocks.c
86521 +++ b/net/ipv4/tcp_minisocks.c
86522 @@ -27,6 +27,10 @@
86523 #include <net/inet_common.h>
86524 #include <net/xfrm.h>
86525
86526 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86527 +extern int grsec_enable_blackhole;
86528 +#endif
86529 +
86530 int sysctl_tcp_syncookies __read_mostly = 1;
86531 EXPORT_SYMBOL(sysctl_tcp_syncookies);
86532
86533 @@ -749,7 +753,10 @@ embryonic_reset:
86534 * avoid becoming vulnerable to outside attack aiming at
86535 * resetting legit local connections.
86536 */
86537 - req->rsk_ops->send_reset(sk, skb);
86538 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86539 + if (!grsec_enable_blackhole)
86540 +#endif
86541 + req->rsk_ops->send_reset(sk, skb);
86542 } else if (fastopen) { /* received a valid RST pkt */
86543 reqsk_fastopen_remove(sk, req, true);
86544 tcp_reset(sk);
86545 diff --git a/net/ipv4/tcp_probe.c b/net/ipv4/tcp_probe.c
86546 index d4943f6..e7a74a5 100644
86547 --- a/net/ipv4/tcp_probe.c
86548 +++ b/net/ipv4/tcp_probe.c
86549 @@ -204,7 +204,7 @@ static ssize_t tcpprobe_read(struct file *file, char __user *buf,
86550 if (cnt + width >= len)
86551 break;
86552
86553 - if (copy_to_user(buf + cnt, tbuf, width))
86554 + if (width > sizeof tbuf || copy_to_user(buf + cnt, tbuf, width))
86555 return -EFAULT;
86556 cnt += width;
86557 }
86558 diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
86559 index b78aac3..e18230b 100644
86560 --- a/net/ipv4/tcp_timer.c
86561 +++ b/net/ipv4/tcp_timer.c
86562 @@ -22,6 +22,10 @@
86563 #include <linux/gfp.h>
86564 #include <net/tcp.h>
86565
86566 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86567 +extern int grsec_lastack_retries;
86568 +#endif
86569 +
86570 int sysctl_tcp_syn_retries __read_mostly = TCP_SYN_RETRIES;
86571 int sysctl_tcp_synack_retries __read_mostly = TCP_SYNACK_RETRIES;
86572 int sysctl_tcp_keepalive_time __read_mostly = TCP_KEEPALIVE_TIME;
86573 @@ -185,6 +189,13 @@ static int tcp_write_timeout(struct sock *sk)
86574 }
86575 }
86576
86577 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86578 + if ((sk->sk_state == TCP_LAST_ACK) &&
86579 + (grsec_lastack_retries > 0) &&
86580 + (grsec_lastack_retries < retry_until))
86581 + retry_until = grsec_lastack_retries;
86582 +#endif
86583 +
86584 if (retransmits_timed_out(sk, retry_until,
86585 syn_set ? 0 : icsk->icsk_user_timeout, syn_set)) {
86586 /* Has it gone just too far? */
86587 diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
86588 index 0a073a2..ddf6279 100644
86589 --- a/net/ipv4/udp.c
86590 +++ b/net/ipv4/udp.c
86591 @@ -87,6 +87,7 @@
86592 #include <linux/types.h>
86593 #include <linux/fcntl.h>
86594 #include <linux/module.h>
86595 +#include <linux/security.h>
86596 #include <linux/socket.h>
86597 #include <linux/sockios.h>
86598 #include <linux/igmp.h>
86599 @@ -111,6 +112,10 @@
86600 #include <trace/events/skb.h>
86601 #include "udp_impl.h"
86602
86603 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86604 +extern int grsec_enable_blackhole;
86605 +#endif
86606 +
86607 struct udp_table udp_table __read_mostly;
86608 EXPORT_SYMBOL(udp_table);
86609
86610 @@ -594,6 +599,9 @@ found:
86611 return s;
86612 }
86613
86614 +extern int gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb);
86615 +extern int gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr);
86616 +
86617 /*
86618 * This routine is called by the ICMP module when it gets some
86619 * sort of error condition. If err < 0 then the socket should
86620 @@ -889,9 +897,18 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
86621 dport = usin->sin_port;
86622 if (dport == 0)
86623 return -EINVAL;
86624 +
86625 + err = gr_search_udp_sendmsg(sk, usin);
86626 + if (err)
86627 + return err;
86628 } else {
86629 if (sk->sk_state != TCP_ESTABLISHED)
86630 return -EDESTADDRREQ;
86631 +
86632 + err = gr_search_udp_sendmsg(sk, NULL);
86633 + if (err)
86634 + return err;
86635 +
86636 daddr = inet->inet_daddr;
86637 dport = inet->inet_dport;
86638 /* Open fast path for connected socket.
86639 @@ -1133,7 +1150,7 @@ static unsigned int first_packet_length(struct sock *sk)
86640 udp_lib_checksum_complete(skb)) {
86641 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
86642 IS_UDPLITE(sk));
86643 - atomic_inc(&sk->sk_drops);
86644 + atomic_inc_unchecked(&sk->sk_drops);
86645 __skb_unlink(skb, rcvq);
86646 __skb_queue_tail(&list_kill, skb);
86647 }
86648 @@ -1219,6 +1236,10 @@ try_again:
86649 if (!skb)
86650 goto out;
86651
86652 + err = gr_search_udp_recvmsg(sk, skb);
86653 + if (err)
86654 + goto out_free;
86655 +
86656 ulen = skb->len - sizeof(struct udphdr);
86657 copied = len;
86658 if (copied > ulen)
86659 @@ -1252,7 +1273,7 @@ try_again:
86660 if (unlikely(err)) {
86661 trace_kfree_skb(skb, udp_recvmsg);
86662 if (!peeked) {
86663 - atomic_inc(&sk->sk_drops);
86664 + atomic_inc_unchecked(&sk->sk_drops);
86665 UDP_INC_STATS_USER(sock_net(sk),
86666 UDP_MIB_INERRORS, is_udplite);
86667 }
86668 @@ -1535,7 +1556,7 @@ int udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
86669
86670 drop:
86671 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
86672 - atomic_inc(&sk->sk_drops);
86673 + atomic_inc_unchecked(&sk->sk_drops);
86674 kfree_skb(skb);
86675 return -1;
86676 }
86677 @@ -1554,7 +1575,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
86678 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
86679
86680 if (!skb1) {
86681 - atomic_inc(&sk->sk_drops);
86682 + atomic_inc_unchecked(&sk->sk_drops);
86683 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
86684 IS_UDPLITE(sk));
86685 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
86686 @@ -1723,6 +1744,9 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
86687 goto csum_error;
86688
86689 UDP_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
86690 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86691 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
86692 +#endif
86693 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
86694
86695 /*
86696 @@ -2152,7 +2176,7 @@ static void udp4_format_sock(struct sock *sp, struct seq_file *f,
86697 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
86698 0, sock_i_ino(sp),
86699 atomic_read(&sp->sk_refcnt), sp,
86700 - atomic_read(&sp->sk_drops), len);
86701 + atomic_read_unchecked(&sp->sk_drops), len);
86702 }
86703
86704 int udp4_seq_show(struct seq_file *seq, void *v)
86705 diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c
86706 index 9a459be..086b866 100644
86707 --- a/net/ipv4/xfrm4_policy.c
86708 +++ b/net/ipv4/xfrm4_policy.c
86709 @@ -264,19 +264,18 @@ static struct ctl_table xfrm4_policy_table[] = {
86710
86711 static int __net_init xfrm4_net_init(struct net *net)
86712 {
86713 - struct ctl_table *table;
86714 + ctl_table_no_const *table = NULL;
86715 struct ctl_table_header *hdr;
86716
86717 - table = xfrm4_policy_table;
86718 if (!net_eq(net, &init_net)) {
86719 - table = kmemdup(table, sizeof(xfrm4_policy_table), GFP_KERNEL);
86720 + table = kmemdup(xfrm4_policy_table, sizeof(xfrm4_policy_table), GFP_KERNEL);
86721 if (!table)
86722 goto err_alloc;
86723
86724 table[0].data = &net->xfrm.xfrm4_dst_ops.gc_thresh;
86725 - }
86726 -
86727 - hdr = register_net_sysctl(net, "net/ipv4", table);
86728 + hdr = register_net_sysctl(net, "net/ipv4", table);
86729 + } else
86730 + hdr = register_net_sysctl(net, "net/ipv4", xfrm4_policy_table);
86731 if (!hdr)
86732 goto err_reg;
86733
86734 @@ -284,8 +283,7 @@ static int __net_init xfrm4_net_init(struct net *net)
86735 return 0;
86736
86737 err_reg:
86738 - if (!net_eq(net, &init_net))
86739 - kfree(table);
86740 + kfree(table);
86741 err_alloc:
86742 return -ENOMEM;
86743 }
86744 diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
86745 index dae802c..bfa4baa 100644
86746 --- a/net/ipv6/addrconf.c
86747 +++ b/net/ipv6/addrconf.c
86748 @@ -2274,7 +2274,7 @@ int addrconf_set_dstaddr(struct net *net, void __user *arg)
86749 p.iph.ihl = 5;
86750 p.iph.protocol = IPPROTO_IPV6;
86751 p.iph.ttl = 64;
86752 - ifr.ifr_ifru.ifru_data = (__force void __user *)&p;
86753 + ifr.ifr_ifru.ifru_data = (void __force_user *)&p;
86754
86755 if (ops->ndo_do_ioctl) {
86756 mm_segment_t oldfs = get_fs();
86757 @@ -4410,7 +4410,7 @@ int addrconf_sysctl_forward(ctl_table *ctl, int write,
86758 int *valp = ctl->data;
86759 int val = *valp;
86760 loff_t pos = *ppos;
86761 - ctl_table lctl;
86762 + ctl_table_no_const lctl;
86763 int ret;
86764
86765 /*
86766 @@ -4492,7 +4492,7 @@ int addrconf_sysctl_disable(ctl_table *ctl, int write,
86767 int *valp = ctl->data;
86768 int val = *valp;
86769 loff_t pos = *ppos;
86770 - ctl_table lctl;
86771 + ctl_table_no_const lctl;
86772 int ret;
86773
86774 /*
86775 diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
86776 index fff5bdd..15194fb 100644
86777 --- a/net/ipv6/icmp.c
86778 +++ b/net/ipv6/icmp.c
86779 @@ -973,7 +973,7 @@ ctl_table ipv6_icmp_table_template[] = {
86780
86781 struct ctl_table * __net_init ipv6_icmp_sysctl_init(struct net *net)
86782 {
86783 - struct ctl_table *table;
86784 + ctl_table_no_const *table;
86785
86786 table = kmemdup(ipv6_icmp_table_template,
86787 sizeof(ipv6_icmp_table_template),
86788 diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
86789 index 95d13c7..791fe2f 100644
86790 --- a/net/ipv6/ip6_gre.c
86791 +++ b/net/ipv6/ip6_gre.c
86792 @@ -73,7 +73,7 @@ struct ip6gre_net {
86793 struct net_device *fb_tunnel_dev;
86794 };
86795
86796 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly;
86797 +static struct rtnl_link_ops ip6gre_link_ops;
86798 static int ip6gre_tunnel_init(struct net_device *dev);
86799 static void ip6gre_tunnel_setup(struct net_device *dev);
86800 static void ip6gre_tunnel_link(struct ip6gre_net *ign, struct ip6_tnl *t);
86801 @@ -1337,7 +1337,7 @@ static void ip6gre_fb_tunnel_init(struct net_device *dev)
86802 }
86803
86804
86805 -static struct inet6_protocol ip6gre_protocol __read_mostly = {
86806 +static struct inet6_protocol ip6gre_protocol = {
86807 .handler = ip6gre_rcv,
86808 .err_handler = ip6gre_err,
86809 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
86810 @@ -1671,7 +1671,7 @@ static const struct nla_policy ip6gre_policy[IFLA_GRE_MAX + 1] = {
86811 [IFLA_GRE_FLAGS] = { .type = NLA_U32 },
86812 };
86813
86814 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
86815 +static struct rtnl_link_ops ip6gre_link_ops = {
86816 .kind = "ip6gre",
86817 .maxtype = IFLA_GRE_MAX,
86818 .policy = ip6gre_policy,
86819 @@ -1684,7 +1684,7 @@ static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
86820 .fill_info = ip6gre_fill_info,
86821 };
86822
86823 -static struct rtnl_link_ops ip6gre_tap_ops __read_mostly = {
86824 +static struct rtnl_link_ops ip6gre_tap_ops = {
86825 .kind = "ip6gretap",
86826 .maxtype = IFLA_GRE_MAX,
86827 .policy = ip6gre_policy,
86828 diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
86829 index fff83cb..82d49dd 100644
86830 --- a/net/ipv6/ip6_tunnel.c
86831 +++ b/net/ipv6/ip6_tunnel.c
86832 @@ -87,7 +87,7 @@ static u32 HASH(const struct in6_addr *addr1, const struct in6_addr *addr2)
86833
86834 static int ip6_tnl_dev_init(struct net_device *dev);
86835 static void ip6_tnl_dev_setup(struct net_device *dev);
86836 -static struct rtnl_link_ops ip6_link_ops __read_mostly;
86837 +static struct rtnl_link_ops ip6_link_ops;
86838
86839 static int ip6_tnl_net_id __read_mostly;
86840 struct ip6_tnl_net {
86841 @@ -1684,7 +1684,7 @@ static const struct nla_policy ip6_tnl_policy[IFLA_IPTUN_MAX + 1] = {
86842 [IFLA_IPTUN_PROTO] = { .type = NLA_U8 },
86843 };
86844
86845 -static struct rtnl_link_ops ip6_link_ops __read_mostly = {
86846 +static struct rtnl_link_ops ip6_link_ops = {
86847 .kind = "ip6tnl",
86848 .maxtype = IFLA_IPTUN_MAX,
86849 .policy = ip6_tnl_policy,
86850 diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
86851 index d1e2e8e..51c19ae 100644
86852 --- a/net/ipv6/ipv6_sockglue.c
86853 +++ b/net/ipv6/ipv6_sockglue.c
86854 @@ -991,7 +991,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
86855 if (sk->sk_type != SOCK_STREAM)
86856 return -ENOPROTOOPT;
86857
86858 - msg.msg_control = optval;
86859 + msg.msg_control = (void __force_kernel *)optval;
86860 msg.msg_controllen = len;
86861 msg.msg_flags = flags;
86862
86863 diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
86864 index 341b54a..591e8ed 100644
86865 --- a/net/ipv6/netfilter/ip6_tables.c
86866 +++ b/net/ipv6/netfilter/ip6_tables.c
86867 @@ -1076,14 +1076,14 @@ static int compat_table_info(const struct xt_table_info *info,
86868 #endif
86869
86870 static int get_info(struct net *net, void __user *user,
86871 - const int *len, int compat)
86872 + int len, int compat)
86873 {
86874 char name[XT_TABLE_MAXNAMELEN];
86875 struct xt_table *t;
86876 int ret;
86877
86878 - if (*len != sizeof(struct ip6t_getinfo)) {
86879 - duprintf("length %u != %zu\n", *len,
86880 + if (len != sizeof(struct ip6t_getinfo)) {
86881 + duprintf("length %u != %zu\n", len,
86882 sizeof(struct ip6t_getinfo));
86883 return -EINVAL;
86884 }
86885 @@ -1120,7 +1120,7 @@ static int get_info(struct net *net, void __user *user,
86886 info.size = private->size;
86887 strcpy(info.name, name);
86888
86889 - if (copy_to_user(user, &info, *len) != 0)
86890 + if (copy_to_user(user, &info, len) != 0)
86891 ret = -EFAULT;
86892 else
86893 ret = 0;
86894 @@ -1974,7 +1974,7 @@ compat_do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
86895
86896 switch (cmd) {
86897 case IP6T_SO_GET_INFO:
86898 - ret = get_info(sock_net(sk), user, len, 1);
86899 + ret = get_info(sock_net(sk), user, *len, 1);
86900 break;
86901 case IP6T_SO_GET_ENTRIES:
86902 ret = compat_get_entries(sock_net(sk), user, len);
86903 @@ -2021,7 +2021,7 @@ do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
86904
86905 switch (cmd) {
86906 case IP6T_SO_GET_INFO:
86907 - ret = get_info(sock_net(sk), user, len, 0);
86908 + ret = get_info(sock_net(sk), user, *len, 0);
86909 break;
86910
86911 case IP6T_SO_GET_ENTRIES:
86912 diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
86913 index 6700069..1e50f42 100644
86914 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c
86915 +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
86916 @@ -89,12 +89,11 @@ static struct ctl_table nf_ct_frag6_sysctl_table[] = {
86917
86918 static int nf_ct_frag6_sysctl_register(struct net *net)
86919 {
86920 - struct ctl_table *table;
86921 + ctl_table_no_const *table = NULL;
86922 struct ctl_table_header *hdr;
86923
86924 - table = nf_ct_frag6_sysctl_table;
86925 if (!net_eq(net, &init_net)) {
86926 - table = kmemdup(table, sizeof(nf_ct_frag6_sysctl_table),
86927 + table = kmemdup(nf_ct_frag6_sysctl_table, sizeof(nf_ct_frag6_sysctl_table),
86928 GFP_KERNEL);
86929 if (table == NULL)
86930 goto err_alloc;
86931 @@ -102,9 +101,9 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
86932 table[0].data = &net->nf_frag.frags.timeout;
86933 table[1].data = &net->nf_frag.frags.low_thresh;
86934 table[2].data = &net->nf_frag.frags.high_thresh;
86935 - }
86936 -
86937 - hdr = register_net_sysctl(net, "net/netfilter", table);
86938 + hdr = register_net_sysctl(net, "net/netfilter", table);
86939 + } else
86940 + hdr = register_net_sysctl(net, "net/netfilter", nf_ct_frag6_sysctl_table);
86941 if (hdr == NULL)
86942 goto err_reg;
86943
86944 @@ -112,8 +111,7 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
86945 return 0;
86946
86947 err_reg:
86948 - if (!net_eq(net, &init_net))
86949 - kfree(table);
86950 + kfree(table);
86951 err_alloc:
86952 return -ENOMEM;
86953 }
86954 diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
86955 index 330b5e7..796fbf1 100644
86956 --- a/net/ipv6/raw.c
86957 +++ b/net/ipv6/raw.c
86958 @@ -378,7 +378,7 @@ static inline int rawv6_rcv_skb(struct sock *sk, struct sk_buff *skb)
86959 {
86960 if ((raw6_sk(sk)->checksum || rcu_access_pointer(sk->sk_filter)) &&
86961 skb_checksum_complete(skb)) {
86962 - atomic_inc(&sk->sk_drops);
86963 + atomic_inc_unchecked(&sk->sk_drops);
86964 kfree_skb(skb);
86965 return NET_RX_DROP;
86966 }
86967 @@ -406,7 +406,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
86968 struct raw6_sock *rp = raw6_sk(sk);
86969
86970 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) {
86971 - atomic_inc(&sk->sk_drops);
86972 + atomic_inc_unchecked(&sk->sk_drops);
86973 kfree_skb(skb);
86974 return NET_RX_DROP;
86975 }
86976 @@ -430,7 +430,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
86977
86978 if (inet->hdrincl) {
86979 if (skb_checksum_complete(skb)) {
86980 - atomic_inc(&sk->sk_drops);
86981 + atomic_inc_unchecked(&sk->sk_drops);
86982 kfree_skb(skb);
86983 return NET_RX_DROP;
86984 }
86985 @@ -603,7 +603,7 @@ out:
86986 return err;
86987 }
86988
86989 -static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
86990 +static int rawv6_send_hdrinc(struct sock *sk, void *from, unsigned int length,
86991 struct flowi6 *fl6, struct dst_entry **dstp,
86992 unsigned int flags)
86993 {
86994 @@ -915,12 +915,15 @@ do_confirm:
86995 static int rawv6_seticmpfilter(struct sock *sk, int level, int optname,
86996 char __user *optval, int optlen)
86997 {
86998 + struct icmp6_filter filter;
86999 +
87000 switch (optname) {
87001 case ICMPV6_FILTER:
87002 if (optlen > sizeof(struct icmp6_filter))
87003 optlen = sizeof(struct icmp6_filter);
87004 - if (copy_from_user(&raw6_sk(sk)->filter, optval, optlen))
87005 + if (copy_from_user(&filter, optval, optlen))
87006 return -EFAULT;
87007 + raw6_sk(sk)->filter = filter;
87008 return 0;
87009 default:
87010 return -ENOPROTOOPT;
87011 @@ -933,6 +936,7 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
87012 char __user *optval, int __user *optlen)
87013 {
87014 int len;
87015 + struct icmp6_filter filter;
87016
87017 switch (optname) {
87018 case ICMPV6_FILTER:
87019 @@ -944,7 +948,8 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
87020 len = sizeof(struct icmp6_filter);
87021 if (put_user(len, optlen))
87022 return -EFAULT;
87023 - if (copy_to_user(optval, &raw6_sk(sk)->filter, len))
87024 + filter = raw6_sk(sk)->filter;
87025 + if (len > sizeof filter || copy_to_user(optval, &filter, len))
87026 return -EFAULT;
87027 return 0;
87028 default:
87029 @@ -1252,7 +1257,7 @@ static void raw6_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
87030 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
87031 0,
87032 sock_i_ino(sp),
87033 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
87034 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
87035 }
87036
87037 static int raw6_seq_show(struct seq_file *seq, void *v)
87038 diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
87039 index 0ba10e5..c14a4f6 100644
87040 --- a/net/ipv6/reassembly.c
87041 +++ b/net/ipv6/reassembly.c
87042 @@ -602,12 +602,11 @@ static struct ctl_table ip6_frags_ctl_table[] = {
87043
87044 static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
87045 {
87046 - struct ctl_table *table;
87047 + ctl_table_no_const *table = NULL;
87048 struct ctl_table_header *hdr;
87049
87050 - table = ip6_frags_ns_ctl_table;
87051 if (!net_eq(net, &init_net)) {
87052 - table = kmemdup(table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
87053 + table = kmemdup(ip6_frags_ns_ctl_table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
87054 if (table == NULL)
87055 goto err_alloc;
87056
87057 @@ -618,9 +617,10 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
87058 /* Don't export sysctls to unprivileged users */
87059 if (net->user_ns != &init_user_ns)
87060 table[0].procname = NULL;
87061 - }
87062 + hdr = register_net_sysctl(net, "net/ipv6", table);
87063 + } else
87064 + hdr = register_net_sysctl(net, "net/ipv6", ip6_frags_ns_ctl_table);
87065
87066 - hdr = register_net_sysctl(net, "net/ipv6", table);
87067 if (hdr == NULL)
87068 goto err_reg;
87069
87070 @@ -628,8 +628,7 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
87071 return 0;
87072
87073 err_reg:
87074 - if (!net_eq(net, &init_net))
87075 - kfree(table);
87076 + kfree(table);
87077 err_alloc:
87078 return -ENOMEM;
87079 }
87080 diff --git a/net/ipv6/route.c b/net/ipv6/route.c
87081 index e5fe004..9fe3e8e 100644
87082 --- a/net/ipv6/route.c
87083 +++ b/net/ipv6/route.c
87084 @@ -2881,7 +2881,7 @@ ctl_table ipv6_route_table_template[] = {
87085
87086 struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net)
87087 {
87088 - struct ctl_table *table;
87089 + ctl_table_no_const *table;
87090
87091 table = kmemdup(ipv6_route_table_template,
87092 sizeof(ipv6_route_table_template),
87093 diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
87094 index 02f96dc..4a5a6e5 100644
87095 --- a/net/ipv6/sit.c
87096 +++ b/net/ipv6/sit.c
87097 @@ -74,7 +74,7 @@ static void ipip6_tunnel_setup(struct net_device *dev);
87098 static void ipip6_dev_free(struct net_device *dev);
87099 static bool check_6rd(struct ip_tunnel *tunnel, const struct in6_addr *v6dst,
87100 __be32 *v4dst);
87101 -static struct rtnl_link_ops sit_link_ops __read_mostly;
87102 +static struct rtnl_link_ops sit_link_ops;
87103
87104 static int sit_net_id __read_mostly;
87105 struct sit_net {
87106 @@ -1486,7 +1486,7 @@ static const struct nla_policy ipip6_policy[IFLA_IPTUN_MAX + 1] = {
87107 #endif
87108 };
87109
87110 -static struct rtnl_link_ops sit_link_ops __read_mostly = {
87111 +static struct rtnl_link_ops sit_link_ops = {
87112 .kind = "sit",
87113 .maxtype = IFLA_IPTUN_MAX,
87114 .policy = ipip6_policy,
87115 diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c
87116 index e85c48b..b8268d3 100644
87117 --- a/net/ipv6/sysctl_net_ipv6.c
87118 +++ b/net/ipv6/sysctl_net_ipv6.c
87119 @@ -40,7 +40,7 @@ static ctl_table ipv6_rotable[] = {
87120
87121 static int __net_init ipv6_sysctl_net_init(struct net *net)
87122 {
87123 - struct ctl_table *ipv6_table;
87124 + ctl_table_no_const *ipv6_table;
87125 struct ctl_table *ipv6_route_table;
87126 struct ctl_table *ipv6_icmp_table;
87127 int err;
87128 diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
87129 index 0fce928..c52a518 100644
87130 --- a/net/ipv6/tcp_ipv6.c
87131 +++ b/net/ipv6/tcp_ipv6.c
87132 @@ -103,6 +103,10 @@ static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb)
87133 inet6_sk(sk)->rx_dst_cookie = rt->rt6i_node->fn_sernum;
87134 }
87135
87136 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87137 +extern int grsec_enable_blackhole;
87138 +#endif
87139 +
87140 static void tcp_v6_hash(struct sock *sk)
87141 {
87142 if (sk->sk_state != TCP_CLOSE) {
87143 @@ -1446,6 +1450,9 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
87144 return 0;
87145
87146 reset:
87147 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87148 + if (!grsec_enable_blackhole)
87149 +#endif
87150 tcp_v6_send_reset(sk, skb);
87151 discard:
87152 if (opt_skb)
87153 @@ -1527,12 +1534,20 @@ static int tcp_v6_rcv(struct sk_buff *skb)
87154 TCP_SKB_CB(skb)->sacked = 0;
87155
87156 sk = __inet6_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
87157 - if (!sk)
87158 + if (!sk) {
87159 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87160 + ret = 1;
87161 +#endif
87162 goto no_tcp_socket;
87163 + }
87164
87165 process:
87166 - if (sk->sk_state == TCP_TIME_WAIT)
87167 + if (sk->sk_state == TCP_TIME_WAIT) {
87168 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87169 + ret = 2;
87170 +#endif
87171 goto do_time_wait;
87172 + }
87173
87174 if (hdr->hop_limit < inet6_sk(sk)->min_hopcount) {
87175 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
87176 @@ -1581,6 +1596,10 @@ no_tcp_socket:
87177 bad_packet:
87178 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
87179 } else {
87180 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87181 + if (!grsec_enable_blackhole || (ret == 1 &&
87182 + (skb->dev->flags & IFF_LOOPBACK)))
87183 +#endif
87184 tcp_v6_send_reset(NULL, skb);
87185 }
87186
87187 diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
87188 index 27f0f8e..949e7ee 100644
87189 --- a/net/ipv6/udp.c
87190 +++ b/net/ipv6/udp.c
87191 @@ -52,6 +52,10 @@
87192 #include <trace/events/skb.h>
87193 #include "udp_impl.h"
87194
87195 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87196 +extern int grsec_enable_blackhole;
87197 +#endif
87198 +
87199 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
87200 {
87201 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
87202 @@ -419,7 +423,7 @@ try_again:
87203 if (unlikely(err)) {
87204 trace_kfree_skb(skb, udpv6_recvmsg);
87205 if (!peeked) {
87206 - atomic_inc(&sk->sk_drops);
87207 + atomic_inc_unchecked(&sk->sk_drops);
87208 if (is_udp4)
87209 UDP_INC_STATS_USER(sock_net(sk),
87210 UDP_MIB_INERRORS,
87211 @@ -657,7 +661,7 @@ int udpv6_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
87212 return rc;
87213 drop:
87214 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
87215 - atomic_inc(&sk->sk_drops);
87216 + atomic_inc_unchecked(&sk->sk_drops);
87217 kfree_skb(skb);
87218 return -1;
87219 }
87220 @@ -715,7 +719,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
87221 if (likely(skb1 == NULL))
87222 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
87223 if (!skb1) {
87224 - atomic_inc(&sk->sk_drops);
87225 + atomic_inc_unchecked(&sk->sk_drops);
87226 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
87227 IS_UDPLITE(sk));
87228 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
87229 @@ -852,6 +856,9 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
87230 goto discard;
87231
87232 UDP6_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
87233 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87234 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
87235 +#endif
87236 icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);
87237
87238 kfree_skb(skb);
87239 @@ -1377,7 +1384,7 @@ static void udp6_sock_seq_show(struct seq_file *seq, struct sock *sp, int bucket
87240 0,
87241 sock_i_ino(sp),
87242 atomic_read(&sp->sk_refcnt), sp,
87243 - atomic_read(&sp->sk_drops));
87244 + atomic_read_unchecked(&sp->sk_drops));
87245 }
87246
87247 int udp6_seq_show(struct seq_file *seq, void *v)
87248 diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
87249 index 23ed03d..465a71d 100644
87250 --- a/net/ipv6/xfrm6_policy.c
87251 +++ b/net/ipv6/xfrm6_policy.c
87252 @@ -324,19 +324,19 @@ static struct ctl_table xfrm6_policy_table[] = {
87253
87254 static int __net_init xfrm6_net_init(struct net *net)
87255 {
87256 - struct ctl_table *table;
87257 + ctl_table_no_const *table = NULL;
87258 struct ctl_table_header *hdr;
87259
87260 - table = xfrm6_policy_table;
87261 if (!net_eq(net, &init_net)) {
87262 - table = kmemdup(table, sizeof(xfrm6_policy_table), GFP_KERNEL);
87263 + table = kmemdup(xfrm6_policy_table, sizeof(xfrm6_policy_table), GFP_KERNEL);
87264 if (!table)
87265 goto err_alloc;
87266
87267 table[0].data = &net->xfrm.xfrm6_dst_ops.gc_thresh;
87268 - }
87269 + hdr = register_net_sysctl(net, "net/ipv6", table);
87270 + } else
87271 + hdr = register_net_sysctl(net, "net/ipv6", xfrm6_policy_table);
87272
87273 - hdr = register_net_sysctl(net, "net/ipv6", table);
87274 if (!hdr)
87275 goto err_reg;
87276
87277 @@ -344,8 +344,7 @@ static int __net_init xfrm6_net_init(struct net *net)
87278 return 0;
87279
87280 err_reg:
87281 - if (!net_eq(net, &init_net))
87282 - kfree(table);
87283 + kfree(table);
87284 err_alloc:
87285 return -ENOMEM;
87286 }
87287 diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
87288 index 362ba47..66196f4 100644
87289 --- a/net/irda/ircomm/ircomm_tty.c
87290 +++ b/net/irda/ircomm/ircomm_tty.c
87291 @@ -319,11 +319,11 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
87292 add_wait_queue(&port->open_wait, &wait);
87293
87294 IRDA_DEBUG(2, "%s(%d):block_til_ready before block on %s open_count=%d\n",
87295 - __FILE__, __LINE__, tty->driver->name, port->count);
87296 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
87297
87298 spin_lock_irqsave(&port->lock, flags);
87299 if (!tty_hung_up_p(filp))
87300 - port->count--;
87301 + atomic_dec(&port->count);
87302 port->blocked_open++;
87303 spin_unlock_irqrestore(&port->lock, flags);
87304
87305 @@ -358,7 +358,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
87306 }
87307
87308 IRDA_DEBUG(1, "%s(%d):block_til_ready blocking on %s open_count=%d\n",
87309 - __FILE__, __LINE__, tty->driver->name, port->count);
87310 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
87311
87312 schedule();
87313 }
87314 @@ -368,12 +368,12 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
87315
87316 spin_lock_irqsave(&port->lock, flags);
87317 if (!tty_hung_up_p(filp))
87318 - port->count++;
87319 + atomic_inc(&port->count);
87320 port->blocked_open--;
87321 spin_unlock_irqrestore(&port->lock, flags);
87322
87323 IRDA_DEBUG(1, "%s(%d):block_til_ready after blocking on %s open_count=%d\n",
87324 - __FILE__, __LINE__, tty->driver->name, port->count);
87325 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
87326
87327 if (!retval)
87328 port->flags |= ASYNC_NORMAL_ACTIVE;
87329 @@ -447,12 +447,12 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
87330
87331 /* ++ is not atomic, so this should be protected - Jean II */
87332 spin_lock_irqsave(&self->port.lock, flags);
87333 - self->port.count++;
87334 + atomic_inc(&self->port.count);
87335 spin_unlock_irqrestore(&self->port.lock, flags);
87336 tty_port_tty_set(&self->port, tty);
87337
87338 IRDA_DEBUG(1, "%s(), %s%d, count = %d\n", __func__ , tty->driver->name,
87339 - self->line, self->port.count);
87340 + self->line, atomic_read(&self->port.count));
87341
87342 /* Not really used by us, but lets do it anyway */
87343 self->port.low_latency = (self->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
87344 @@ -989,7 +989,7 @@ static void ircomm_tty_hangup(struct tty_struct *tty)
87345 tty_kref_put(port->tty);
87346 }
87347 port->tty = NULL;
87348 - port->count = 0;
87349 + atomic_set(&port->count, 0);
87350 spin_unlock_irqrestore(&port->lock, flags);
87351
87352 wake_up_interruptible(&port->open_wait);
87353 @@ -1346,7 +1346,7 @@ static void ircomm_tty_line_info(struct ircomm_tty_cb *self, struct seq_file *m)
87354 seq_putc(m, '\n');
87355
87356 seq_printf(m, "Role: %s\n", self->client ? "client" : "server");
87357 - seq_printf(m, "Open count: %d\n", self->port.count);
87358 + seq_printf(m, "Open count: %d\n", atomic_read(&self->port.count));
87359 seq_printf(m, "Max data size: %d\n", self->max_data_size);
87360 seq_printf(m, "Max header size: %d\n", self->max_header_size);
87361
87362 diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
87363 index 206ce6d..cfb27cd 100644
87364 --- a/net/iucv/af_iucv.c
87365 +++ b/net/iucv/af_iucv.c
87366 @@ -773,10 +773,10 @@ static int iucv_sock_autobind(struct sock *sk)
87367
87368 write_lock_bh(&iucv_sk_list.lock);
87369
87370 - sprintf(name, "%08x", atomic_inc_return(&iucv_sk_list.autobind_name));
87371 + sprintf(name, "%08x", atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
87372 while (__iucv_get_sock_by_name(name)) {
87373 sprintf(name, "%08x",
87374 - atomic_inc_return(&iucv_sk_list.autobind_name));
87375 + atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
87376 }
87377
87378 write_unlock_bh(&iucv_sk_list.lock);
87379 diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c
87380 index 4fe76ff..426a904 100644
87381 --- a/net/iucv/iucv.c
87382 +++ b/net/iucv/iucv.c
87383 @@ -690,7 +690,7 @@ static int __cpuinit iucv_cpu_notify(struct notifier_block *self,
87384 return NOTIFY_OK;
87385 }
87386
87387 -static struct notifier_block __refdata iucv_cpu_notifier = {
87388 +static struct notifier_block iucv_cpu_notifier = {
87389 .notifier_call = iucv_cpu_notify,
87390 };
87391
87392 diff --git a/net/key/af_key.c b/net/key/af_key.c
87393 index 5b1e5af..2358147 100644
87394 --- a/net/key/af_key.c
87395 +++ b/net/key/af_key.c
87396 @@ -3041,10 +3041,10 @@ static int pfkey_send_policy_notify(struct xfrm_policy *xp, int dir, const struc
87397 static u32 get_acqseq(void)
87398 {
87399 u32 res;
87400 - static atomic_t acqseq;
87401 + static atomic_unchecked_t acqseq;
87402
87403 do {
87404 - res = atomic_inc_return(&acqseq);
87405 + res = atomic_inc_return_unchecked(&acqseq);
87406 } while (!res);
87407 return res;
87408 }
87409 diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
87410 index 843d8c4..cb04fa1 100644
87411 --- a/net/mac80211/cfg.c
87412 +++ b/net/mac80211/cfg.c
87413 @@ -799,7 +799,7 @@ static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
87414 ret = ieee80211_vif_use_channel(sdata, chandef,
87415 IEEE80211_CHANCTX_EXCLUSIVE);
87416 }
87417 - } else if (local->open_count == local->monitors) {
87418 + } else if (local_read(&local->open_count) == local->monitors) {
87419 local->_oper_channel = chandef->chan;
87420 local->_oper_channel_type = cfg80211_get_chandef_type(chandef);
87421 ieee80211_hw_config(local, 0);
87422 @@ -2834,7 +2834,7 @@ static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
87423 else
87424 local->probe_req_reg--;
87425
87426 - if (!local->open_count)
87427 + if (!local_read(&local->open_count))
87428 break;
87429
87430 ieee80211_queue_work(&local->hw, &local->reconfig_filter);
87431 @@ -3297,8 +3297,8 @@ static int ieee80211_cfg_get_channel(struct wiphy *wiphy,
87432 if (chanctx_conf) {
87433 *chandef = chanctx_conf->def;
87434 ret = 0;
87435 - } else if (local->open_count > 0 &&
87436 - local->open_count == local->monitors &&
87437 + } else if (local_read(&local->open_count) > 0 &&
87438 + local_read(&local->open_count) == local->monitors &&
87439 sdata->vif.type == NL80211_IFTYPE_MONITOR) {
87440 if (local->use_chanctx)
87441 *chandef = local->monitor_chandef;
87442 diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
87443 index 5672533..6738c93 100644
87444 --- a/net/mac80211/ieee80211_i.h
87445 +++ b/net/mac80211/ieee80211_i.h
87446 @@ -28,6 +28,7 @@
87447 #include <net/ieee80211_radiotap.h>
87448 #include <net/cfg80211.h>
87449 #include <net/mac80211.h>
87450 +#include <asm/local.h>
87451 #include "key.h"
87452 #include "sta_info.h"
87453 #include "debug.h"
87454 @@ -897,7 +898,7 @@ struct ieee80211_local {
87455 /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
87456 spinlock_t queue_stop_reason_lock;
87457
87458 - int open_count;
87459 + local_t open_count;
87460 int monitors, cooked_mntrs;
87461 /* number of interfaces with corresponding FIF_ flags */
87462 int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll,
87463 diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
87464 index d51ca9d..042c35f 100644
87465 --- a/net/mac80211/iface.c
87466 +++ b/net/mac80211/iface.c
87467 @@ -495,7 +495,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
87468 break;
87469 }
87470
87471 - if (local->open_count == 0) {
87472 + if (local_read(&local->open_count) == 0) {
87473 res = drv_start(local);
87474 if (res)
87475 goto err_del_bss;
87476 @@ -540,7 +540,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
87477 break;
87478 }
87479
87480 - if (local->monitors == 0 && local->open_count == 0) {
87481 + if (local->monitors == 0 && local_read(&local->open_count) == 0) {
87482 res = ieee80211_add_virtual_monitor(local);
87483 if (res)
87484 goto err_stop;
87485 @@ -649,7 +649,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
87486 atomic_inc(&local->iff_promiscs);
87487
87488 if (coming_up)
87489 - local->open_count++;
87490 + local_inc(&local->open_count);
87491
87492 if (hw_reconf_flags)
87493 ieee80211_hw_config(local, hw_reconf_flags);
87494 @@ -663,7 +663,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
87495 err_del_interface:
87496 drv_remove_interface(local, sdata);
87497 err_stop:
87498 - if (!local->open_count)
87499 + if (!local_read(&local->open_count))
87500 drv_stop(local);
87501 err_del_bss:
87502 sdata->bss = NULL;
87503 @@ -806,7 +806,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
87504 }
87505
87506 if (going_down)
87507 - local->open_count--;
87508 + local_dec(&local->open_count);
87509
87510 switch (sdata->vif.type) {
87511 case NL80211_IFTYPE_AP_VLAN:
87512 @@ -871,7 +871,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
87513
87514 ieee80211_recalc_ps(local, -1);
87515
87516 - if (local->open_count == 0) {
87517 + if (local_read(&local->open_count) == 0) {
87518 if (local->ops->napi_poll)
87519 napi_disable(&local->napi);
87520 ieee80211_clear_tx_pending(local);
87521 @@ -897,7 +897,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
87522 }
87523 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
87524
87525 - if (local->monitors == local->open_count && local->monitors > 0)
87526 + if (local->monitors == local_read(&local->open_count) && local->monitors > 0)
87527 ieee80211_add_virtual_monitor(local);
87528 }
87529
87530 diff --git a/net/mac80211/main.c b/net/mac80211/main.c
87531 index 1a8591b..ef5db54 100644
87532 --- a/net/mac80211/main.c
87533 +++ b/net/mac80211/main.c
87534 @@ -180,7 +180,7 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed)
87535 changed &= ~(IEEE80211_CONF_CHANGE_CHANNEL |
87536 IEEE80211_CONF_CHANGE_POWER);
87537
87538 - if (changed && local->open_count) {
87539 + if (changed && local_read(&local->open_count)) {
87540 ret = drv_config(local, changed);
87541 /*
87542 * Goal:
87543 diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c
87544 index 835584c..be46e67 100644
87545 --- a/net/mac80211/pm.c
87546 +++ b/net/mac80211/pm.c
87547 @@ -33,7 +33,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
87548 struct sta_info *sta;
87549 struct ieee80211_chanctx *ctx;
87550
87551 - if (!local->open_count)
87552 + if (!local_read(&local->open_count))
87553 goto suspend;
87554
87555 ieee80211_scan_cancel(local);
87556 @@ -75,7 +75,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
87557 cancel_work_sync(&local->dynamic_ps_enable_work);
87558 del_timer_sync(&local->dynamic_ps_timer);
87559
87560 - local->wowlan = wowlan && local->open_count;
87561 + local->wowlan = wowlan && local_read(&local->open_count);
87562 if (local->wowlan) {
87563 int err = drv_suspend(local, wowlan);
87564 if (err < 0) {
87565 @@ -214,7 +214,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
87566 mutex_unlock(&local->chanctx_mtx);
87567
87568 /* stop hardware - this must stop RX */
87569 - if (local->open_count)
87570 + if (local_read(&local->open_count))
87571 ieee80211_stop_device(local);
87572
87573 suspend:
87574 diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
87575 index dd88381..eef4dd6 100644
87576 --- a/net/mac80211/rate.c
87577 +++ b/net/mac80211/rate.c
87578 @@ -493,7 +493,7 @@ int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
87579
87580 ASSERT_RTNL();
87581
87582 - if (local->open_count)
87583 + if (local_read(&local->open_count))
87584 return -EBUSY;
87585
87586 if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) {
87587 diff --git a/net/mac80211/rc80211_pid_debugfs.c b/net/mac80211/rc80211_pid_debugfs.c
87588 index c97a065..ff61928 100644
87589 --- a/net/mac80211/rc80211_pid_debugfs.c
87590 +++ b/net/mac80211/rc80211_pid_debugfs.c
87591 @@ -193,7 +193,7 @@ static ssize_t rate_control_pid_events_read(struct file *file, char __user *buf,
87592
87593 spin_unlock_irqrestore(&events->lock, status);
87594
87595 - if (copy_to_user(buf, pb, p))
87596 + if (p > sizeof(pb) || copy_to_user(buf, pb, p))
87597 return -EFAULT;
87598
87599 return p;
87600 diff --git a/net/mac80211/util.c b/net/mac80211/util.c
87601 index 0f38f43..e53d4a8 100644
87602 --- a/net/mac80211/util.c
87603 +++ b/net/mac80211/util.c
87604 @@ -1388,7 +1388,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
87605 }
87606 #endif
87607 /* everything else happens only if HW was up & running */
87608 - if (!local->open_count)
87609 + if (!local_read(&local->open_count))
87610 goto wake_up;
87611
87612 /*
87613 diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
87614 index 56d22ca..87c778f 100644
87615 --- a/net/netfilter/Kconfig
87616 +++ b/net/netfilter/Kconfig
87617 @@ -958,6 +958,16 @@ config NETFILTER_XT_MATCH_ESP
87618
87619 To compile it as a module, choose M here. If unsure, say N.
87620
87621 +config NETFILTER_XT_MATCH_GRADM
87622 + tristate '"gradm" match support'
87623 + depends on NETFILTER_XTABLES && NETFILTER_ADVANCED
87624 + depends on GRKERNSEC && !GRKERNSEC_NO_RBAC
87625 + ---help---
87626 + The gradm match allows to match on grsecurity RBAC being enabled.
87627 + It is useful when iptables rules are applied early on bootup to
87628 + prevent connections to the machine (except from a trusted host)
87629 + while the RBAC system is disabled.
87630 +
87631 config NETFILTER_XT_MATCH_HASHLIMIT
87632 tristate '"hashlimit" match support'
87633 depends on (IP6_NF_IPTABLES || IP6_NF_IPTABLES=n)
87634 diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile
87635 index a1abf87..dbcb7ee 100644
87636 --- a/net/netfilter/Makefile
87637 +++ b/net/netfilter/Makefile
87638 @@ -112,6 +112,7 @@ obj-$(CONFIG_NETFILTER_XT_MATCH_DEVGROUP) += xt_devgroup.o
87639 obj-$(CONFIG_NETFILTER_XT_MATCH_DSCP) += xt_dscp.o
87640 obj-$(CONFIG_NETFILTER_XT_MATCH_ECN) += xt_ecn.o
87641 obj-$(CONFIG_NETFILTER_XT_MATCH_ESP) += xt_esp.o
87642 +obj-$(CONFIG_NETFILTER_XT_MATCH_GRADM) += xt_gradm.o
87643 obj-$(CONFIG_NETFILTER_XT_MATCH_HASHLIMIT) += xt_hashlimit.o
87644 obj-$(CONFIG_NETFILTER_XT_MATCH_HELPER) += xt_helper.o
87645 obj-$(CONFIG_NETFILTER_XT_MATCH_HL) += xt_hl.o
87646 diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
87647 index 1ba9dbc..e39f4ca 100644
87648 --- a/net/netfilter/ipset/ip_set_core.c
87649 +++ b/net/netfilter/ipset/ip_set_core.c
87650 @@ -1801,7 +1801,7 @@ done:
87651 return ret;
87652 }
87653
87654 -static struct nf_sockopt_ops so_set __read_mostly = {
87655 +static struct nf_sockopt_ops so_set = {
87656 .pf = PF_INET,
87657 .get_optmin = SO_IP_SET,
87658 .get_optmax = SO_IP_SET + 1,
87659 diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
87660 index 704e514..d644cc2 100644
87661 --- a/net/netfilter/ipvs/ip_vs_conn.c
87662 +++ b/net/netfilter/ipvs/ip_vs_conn.c
87663 @@ -551,7 +551,7 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)
87664 /* Increase the refcnt counter of the dest */
87665 atomic_inc(&dest->refcnt);
87666
87667 - conn_flags = atomic_read(&dest->conn_flags);
87668 + conn_flags = atomic_read_unchecked(&dest->conn_flags);
87669 if (cp->protocol != IPPROTO_UDP)
87670 conn_flags &= ~IP_VS_CONN_F_ONE_PACKET;
87671 flags = cp->flags;
87672 @@ -895,7 +895,7 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p,
87673 atomic_set(&cp->refcnt, 1);
87674
87675 atomic_set(&cp->n_control, 0);
87676 - atomic_set(&cp->in_pkts, 0);
87677 + atomic_set_unchecked(&cp->in_pkts, 0);
87678
87679 atomic_inc(&ipvs->conn_count);
87680 if (flags & IP_VS_CONN_F_NO_CPORT)
87681 @@ -1174,7 +1174,7 @@ static inline int todrop_entry(struct ip_vs_conn *cp)
87682
87683 /* Don't drop the entry if its number of incoming packets is not
87684 located in [0, 8] */
87685 - i = atomic_read(&cp->in_pkts);
87686 + i = atomic_read_unchecked(&cp->in_pkts);
87687 if (i > 8 || i < 0) return 0;
87688
87689 if (!todrop_rate[i]) return 0;
87690 diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
87691 index 61f49d2..6c8c5bc 100644
87692 --- a/net/netfilter/ipvs/ip_vs_core.c
87693 +++ b/net/netfilter/ipvs/ip_vs_core.c
87694 @@ -559,7 +559,7 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,
87695 ret = cp->packet_xmit(skb, cp, pd->pp, iph);
87696 /* do not touch skb anymore */
87697
87698 - atomic_inc(&cp->in_pkts);
87699 + atomic_inc_unchecked(&cp->in_pkts);
87700 ip_vs_conn_put(cp);
87701 return ret;
87702 }
87703 @@ -1689,7 +1689,7 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af)
87704 if (cp->flags & IP_VS_CONN_F_ONE_PACKET)
87705 pkts = sysctl_sync_threshold(ipvs);
87706 else
87707 - pkts = atomic_add_return(1, &cp->in_pkts);
87708 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
87709
87710 if (ipvs->sync_state & IP_VS_STATE_MASTER)
87711 ip_vs_sync_conn(net, cp, pkts);
87712 diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
87713 index 9e2d1cc..7f8f569 100644
87714 --- a/net/netfilter/ipvs/ip_vs_ctl.c
87715 +++ b/net/netfilter/ipvs/ip_vs_ctl.c
87716 @@ -787,7 +787,7 @@ __ip_vs_update_dest(struct ip_vs_service *svc, struct ip_vs_dest *dest,
87717 ip_vs_rs_hash(ipvs, dest);
87718 write_unlock_bh(&ipvs->rs_lock);
87719 }
87720 - atomic_set(&dest->conn_flags, conn_flags);
87721 + atomic_set_unchecked(&dest->conn_flags, conn_flags);
87722
87723 /* bind the service */
87724 if (!dest->svc) {
87725 @@ -1688,7 +1688,7 @@ proc_do_sync_ports(ctl_table *table, int write,
87726 * align with netns init in ip_vs_control_net_init()
87727 */
87728
87729 -static struct ctl_table vs_vars[] = {
87730 +static ctl_table_no_const vs_vars[] __read_only = {
87731 {
87732 .procname = "amemthresh",
87733 .maxlen = sizeof(int),
87734 @@ -2087,7 +2087,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
87735 " %-7s %-6d %-10d %-10d\n",
87736 &dest->addr.in6,
87737 ntohs(dest->port),
87738 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
87739 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
87740 atomic_read(&dest->weight),
87741 atomic_read(&dest->activeconns),
87742 atomic_read(&dest->inactconns));
87743 @@ -2098,7 +2098,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
87744 "%-7s %-6d %-10d %-10d\n",
87745 ntohl(dest->addr.ip),
87746 ntohs(dest->port),
87747 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
87748 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
87749 atomic_read(&dest->weight),
87750 atomic_read(&dest->activeconns),
87751 atomic_read(&dest->inactconns));
87752 @@ -2568,7 +2568,7 @@ __ip_vs_get_dest_entries(struct net *net, const struct ip_vs_get_dests *get,
87753
87754 entry.addr = dest->addr.ip;
87755 entry.port = dest->port;
87756 - entry.conn_flags = atomic_read(&dest->conn_flags);
87757 + entry.conn_flags = atomic_read_unchecked(&dest->conn_flags);
87758 entry.weight = atomic_read(&dest->weight);
87759 entry.u_threshold = dest->u_threshold;
87760 entry.l_threshold = dest->l_threshold;
87761 @@ -3104,7 +3104,7 @@ static int ip_vs_genl_fill_dest(struct sk_buff *skb, struct ip_vs_dest *dest)
87762 if (nla_put(skb, IPVS_DEST_ATTR_ADDR, sizeof(dest->addr), &dest->addr) ||
87763 nla_put_u16(skb, IPVS_DEST_ATTR_PORT, dest->port) ||
87764 nla_put_u32(skb, IPVS_DEST_ATTR_FWD_METHOD,
87765 - (atomic_read(&dest->conn_flags) &
87766 + (atomic_read_unchecked(&dest->conn_flags) &
87767 IP_VS_CONN_F_FWD_MASK)) ||
87768 nla_put_u32(skb, IPVS_DEST_ATTR_WEIGHT,
87769 atomic_read(&dest->weight)) ||
87770 @@ -3694,7 +3694,7 @@ static int __net_init ip_vs_control_net_init_sysctl(struct net *net)
87771 {
87772 int idx;
87773 struct netns_ipvs *ipvs = net_ipvs(net);
87774 - struct ctl_table *tbl;
87775 + ctl_table_no_const *tbl;
87776
87777 atomic_set(&ipvs->dropentry, 0);
87778 spin_lock_init(&ipvs->dropentry_lock);
87779 diff --git a/net/netfilter/ipvs/ip_vs_lblc.c b/net/netfilter/ipvs/ip_vs_lblc.c
87780 index fdd89b9..bd96aa9 100644
87781 --- a/net/netfilter/ipvs/ip_vs_lblc.c
87782 +++ b/net/netfilter/ipvs/ip_vs_lblc.c
87783 @@ -115,7 +115,7 @@ struct ip_vs_lblc_table {
87784 * IPVS LBLC sysctl table
87785 */
87786 #ifdef CONFIG_SYSCTL
87787 -static ctl_table vs_vars_table[] = {
87788 +static ctl_table_no_const vs_vars_table[] __read_only = {
87789 {
87790 .procname = "lblc_expiration",
87791 .data = NULL,
87792 diff --git a/net/netfilter/ipvs/ip_vs_lblcr.c b/net/netfilter/ipvs/ip_vs_lblcr.c
87793 index c03b6a3..8ce3681 100644
87794 --- a/net/netfilter/ipvs/ip_vs_lblcr.c
87795 +++ b/net/netfilter/ipvs/ip_vs_lblcr.c
87796 @@ -288,7 +288,7 @@ struct ip_vs_lblcr_table {
87797 * IPVS LBLCR sysctl table
87798 */
87799
87800 -static ctl_table vs_vars_table[] = {
87801 +static ctl_table_no_const vs_vars_table[] __read_only = {
87802 {
87803 .procname = "lblcr_expiration",
87804 .data = NULL,
87805 diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
87806 index 44fd10c..2a163b3 100644
87807 --- a/net/netfilter/ipvs/ip_vs_sync.c
87808 +++ b/net/netfilter/ipvs/ip_vs_sync.c
87809 @@ -596,7 +596,7 @@ static void ip_vs_sync_conn_v0(struct net *net, struct ip_vs_conn *cp,
87810 cp = cp->control;
87811 if (cp) {
87812 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
87813 - pkts = atomic_add_return(1, &cp->in_pkts);
87814 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
87815 else
87816 pkts = sysctl_sync_threshold(ipvs);
87817 ip_vs_sync_conn(net, cp->control, pkts);
87818 @@ -758,7 +758,7 @@ control:
87819 if (!cp)
87820 return;
87821 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
87822 - pkts = atomic_add_return(1, &cp->in_pkts);
87823 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
87824 else
87825 pkts = sysctl_sync_threshold(ipvs);
87826 goto sloop;
87827 @@ -885,7 +885,7 @@ static void ip_vs_proc_conn(struct net *net, struct ip_vs_conn_param *param,
87828
87829 if (opt)
87830 memcpy(&cp->in_seq, opt, sizeof(*opt));
87831 - atomic_set(&cp->in_pkts, sysctl_sync_threshold(ipvs));
87832 + atomic_set_unchecked(&cp->in_pkts, sysctl_sync_threshold(ipvs));
87833 cp->state = state;
87834 cp->old_state = cp->state;
87835 /*
87836 diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
87837 index ee6b7a9..f9a89f6 100644
87838 --- a/net/netfilter/ipvs/ip_vs_xmit.c
87839 +++ b/net/netfilter/ipvs/ip_vs_xmit.c
87840 @@ -1210,7 +1210,7 @@ ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
87841 else
87842 rc = NF_ACCEPT;
87843 /* do not touch skb anymore */
87844 - atomic_inc(&cp->in_pkts);
87845 + atomic_inc_unchecked(&cp->in_pkts);
87846 goto out;
87847 }
87848
87849 @@ -1332,7 +1332,7 @@ ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
87850 else
87851 rc = NF_ACCEPT;
87852 /* do not touch skb anymore */
87853 - atomic_inc(&cp->in_pkts);
87854 + atomic_inc_unchecked(&cp->in_pkts);
87855 goto out;
87856 }
87857
87858 diff --git a/net/netfilter/nf_conntrack_acct.c b/net/netfilter/nf_conntrack_acct.c
87859 index 2d3030a..7ba1c0a 100644
87860 --- a/net/netfilter/nf_conntrack_acct.c
87861 +++ b/net/netfilter/nf_conntrack_acct.c
87862 @@ -60,7 +60,7 @@ static struct nf_ct_ext_type acct_extend __read_mostly = {
87863 #ifdef CONFIG_SYSCTL
87864 static int nf_conntrack_acct_init_sysctl(struct net *net)
87865 {
87866 - struct ctl_table *table;
87867 + ctl_table_no_const *table;
87868
87869 table = kmemdup(acct_sysctl_table, sizeof(acct_sysctl_table),
87870 GFP_KERNEL);
87871 diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
87872 index c8e001a..f842a8b 100644
87873 --- a/net/netfilter/nf_conntrack_core.c
87874 +++ b/net/netfilter/nf_conntrack_core.c
87875 @@ -1594,6 +1594,10 @@ void nf_conntrack_init_end(void)
87876 #define DYING_NULLS_VAL ((1<<30)+1)
87877 #define TEMPLATE_NULLS_VAL ((1<<30)+2)
87878
87879 +#ifdef CONFIG_GRKERNSEC_HIDESYM
87880 +static atomic_unchecked_t conntrack_cache_id = ATOMIC_INIT(0);
87881 +#endif
87882 +
87883 int nf_conntrack_init_net(struct net *net)
87884 {
87885 int ret;
87886 @@ -1608,7 +1612,11 @@ int nf_conntrack_init_net(struct net *net)
87887 goto err_stat;
87888 }
87889
87890 +#ifdef CONFIG_GRKERNSEC_HIDESYM
87891 + net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%08lx", atomic_inc_return_unchecked(&conntrack_cache_id));
87892 +#else
87893 net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%p", net);
87894 +#endif
87895 if (!net->ct.slabname) {
87896 ret = -ENOMEM;
87897 goto err_slabname;
87898 diff --git a/net/netfilter/nf_conntrack_ecache.c b/net/netfilter/nf_conntrack_ecache.c
87899 index b5d2eb8..61ef19a 100644
87900 --- a/net/netfilter/nf_conntrack_ecache.c
87901 +++ b/net/netfilter/nf_conntrack_ecache.c
87902 @@ -186,7 +186,7 @@ static struct nf_ct_ext_type event_extend __read_mostly = {
87903 #ifdef CONFIG_SYSCTL
87904 static int nf_conntrack_event_init_sysctl(struct net *net)
87905 {
87906 - struct ctl_table *table;
87907 + ctl_table_no_const *table;
87908
87909 table = kmemdup(event_sysctl_table, sizeof(event_sysctl_table),
87910 GFP_KERNEL);
87911 diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c
87912 index 94b4b98..97cf0ad 100644
87913 --- a/net/netfilter/nf_conntrack_helper.c
87914 +++ b/net/netfilter/nf_conntrack_helper.c
87915 @@ -56,7 +56,7 @@ static struct ctl_table helper_sysctl_table[] = {
87916
87917 static int nf_conntrack_helper_init_sysctl(struct net *net)
87918 {
87919 - struct ctl_table *table;
87920 + ctl_table_no_const *table;
87921
87922 table = kmemdup(helper_sysctl_table, sizeof(helper_sysctl_table),
87923 GFP_KERNEL);
87924 diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c
87925 index 58ab405..50eb8d3 100644
87926 --- a/net/netfilter/nf_conntrack_proto.c
87927 +++ b/net/netfilter/nf_conntrack_proto.c
87928 @@ -51,7 +51,7 @@ nf_ct_register_sysctl(struct net *net,
87929
87930 static void
87931 nf_ct_unregister_sysctl(struct ctl_table_header **header,
87932 - struct ctl_table **table,
87933 + ctl_table_no_const **table,
87934 unsigned int users)
87935 {
87936 if (users > 0)
87937 diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
87938 index fedee39..d62a93d 100644
87939 --- a/net/netfilter/nf_conntrack_standalone.c
87940 +++ b/net/netfilter/nf_conntrack_standalone.c
87941 @@ -470,7 +470,7 @@ static ctl_table nf_ct_netfilter_table[] = {
87942
87943 static int nf_conntrack_standalone_init_sysctl(struct net *net)
87944 {
87945 - struct ctl_table *table;
87946 + ctl_table_no_const *table;
87947
87948 table = kmemdup(nf_ct_sysctl_table, sizeof(nf_ct_sysctl_table),
87949 GFP_KERNEL);
87950 diff --git a/net/netfilter/nf_conntrack_timestamp.c b/net/netfilter/nf_conntrack_timestamp.c
87951 index 902fb0a..87f7fdb 100644
87952 --- a/net/netfilter/nf_conntrack_timestamp.c
87953 +++ b/net/netfilter/nf_conntrack_timestamp.c
87954 @@ -42,7 +42,7 @@ static struct nf_ct_ext_type tstamp_extend __read_mostly = {
87955 #ifdef CONFIG_SYSCTL
87956 static int nf_conntrack_tstamp_init_sysctl(struct net *net)
87957 {
87958 - struct ctl_table *table;
87959 + ctl_table_no_const *table;
87960
87961 table = kmemdup(tstamp_sysctl_table, sizeof(tstamp_sysctl_table),
87962 GFP_KERNEL);
87963 diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c
87964 index 9e31269..bc4c1b7 100644
87965 --- a/net/netfilter/nf_log.c
87966 +++ b/net/netfilter/nf_log.c
87967 @@ -215,7 +215,7 @@ static const struct file_operations nflog_file_ops = {
87968
87969 #ifdef CONFIG_SYSCTL
87970 static char nf_log_sysctl_fnames[NFPROTO_NUMPROTO-NFPROTO_UNSPEC][3];
87971 -static struct ctl_table nf_log_sysctl_table[NFPROTO_NUMPROTO+1];
87972 +static ctl_table_no_const nf_log_sysctl_table[NFPROTO_NUMPROTO+1] __read_only;
87973 static struct ctl_table_header *nf_log_dir_header;
87974
87975 static int nf_log_proc_dostring(ctl_table *table, int write,
87976 @@ -246,14 +246,16 @@ static int nf_log_proc_dostring(ctl_table *table, int write,
87977 rcu_assign_pointer(nf_loggers[tindex], logger);
87978 mutex_unlock(&nf_log_mutex);
87979 } else {
87980 + ctl_table_no_const nf_log_table = *table;
87981 +
87982 mutex_lock(&nf_log_mutex);
87983 logger = rcu_dereference_protected(nf_loggers[tindex],
87984 lockdep_is_held(&nf_log_mutex));
87985 if (!logger)
87986 - table->data = "NONE";
87987 + nf_log_table.data = "NONE";
87988 else
87989 - table->data = logger->name;
87990 - r = proc_dostring(table, write, buffer, lenp, ppos);
87991 + nf_log_table.data = logger->name;
87992 + r = proc_dostring(&nf_log_table, write, buffer, lenp, ppos);
87993 mutex_unlock(&nf_log_mutex);
87994 }
87995
87996 diff --git a/net/netfilter/nf_sockopt.c b/net/netfilter/nf_sockopt.c
87997 index f042ae5..30ea486 100644
87998 --- a/net/netfilter/nf_sockopt.c
87999 +++ b/net/netfilter/nf_sockopt.c
88000 @@ -45,7 +45,7 @@ int nf_register_sockopt(struct nf_sockopt_ops *reg)
88001 }
88002 }
88003
88004 - list_add(&reg->list, &nf_sockopts);
88005 + pax_list_add((struct list_head *)&reg->list, &nf_sockopts);
88006 out:
88007 mutex_unlock(&nf_sockopt_mutex);
88008 return ret;
88009 @@ -55,7 +55,7 @@ EXPORT_SYMBOL(nf_register_sockopt);
88010 void nf_unregister_sockopt(struct nf_sockopt_ops *reg)
88011 {
88012 mutex_lock(&nf_sockopt_mutex);
88013 - list_del(&reg->list);
88014 + pax_list_del((struct list_head *)&reg->list);
88015 mutex_unlock(&nf_sockopt_mutex);
88016 }
88017 EXPORT_SYMBOL(nf_unregister_sockopt);
88018 diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
88019 index f248db5..3778ad9 100644
88020 --- a/net/netfilter/nfnetlink_log.c
88021 +++ b/net/netfilter/nfnetlink_log.c
88022 @@ -72,7 +72,7 @@ struct nfulnl_instance {
88023 };
88024
88025 static DEFINE_SPINLOCK(instances_lock);
88026 -static atomic_t global_seq;
88027 +static atomic_unchecked_t global_seq;
88028
88029 #define INSTANCE_BUCKETS 16
88030 static struct hlist_head instance_table[INSTANCE_BUCKETS];
88031 @@ -536,7 +536,7 @@ __build_packet_message(struct nfulnl_instance *inst,
88032 /* global sequence number */
88033 if ((inst->flags & NFULNL_CFG_F_SEQ_GLOBAL) &&
88034 nla_put_be32(inst->skb, NFULA_SEQ_GLOBAL,
88035 - htonl(atomic_inc_return(&global_seq))))
88036 + htonl(atomic_inc_return_unchecked(&global_seq))))
88037 goto nla_put_failure;
88038
88039 if (data_len) {
88040 diff --git a/net/netfilter/xt_gradm.c b/net/netfilter/xt_gradm.c
88041 new file mode 100644
88042 index 0000000..c566332
88043 --- /dev/null
88044 +++ b/net/netfilter/xt_gradm.c
88045 @@ -0,0 +1,51 @@
88046 +/*
88047 + * gradm match for netfilter
88048 + * Copyright © Zbigniew Krzystolik, 2010
88049 + *
88050 + * This program is free software; you can redistribute it and/or modify
88051 + * it under the terms of the GNU General Public License; either version
88052 + * 2 or 3 as published by the Free Software Foundation.
88053 + */
88054 +#include <linux/module.h>
88055 +#include <linux/moduleparam.h>
88056 +#include <linux/skbuff.h>
88057 +#include <linux/netfilter/x_tables.h>
88058 +#include <linux/grsecurity.h>
88059 +#include <linux/netfilter/xt_gradm.h>
88060 +
88061 +static bool
88062 +gradm_mt(const struct sk_buff *skb, struct xt_action_param *par)
88063 +{
88064 + const struct xt_gradm_mtinfo *info = par->matchinfo;
88065 + bool retval = false;
88066 + if (gr_acl_is_enabled())
88067 + retval = true;
88068 + return retval ^ info->invflags;
88069 +}
88070 +
88071 +static struct xt_match gradm_mt_reg __read_mostly = {
88072 + .name = "gradm",
88073 + .revision = 0,
88074 + .family = NFPROTO_UNSPEC,
88075 + .match = gradm_mt,
88076 + .matchsize = XT_ALIGN(sizeof(struct xt_gradm_mtinfo)),
88077 + .me = THIS_MODULE,
88078 +};
88079 +
88080 +static int __init gradm_mt_init(void)
88081 +{
88082 + return xt_register_match(&gradm_mt_reg);
88083 +}
88084 +
88085 +static void __exit gradm_mt_exit(void)
88086 +{
88087 + xt_unregister_match(&gradm_mt_reg);
88088 +}
88089 +
88090 +module_init(gradm_mt_init);
88091 +module_exit(gradm_mt_exit);
88092 +MODULE_AUTHOR("Zbigniew Krzystolik <zbyniu@destrukcja.pl>");
88093 +MODULE_DESCRIPTION("Xtables: Grsecurity RBAC match");
88094 +MODULE_LICENSE("GPL");
88095 +MODULE_ALIAS("ipt_gradm");
88096 +MODULE_ALIAS("ip6t_gradm");
88097 diff --git a/net/netfilter/xt_statistic.c b/net/netfilter/xt_statistic.c
88098 index 4fe4fb4..87a89e5 100644
88099 --- a/net/netfilter/xt_statistic.c
88100 +++ b/net/netfilter/xt_statistic.c
88101 @@ -19,7 +19,7 @@
88102 #include <linux/module.h>
88103
88104 struct xt_statistic_priv {
88105 - atomic_t count;
88106 + atomic_unchecked_t count;
88107 } ____cacheline_aligned_in_smp;
88108
88109 MODULE_LICENSE("GPL");
88110 @@ -42,9 +42,9 @@ statistic_mt(const struct sk_buff *skb, struct xt_action_param *par)
88111 break;
88112 case XT_STATISTIC_MODE_NTH:
88113 do {
88114 - oval = atomic_read(&info->master->count);
88115 + oval = atomic_read_unchecked(&info->master->count);
88116 nval = (oval == info->u.nth.every) ? 0 : oval + 1;
88117 - } while (atomic_cmpxchg(&info->master->count, oval, nval) != oval);
88118 + } while (atomic_cmpxchg_unchecked(&info->master->count, oval, nval) != oval);
88119 if (nval == 0)
88120 ret = !ret;
88121 break;
88122 @@ -64,7 +64,7 @@ static int statistic_mt_check(const struct xt_mtchk_param *par)
88123 info->master = kzalloc(sizeof(*info->master), GFP_KERNEL);
88124 if (info->master == NULL)
88125 return -ENOMEM;
88126 - atomic_set(&info->master->count, info->u.nth.count);
88127 + atomic_set_unchecked(&info->master->count, info->u.nth.count);
88128
88129 return 0;
88130 }
88131 diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
88132 index 1e3fd5b..ad397ea 100644
88133 --- a/net/netlink/af_netlink.c
88134 +++ b/net/netlink/af_netlink.c
88135 @@ -781,7 +781,7 @@ static void netlink_overrun(struct sock *sk)
88136 sk->sk_error_report(sk);
88137 }
88138 }
88139 - atomic_inc(&sk->sk_drops);
88140 + atomic_inc_unchecked(&sk->sk_drops);
88141 }
88142
88143 static struct sock *netlink_getsockbyportid(struct sock *ssk, u32 portid)
88144 @@ -2063,7 +2063,7 @@ static int netlink_seq_show(struct seq_file *seq, void *v)
88145 sk_wmem_alloc_get(s),
88146 nlk->cb,
88147 atomic_read(&s->sk_refcnt),
88148 - atomic_read(&s->sk_drops),
88149 + atomic_read_unchecked(&s->sk_drops),
88150 sock_i_ino(s)
88151 );
88152
88153 diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
88154 index 5a55be3..7630745 100644
88155 --- a/net/netlink/genetlink.c
88156 +++ b/net/netlink/genetlink.c
88157 @@ -296,18 +296,20 @@ int genl_register_ops(struct genl_family *family, struct genl_ops *ops)
88158 goto errout;
88159 }
88160
88161 + pax_open_kernel();
88162 if (ops->dumpit)
88163 - ops->flags |= GENL_CMD_CAP_DUMP;
88164 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DUMP;
88165 if (ops->doit)
88166 - ops->flags |= GENL_CMD_CAP_DO;
88167 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DO;
88168 if (ops->policy)
88169 - ops->flags |= GENL_CMD_CAP_HASPOL;
88170 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_HASPOL;
88171 + pax_close_kernel();
88172
88173 genl_lock();
88174 - list_add_tail(&ops->ops_list, &family->ops_list);
88175 + pax_list_add_tail((struct list_head *)&ops->ops_list, &family->ops_list);
88176 genl_unlock();
88177
88178 - genl_ctrl_event(CTRL_CMD_NEWOPS, ops);
88179 + genl_ctrl_event(CTRL_CMD_NEWOPS, (void *)ops);
88180 err = 0;
88181 errout:
88182 return err;
88183 @@ -337,9 +339,9 @@ int genl_unregister_ops(struct genl_family *family, struct genl_ops *ops)
88184 genl_lock();
88185 list_for_each_entry(rc, &family->ops_list, ops_list) {
88186 if (rc == ops) {
88187 - list_del(&ops->ops_list);
88188 + pax_list_del((struct list_head *)&ops->ops_list);
88189 genl_unlock();
88190 - genl_ctrl_event(CTRL_CMD_DELOPS, ops);
88191 + genl_ctrl_event(CTRL_CMD_DELOPS, (void *)ops);
88192 return 0;
88193 }
88194 }
88195 diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
88196 index 103bd70..f21aad3 100644
88197 --- a/net/netrom/af_netrom.c
88198 +++ b/net/netrom/af_netrom.c
88199 @@ -834,6 +834,7 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
88200 struct sock *sk = sock->sk;
88201 struct nr_sock *nr = nr_sk(sk);
88202
88203 + memset(sax, 0, sizeof(*sax));
88204 lock_sock(sk);
88205 if (peer != 0) {
88206 if (sk->sk_state != TCP_ESTABLISHED) {
88207 @@ -848,7 +849,6 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
88208 *uaddr_len = sizeof(struct full_sockaddr_ax25);
88209 } else {
88210 sax->fsa_ax25.sax25_family = AF_NETROM;
88211 - sax->fsa_ax25.sax25_ndigis = 0;
88212 sax->fsa_ax25.sax25_call = nr->source_addr;
88213 *uaddr_len = sizeof(struct sockaddr_ax25);
88214 }
88215 diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
88216 index f83e172..b57140d 100644
88217 --- a/net/packet/af_packet.c
88218 +++ b/net/packet/af_packet.c
88219 @@ -1571,7 +1571,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
88220
88221 spin_lock(&sk->sk_receive_queue.lock);
88222 po->stats.tp_packets++;
88223 - skb->dropcount = atomic_read(&sk->sk_drops);
88224 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
88225 __skb_queue_tail(&sk->sk_receive_queue, skb);
88226 spin_unlock(&sk->sk_receive_queue.lock);
88227 sk->sk_data_ready(sk, skb->len);
88228 @@ -1580,7 +1580,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
88229 drop_n_acct:
88230 spin_lock(&sk->sk_receive_queue.lock);
88231 po->stats.tp_drops++;
88232 - atomic_inc(&sk->sk_drops);
88233 + atomic_inc_unchecked(&sk->sk_drops);
88234 spin_unlock(&sk->sk_receive_queue.lock);
88235
88236 drop_n_restore:
88237 @@ -2558,6 +2558,7 @@ out:
88238
88239 static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
88240 {
88241 + struct sock_extended_err ee;
88242 struct sock_exterr_skb *serr;
88243 struct sk_buff *skb, *skb2;
88244 int copied, err;
88245 @@ -2579,8 +2580,9 @@ static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
88246 sock_recv_timestamp(msg, sk, skb);
88247
88248 serr = SKB_EXT_ERR(skb);
88249 + ee = serr->ee;
88250 put_cmsg(msg, SOL_PACKET, PACKET_TX_TIMESTAMP,
88251 - sizeof(serr->ee), &serr->ee);
88252 + sizeof ee, &ee);
88253
88254 msg->msg_flags |= MSG_ERRQUEUE;
88255 err = copied;
88256 @@ -3205,7 +3207,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
88257 case PACKET_HDRLEN:
88258 if (len > sizeof(int))
88259 len = sizeof(int);
88260 - if (copy_from_user(&val, optval, len))
88261 + if (len > sizeof(val) || copy_from_user(&val, optval, len))
88262 return -EFAULT;
88263 switch (val) {
88264 case TPACKET_V1:
88265 @@ -3247,7 +3249,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
88266 len = lv;
88267 if (put_user(len, optlen))
88268 return -EFAULT;
88269 - if (copy_to_user(optval, data, len))
88270 + if (len > sizeof(st) || copy_to_user(optval, data, len))
88271 return -EFAULT;
88272 return 0;
88273 }
88274 diff --git a/net/phonet/af_phonet.c b/net/phonet/af_phonet.c
88275 index 5a940db..d6a502d 100644
88276 --- a/net/phonet/af_phonet.c
88277 +++ b/net/phonet/af_phonet.c
88278 @@ -469,7 +469,7 @@ int __init_or_module phonet_proto_register(unsigned int protocol,
88279 {
88280 int err = 0;
88281
88282 - if (protocol >= PHONET_NPROTO)
88283 + if (protocol < 0 || protocol >= PHONET_NPROTO)
88284 return -EINVAL;
88285
88286 err = proto_register(pp->prot, 1);
88287 diff --git a/net/phonet/pep.c b/net/phonet/pep.c
88288 index e774117..900b8b7 100644
88289 --- a/net/phonet/pep.c
88290 +++ b/net/phonet/pep.c
88291 @@ -388,7 +388,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
88292
88293 case PNS_PEP_CTRL_REQ:
88294 if (skb_queue_len(&pn->ctrlreq_queue) >= PNPIPE_CTRLREQ_MAX) {
88295 - atomic_inc(&sk->sk_drops);
88296 + atomic_inc_unchecked(&sk->sk_drops);
88297 break;
88298 }
88299 __skb_pull(skb, 4);
88300 @@ -409,7 +409,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
88301 }
88302
88303 if (pn->rx_credits == 0) {
88304 - atomic_inc(&sk->sk_drops);
88305 + atomic_inc_unchecked(&sk->sk_drops);
88306 err = -ENOBUFS;
88307 break;
88308 }
88309 @@ -580,7 +580,7 @@ static int pipe_handler_do_rcv(struct sock *sk, struct sk_buff *skb)
88310 }
88311
88312 if (pn->rx_credits == 0) {
88313 - atomic_inc(&sk->sk_drops);
88314 + atomic_inc_unchecked(&sk->sk_drops);
88315 err = NET_RX_DROP;
88316 break;
88317 }
88318 diff --git a/net/phonet/socket.c b/net/phonet/socket.c
88319 index 1afd138..0b42453 100644
88320 --- a/net/phonet/socket.c
88321 +++ b/net/phonet/socket.c
88322 @@ -612,7 +612,7 @@ static int pn_sock_seq_show(struct seq_file *seq, void *v)
88323 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sk)),
88324 sock_i_ino(sk),
88325 atomic_read(&sk->sk_refcnt), sk,
88326 - atomic_read(&sk->sk_drops), &len);
88327 + atomic_read_unchecked(&sk->sk_drops), &len);
88328 }
88329 seq_printf(seq, "%*s\n", 127 - len, "");
88330 return 0;
88331 diff --git a/net/phonet/sysctl.c b/net/phonet/sysctl.c
88332 index d6bbbbd..61561e4 100644
88333 --- a/net/phonet/sysctl.c
88334 +++ b/net/phonet/sysctl.c
88335 @@ -67,7 +67,7 @@ static int proc_local_port_range(ctl_table *table, int write,
88336 {
88337 int ret;
88338 int range[2] = {local_port_range[0], local_port_range[1]};
88339 - ctl_table tmp = {
88340 + ctl_table_no_const tmp = {
88341 .data = &range,
88342 .maxlen = sizeof(range),
88343 .mode = table->mode,
88344 diff --git a/net/rds/cong.c b/net/rds/cong.c
88345 index e5b65ac..f3b6fb7 100644
88346 --- a/net/rds/cong.c
88347 +++ b/net/rds/cong.c
88348 @@ -78,7 +78,7 @@
88349 * finds that the saved generation number is smaller than the global generation
88350 * number, it wakes up the process.
88351 */
88352 -static atomic_t rds_cong_generation = ATOMIC_INIT(0);
88353 +static atomic_unchecked_t rds_cong_generation = ATOMIC_INIT(0);
88354
88355 /*
88356 * Congestion monitoring
88357 @@ -233,7 +233,7 @@ void rds_cong_map_updated(struct rds_cong_map *map, uint64_t portmask)
88358 rdsdebug("waking map %p for %pI4\n",
88359 map, &map->m_addr);
88360 rds_stats_inc(s_cong_update_received);
88361 - atomic_inc(&rds_cong_generation);
88362 + atomic_inc_unchecked(&rds_cong_generation);
88363 if (waitqueue_active(&map->m_waitq))
88364 wake_up(&map->m_waitq);
88365 if (waitqueue_active(&rds_poll_waitq))
88366 @@ -259,7 +259,7 @@ EXPORT_SYMBOL_GPL(rds_cong_map_updated);
88367
88368 int rds_cong_updated_since(unsigned long *recent)
88369 {
88370 - unsigned long gen = atomic_read(&rds_cong_generation);
88371 + unsigned long gen = atomic_read_unchecked(&rds_cong_generation);
88372
88373 if (likely(*recent == gen))
88374 return 0;
88375 diff --git a/net/rds/ib.h b/net/rds/ib.h
88376 index 7280ab8..e04f4ea 100644
88377 --- a/net/rds/ib.h
88378 +++ b/net/rds/ib.h
88379 @@ -128,7 +128,7 @@ struct rds_ib_connection {
88380 /* sending acks */
88381 unsigned long i_ack_flags;
88382 #ifdef KERNEL_HAS_ATOMIC64
88383 - atomic64_t i_ack_next; /* next ACK to send */
88384 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
88385 #else
88386 spinlock_t i_ack_lock; /* protect i_ack_next */
88387 u64 i_ack_next; /* next ACK to send */
88388 diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
88389 index 31b74f5..dc1fbfa 100644
88390 --- a/net/rds/ib_cm.c
88391 +++ b/net/rds/ib_cm.c
88392 @@ -717,7 +717,7 @@ void rds_ib_conn_shutdown(struct rds_connection *conn)
88393 /* Clear the ACK state */
88394 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
88395 #ifdef KERNEL_HAS_ATOMIC64
88396 - atomic64_set(&ic->i_ack_next, 0);
88397 + atomic64_set_unchecked(&ic->i_ack_next, 0);
88398 #else
88399 ic->i_ack_next = 0;
88400 #endif
88401 diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
88402 index 8eb9501..0c386ff 100644
88403 --- a/net/rds/ib_recv.c
88404 +++ b/net/rds/ib_recv.c
88405 @@ -597,7 +597,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
88406 static void rds_ib_set_ack(struct rds_ib_connection *ic, u64 seq,
88407 int ack_required)
88408 {
88409 - atomic64_set(&ic->i_ack_next, seq);
88410 + atomic64_set_unchecked(&ic->i_ack_next, seq);
88411 if (ack_required) {
88412 smp_mb__before_clear_bit();
88413 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
88414 @@ -609,7 +609,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
88415 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
88416 smp_mb__after_clear_bit();
88417
88418 - return atomic64_read(&ic->i_ack_next);
88419 + return atomic64_read_unchecked(&ic->i_ack_next);
88420 }
88421 #endif
88422
88423 diff --git a/net/rds/iw.h b/net/rds/iw.h
88424 index 04ce3b1..48119a6 100644
88425 --- a/net/rds/iw.h
88426 +++ b/net/rds/iw.h
88427 @@ -134,7 +134,7 @@ struct rds_iw_connection {
88428 /* sending acks */
88429 unsigned long i_ack_flags;
88430 #ifdef KERNEL_HAS_ATOMIC64
88431 - atomic64_t i_ack_next; /* next ACK to send */
88432 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
88433 #else
88434 spinlock_t i_ack_lock; /* protect i_ack_next */
88435 u64 i_ack_next; /* next ACK to send */
88436 diff --git a/net/rds/iw_cm.c b/net/rds/iw_cm.c
88437 index a91e1db..cf3053f 100644
88438 --- a/net/rds/iw_cm.c
88439 +++ b/net/rds/iw_cm.c
88440 @@ -663,7 +663,7 @@ void rds_iw_conn_shutdown(struct rds_connection *conn)
88441 /* Clear the ACK state */
88442 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
88443 #ifdef KERNEL_HAS_ATOMIC64
88444 - atomic64_set(&ic->i_ack_next, 0);
88445 + atomic64_set_unchecked(&ic->i_ack_next, 0);
88446 #else
88447 ic->i_ack_next = 0;
88448 #endif
88449 diff --git a/net/rds/iw_recv.c b/net/rds/iw_recv.c
88450 index 4503335..db566b4 100644
88451 --- a/net/rds/iw_recv.c
88452 +++ b/net/rds/iw_recv.c
88453 @@ -427,7 +427,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
88454 static void rds_iw_set_ack(struct rds_iw_connection *ic, u64 seq,
88455 int ack_required)
88456 {
88457 - atomic64_set(&ic->i_ack_next, seq);
88458 + atomic64_set_unchecked(&ic->i_ack_next, seq);
88459 if (ack_required) {
88460 smp_mb__before_clear_bit();
88461 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
88462 @@ -439,7 +439,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
88463 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
88464 smp_mb__after_clear_bit();
88465
88466 - return atomic64_read(&ic->i_ack_next);
88467 + return atomic64_read_unchecked(&ic->i_ack_next);
88468 }
88469 #endif
88470
88471 diff --git a/net/rds/rds.h b/net/rds/rds.h
88472 index ec1d731..90a3a8d 100644
88473 --- a/net/rds/rds.h
88474 +++ b/net/rds/rds.h
88475 @@ -449,7 +449,7 @@ struct rds_transport {
88476 void (*sync_mr)(void *trans_private, int direction);
88477 void (*free_mr)(void *trans_private, int invalidate);
88478 void (*flush_mrs)(void);
88479 -};
88480 +} __do_const;
88481
88482 struct rds_sock {
88483 struct sock rs_sk;
88484 diff --git a/net/rds/tcp.c b/net/rds/tcp.c
88485 index edac9ef..16bcb98 100644
88486 --- a/net/rds/tcp.c
88487 +++ b/net/rds/tcp.c
88488 @@ -59,7 +59,7 @@ void rds_tcp_nonagle(struct socket *sock)
88489 int val = 1;
88490
88491 set_fs(KERNEL_DS);
88492 - sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __user *)&val,
88493 + sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __force_user *)&val,
88494 sizeof(val));
88495 set_fs(oldfs);
88496 }
88497 diff --git a/net/rds/tcp_send.c b/net/rds/tcp_send.c
88498 index 81cf5a4..b5826ff 100644
88499 --- a/net/rds/tcp_send.c
88500 +++ b/net/rds/tcp_send.c
88501 @@ -43,7 +43,7 @@ static void rds_tcp_cork(struct socket *sock, int val)
88502
88503 oldfs = get_fs();
88504 set_fs(KERNEL_DS);
88505 - sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __user *)&val,
88506 + sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __force_user *)&val,
88507 sizeof(val));
88508 set_fs(oldfs);
88509 }
88510 diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c
88511 index e61aa60..f07cc89 100644
88512 --- a/net/rxrpc/af_rxrpc.c
88513 +++ b/net/rxrpc/af_rxrpc.c
88514 @@ -40,7 +40,7 @@ static const struct proto_ops rxrpc_rpc_ops;
88515 __be32 rxrpc_epoch;
88516
88517 /* current debugging ID */
88518 -atomic_t rxrpc_debug_id;
88519 +atomic_unchecked_t rxrpc_debug_id;
88520
88521 /* count of skbs currently in use */
88522 atomic_t rxrpc_n_skbs;
88523 diff --git a/net/rxrpc/ar-ack.c b/net/rxrpc/ar-ack.c
88524 index e4d9cbc..b229649 100644
88525 --- a/net/rxrpc/ar-ack.c
88526 +++ b/net/rxrpc/ar-ack.c
88527 @@ -175,7 +175,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
88528
88529 _enter("{%d,%d,%d,%d},",
88530 call->acks_hard, call->acks_unacked,
88531 - atomic_read(&call->sequence),
88532 + atomic_read_unchecked(&call->sequence),
88533 CIRC_CNT(call->acks_head, call->acks_tail, call->acks_winsz));
88534
88535 stop = 0;
88536 @@ -199,7 +199,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
88537
88538 /* each Tx packet has a new serial number */
88539 sp->hdr.serial =
88540 - htonl(atomic_inc_return(&call->conn->serial));
88541 + htonl(atomic_inc_return_unchecked(&call->conn->serial));
88542
88543 hdr = (struct rxrpc_header *) txb->head;
88544 hdr->serial = sp->hdr.serial;
88545 @@ -403,7 +403,7 @@ static void rxrpc_rotate_tx_window(struct rxrpc_call *call, u32 hard)
88546 */
88547 static void rxrpc_clear_tx_window(struct rxrpc_call *call)
88548 {
88549 - rxrpc_rotate_tx_window(call, atomic_read(&call->sequence));
88550 + rxrpc_rotate_tx_window(call, atomic_read_unchecked(&call->sequence));
88551 }
88552
88553 /*
88554 @@ -629,7 +629,7 @@ process_further:
88555
88556 latest = ntohl(sp->hdr.serial);
88557 hard = ntohl(ack.firstPacket);
88558 - tx = atomic_read(&call->sequence);
88559 + tx = atomic_read_unchecked(&call->sequence);
88560
88561 _proto("Rx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
88562 latest,
88563 @@ -1161,7 +1161,7 @@ void rxrpc_process_call(struct work_struct *work)
88564 goto maybe_reschedule;
88565
88566 send_ACK_with_skew:
88567 - ack.maxSkew = htons(atomic_read(&call->conn->hi_serial) -
88568 + ack.maxSkew = htons(atomic_read_unchecked(&call->conn->hi_serial) -
88569 ntohl(ack.serial));
88570 send_ACK:
88571 mtu = call->conn->trans->peer->if_mtu;
88572 @@ -1173,7 +1173,7 @@ send_ACK:
88573 ackinfo.rxMTU = htonl(5692);
88574 ackinfo.jumbo_max = htonl(4);
88575
88576 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
88577 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
88578 _proto("Tx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
88579 ntohl(hdr.serial),
88580 ntohs(ack.maxSkew),
88581 @@ -1191,7 +1191,7 @@ send_ACK:
88582 send_message:
88583 _debug("send message");
88584
88585 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
88586 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
88587 _proto("Tx %s %%%u", rxrpc_pkts[hdr.type], ntohl(hdr.serial));
88588 send_message_2:
88589
88590 diff --git a/net/rxrpc/ar-call.c b/net/rxrpc/ar-call.c
88591 index a3bbb36..3341fb9 100644
88592 --- a/net/rxrpc/ar-call.c
88593 +++ b/net/rxrpc/ar-call.c
88594 @@ -83,7 +83,7 @@ static struct rxrpc_call *rxrpc_alloc_call(gfp_t gfp)
88595 spin_lock_init(&call->lock);
88596 rwlock_init(&call->state_lock);
88597 atomic_set(&call->usage, 1);
88598 - call->debug_id = atomic_inc_return(&rxrpc_debug_id);
88599 + call->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
88600 call->state = RXRPC_CALL_CLIENT_SEND_REQUEST;
88601
88602 memset(&call->sock_node, 0xed, sizeof(call->sock_node));
88603 diff --git a/net/rxrpc/ar-connection.c b/net/rxrpc/ar-connection.c
88604 index 4106ca9..a338d7a 100644
88605 --- a/net/rxrpc/ar-connection.c
88606 +++ b/net/rxrpc/ar-connection.c
88607 @@ -206,7 +206,7 @@ static struct rxrpc_connection *rxrpc_alloc_connection(gfp_t gfp)
88608 rwlock_init(&conn->lock);
88609 spin_lock_init(&conn->state_lock);
88610 atomic_set(&conn->usage, 1);
88611 - conn->debug_id = atomic_inc_return(&rxrpc_debug_id);
88612 + conn->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
88613 conn->avail_calls = RXRPC_MAXCALLS;
88614 conn->size_align = 4;
88615 conn->header_size = sizeof(struct rxrpc_header);
88616 diff --git a/net/rxrpc/ar-connevent.c b/net/rxrpc/ar-connevent.c
88617 index e7ed43a..6afa140 100644
88618 --- a/net/rxrpc/ar-connevent.c
88619 +++ b/net/rxrpc/ar-connevent.c
88620 @@ -109,7 +109,7 @@ static int rxrpc_abort_connection(struct rxrpc_connection *conn,
88621
88622 len = iov[0].iov_len + iov[1].iov_len;
88623
88624 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
88625 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
88626 _proto("Tx CONN ABORT %%%u { %d }", ntohl(hdr.serial), abort_code);
88627
88628 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
88629 diff --git a/net/rxrpc/ar-input.c b/net/rxrpc/ar-input.c
88630 index 529572f..c758ca7 100644
88631 --- a/net/rxrpc/ar-input.c
88632 +++ b/net/rxrpc/ar-input.c
88633 @@ -340,9 +340,9 @@ void rxrpc_fast_process_packet(struct rxrpc_call *call, struct sk_buff *skb)
88634 /* track the latest serial number on this connection for ACK packet
88635 * information */
88636 serial = ntohl(sp->hdr.serial);
88637 - hi_serial = atomic_read(&call->conn->hi_serial);
88638 + hi_serial = atomic_read_unchecked(&call->conn->hi_serial);
88639 while (serial > hi_serial)
88640 - hi_serial = atomic_cmpxchg(&call->conn->hi_serial, hi_serial,
88641 + hi_serial = atomic_cmpxchg_unchecked(&call->conn->hi_serial, hi_serial,
88642 serial);
88643
88644 /* request ACK generation for any ACK or DATA packet that requests
88645 diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
88646 index a693aca..81e7293 100644
88647 --- a/net/rxrpc/ar-internal.h
88648 +++ b/net/rxrpc/ar-internal.h
88649 @@ -272,8 +272,8 @@ struct rxrpc_connection {
88650 int error; /* error code for local abort */
88651 int debug_id; /* debug ID for printks */
88652 unsigned int call_counter; /* call ID counter */
88653 - atomic_t serial; /* packet serial number counter */
88654 - atomic_t hi_serial; /* highest serial number received */
88655 + atomic_unchecked_t serial; /* packet serial number counter */
88656 + atomic_unchecked_t hi_serial; /* highest serial number received */
88657 u8 avail_calls; /* number of calls available */
88658 u8 size_align; /* data size alignment (for security) */
88659 u8 header_size; /* rxrpc + security header size */
88660 @@ -346,7 +346,7 @@ struct rxrpc_call {
88661 spinlock_t lock;
88662 rwlock_t state_lock; /* lock for state transition */
88663 atomic_t usage;
88664 - atomic_t sequence; /* Tx data packet sequence counter */
88665 + atomic_unchecked_t sequence; /* Tx data packet sequence counter */
88666 u32 abort_code; /* local/remote abort code */
88667 enum { /* current state of call */
88668 RXRPC_CALL_CLIENT_SEND_REQUEST, /* - client sending request phase */
88669 @@ -420,7 +420,7 @@ static inline void rxrpc_abort_call(struct rxrpc_call *call, u32 abort_code)
88670 */
88671 extern atomic_t rxrpc_n_skbs;
88672 extern __be32 rxrpc_epoch;
88673 -extern atomic_t rxrpc_debug_id;
88674 +extern atomic_unchecked_t rxrpc_debug_id;
88675 extern struct workqueue_struct *rxrpc_workqueue;
88676
88677 /*
88678 diff --git a/net/rxrpc/ar-local.c b/net/rxrpc/ar-local.c
88679 index 87f7135..74d3703 100644
88680 --- a/net/rxrpc/ar-local.c
88681 +++ b/net/rxrpc/ar-local.c
88682 @@ -45,7 +45,7 @@ struct rxrpc_local *rxrpc_alloc_local(struct sockaddr_rxrpc *srx)
88683 spin_lock_init(&local->lock);
88684 rwlock_init(&local->services_lock);
88685 atomic_set(&local->usage, 1);
88686 - local->debug_id = atomic_inc_return(&rxrpc_debug_id);
88687 + local->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
88688 memcpy(&local->srx, srx, sizeof(*srx));
88689 }
88690
88691 diff --git a/net/rxrpc/ar-output.c b/net/rxrpc/ar-output.c
88692 index e1ac183..b43e10e 100644
88693 --- a/net/rxrpc/ar-output.c
88694 +++ b/net/rxrpc/ar-output.c
88695 @@ -682,9 +682,9 @@ static int rxrpc_send_data(struct kiocb *iocb,
88696 sp->hdr.cid = call->cid;
88697 sp->hdr.callNumber = call->call_id;
88698 sp->hdr.seq =
88699 - htonl(atomic_inc_return(&call->sequence));
88700 + htonl(atomic_inc_return_unchecked(&call->sequence));
88701 sp->hdr.serial =
88702 - htonl(atomic_inc_return(&conn->serial));
88703 + htonl(atomic_inc_return_unchecked(&conn->serial));
88704 sp->hdr.type = RXRPC_PACKET_TYPE_DATA;
88705 sp->hdr.userStatus = 0;
88706 sp->hdr.securityIndex = conn->security_ix;
88707 diff --git a/net/rxrpc/ar-peer.c b/net/rxrpc/ar-peer.c
88708 index bebaa43..2644591 100644
88709 --- a/net/rxrpc/ar-peer.c
88710 +++ b/net/rxrpc/ar-peer.c
88711 @@ -72,7 +72,7 @@ static struct rxrpc_peer *rxrpc_alloc_peer(struct sockaddr_rxrpc *srx,
88712 INIT_LIST_HEAD(&peer->error_targets);
88713 spin_lock_init(&peer->lock);
88714 atomic_set(&peer->usage, 1);
88715 - peer->debug_id = atomic_inc_return(&rxrpc_debug_id);
88716 + peer->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
88717 memcpy(&peer->srx, srx, sizeof(*srx));
88718
88719 rxrpc_assess_MTU_size(peer);
88720 diff --git a/net/rxrpc/ar-proc.c b/net/rxrpc/ar-proc.c
88721 index 38047f7..9f48511 100644
88722 --- a/net/rxrpc/ar-proc.c
88723 +++ b/net/rxrpc/ar-proc.c
88724 @@ -164,8 +164,8 @@ static int rxrpc_connection_seq_show(struct seq_file *seq, void *v)
88725 atomic_read(&conn->usage),
88726 rxrpc_conn_states[conn->state],
88727 key_serial(conn->key),
88728 - atomic_read(&conn->serial),
88729 - atomic_read(&conn->hi_serial));
88730 + atomic_read_unchecked(&conn->serial),
88731 + atomic_read_unchecked(&conn->hi_serial));
88732
88733 return 0;
88734 }
88735 diff --git a/net/rxrpc/ar-transport.c b/net/rxrpc/ar-transport.c
88736 index 92df566..87ec1bf 100644
88737 --- a/net/rxrpc/ar-transport.c
88738 +++ b/net/rxrpc/ar-transport.c
88739 @@ -47,7 +47,7 @@ static struct rxrpc_transport *rxrpc_alloc_transport(struct rxrpc_local *local,
88740 spin_lock_init(&trans->client_lock);
88741 rwlock_init(&trans->conn_lock);
88742 atomic_set(&trans->usage, 1);
88743 - trans->debug_id = atomic_inc_return(&rxrpc_debug_id);
88744 + trans->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
88745
88746 if (peer->srx.transport.family == AF_INET) {
88747 switch (peer->srx.transport_type) {
88748 diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
88749 index f226709..0e735a8 100644
88750 --- a/net/rxrpc/rxkad.c
88751 +++ b/net/rxrpc/rxkad.c
88752 @@ -610,7 +610,7 @@ static int rxkad_issue_challenge(struct rxrpc_connection *conn)
88753
88754 len = iov[0].iov_len + iov[1].iov_len;
88755
88756 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
88757 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
88758 _proto("Tx CHALLENGE %%%u", ntohl(hdr.serial));
88759
88760 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
88761 @@ -660,7 +660,7 @@ static int rxkad_send_response(struct rxrpc_connection *conn,
88762
88763 len = iov[0].iov_len + iov[1].iov_len + iov[2].iov_len;
88764
88765 - hdr->serial = htonl(atomic_inc_return(&conn->serial));
88766 + hdr->serial = htonl(atomic_inc_return_unchecked(&conn->serial));
88767 _proto("Tx RESPONSE %%%u", ntohl(hdr->serial));
88768
88769 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 3, len);
88770 diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
88771 index 391a245..296b3d7 100644
88772 --- a/net/sctp/ipv6.c
88773 +++ b/net/sctp/ipv6.c
88774 @@ -981,7 +981,7 @@ static const struct inet6_protocol sctpv6_protocol = {
88775 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL,
88776 };
88777
88778 -static struct sctp_af sctp_af_inet6 = {
88779 +static struct sctp_af sctp_af_inet6 __read_only = {
88780 .sa_family = AF_INET6,
88781 .sctp_xmit = sctp_v6_xmit,
88782 .setsockopt = ipv6_setsockopt,
88783 @@ -1013,7 +1013,7 @@ static struct sctp_af sctp_af_inet6 = {
88784 #endif
88785 };
88786
88787 -static struct sctp_pf sctp_pf_inet6 = {
88788 +static struct sctp_pf sctp_pf_inet6 __read_only = {
88789 .event_msgname = sctp_inet6_event_msgname,
88790 .skb_msgname = sctp_inet6_skb_msgname,
88791 .af_supported = sctp_inet6_af_supported,
88792 @@ -1038,7 +1038,7 @@ void sctp_v6_pf_init(void)
88793
88794 void sctp_v6_pf_exit(void)
88795 {
88796 - list_del(&sctp_af_inet6.list);
88797 + pax_list_del(&sctp_af_inet6.list);
88798 }
88799
88800 /* Initialize IPv6 support and register with socket layer. */
88801 diff --git a/net/sctp/probe.c b/net/sctp/probe.c
88802 index ad0dba8..e62c225 100644
88803 --- a/net/sctp/probe.c
88804 +++ b/net/sctp/probe.c
88805 @@ -63,7 +63,7 @@ static struct {
88806 struct timespec tstart;
88807 } sctpw;
88808
88809 -static void printl(const char *fmt, ...)
88810 +static __printf(1, 2) void printl(const char *fmt, ...)
88811 {
88812 va_list args;
88813 int len;
88814 diff --git a/net/sctp/proc.c b/net/sctp/proc.c
88815 index ab3bba8..2fbab4e 100644
88816 --- a/net/sctp/proc.c
88817 +++ b/net/sctp/proc.c
88818 @@ -336,7 +336,8 @@ static int sctp_assocs_seq_show(struct seq_file *seq, void *v)
88819 seq_printf(seq,
88820 "%8pK %8pK %-3d %-3d %-2d %-4d "
88821 "%4d %8d %8d %7d %5lu %-5d %5d ",
88822 - assoc, sk, sctp_sk(sk)->type, sk->sk_state,
88823 + assoc, sk,
88824 + sctp_sk(sk)->type, sk->sk_state,
88825 assoc->state, hash,
88826 assoc->assoc_id,
88827 assoc->sndbuf_used,
88828 diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
88829 index 1c2e46c..f91cf5e 100644
88830 --- a/net/sctp/protocol.c
88831 +++ b/net/sctp/protocol.c
88832 @@ -834,8 +834,10 @@ int sctp_register_af(struct sctp_af *af)
88833 return 0;
88834 }
88835
88836 + pax_open_kernel();
88837 INIT_LIST_HEAD(&af->list);
88838 - list_add_tail(&af->list, &sctp_address_families);
88839 + pax_close_kernel();
88840 + pax_list_add_tail(&af->list, &sctp_address_families);
88841 return 1;
88842 }
88843
88844 @@ -966,7 +968,7 @@ static inline int sctp_v4_xmit(struct sk_buff *skb,
88845
88846 static struct sctp_af sctp_af_inet;
88847
88848 -static struct sctp_pf sctp_pf_inet = {
88849 +static struct sctp_pf sctp_pf_inet __read_only = {
88850 .event_msgname = sctp_inet_event_msgname,
88851 .skb_msgname = sctp_inet_skb_msgname,
88852 .af_supported = sctp_inet_af_supported,
88853 @@ -1037,7 +1039,7 @@ static const struct net_protocol sctp_protocol = {
88854 };
88855
88856 /* IPv4 address related functions. */
88857 -static struct sctp_af sctp_af_inet = {
88858 +static struct sctp_af sctp_af_inet __read_only = {
88859 .sa_family = AF_INET,
88860 .sctp_xmit = sctp_v4_xmit,
88861 .setsockopt = ip_setsockopt,
88862 @@ -1122,7 +1124,7 @@ static void sctp_v4_pf_init(void)
88863
88864 static void sctp_v4_pf_exit(void)
88865 {
88866 - list_del(&sctp_af_inet.list);
88867 + pax_list_del(&sctp_af_inet.list);
88868 }
88869
88870 static int sctp_v4_protosw_init(void)
88871 diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
88872 index 8aab894..f6b7e7d 100644
88873 --- a/net/sctp/sm_sideeffect.c
88874 +++ b/net/sctp/sm_sideeffect.c
88875 @@ -447,7 +447,7 @@ static void sctp_generate_sack_event(unsigned long data)
88876 sctp_generate_timeout_event(asoc, SCTP_EVENT_TIMEOUT_SACK);
88877 }
88878
88879 -sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
88880 +sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
88881 NULL,
88882 sctp_generate_t1_cookie_event,
88883 sctp_generate_t1_init_event,
88884 diff --git a/net/sctp/socket.c b/net/sctp/socket.c
88885 index b907073..57fef6c 100644
88886 --- a/net/sctp/socket.c
88887 +++ b/net/sctp/socket.c
88888 @@ -2166,11 +2166,13 @@ static int sctp_setsockopt_events(struct sock *sk, char __user *optval,
88889 {
88890 struct sctp_association *asoc;
88891 struct sctp_ulpevent *event;
88892 + struct sctp_event_subscribe subscribe;
88893
88894 if (optlen > sizeof(struct sctp_event_subscribe))
88895 return -EINVAL;
88896 - if (copy_from_user(&sctp_sk(sk)->subscribe, optval, optlen))
88897 + if (copy_from_user(&subscribe, optval, optlen))
88898 return -EFAULT;
88899 + sctp_sk(sk)->subscribe = subscribe;
88900
88901 /*
88902 * At the time when a user app subscribes to SCTP_SENDER_DRY_EVENT,
88903 @@ -4215,13 +4217,16 @@ static int sctp_getsockopt_disable_fragments(struct sock *sk, int len,
88904 static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
88905 int __user *optlen)
88906 {
88907 + struct sctp_event_subscribe subscribe;
88908 +
88909 if (len <= 0)
88910 return -EINVAL;
88911 if (len > sizeof(struct sctp_event_subscribe))
88912 len = sizeof(struct sctp_event_subscribe);
88913 if (put_user(len, optlen))
88914 return -EFAULT;
88915 - if (copy_to_user(optval, &sctp_sk(sk)->subscribe, len))
88916 + subscribe = sctp_sk(sk)->subscribe;
88917 + if (copy_to_user(optval, &subscribe, len))
88918 return -EFAULT;
88919 return 0;
88920 }
88921 @@ -4239,6 +4244,8 @@ static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
88922 */
88923 static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optval, int __user *optlen)
88924 {
88925 + __u32 autoclose;
88926 +
88927 /* Applicable to UDP-style socket only */
88928 if (sctp_style(sk, TCP))
88929 return -EOPNOTSUPP;
88930 @@ -4247,7 +4254,8 @@ static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optv
88931 len = sizeof(int);
88932 if (put_user(len, optlen))
88933 return -EFAULT;
88934 - if (copy_to_user(optval, &sctp_sk(sk)->autoclose, sizeof(int)))
88935 + autoclose = sctp_sk(sk)->autoclose;
88936 + if (copy_to_user(optval, &autoclose, sizeof(int)))
88937 return -EFAULT;
88938 return 0;
88939 }
88940 @@ -4619,12 +4627,15 @@ static int sctp_getsockopt_delayed_ack(struct sock *sk, int len,
88941 */
88942 static int sctp_getsockopt_initmsg(struct sock *sk, int len, char __user *optval, int __user *optlen)
88943 {
88944 + struct sctp_initmsg initmsg;
88945 +
88946 if (len < sizeof(struct sctp_initmsg))
88947 return -EINVAL;
88948 len = sizeof(struct sctp_initmsg);
88949 if (put_user(len, optlen))
88950 return -EFAULT;
88951 - if (copy_to_user(optval, &sctp_sk(sk)->initmsg, len))
88952 + initmsg = sctp_sk(sk)->initmsg;
88953 + if (copy_to_user(optval, &initmsg, len))
88954 return -EFAULT;
88955 return 0;
88956 }
88957 @@ -4665,6 +4676,8 @@ static int sctp_getsockopt_peer_addrs(struct sock *sk, int len,
88958 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
88959 if (space_left < addrlen)
88960 return -ENOMEM;
88961 + if (addrlen > sizeof(temp) || addrlen < 0)
88962 + return -EFAULT;
88963 if (copy_to_user(to, &temp, addrlen))
88964 return -EFAULT;
88965 to += addrlen;
88966 diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
88967 index bf3c6e8..376d8d0 100644
88968 --- a/net/sctp/sysctl.c
88969 +++ b/net/sctp/sysctl.c
88970 @@ -307,7 +307,7 @@ static int proc_sctp_do_hmac_alg(ctl_table *ctl,
88971 {
88972 struct net *net = current->nsproxy->net_ns;
88973 char tmp[8];
88974 - ctl_table tbl;
88975 + ctl_table_no_const tbl;
88976 int ret;
88977 int changed = 0;
88978 char *none = "none";
88979 @@ -350,7 +350,7 @@ static int proc_sctp_do_hmac_alg(ctl_table *ctl,
88980
88981 int sctp_sysctl_net_register(struct net *net)
88982 {
88983 - struct ctl_table *table;
88984 + ctl_table_no_const *table;
88985 int i;
88986
88987 table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
88988 diff --git a/net/socket.c b/net/socket.c
88989 index 88f759a..c6933de 100644
88990 --- a/net/socket.c
88991 +++ b/net/socket.c
88992 @@ -88,6 +88,7 @@
88993 #include <linux/magic.h>
88994 #include <linux/slab.h>
88995 #include <linux/xattr.h>
88996 +#include <linux/in.h>
88997
88998 #include <asm/uaccess.h>
88999 #include <asm/unistd.h>
89000 @@ -105,6 +106,8 @@
89001 #include <linux/sockios.h>
89002 #include <linux/atalk.h>
89003
89004 +#include <linux/grsock.h>
89005 +
89006 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
89007 static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
89008 unsigned long nr_segs, loff_t pos);
89009 @@ -321,7 +324,7 @@ static struct dentry *sockfs_mount(struct file_system_type *fs_type,
89010 &sockfs_dentry_operations, SOCKFS_MAGIC);
89011 }
89012
89013 -static struct vfsmount *sock_mnt __read_mostly;
89014 +struct vfsmount *sock_mnt __read_mostly;
89015
89016 static struct file_system_type sock_fs_type = {
89017 .name = "sockfs",
89018 @@ -1268,6 +1271,8 @@ int __sock_create(struct net *net, int family, int type, int protocol,
89019 return -EAFNOSUPPORT;
89020 if (type < 0 || type >= SOCK_MAX)
89021 return -EINVAL;
89022 + if (protocol < 0)
89023 + return -EINVAL;
89024
89025 /* Compatibility.
89026
89027 @@ -1399,6 +1404,16 @@ SYSCALL_DEFINE3(socket, int, family, int, type, int, protocol)
89028 if (SOCK_NONBLOCK != O_NONBLOCK && (flags & SOCK_NONBLOCK))
89029 flags = (flags & ~SOCK_NONBLOCK) | O_NONBLOCK;
89030
89031 + if(!gr_search_socket(family, type, protocol)) {
89032 + retval = -EACCES;
89033 + goto out;
89034 + }
89035 +
89036 + if (gr_handle_sock_all(family, type, protocol)) {
89037 + retval = -EACCES;
89038 + goto out;
89039 + }
89040 +
89041 retval = sock_create(family, type, protocol, &sock);
89042 if (retval < 0)
89043 goto out;
89044 @@ -1526,6 +1541,14 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
89045 if (sock) {
89046 err = move_addr_to_kernel(umyaddr, addrlen, &address);
89047 if (err >= 0) {
89048 + if (gr_handle_sock_server((struct sockaddr *)&address)) {
89049 + err = -EACCES;
89050 + goto error;
89051 + }
89052 + err = gr_search_bind(sock, (struct sockaddr_in *)&address);
89053 + if (err)
89054 + goto error;
89055 +
89056 err = security_socket_bind(sock,
89057 (struct sockaddr *)&address,
89058 addrlen);
89059 @@ -1534,6 +1557,7 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
89060 (struct sockaddr *)
89061 &address, addrlen);
89062 }
89063 +error:
89064 fput_light(sock->file, fput_needed);
89065 }
89066 return err;
89067 @@ -1557,10 +1581,20 @@ SYSCALL_DEFINE2(listen, int, fd, int, backlog)
89068 if ((unsigned int)backlog > somaxconn)
89069 backlog = somaxconn;
89070
89071 + if (gr_handle_sock_server_other(sock->sk)) {
89072 + err = -EPERM;
89073 + goto error;
89074 + }
89075 +
89076 + err = gr_search_listen(sock);
89077 + if (err)
89078 + goto error;
89079 +
89080 err = security_socket_listen(sock, backlog);
89081 if (!err)
89082 err = sock->ops->listen(sock, backlog);
89083
89084 +error:
89085 fput_light(sock->file, fput_needed);
89086 }
89087 return err;
89088 @@ -1604,6 +1638,18 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
89089 newsock->type = sock->type;
89090 newsock->ops = sock->ops;
89091
89092 + if (gr_handle_sock_server_other(sock->sk)) {
89093 + err = -EPERM;
89094 + sock_release(newsock);
89095 + goto out_put;
89096 + }
89097 +
89098 + err = gr_search_accept(sock);
89099 + if (err) {
89100 + sock_release(newsock);
89101 + goto out_put;
89102 + }
89103 +
89104 /*
89105 * We don't need try_module_get here, as the listening socket (sock)
89106 * has the protocol module (sock->ops->owner) held.
89107 @@ -1649,6 +1695,8 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
89108 fd_install(newfd, newfile);
89109 err = newfd;
89110
89111 + gr_attach_curr_ip(newsock->sk);
89112 +
89113 out_put:
89114 fput_light(sock->file, fput_needed);
89115 out:
89116 @@ -1681,6 +1729,7 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
89117 int, addrlen)
89118 {
89119 struct socket *sock;
89120 + struct sockaddr *sck;
89121 struct sockaddr_storage address;
89122 int err, fput_needed;
89123
89124 @@ -1691,6 +1740,17 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
89125 if (err < 0)
89126 goto out_put;
89127
89128 + sck = (struct sockaddr *)&address;
89129 +
89130 + if (gr_handle_sock_client(sck)) {
89131 + err = -EACCES;
89132 + goto out_put;
89133 + }
89134 +
89135 + err = gr_search_connect(sock, (struct sockaddr_in *)sck);
89136 + if (err)
89137 + goto out_put;
89138 +
89139 err =
89140 security_socket_connect(sock, (struct sockaddr *)&address, addrlen);
89141 if (err)
89142 @@ -1772,6 +1832,8 @@ SYSCALL_DEFINE3(getpeername, int, fd, struct sockaddr __user *, usockaddr,
89143 * the protocol.
89144 */
89145
89146 +asmlinkage long sys_sendto(int, void *, size_t, unsigned, struct sockaddr *, int);
89147 +
89148 SYSCALL_DEFINE6(sendto, int, fd, void __user *, buff, size_t, len,
89149 unsigned int, flags, struct sockaddr __user *, addr,
89150 int, addr_len)
89151 @@ -1838,7 +1900,7 @@ SYSCALL_DEFINE6(recvfrom, int, fd, void __user *, ubuf, size_t, size,
89152 struct socket *sock;
89153 struct iovec iov;
89154 struct msghdr msg;
89155 - struct sockaddr_storage address;
89156 + struct sockaddr_storage address = { };
89157 int err, err2;
89158 int fput_needed;
89159
89160 @@ -2045,7 +2107,7 @@ static int __sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
89161 * checking falls down on this.
89162 */
89163 if (copy_from_user(ctl_buf,
89164 - (void __user __force *)msg_sys->msg_control,
89165 + (void __force_user *)msg_sys->msg_control,
89166 ctl_len))
89167 goto out_freectl;
89168 msg_sys->msg_control = ctl_buf;
89169 @@ -2185,7 +2247,7 @@ static int __sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
89170 int err, total_len, len;
89171
89172 /* kernel mode address */
89173 - struct sockaddr_storage addr;
89174 + struct sockaddr_storage addr = { };
89175
89176 /* user mode address pointers */
89177 struct sockaddr __user *uaddr;
89178 @@ -2213,7 +2275,7 @@ static int __sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
89179 * kernel msghdr to use the kernel address space)
89180 */
89181
89182 - uaddr = (__force void __user *)msg_sys->msg_name;
89183 + uaddr = (void __force_user *)msg_sys->msg_name;
89184 uaddr_len = COMPAT_NAMELEN(msg);
89185 if (MSG_CMSG_COMPAT & flags) {
89186 err = verify_compat_iovec(msg_sys, iov, &addr, VERIFY_WRITE);
89187 @@ -2952,7 +3014,7 @@ static int bond_ioctl(struct net *net, unsigned int cmd,
89188 old_fs = get_fs();
89189 set_fs(KERNEL_DS);
89190 err = dev_ioctl(net, cmd,
89191 - (struct ifreq __user __force *) &kifr);
89192 + (struct ifreq __force_user *) &kifr);
89193 set_fs(old_fs);
89194
89195 return err;
89196 @@ -3061,7 +3123,7 @@ static int compat_sioc_ifmap(struct net *net, unsigned int cmd,
89197
89198 old_fs = get_fs();
89199 set_fs(KERNEL_DS);
89200 - err = dev_ioctl(net, cmd, (void __user __force *)&ifr);
89201 + err = dev_ioctl(net, cmd, (void __force_user *)&ifr);
89202 set_fs(old_fs);
89203
89204 if (cmd == SIOCGIFMAP && !err) {
89205 @@ -3166,7 +3228,7 @@ static int routing_ioctl(struct net *net, struct socket *sock,
89206 ret |= __get_user(rtdev, &(ur4->rt_dev));
89207 if (rtdev) {
89208 ret |= copy_from_user(devname, compat_ptr(rtdev), 15);
89209 - r4.rt_dev = (char __user __force *)devname;
89210 + r4.rt_dev = (char __force_user *)devname;
89211 devname[15] = 0;
89212 } else
89213 r4.rt_dev = NULL;
89214 @@ -3392,8 +3454,8 @@ int kernel_getsockopt(struct socket *sock, int level, int optname,
89215 int __user *uoptlen;
89216 int err;
89217
89218 - uoptval = (char __user __force *) optval;
89219 - uoptlen = (int __user __force *) optlen;
89220 + uoptval = (char __force_user *) optval;
89221 + uoptlen = (int __force_user *) optlen;
89222
89223 set_fs(KERNEL_DS);
89224 if (level == SOL_SOCKET)
89225 @@ -3413,7 +3475,7 @@ int kernel_setsockopt(struct socket *sock, int level, int optname,
89226 char __user *uoptval;
89227 int err;
89228
89229 - uoptval = (char __user __force *) optval;
89230 + uoptval = (char __force_user *) optval;
89231
89232 set_fs(KERNEL_DS);
89233 if (level == SOL_SOCKET)
89234 diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
89235 index d5f35f1..da2680b5 100644
89236 --- a/net/sunrpc/clnt.c
89237 +++ b/net/sunrpc/clnt.c
89238 @@ -1283,7 +1283,9 @@ call_start(struct rpc_task *task)
89239 (RPC_IS_ASYNC(task) ? "async" : "sync"));
89240
89241 /* Increment call count */
89242 - task->tk_msg.rpc_proc->p_count++;
89243 + pax_open_kernel();
89244 + (*(unsigned int *)&task->tk_msg.rpc_proc->p_count)++;
89245 + pax_close_kernel();
89246 clnt->cl_stats->rpccnt++;
89247 task->tk_action = call_reserve;
89248 }
89249 diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
89250 index f8529fc..ce8c643 100644
89251 --- a/net/sunrpc/sched.c
89252 +++ b/net/sunrpc/sched.c
89253 @@ -261,9 +261,9 @@ static int rpc_wait_bit_killable(void *word)
89254 #ifdef RPC_DEBUG
89255 static void rpc_task_set_debuginfo(struct rpc_task *task)
89256 {
89257 - static atomic_t rpc_pid;
89258 + static atomic_unchecked_t rpc_pid;
89259
89260 - task->tk_pid = atomic_inc_return(&rpc_pid);
89261 + task->tk_pid = atomic_inc_return_unchecked(&rpc_pid);
89262 }
89263 #else
89264 static inline void rpc_task_set_debuginfo(struct rpc_task *task)
89265 diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
89266 index 89a588b..ba2cef8 100644
89267 --- a/net/sunrpc/svc.c
89268 +++ b/net/sunrpc/svc.c
89269 @@ -1160,7 +1160,9 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv)
89270 svc_putnl(resv, RPC_SUCCESS);
89271
89272 /* Bump per-procedure stats counter */
89273 - procp->pc_count++;
89274 + pax_open_kernel();
89275 + (*(unsigned int *)&procp->pc_count)++;
89276 + pax_close_kernel();
89277
89278 /* Initialize storage for argp and resp */
89279 memset(rqstp->rq_argp, 0, procp->pc_argsize);
89280 diff --git a/net/sunrpc/xprtrdma/svc_rdma.c b/net/sunrpc/xprtrdma/svc_rdma.c
89281 index 8343737..677025e 100644
89282 --- a/net/sunrpc/xprtrdma/svc_rdma.c
89283 +++ b/net/sunrpc/xprtrdma/svc_rdma.c
89284 @@ -62,15 +62,15 @@ unsigned int svcrdma_max_req_size = RPCRDMA_MAX_REQ_SIZE;
89285 static unsigned int min_max_inline = 4096;
89286 static unsigned int max_max_inline = 65536;
89287
89288 -atomic_t rdma_stat_recv;
89289 -atomic_t rdma_stat_read;
89290 -atomic_t rdma_stat_write;
89291 -atomic_t rdma_stat_sq_starve;
89292 -atomic_t rdma_stat_rq_starve;
89293 -atomic_t rdma_stat_rq_poll;
89294 -atomic_t rdma_stat_rq_prod;
89295 -atomic_t rdma_stat_sq_poll;
89296 -atomic_t rdma_stat_sq_prod;
89297 +atomic_unchecked_t rdma_stat_recv;
89298 +atomic_unchecked_t rdma_stat_read;
89299 +atomic_unchecked_t rdma_stat_write;
89300 +atomic_unchecked_t rdma_stat_sq_starve;
89301 +atomic_unchecked_t rdma_stat_rq_starve;
89302 +atomic_unchecked_t rdma_stat_rq_poll;
89303 +atomic_unchecked_t rdma_stat_rq_prod;
89304 +atomic_unchecked_t rdma_stat_sq_poll;
89305 +atomic_unchecked_t rdma_stat_sq_prod;
89306
89307 /* Temporary NFS request map and context caches */
89308 struct kmem_cache *svc_rdma_map_cachep;
89309 @@ -110,7 +110,7 @@ static int read_reset_stat(ctl_table *table, int write,
89310 len -= *ppos;
89311 if (len > *lenp)
89312 len = *lenp;
89313 - if (len && copy_to_user(buffer, str_buf, len))
89314 + if (len > sizeof str_buf || (len && copy_to_user(buffer, str_buf, len)))
89315 return -EFAULT;
89316 *lenp = len;
89317 *ppos += len;
89318 @@ -151,63 +151,63 @@ static ctl_table svcrdma_parm_table[] = {
89319 {
89320 .procname = "rdma_stat_read",
89321 .data = &rdma_stat_read,
89322 - .maxlen = sizeof(atomic_t),
89323 + .maxlen = sizeof(atomic_unchecked_t),
89324 .mode = 0644,
89325 .proc_handler = read_reset_stat,
89326 },
89327 {
89328 .procname = "rdma_stat_recv",
89329 .data = &rdma_stat_recv,
89330 - .maxlen = sizeof(atomic_t),
89331 + .maxlen = sizeof(atomic_unchecked_t),
89332 .mode = 0644,
89333 .proc_handler = read_reset_stat,
89334 },
89335 {
89336 .procname = "rdma_stat_write",
89337 .data = &rdma_stat_write,
89338 - .maxlen = sizeof(atomic_t),
89339 + .maxlen = sizeof(atomic_unchecked_t),
89340 .mode = 0644,
89341 .proc_handler = read_reset_stat,
89342 },
89343 {
89344 .procname = "rdma_stat_sq_starve",
89345 .data = &rdma_stat_sq_starve,
89346 - .maxlen = sizeof(atomic_t),
89347 + .maxlen = sizeof(atomic_unchecked_t),
89348 .mode = 0644,
89349 .proc_handler = read_reset_stat,
89350 },
89351 {
89352 .procname = "rdma_stat_rq_starve",
89353 .data = &rdma_stat_rq_starve,
89354 - .maxlen = sizeof(atomic_t),
89355 + .maxlen = sizeof(atomic_unchecked_t),
89356 .mode = 0644,
89357 .proc_handler = read_reset_stat,
89358 },
89359 {
89360 .procname = "rdma_stat_rq_poll",
89361 .data = &rdma_stat_rq_poll,
89362 - .maxlen = sizeof(atomic_t),
89363 + .maxlen = sizeof(atomic_unchecked_t),
89364 .mode = 0644,
89365 .proc_handler = read_reset_stat,
89366 },
89367 {
89368 .procname = "rdma_stat_rq_prod",
89369 .data = &rdma_stat_rq_prod,
89370 - .maxlen = sizeof(atomic_t),
89371 + .maxlen = sizeof(atomic_unchecked_t),
89372 .mode = 0644,
89373 .proc_handler = read_reset_stat,
89374 },
89375 {
89376 .procname = "rdma_stat_sq_poll",
89377 .data = &rdma_stat_sq_poll,
89378 - .maxlen = sizeof(atomic_t),
89379 + .maxlen = sizeof(atomic_unchecked_t),
89380 .mode = 0644,
89381 .proc_handler = read_reset_stat,
89382 },
89383 {
89384 .procname = "rdma_stat_sq_prod",
89385 .data = &rdma_stat_sq_prod,
89386 - .maxlen = sizeof(atomic_t),
89387 + .maxlen = sizeof(atomic_unchecked_t),
89388 .mode = 0644,
89389 .proc_handler = read_reset_stat,
89390 },
89391 diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
89392 index 0ce7552..d074459 100644
89393 --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
89394 +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
89395 @@ -501,7 +501,7 @@ next_sge:
89396 svc_rdma_put_context(ctxt, 0);
89397 goto out;
89398 }
89399 - atomic_inc(&rdma_stat_read);
89400 + atomic_inc_unchecked(&rdma_stat_read);
89401
89402 if (read_wr.num_sge < chl_map->ch[ch_no].count) {
89403 chl_map->ch[ch_no].count -= read_wr.num_sge;
89404 @@ -611,7 +611,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
89405 dto_q);
89406 list_del_init(&ctxt->dto_q);
89407 } else {
89408 - atomic_inc(&rdma_stat_rq_starve);
89409 + atomic_inc_unchecked(&rdma_stat_rq_starve);
89410 clear_bit(XPT_DATA, &xprt->xpt_flags);
89411 ctxt = NULL;
89412 }
89413 @@ -631,7 +631,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
89414 dprintk("svcrdma: processing ctxt=%p on xprt=%p, rqstp=%p, status=%d\n",
89415 ctxt, rdma_xprt, rqstp, ctxt->wc_status);
89416 BUG_ON(ctxt->wc_status != IB_WC_SUCCESS);
89417 - atomic_inc(&rdma_stat_recv);
89418 + atomic_inc_unchecked(&rdma_stat_recv);
89419
89420 /* Build up the XDR from the receive buffers. */
89421 rdma_build_arg_xdr(rqstp, ctxt, ctxt->byte_len);
89422 diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
89423 index c1d124d..acfc59e 100644
89424 --- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
89425 +++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
89426 @@ -362,7 +362,7 @@ static int send_write(struct svcxprt_rdma *xprt, struct svc_rqst *rqstp,
89427 write_wr.wr.rdma.remote_addr = to;
89428
89429 /* Post It */
89430 - atomic_inc(&rdma_stat_write);
89431 + atomic_inc_unchecked(&rdma_stat_write);
89432 if (svc_rdma_send(xprt, &write_wr))
89433 goto err;
89434 return 0;
89435 diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c b/net/sunrpc/xprtrdma/svc_rdma_transport.c
89436 index 62e4f9b..dd3f2d7 100644
89437 --- a/net/sunrpc/xprtrdma/svc_rdma_transport.c
89438 +++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c
89439 @@ -292,7 +292,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
89440 return;
89441
89442 ib_req_notify_cq(xprt->sc_rq_cq, IB_CQ_NEXT_COMP);
89443 - atomic_inc(&rdma_stat_rq_poll);
89444 + atomic_inc_unchecked(&rdma_stat_rq_poll);
89445
89446 while ((ret = ib_poll_cq(xprt->sc_rq_cq, 1, &wc)) > 0) {
89447 ctxt = (struct svc_rdma_op_ctxt *)(unsigned long)wc.wr_id;
89448 @@ -314,7 +314,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
89449 }
89450
89451 if (ctxt)
89452 - atomic_inc(&rdma_stat_rq_prod);
89453 + atomic_inc_unchecked(&rdma_stat_rq_prod);
89454
89455 set_bit(XPT_DATA, &xprt->sc_xprt.xpt_flags);
89456 /*
89457 @@ -386,7 +386,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
89458 return;
89459
89460 ib_req_notify_cq(xprt->sc_sq_cq, IB_CQ_NEXT_COMP);
89461 - atomic_inc(&rdma_stat_sq_poll);
89462 + atomic_inc_unchecked(&rdma_stat_sq_poll);
89463 while ((ret = ib_poll_cq(cq, 1, &wc)) > 0) {
89464 if (wc.status != IB_WC_SUCCESS)
89465 /* Close the transport */
89466 @@ -404,7 +404,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
89467 }
89468
89469 if (ctxt)
89470 - atomic_inc(&rdma_stat_sq_prod);
89471 + atomic_inc_unchecked(&rdma_stat_sq_prod);
89472 }
89473
89474 static void sq_comp_handler(struct ib_cq *cq, void *cq_context)
89475 @@ -1262,7 +1262,7 @@ int svc_rdma_send(struct svcxprt_rdma *xprt, struct ib_send_wr *wr)
89476 spin_lock_bh(&xprt->sc_lock);
89477 if (xprt->sc_sq_depth < atomic_read(&xprt->sc_sq_count) + wr_count) {
89478 spin_unlock_bh(&xprt->sc_lock);
89479 - atomic_inc(&rdma_stat_sq_starve);
89480 + atomic_inc_unchecked(&rdma_stat_sq_starve);
89481
89482 /* See if we can opportunistically reap SQ WR to make room */
89483 sq_cq_reap(xprt);
89484 diff --git a/net/sysctl_net.c b/net/sysctl_net.c
89485 index 9bc6db0..47ac8c0 100644
89486 --- a/net/sysctl_net.c
89487 +++ b/net/sysctl_net.c
89488 @@ -46,7 +46,7 @@ static int net_ctl_permissions(struct ctl_table_header *head,
89489 kgid_t root_gid = make_kgid(net->user_ns, 0);
89490
89491 /* Allow network administrator to have same access as root. */
89492 - if (ns_capable(net->user_ns, CAP_NET_ADMIN) ||
89493 + if (ns_capable_nolog(net->user_ns, CAP_NET_ADMIN) ||
89494 uid_eq(root_uid, current_uid())) {
89495 int mode = (table->mode >> 6) & 7;
89496 return (mode << 6) | (mode << 3) | mode;
89497 diff --git a/net/tipc/link.c b/net/tipc/link.c
89498 index daa6080..2bbbe70 100644
89499 --- a/net/tipc/link.c
89500 +++ b/net/tipc/link.c
89501 @@ -1201,7 +1201,7 @@ static int link_send_sections_long(struct tipc_port *sender,
89502 struct tipc_msg fragm_hdr;
89503 struct sk_buff *buf, *buf_chain, *prev;
89504 u32 fragm_crs, fragm_rest, hsz, sect_rest;
89505 - const unchar *sect_crs;
89506 + const unchar __user *sect_crs;
89507 int curr_sect;
89508 u32 fragm_no;
89509
89510 @@ -1242,7 +1242,7 @@ again:
89511
89512 if (!sect_rest) {
89513 sect_rest = msg_sect[++curr_sect].iov_len;
89514 - sect_crs = (const unchar *)msg_sect[curr_sect].iov_base;
89515 + sect_crs = (const unchar __user *)msg_sect[curr_sect].iov_base;
89516 }
89517
89518 if (sect_rest < fragm_rest)
89519 @@ -1261,7 +1261,7 @@ error:
89520 }
89521 } else
89522 skb_copy_to_linear_data_offset(buf, fragm_crs,
89523 - sect_crs, sz);
89524 + (const void __force_kernel *)sect_crs, sz);
89525 sect_crs += sz;
89526 sect_rest -= sz;
89527 fragm_crs += sz;
89528 @@ -2306,8 +2306,11 @@ static int link_recv_changeover_msg(struct tipc_link **l_ptr,
89529 struct tipc_msg *tunnel_msg = buf_msg(tunnel_buf);
89530 u32 msg_typ = msg_type(tunnel_msg);
89531 u32 msg_count = msg_msgcnt(tunnel_msg);
89532 + u32 bearer_id = msg_bearer_id(tunnel_msg);
89533
89534 - dest_link = (*l_ptr)->owner->links[msg_bearer_id(tunnel_msg)];
89535 + if (bearer_id >= MAX_BEARERS)
89536 + goto exit;
89537 + dest_link = (*l_ptr)->owner->links[bearer_id];
89538 if (!dest_link)
89539 goto exit;
89540 if (dest_link == *l_ptr) {
89541 @@ -2521,14 +2524,16 @@ int tipc_link_recv_fragment(struct sk_buff **pending, struct sk_buff **fb,
89542 struct tipc_msg *imsg = (struct tipc_msg *)msg_data(fragm);
89543 u32 msg_sz = msg_size(imsg);
89544 u32 fragm_sz = msg_data_sz(fragm);
89545 - u32 exp_fragm_cnt = msg_sz/fragm_sz + !!(msg_sz % fragm_sz);
89546 + u32 exp_fragm_cnt;
89547 u32 max = TIPC_MAX_USER_MSG_SIZE + NAMED_H_SIZE;
89548 +
89549 if (msg_type(imsg) == TIPC_MCAST_MSG)
89550 max = TIPC_MAX_USER_MSG_SIZE + MCAST_H_SIZE;
89551 - if (msg_size(imsg) > max) {
89552 + if (fragm_sz == 0 || msg_size(imsg) > max) {
89553 kfree_skb(fbuf);
89554 return 0;
89555 }
89556 + exp_fragm_cnt = msg_sz / fragm_sz + !!(msg_sz % fragm_sz);
89557 pbuf = tipc_buf_acquire(msg_size(imsg));
89558 if (pbuf != NULL) {
89559 pbuf->next = *pending;
89560 diff --git a/net/tipc/msg.c b/net/tipc/msg.c
89561 index f2db8a8..9245aa4 100644
89562 --- a/net/tipc/msg.c
89563 +++ b/net/tipc/msg.c
89564 @@ -98,7 +98,7 @@ int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect,
89565 msg_sect[cnt].iov_len);
89566 else
89567 skb_copy_to_linear_data_offset(*buf, pos,
89568 - msg_sect[cnt].iov_base,
89569 + (const void __force_kernel *)msg_sect[cnt].iov_base,
89570 msg_sect[cnt].iov_len);
89571 pos += msg_sect[cnt].iov_len;
89572 }
89573 diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
89574 index 6b42d47..2ac24d5 100644
89575 --- a/net/tipc/subscr.c
89576 +++ b/net/tipc/subscr.c
89577 @@ -96,7 +96,7 @@ static void subscr_send_event(struct tipc_subscription *sub,
89578 {
89579 struct iovec msg_sect;
89580
89581 - msg_sect.iov_base = (void *)&sub->evt;
89582 + msg_sect.iov_base = (void __force_user *)&sub->evt;
89583 msg_sect.iov_len = sizeof(struct tipc_event);
89584
89585 sub->evt.event = htohl(event, sub->swap);
89586 diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
89587 index 2db702d..09a77488 100644
89588 --- a/net/unix/af_unix.c
89589 +++ b/net/unix/af_unix.c
89590 @@ -783,6 +783,12 @@ static struct sock *unix_find_other(struct net *net,
89591 err = -ECONNREFUSED;
89592 if (!S_ISSOCK(inode->i_mode))
89593 goto put_fail;
89594 +
89595 + if (!gr_acl_handle_unix(path.dentry, path.mnt)) {
89596 + err = -EACCES;
89597 + goto put_fail;
89598 + }
89599 +
89600 u = unix_find_socket_byinode(inode);
89601 if (!u)
89602 goto put_fail;
89603 @@ -803,6 +809,13 @@ static struct sock *unix_find_other(struct net *net,
89604 if (u) {
89605 struct dentry *dentry;
89606 dentry = unix_sk(u)->path.dentry;
89607 +
89608 + if (!gr_handle_chroot_unix(pid_vnr(u->sk_peer_pid))) {
89609 + err = -EPERM;
89610 + sock_put(u);
89611 + goto fail;
89612 + }
89613 +
89614 if (dentry)
89615 touch_atime(&unix_sk(u)->path);
89616 } else
89617 @@ -836,12 +849,18 @@ static int unix_mknod(const char *sun_path, umode_t mode, struct path *res)
89618 */
89619 err = security_path_mknod(&path, dentry, mode, 0);
89620 if (!err) {
89621 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
89622 + err = -EACCES;
89623 + goto out;
89624 + }
89625 err = vfs_mknod(path.dentry->d_inode, dentry, mode, 0);
89626 if (!err) {
89627 res->mnt = mntget(path.mnt);
89628 res->dentry = dget(dentry);
89629 + gr_handle_create(dentry, path.mnt);
89630 }
89631 }
89632 +out:
89633 done_path_create(&path, dentry);
89634 return err;
89635 }
89636 @@ -2323,9 +2342,13 @@ static int unix_seq_show(struct seq_file *seq, void *v)
89637 seq_puts(seq, "Num RefCount Protocol Flags Type St "
89638 "Inode Path\n");
89639 else {
89640 - struct sock *s = v;
89641 + struct sock *s = v, *peer;
89642 struct unix_sock *u = unix_sk(s);
89643 unix_state_lock(s);
89644 + peer = unix_peer(s);
89645 + unix_state_unlock(s);
89646 +
89647 + unix_state_double_lock(s, peer);
89648
89649 seq_printf(seq, "%pK: %08X %08X %08X %04X %02X %5lu",
89650 s,
89651 @@ -2352,8 +2375,10 @@ static int unix_seq_show(struct seq_file *seq, void *v)
89652 }
89653 for ( ; i < len; i++)
89654 seq_putc(seq, u->addr->name->sun_path[i]);
89655 - }
89656 - unix_state_unlock(s);
89657 + } else if (peer)
89658 + seq_printf(seq, " P%lu", sock_i_ino(peer));
89659 +
89660 + unix_state_double_unlock(s, peer);
89661 seq_putc(seq, '\n');
89662 }
89663
89664 diff --git a/net/unix/sysctl_net_unix.c b/net/unix/sysctl_net_unix.c
89665 index 8800604..0526440 100644
89666 --- a/net/unix/sysctl_net_unix.c
89667 +++ b/net/unix/sysctl_net_unix.c
89668 @@ -28,7 +28,7 @@ static ctl_table unix_table[] = {
89669
89670 int __net_init unix_sysctl_register(struct net *net)
89671 {
89672 - struct ctl_table *table;
89673 + ctl_table_no_const *table;
89674
89675 table = kmemdup(unix_table, sizeof(unix_table), GFP_KERNEL);
89676 if (table == NULL)
89677 diff --git a/net/wireless/wext-core.c b/net/wireless/wext-core.c
89678 index c8717c1..08539f5 100644
89679 --- a/net/wireless/wext-core.c
89680 +++ b/net/wireless/wext-core.c
89681 @@ -748,8 +748,7 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
89682 */
89683
89684 /* Support for very large requests */
89685 - if ((descr->flags & IW_DESCR_FLAG_NOMAX) &&
89686 - (user_length > descr->max_tokens)) {
89687 + if (user_length > descr->max_tokens) {
89688 /* Allow userspace to GET more than max so
89689 * we can support any size GET requests.
89690 * There is still a limit : -ENOMEM.
89691 @@ -788,22 +787,6 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
89692 }
89693 }
89694
89695 - if (IW_IS_GET(cmd) && !(descr->flags & IW_DESCR_FLAG_NOMAX)) {
89696 - /*
89697 - * If this is a GET, but not NOMAX, it means that the extra
89698 - * data is not bounded by userspace, but by max_tokens. Thus
89699 - * set the length to max_tokens. This matches the extra data
89700 - * allocation.
89701 - * The driver should fill it with the number of tokens it
89702 - * provided, and it may check iwp->length rather than having
89703 - * knowledge of max_tokens. If the driver doesn't change the
89704 - * iwp->length, this ioctl just copies back max_token tokens
89705 - * filled with zeroes. Hopefully the driver isn't claiming
89706 - * them to be valid data.
89707 - */
89708 - iwp->length = descr->max_tokens;
89709 - }
89710 -
89711 err = handler(dev, info, (union iwreq_data *) iwp, extra);
89712
89713 iwp->length += essid_compat;
89714 diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
89715 index 167c67d..3f2ae427 100644
89716 --- a/net/xfrm/xfrm_policy.c
89717 +++ b/net/xfrm/xfrm_policy.c
89718 @@ -334,7 +334,7 @@ static void xfrm_policy_kill(struct xfrm_policy *policy)
89719 {
89720 policy->walk.dead = 1;
89721
89722 - atomic_inc(&policy->genid);
89723 + atomic_inc_unchecked(&policy->genid);
89724
89725 del_timer(&policy->polq.hold_timer);
89726 xfrm_queue_purge(&policy->polq.hold_queue);
89727 @@ -659,7 +659,7 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl)
89728 hlist_add_head(&policy->bydst, chain);
89729 xfrm_pol_hold(policy);
89730 net->xfrm.policy_count[dir]++;
89731 - atomic_inc(&flow_cache_genid);
89732 + atomic_inc_unchecked(&flow_cache_genid);
89733 rt_genid_bump(net);
89734 if (delpol) {
89735 xfrm_policy_requeue(delpol, policy);
89736 @@ -1611,7 +1611,7 @@ free_dst:
89737 goto out;
89738 }
89739
89740 -static int inline
89741 +static inline int
89742 xfrm_dst_alloc_copy(void **target, const void *src, int size)
89743 {
89744 if (!*target) {
89745 @@ -1623,7 +1623,7 @@ xfrm_dst_alloc_copy(void **target, const void *src, int size)
89746 return 0;
89747 }
89748
89749 -static int inline
89750 +static inline int
89751 xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
89752 {
89753 #ifdef CONFIG_XFRM_SUB_POLICY
89754 @@ -1635,7 +1635,7 @@ xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
89755 #endif
89756 }
89757
89758 -static int inline
89759 +static inline int
89760 xfrm_dst_update_origin(struct dst_entry *dst, const struct flowi *fl)
89761 {
89762 #ifdef CONFIG_XFRM_SUB_POLICY
89763 @@ -1729,7 +1729,7 @@ xfrm_resolve_and_create_bundle(struct xfrm_policy **pols, int num_pols,
89764
89765 xdst->num_pols = num_pols;
89766 memcpy(xdst->pols, pols, sizeof(struct xfrm_policy*) * num_pols);
89767 - xdst->policy_genid = atomic_read(&pols[0]->genid);
89768 + xdst->policy_genid = atomic_read_unchecked(&pols[0]->genid);
89769
89770 return xdst;
89771 }
89772 @@ -2598,7 +2598,7 @@ static int xfrm_bundle_ok(struct xfrm_dst *first)
89773 if (xdst->xfrm_genid != dst->xfrm->genid)
89774 return 0;
89775 if (xdst->num_pols > 0 &&
89776 - xdst->policy_genid != atomic_read(&xdst->pols[0]->genid))
89777 + xdst->policy_genid != atomic_read_unchecked(&xdst->pols[0]->genid))
89778 return 0;
89779
89780 mtu = dst_mtu(dst->child);
89781 @@ -2686,8 +2686,11 @@ int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo)
89782 dst_ops->link_failure = xfrm_link_failure;
89783 if (likely(dst_ops->neigh_lookup == NULL))
89784 dst_ops->neigh_lookup = xfrm_neigh_lookup;
89785 - if (likely(afinfo->garbage_collect == NULL))
89786 - afinfo->garbage_collect = xfrm_garbage_collect_deferred;
89787 + if (likely(afinfo->garbage_collect == NULL)) {
89788 + pax_open_kernel();
89789 + *(void **)&afinfo->garbage_collect = xfrm_garbage_collect_deferred;
89790 + pax_close_kernel();
89791 + }
89792 rcu_assign_pointer(xfrm_policy_afinfo[afinfo->family], afinfo);
89793 }
89794 spin_unlock(&xfrm_policy_afinfo_lock);
89795 @@ -2741,7 +2744,9 @@ int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo)
89796 dst_ops->check = NULL;
89797 dst_ops->negative_advice = NULL;
89798 dst_ops->link_failure = NULL;
89799 - afinfo->garbage_collect = NULL;
89800 + pax_open_kernel();
89801 + *(void **)&afinfo->garbage_collect = NULL;
89802 + pax_close_kernel();
89803 }
89804 return err;
89805 }
89806 @@ -3124,7 +3129,7 @@ static int xfrm_policy_migrate(struct xfrm_policy *pol,
89807 sizeof(pol->xfrm_vec[i].saddr));
89808 pol->xfrm_vec[i].encap_family = mp->new_family;
89809 /* flush bundles */
89810 - atomic_inc(&pol->genid);
89811 + atomic_inc_unchecked(&pol->genid);
89812 }
89813 }
89814
89815 diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
89816 index 2c341bd..4404211 100644
89817 --- a/net/xfrm/xfrm_state.c
89818 +++ b/net/xfrm/xfrm_state.c
89819 @@ -177,12 +177,14 @@ int xfrm_register_type(const struct xfrm_type *type, unsigned short family)
89820
89821 if (unlikely(afinfo == NULL))
89822 return -EAFNOSUPPORT;
89823 - typemap = afinfo->type_map;
89824 + typemap = (const struct xfrm_type **)afinfo->type_map;
89825 spin_lock_bh(&xfrm_type_lock);
89826
89827 - if (likely(typemap[type->proto] == NULL))
89828 + if (likely(typemap[type->proto] == NULL)) {
89829 + pax_open_kernel();
89830 typemap[type->proto] = type;
89831 - else
89832 + pax_close_kernel();
89833 + } else
89834 err = -EEXIST;
89835 spin_unlock_bh(&xfrm_type_lock);
89836 xfrm_state_put_afinfo(afinfo);
89837 @@ -198,13 +200,16 @@ int xfrm_unregister_type(const struct xfrm_type *type, unsigned short family)
89838
89839 if (unlikely(afinfo == NULL))
89840 return -EAFNOSUPPORT;
89841 - typemap = afinfo->type_map;
89842 + typemap = (const struct xfrm_type **)afinfo->type_map;
89843 spin_lock_bh(&xfrm_type_lock);
89844
89845 if (unlikely(typemap[type->proto] != type))
89846 err = -ENOENT;
89847 - else
89848 + else {
89849 + pax_open_kernel();
89850 typemap[type->proto] = NULL;
89851 + pax_close_kernel();
89852 + }
89853 spin_unlock_bh(&xfrm_type_lock);
89854 xfrm_state_put_afinfo(afinfo);
89855 return err;
89856 @@ -214,7 +219,6 @@ EXPORT_SYMBOL(xfrm_unregister_type);
89857 static const struct xfrm_type *xfrm_get_type(u8 proto, unsigned short family)
89858 {
89859 struct xfrm_state_afinfo *afinfo;
89860 - const struct xfrm_type **typemap;
89861 const struct xfrm_type *type;
89862 int modload_attempted = 0;
89863
89864 @@ -222,9 +226,8 @@ retry:
89865 afinfo = xfrm_state_get_afinfo(family);
89866 if (unlikely(afinfo == NULL))
89867 return NULL;
89868 - typemap = afinfo->type_map;
89869
89870 - type = typemap[proto];
89871 + type = afinfo->type_map[proto];
89872 if (unlikely(type && !try_module_get(type->owner)))
89873 type = NULL;
89874 if (!type && !modload_attempted) {
89875 @@ -258,7 +261,7 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
89876 return -EAFNOSUPPORT;
89877
89878 err = -EEXIST;
89879 - modemap = afinfo->mode_map;
89880 + modemap = (struct xfrm_mode **)afinfo->mode_map;
89881 spin_lock_bh(&xfrm_mode_lock);
89882 if (modemap[mode->encap])
89883 goto out;
89884 @@ -267,8 +270,10 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
89885 if (!try_module_get(afinfo->owner))
89886 goto out;
89887
89888 - mode->afinfo = afinfo;
89889 + pax_open_kernel();
89890 + *(const void **)&mode->afinfo = afinfo;
89891 modemap[mode->encap] = mode;
89892 + pax_close_kernel();
89893 err = 0;
89894
89895 out:
89896 @@ -292,10 +297,12 @@ int xfrm_unregister_mode(struct xfrm_mode *mode, int family)
89897 return -EAFNOSUPPORT;
89898
89899 err = -ENOENT;
89900 - modemap = afinfo->mode_map;
89901 + modemap = (struct xfrm_mode **)afinfo->mode_map;
89902 spin_lock_bh(&xfrm_mode_lock);
89903 if (likely(modemap[mode->encap] == mode)) {
89904 + pax_open_kernel();
89905 modemap[mode->encap] = NULL;
89906 + pax_close_kernel();
89907 module_put(mode->afinfo->owner);
89908 err = 0;
89909 }
89910 diff --git a/net/xfrm/xfrm_sysctl.c b/net/xfrm/xfrm_sysctl.c
89911 index 05a6e3d..6716ec9 100644
89912 --- a/net/xfrm/xfrm_sysctl.c
89913 +++ b/net/xfrm/xfrm_sysctl.c
89914 @@ -42,7 +42,7 @@ static struct ctl_table xfrm_table[] = {
89915
89916 int __net_init xfrm_sysctl_init(struct net *net)
89917 {
89918 - struct ctl_table *table;
89919 + ctl_table_no_const *table;
89920
89921 __xfrm_sysctl_init(net);
89922
89923 diff --git a/scripts/Makefile.build b/scripts/Makefile.build
89924 index 0e801c3..5c8ad3b 100644
89925 --- a/scripts/Makefile.build
89926 +++ b/scripts/Makefile.build
89927 @@ -111,7 +111,7 @@ endif
89928 endif
89929
89930 # Do not include host rules unless needed
89931 -ifneq ($(hostprogs-y)$(hostprogs-m),)
89932 +ifneq ($(hostprogs-y)$(hostprogs-m)$(hostlibs-y)$(hostlibs-m)$(hostcxxlibs-y)$(hostcxxlibs-m),)
89933 include scripts/Makefile.host
89934 endif
89935
89936 diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
89937 index 686cb0d..9d653bf 100644
89938 --- a/scripts/Makefile.clean
89939 +++ b/scripts/Makefile.clean
89940 @@ -43,7 +43,8 @@ subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn))
89941 __clean-files := $(extra-y) $(always) \
89942 $(targets) $(clean-files) \
89943 $(host-progs) \
89944 - $(hostprogs-y) $(hostprogs-m) $(hostprogs-)
89945 + $(hostprogs-y) $(hostprogs-m) $(hostprogs-) \
89946 + $(hostlibs-y) $(hostlibs-m) $(hostlibs-)
89947
89948 __clean-files := $(filter-out $(no-clean-files), $(__clean-files))
89949
89950 diff --git a/scripts/Makefile.host b/scripts/Makefile.host
89951 index 1ac414f..38575f7 100644
89952 --- a/scripts/Makefile.host
89953 +++ b/scripts/Makefile.host
89954 @@ -31,6 +31,8 @@
89955 # Note: Shared libraries consisting of C++ files are not supported
89956
89957 __hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
89958 +__hostlibs := $(sort $(hostlibs-y) $(hostlibs-m))
89959 +__hostcxxlibs := $(sort $(hostcxxlibs-y) $(hostcxxlibs-m))
89960
89961 # C code
89962 # Executables compiled from a single .c file
89963 @@ -54,11 +56,15 @@ host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs)))
89964 # Shared libaries (only .c supported)
89965 # Shared libraries (.so) - all .so files referenced in "xxx-objs"
89966 host-cshlib := $(sort $(filter %.so, $(host-cobjs)))
89967 +host-cshlib += $(sort $(filter %.so, $(__hostlibs)))
89968 +host-cxxshlib := $(sort $(filter %.so, $(__hostcxxlibs)))
89969 # Remove .so files from "xxx-objs"
89970 host-cobjs := $(filter-out %.so,$(host-cobjs))
89971 +host-cxxobjs := $(filter-out %.so,$(host-cxxobjs))
89972
89973 -#Object (.o) files used by the shared libaries
89974 +# Object (.o) files used by the shared libaries
89975 host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs))))
89976 +host-cxxshobjs := $(sort $(foreach m,$(host-cxxshlib),$($(m:.so=-objs))))
89977
89978 # output directory for programs/.o files
89979 # hostprogs-y := tools/build may have been specified. Retrieve directory
89980 @@ -82,7 +88,9 @@ host-cobjs := $(addprefix $(obj)/,$(host-cobjs))
89981 host-cxxmulti := $(addprefix $(obj)/,$(host-cxxmulti))
89982 host-cxxobjs := $(addprefix $(obj)/,$(host-cxxobjs))
89983 host-cshlib := $(addprefix $(obj)/,$(host-cshlib))
89984 +host-cxxshlib := $(addprefix $(obj)/,$(host-cxxshlib))
89985 host-cshobjs := $(addprefix $(obj)/,$(host-cshobjs))
89986 +host-cxxshobjs := $(addprefix $(obj)/,$(host-cxxshobjs))
89987 host-objdirs := $(addprefix $(obj)/,$(host-objdirs))
89988
89989 obj-dirs += $(host-objdirs)
89990 @@ -156,6 +164,13 @@ quiet_cmd_host-cshobjs = HOSTCC -fPIC $@
89991 $(host-cshobjs): $(obj)/%.o: $(src)/%.c FORCE
89992 $(call if_changed_dep,host-cshobjs)
89993
89994 +# Compile .c file, create position independent .o file
89995 +# host-cxxshobjs -> .o
89996 +quiet_cmd_host-cxxshobjs = HOSTCXX -fPIC $@
89997 + cmd_host-cxxshobjs = $(HOSTCXX) $(hostcxx_flags) -fPIC -c -o $@ $<
89998 +$(host-cxxshobjs): $(obj)/%.o: $(src)/%.c FORCE
89999 + $(call if_changed_dep,host-cxxshobjs)
90000 +
90001 # Link a shared library, based on position independent .o files
90002 # *.o -> .so shared library (host-cshlib)
90003 quiet_cmd_host-cshlib = HOSTLLD -shared $@
90004 @@ -165,6 +180,15 @@ quiet_cmd_host-cshlib = HOSTLLD -shared $@
90005 $(host-cshlib): $(obj)/%: $(host-cshobjs) FORCE
90006 $(call if_changed,host-cshlib)
90007
90008 +# Link a shared library, based on position independent .o files
90009 +# *.o -> .so shared library (host-cxxshlib)
90010 +quiet_cmd_host-cxxshlib = HOSTLLD -shared $@
90011 + cmd_host-cxxshlib = $(HOSTCXX) $(HOSTLDFLAGS) -shared -o $@ \
90012 + $(addprefix $(obj)/,$($(@F:.so=-objs))) \
90013 + $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
90014 +$(host-cxxshlib): $(obj)/%: $(host-cxxshobjs) FORCE
90015 + $(call if_changed,host-cxxshlib)
90016 +
90017 targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\
90018 - $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs)
90019 + $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs) $(host-cxxshlib) $(host-cxxshobjs)
90020
90021 diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
90022 index 7f6425e..9864506 100644
90023 --- a/scripts/basic/fixdep.c
90024 +++ b/scripts/basic/fixdep.c
90025 @@ -161,7 +161,7 @@ static unsigned int strhash(const char *str, unsigned int sz)
90026 /*
90027 * Lookup a value in the configuration string.
90028 */
90029 -static int is_defined_config(const char *name, int len, unsigned int hash)
90030 +static int is_defined_config(const char *name, unsigned int len, unsigned int hash)
90031 {
90032 struct item *aux;
90033
90034 @@ -211,10 +211,10 @@ static void clear_config(void)
90035 /*
90036 * Record the use of a CONFIG_* word.
90037 */
90038 -static void use_config(const char *m, int slen)
90039 +static void use_config(const char *m, unsigned int slen)
90040 {
90041 unsigned int hash = strhash(m, slen);
90042 - int c, i;
90043 + unsigned int c, i;
90044
90045 if (is_defined_config(m, slen, hash))
90046 return;
90047 @@ -235,9 +235,9 @@ static void use_config(const char *m, int slen)
90048
90049 static void parse_config_file(const char *map, size_t len)
90050 {
90051 - const int *end = (const int *) (map + len);
90052 + const unsigned int *end = (const unsigned int *) (map + len);
90053 /* start at +1, so that p can never be < map */
90054 - const int *m = (const int *) map + 1;
90055 + const unsigned int *m = (const unsigned int *) map + 1;
90056 const char *p, *q;
90057
90058 for (; m < end; m++) {
90059 @@ -406,7 +406,7 @@ static void print_deps(void)
90060 static void traps(void)
90061 {
90062 static char test[] __attribute__((aligned(sizeof(int)))) = "CONF";
90063 - int *p = (int *)test;
90064 + unsigned int *p = (unsigned int *)test;
90065
90066 if (*p != INT_CONF) {
90067 fprintf(stderr, "fixdep: sizeof(int) != 4 or wrong endianness? %#x\n",
90068 diff --git a/scripts/gcc-plugin.sh b/scripts/gcc-plugin.sh
90069 new file mode 100644
90070 index 0000000..5e0222d
90071 --- /dev/null
90072 +++ b/scripts/gcc-plugin.sh
90073 @@ -0,0 +1,17 @@
90074 +#!/bin/bash
90075 +plugincc=`$1 -E -shared - -o /dev/null -I\`$3 -print-file-name=plugin\`/include 2>&1 <<EOF
90076 +#include "gcc-plugin.h"
90077 +#include "tree.h"
90078 +#include "tm.h"
90079 +#include "rtl.h"
90080 +#ifdef ENABLE_BUILD_WITH_CXX
90081 +#warning $2
90082 +#else
90083 +#warning $1
90084 +#endif
90085 +EOF`
90086 +if [ $? -eq 0 ]
90087 +then
90088 + [[ "$plugincc" =~ "$1" ]] && echo "$1"
90089 + [[ "$plugincc" =~ "$2" ]] && echo "$2"
90090 +fi
90091 diff --git a/scripts/headers_install.pl b/scripts/headers_install.pl
90092 index 581ca99..a6ff02e 100644
90093 --- a/scripts/headers_install.pl
90094 +++ b/scripts/headers_install.pl
90095 @@ -35,6 +35,7 @@ foreach my $filename (@files) {
90096 $line =~ s/([\s(])__user\s/$1/g;
90097 $line =~ s/([\s(])__force\s/$1/g;
90098 $line =~ s/([\s(])__iomem\s/$1/g;
90099 + $line =~ s/(\s?)__intentional_overflow\([-\d\s,]*\)\s?/$1/g;
90100 $line =~ s/\s__attribute_const__\s/ /g;
90101 $line =~ s/\s__attribute_const__$//g;
90102 $line =~ s/\b__packed\b/__attribute__((packed))/g;
90103 diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
90104 index 3d569d6..0c09522 100644
90105 --- a/scripts/link-vmlinux.sh
90106 +++ b/scripts/link-vmlinux.sh
90107 @@ -159,7 +159,7 @@ else
90108 fi;
90109
90110 # final build of init/
90111 -${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init
90112 +${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init GCC_PLUGINS_CFLAGS="${GCC_PLUGINS_CFLAGS}" GCC_PLUGINS_AFLAGS="${GCC_PLUGINS_AFLAGS}"
90113
90114 kallsymso=""
90115 kallsyms_vmlinux=""
90116 diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
90117 index 771ac17..9f0d3ee 100644
90118 --- a/scripts/mod/file2alias.c
90119 +++ b/scripts/mod/file2alias.c
90120 @@ -140,7 +140,7 @@ static void device_id_check(const char *modname, const char *device_id,
90121 unsigned long size, unsigned long id_size,
90122 void *symval)
90123 {
90124 - int i;
90125 + unsigned int i;
90126
90127 if (size % id_size || size < id_size) {
90128 fatal("%s: sizeof(struct %s_device_id)=%lu is not a modulo "
90129 @@ -168,7 +168,7 @@ static void device_id_check(const char *modname, const char *device_id,
90130 /* USB is special because the bcdDevice can be matched against a numeric range */
90131 /* Looks like "usb:vNpNdNdcNdscNdpNicNiscNipNinN" */
90132 static void do_usb_entry(void *symval,
90133 - unsigned int bcdDevice_initial, int bcdDevice_initial_digits,
90134 + unsigned int bcdDevice_initial, unsigned int bcdDevice_initial_digits,
90135 unsigned char range_lo, unsigned char range_hi,
90136 unsigned char max, struct module *mod)
90137 {
90138 @@ -278,7 +278,7 @@ static void do_usb_entry_multi(void *symval, struct module *mod)
90139 {
90140 unsigned int devlo, devhi;
90141 unsigned char chi, clo, max;
90142 - int ndigits;
90143 + unsigned int ndigits;
90144
90145 DEF_FIELD(symval, usb_device_id, match_flags);
90146 DEF_FIELD(symval, usb_device_id, idVendor);
90147 @@ -531,7 +531,7 @@ static void do_pnp_device_entry(void *symval, unsigned long size,
90148 for (i = 0; i < count; i++) {
90149 DEF_FIELD_ADDR(symval + i*id_size, pnp_device_id, id);
90150 char acpi_id[sizeof(*id)];
90151 - int j;
90152 + unsigned int j;
90153
90154 buf_printf(&mod->dev_table_buf,
90155 "MODULE_ALIAS(\"pnp:d%s*\");\n", *id);
90156 @@ -560,7 +560,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
90157
90158 for (j = 0; j < PNP_MAX_DEVICES; j++) {
90159 const char *id = (char *)(*devs)[j].id;
90160 - int i2, j2;
90161 + unsigned int i2, j2;
90162 int dup = 0;
90163
90164 if (!id[0])
90165 @@ -586,7 +586,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
90166 /* add an individual alias for every device entry */
90167 if (!dup) {
90168 char acpi_id[PNP_ID_LEN];
90169 - int k;
90170 + unsigned int k;
90171
90172 buf_printf(&mod->dev_table_buf,
90173 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
90174 @@ -938,7 +938,7 @@ static void dmi_ascii_filter(char *d, const char *s)
90175 static int do_dmi_entry(const char *filename, void *symval,
90176 char *alias)
90177 {
90178 - int i, j;
90179 + unsigned int i, j;
90180 DEF_FIELD_ADDR(symval, dmi_system_id, matches);
90181 sprintf(alias, "dmi*");
90182
90183 diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
90184 index 78b30c1..536850d 100644
90185 --- a/scripts/mod/modpost.c
90186 +++ b/scripts/mod/modpost.c
90187 @@ -931,6 +931,7 @@ enum mismatch {
90188 ANY_INIT_TO_ANY_EXIT,
90189 ANY_EXIT_TO_ANY_INIT,
90190 EXPORT_TO_INIT_EXIT,
90191 + DATA_TO_TEXT
90192 };
90193
90194 struct sectioncheck {
90195 @@ -1045,6 +1046,12 @@ const struct sectioncheck sectioncheck[] = {
90196 .tosec = { INIT_SECTIONS, EXIT_SECTIONS, NULL },
90197 .mismatch = EXPORT_TO_INIT_EXIT,
90198 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
90199 +},
90200 +/* Do not reference code from writable data */
90201 +{
90202 + .fromsec = { DATA_SECTIONS, NULL },
90203 + .tosec = { TEXT_SECTIONS, NULL },
90204 + .mismatch = DATA_TO_TEXT
90205 }
90206 };
90207
90208 @@ -1167,10 +1174,10 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr,
90209 continue;
90210 if (ELF_ST_TYPE(sym->st_info) == STT_SECTION)
90211 continue;
90212 - if (sym->st_value == addr)
90213 - return sym;
90214 /* Find a symbol nearby - addr are maybe negative */
90215 d = sym->st_value - addr;
90216 + if (d == 0)
90217 + return sym;
90218 if (d < 0)
90219 d = addr - sym->st_value;
90220 if (d < distance) {
90221 @@ -1449,6 +1456,14 @@ static void report_sec_mismatch(const char *modname,
90222 tosym, prl_to, prl_to, tosym);
90223 free(prl_to);
90224 break;
90225 + case DATA_TO_TEXT:
90226 +#if 0
90227 + fprintf(stderr,
90228 + "The %s %s:%s references\n"
90229 + "the %s %s:%s%s\n",
90230 + from, fromsec, fromsym, to, tosec, tosym, to_p);
90231 +#endif
90232 + break;
90233 }
90234 fprintf(stderr, "\n");
90235 }
90236 @@ -1683,7 +1698,7 @@ static void section_rel(const char *modname, struct elf_info *elf,
90237 static void check_sec_ref(struct module *mod, const char *modname,
90238 struct elf_info *elf)
90239 {
90240 - int i;
90241 + unsigned int i;
90242 Elf_Shdr *sechdrs = elf->sechdrs;
90243
90244 /* Walk through all sections */
90245 @@ -1781,7 +1796,7 @@ void __attribute__((format(printf, 2, 3))) buf_printf(struct buffer *buf,
90246 va_end(ap);
90247 }
90248
90249 -void buf_write(struct buffer *buf, const char *s, int len)
90250 +void buf_write(struct buffer *buf, const char *s, unsigned int len)
90251 {
90252 if (buf->size - buf->pos < len) {
90253 buf->size += len + SZ;
90254 @@ -1999,7 +2014,7 @@ static void write_if_changed(struct buffer *b, const char *fname)
90255 if (fstat(fileno(file), &st) < 0)
90256 goto close_write;
90257
90258 - if (st.st_size != b->pos)
90259 + if (st.st_size != (off_t)b->pos)
90260 goto close_write;
90261
90262 tmp = NOFAIL(malloc(b->pos));
90263 diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
90264 index 51207e4..f7d603d 100644
90265 --- a/scripts/mod/modpost.h
90266 +++ b/scripts/mod/modpost.h
90267 @@ -92,15 +92,15 @@ void *do_nofail(void *ptr, const char *expr);
90268
90269 struct buffer {
90270 char *p;
90271 - int pos;
90272 - int size;
90273 + unsigned int pos;
90274 + unsigned int size;
90275 };
90276
90277 void __attribute__((format(printf, 2, 3)))
90278 buf_printf(struct buffer *buf, const char *fmt, ...);
90279
90280 void
90281 -buf_write(struct buffer *buf, const char *s, int len);
90282 +buf_write(struct buffer *buf, const char *s, unsigned int len);
90283
90284 struct module {
90285 struct module *next;
90286 diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c
90287 index 9dfcd6d..099068e 100644
90288 --- a/scripts/mod/sumversion.c
90289 +++ b/scripts/mod/sumversion.c
90290 @@ -470,7 +470,7 @@ static void write_version(const char *filename, const char *sum,
90291 goto out;
90292 }
90293
90294 - if (write(fd, sum, strlen(sum)+1) != strlen(sum)+1) {
90295 + if (write(fd, sum, strlen(sum)+1) != (ssize_t)strlen(sum)+1) {
90296 warn("writing sum in %s failed: %s\n",
90297 filename, strerror(errno));
90298 goto out;
90299 diff --git a/scripts/package/builddeb b/scripts/package/builddeb
90300 index acb8650..b8c5f02 100644
90301 --- a/scripts/package/builddeb
90302 +++ b/scripts/package/builddeb
90303 @@ -246,6 +246,7 @@ fi
90304 (cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl > "$objtree/debian/hdrsrcfiles")
90305 (cd $srctree; find arch/$SRCARCH/include include scripts -type f >> "$objtree/debian/hdrsrcfiles")
90306 (cd $objtree; find arch/$SRCARCH/include .config Module.symvers include scripts -type f >> "$objtree/debian/hdrobjfiles")
90307 +(cd $objtree; find tools/gcc -name \*.so >> "$objtree/debian/hdrobjfiles")
90308 destdir=$kernel_headers_dir/usr/src/linux-headers-$version
90309 mkdir -p "$destdir"
90310 (cd $srctree; tar -c -f - -T "$objtree/debian/hdrsrcfiles") | (cd $destdir; tar -xf -)
90311 diff --git a/scripts/pnmtologo.c b/scripts/pnmtologo.c
90312 index 68bb4ef..2f419e1 100644
90313 --- a/scripts/pnmtologo.c
90314 +++ b/scripts/pnmtologo.c
90315 @@ -244,14 +244,14 @@ static void write_header(void)
90316 fprintf(out, " * Linux logo %s\n", logoname);
90317 fputs(" */\n\n", out);
90318 fputs("#include <linux/linux_logo.h>\n\n", out);
90319 - fprintf(out, "static unsigned char %s_data[] __initdata = {\n",
90320 + fprintf(out, "static unsigned char %s_data[] = {\n",
90321 logoname);
90322 }
90323
90324 static void write_footer(void)
90325 {
90326 fputs("\n};\n\n", out);
90327 - fprintf(out, "const struct linux_logo %s __initconst = {\n", logoname);
90328 + fprintf(out, "const struct linux_logo %s = {\n", logoname);
90329 fprintf(out, "\t.type\t\t= %s,\n", logo_types[logo_type]);
90330 fprintf(out, "\t.width\t\t= %d,\n", logo_width);
90331 fprintf(out, "\t.height\t\t= %d,\n", logo_height);
90332 @@ -381,7 +381,7 @@ static void write_logo_clut224(void)
90333 fputs("\n};\n\n", out);
90334
90335 /* write logo clut */
90336 - fprintf(out, "static unsigned char %s_clut[] __initdata = {\n",
90337 + fprintf(out, "static unsigned char %s_clut[] = {\n",
90338 logoname);
90339 write_hex_cnt = 0;
90340 for (i = 0; i < logo_clutsize; i++) {
90341 diff --git a/scripts/sortextable.h b/scripts/sortextable.h
90342 index f5eb43d..1814de8 100644
90343 --- a/scripts/sortextable.h
90344 +++ b/scripts/sortextable.h
90345 @@ -106,9 +106,9 @@ do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort)
90346 const char *secstrtab;
90347 const char *strtab;
90348 char *extab_image;
90349 - int extab_index = 0;
90350 - int i;
90351 - int idx;
90352 + unsigned int extab_index = 0;
90353 + unsigned int i;
90354 + unsigned int idx;
90355
90356 shdr = (Elf_Shdr *)((char *)ehdr + _r(&ehdr->e_shoff));
90357 shstrtab_sec = shdr + r2(&ehdr->e_shstrndx);
90358 diff --git a/security/Kconfig b/security/Kconfig
90359 index e9c6ac7..e6254cf 100644
90360 --- a/security/Kconfig
90361 +++ b/security/Kconfig
90362 @@ -4,6 +4,944 @@
90363
90364 menu "Security options"
90365
90366 +menu "Grsecurity"
90367 +
90368 + config ARCH_TRACK_EXEC_LIMIT
90369 + bool
90370 +
90371 + config PAX_KERNEXEC_PLUGIN
90372 + bool
90373 +
90374 + config PAX_PER_CPU_PGD
90375 + bool
90376 +
90377 + config TASK_SIZE_MAX_SHIFT
90378 + int
90379 + depends on X86_64
90380 + default 47 if !PAX_PER_CPU_PGD
90381 + default 42 if PAX_PER_CPU_PGD
90382 +
90383 + config PAX_ENABLE_PAE
90384 + bool
90385 + default y if (X86_32 && (MPENTIUM4 || MK8 || MPSC || MCORE2 || MATOM))
90386 +
90387 + config PAX_USERCOPY_SLABS
90388 + bool
90389 +
90390 +config GRKERNSEC
90391 + bool "Grsecurity"
90392 + select CRYPTO
90393 + select CRYPTO_SHA256
90394 + select PROC_FS
90395 + select STOP_MACHINE
90396 + select TTY
90397 + help
90398 + If you say Y here, you will be able to configure many features
90399 + that will enhance the security of your system. It is highly
90400 + recommended that you say Y here and read through the help
90401 + for each option so that you fully understand the features and
90402 + can evaluate their usefulness for your machine.
90403 +
90404 +choice
90405 + prompt "Configuration Method"
90406 + depends on GRKERNSEC
90407 + default GRKERNSEC_CONFIG_CUSTOM
90408 + help
90409 +
90410 +config GRKERNSEC_CONFIG_AUTO
90411 + bool "Automatic"
90412 + help
90413 + If you choose this configuration method, you'll be able to answer a small
90414 + number of simple questions about how you plan to use this kernel.
90415 + The settings of grsecurity and PaX will be automatically configured for
90416 + the highest commonly-used settings within the provided constraints.
90417 +
90418 + If you require additional configuration, custom changes can still be made
90419 + from the "custom configuration" menu.
90420 +
90421 +config GRKERNSEC_CONFIG_CUSTOM
90422 + bool "Custom"
90423 + help
90424 + If you choose this configuration method, you'll be able to configure all
90425 + grsecurity and PaX settings manually. Via this method, no options are
90426 + automatically enabled.
90427 +
90428 +endchoice
90429 +
90430 +choice
90431 + prompt "Usage Type"
90432 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
90433 + default GRKERNSEC_CONFIG_SERVER
90434 + help
90435 +
90436 +config GRKERNSEC_CONFIG_SERVER
90437 + bool "Server"
90438 + help
90439 + Choose this option if you plan to use this kernel on a server.
90440 +
90441 +config GRKERNSEC_CONFIG_DESKTOP
90442 + bool "Desktop"
90443 + help
90444 + Choose this option if you plan to use this kernel on a desktop.
90445 +
90446 +endchoice
90447 +
90448 +choice
90449 + prompt "Virtualization Type"
90450 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO)
90451 + default GRKERNSEC_CONFIG_VIRT_NONE
90452 + help
90453 +
90454 +config GRKERNSEC_CONFIG_VIRT_NONE
90455 + bool "None"
90456 + help
90457 + Choose this option if this kernel will be run on bare metal.
90458 +
90459 +config GRKERNSEC_CONFIG_VIRT_GUEST
90460 + bool "Guest"
90461 + help
90462 + Choose this option if this kernel will be run as a VM guest.
90463 +
90464 +config GRKERNSEC_CONFIG_VIRT_HOST
90465 + bool "Host"
90466 + help
90467 + Choose this option if this kernel will be run as a VM host.
90468 +
90469 +endchoice
90470 +
90471 +choice
90472 + prompt "Virtualization Hardware"
90473 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
90474 + help
90475 +
90476 +config GRKERNSEC_CONFIG_VIRT_EPT
90477 + bool "EPT/RVI Processor Support"
90478 + depends on X86
90479 + help
90480 + Choose this option if your CPU supports the EPT or RVI features of 2nd-gen
90481 + hardware virtualization. This allows for additional kernel hardening protections
90482 + to operate without additional performance impact.
90483 +
90484 + To see if your Intel processor supports EPT, see:
90485 + http://ark.intel.com/Products/VirtualizationTechnology
90486 + (Most Core i3/5/7 support EPT)
90487 +
90488 + To see if your AMD processor supports RVI, see:
90489 + http://support.amd.com/us/kbarticles/Pages/GPU120AMDRVICPUsHyperVWin8.aspx
90490 +
90491 +config GRKERNSEC_CONFIG_VIRT_SOFT
90492 + bool "First-gen/No Hardware Virtualization"
90493 + help
90494 + Choose this option if you use an Atom/Pentium/Core 2 processor that either doesn't
90495 + support hardware virtualization or doesn't support the EPT/RVI extensions.
90496 +
90497 +endchoice
90498 +
90499 +choice
90500 + prompt "Virtualization Software"
90501 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
90502 + help
90503 +
90504 +config GRKERNSEC_CONFIG_VIRT_XEN
90505 + bool "Xen"
90506 + help
90507 + Choose this option if this kernel is running as a Xen guest or host.
90508 +
90509 +config GRKERNSEC_CONFIG_VIRT_VMWARE
90510 + bool "VMWare"
90511 + help
90512 + Choose this option if this kernel is running as a VMWare guest or host.
90513 +
90514 +config GRKERNSEC_CONFIG_VIRT_KVM
90515 + bool "KVM"
90516 + help
90517 + Choose this option if this kernel is running as a KVM guest or host.
90518 +
90519 +config GRKERNSEC_CONFIG_VIRT_VIRTUALBOX
90520 + bool "VirtualBox"
90521 + help
90522 + Choose this option if this kernel is running as a VirtualBox guest or host.
90523 +
90524 +endchoice
90525 +
90526 +choice
90527 + prompt "Required Priorities"
90528 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
90529 + default GRKERNSEC_CONFIG_PRIORITY_PERF
90530 + help
90531 +
90532 +config GRKERNSEC_CONFIG_PRIORITY_PERF
90533 + bool "Performance"
90534 + help
90535 + Choose this option if performance is of highest priority for this deployment
90536 + of grsecurity. Features like UDEREF on a 64bit kernel, kernel stack clearing,
90537 + clearing of structures intended for userland, and freed memory sanitizing will
90538 + be disabled.
90539 +
90540 +config GRKERNSEC_CONFIG_PRIORITY_SECURITY
90541 + bool "Security"
90542 + help
90543 + Choose this option if security is of highest priority for this deployment of
90544 + grsecurity. UDEREF, kernel stack clearing, clearing of structures intended
90545 + for userland, and freed memory sanitizing will be enabled for this kernel.
90546 + In a worst-case scenario, these features can introduce a 20% performance hit
90547 + (UDEREF on x64 contributing half of this hit).
90548 +
90549 +endchoice
90550 +
90551 +menu "Default Special Groups"
90552 +depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
90553 +
90554 +config GRKERNSEC_PROC_GID
90555 + int "GID exempted from /proc restrictions"
90556 + default 1001
90557 + help
90558 + Setting this GID determines which group will be exempted from
90559 + grsecurity's /proc restrictions, allowing users of the specified
90560 + group to view network statistics and the existence of other users'
90561 + processes on the system. This GID may also be chosen at boot time
90562 + via "grsec_proc_gid=" on the kernel commandline.
90563 +
90564 +config GRKERNSEC_TPE_UNTRUSTED_GID
90565 + int "GID for TPE-untrusted users"
90566 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
90567 + default 1005
90568 + help
90569 + Setting this GID determines which group untrusted users should
90570 + be added to. These users will be placed under grsecurity's Trusted Path
90571 + Execution mechanism, preventing them from executing their own binaries.
90572 + The users will only be able to execute binaries in directories owned and
90573 + writable only by the root user. If the sysctl option is enabled, a sysctl
90574 + option with name "tpe_gid" is created.
90575 +
90576 +config GRKERNSEC_TPE_TRUSTED_GID
90577 + int "GID for TPE-trusted users"
90578 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
90579 + default 1005
90580 + help
90581 + Setting this GID determines what group TPE restrictions will be
90582 + *disabled* for. If the sysctl option is enabled, a sysctl option
90583 + with name "tpe_gid" is created.
90584 +
90585 +config GRKERNSEC_SYMLINKOWN_GID
90586 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
90587 + depends on GRKERNSEC_CONFIG_SERVER
90588 + default 1006
90589 + help
90590 + Setting this GID determines what group kernel-enforced
90591 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
90592 + is enabled, a sysctl option with name "symlinkown_gid" is created.
90593 +
90594 +
90595 +endmenu
90596 +
90597 +menu "Customize Configuration"
90598 +depends on GRKERNSEC
90599 +
90600 +menu "PaX"
90601 +
90602 +config PAX
90603 + bool "Enable various PaX features"
90604 + default y if GRKERNSEC_CONFIG_AUTO
90605 + depends on GRKERNSEC && (ALPHA || ARM || AVR32 || IA64 || MIPS || PARISC || PPC || SPARC || X86)
90606 + help
90607 + This allows you to enable various PaX features. PaX adds
90608 + intrusion prevention mechanisms to the kernel that reduce
90609 + the risks posed by exploitable memory corruption bugs.
90610 +
90611 +menu "PaX Control"
90612 + depends on PAX
90613 +
90614 +config PAX_SOFTMODE
90615 + bool 'Support soft mode'
90616 + help
90617 + Enabling this option will allow you to run PaX in soft mode, that
90618 + is, PaX features will not be enforced by default, only on executables
90619 + marked explicitly. You must also enable PT_PAX_FLAGS or XATTR_PAX_FLAGS
90620 + support as they are the only way to mark executables for soft mode use.
90621 +
90622 + Soft mode can be activated by using the "pax_softmode=1" kernel command
90623 + line option on boot. Furthermore you can control various PaX features
90624 + at runtime via the entries in /proc/sys/kernel/pax.
90625 +
90626 +config PAX_EI_PAX
90627 + bool 'Use legacy ELF header marking'
90628 + default y if GRKERNSEC_CONFIG_AUTO
90629 + help
90630 + Enabling this option will allow you to control PaX features on
90631 + a per executable basis via the 'chpax' utility available at
90632 + http://pax.grsecurity.net/. The control flags will be read from
90633 + an otherwise reserved part of the ELF header. This marking has
90634 + numerous drawbacks (no support for soft-mode, toolchain does not
90635 + know about the non-standard use of the ELF header) therefore it
90636 + has been deprecated in favour of PT_PAX_FLAGS and XATTR_PAX_FLAGS
90637 + support.
90638 +
90639 + Note that if you enable PT_PAX_FLAGS or XATTR_PAX_FLAGS marking
90640 + support as well, they will override the legacy EI_PAX marks.
90641 +
90642 + If you enable none of the marking options then all applications
90643 + will run with PaX enabled on them by default.
90644 +
90645 +config PAX_PT_PAX_FLAGS
90646 + bool 'Use ELF program header marking'
90647 + default y if GRKERNSEC_CONFIG_AUTO
90648 + help
90649 + Enabling this option will allow you to control PaX features on
90650 + a per executable basis via the 'paxctl' utility available at
90651 + http://pax.grsecurity.net/. The control flags will be read from
90652 + a PaX specific ELF program header (PT_PAX_FLAGS). This marking
90653 + has the benefits of supporting both soft mode and being fully
90654 + integrated into the toolchain (the binutils patch is available
90655 + from http://pax.grsecurity.net).
90656 +
90657 + Note that if you enable the legacy EI_PAX marking support as well,
90658 + the EI_PAX marks will be overridden by the PT_PAX_FLAGS marks.
90659 +
90660 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
90661 + must make sure that the marks are the same if a binary has both marks.
90662 +
90663 + If you enable none of the marking options then all applications
90664 + will run with PaX enabled on them by default.
90665 +
90666 +config PAX_XATTR_PAX_FLAGS
90667 + bool 'Use filesystem extended attributes marking'
90668 + default y if GRKERNSEC_CONFIG_AUTO
90669 + select CIFS_XATTR if CIFS
90670 + select EXT2_FS_XATTR if EXT2_FS
90671 + select EXT3_FS_XATTR if EXT3_FS
90672 + select EXT4_FS_XATTR if EXT4_FS
90673 + select JFFS2_FS_XATTR if JFFS2_FS
90674 + select REISERFS_FS_XATTR if REISERFS_FS
90675 + select SQUASHFS_XATTR if SQUASHFS
90676 + select TMPFS_XATTR if TMPFS
90677 + select UBIFS_FS_XATTR if UBIFS_FS
90678 + help
90679 + Enabling this option will allow you to control PaX features on
90680 + a per executable basis via the 'setfattr' utility. The control
90681 + flags will be read from the user.pax.flags extended attribute of
90682 + the file. This marking has the benefit of supporting binary-only
90683 + applications that self-check themselves (e.g., skype) and would
90684 + not tolerate chpax/paxctl changes. The main drawback is that
90685 + extended attributes are not supported by some filesystems (e.g.,
90686 + isofs, udf, vfat) so copying files through such filesystems will
90687 + lose the extended attributes and these PaX markings.
90688 +
90689 + Note that if you enable the legacy EI_PAX marking support as well,
90690 + the EI_PAX marks will be overridden by the XATTR_PAX_FLAGS marks.
90691 +
90692 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
90693 + must make sure that the marks are the same if a binary has both marks.
90694 +
90695 + If you enable none of the marking options then all applications
90696 + will run with PaX enabled on them by default.
90697 +
90698 +choice
90699 + prompt 'MAC system integration'
90700 + default PAX_HAVE_ACL_FLAGS
90701 + help
90702 + Mandatory Access Control systems have the option of controlling
90703 + PaX flags on a per executable basis, choose the method supported
90704 + by your particular system.
90705 +
90706 + - "none": if your MAC system does not interact with PaX,
90707 + - "direct": if your MAC system defines pax_set_initial_flags() itself,
90708 + - "hook": if your MAC system uses the pax_set_initial_flags_func callback.
90709 +
90710 + NOTE: this option is for developers/integrators only.
90711 +
90712 + config PAX_NO_ACL_FLAGS
90713 + bool 'none'
90714 +
90715 + config PAX_HAVE_ACL_FLAGS
90716 + bool 'direct'
90717 +
90718 + config PAX_HOOK_ACL_FLAGS
90719 + bool 'hook'
90720 +endchoice
90721 +
90722 +endmenu
90723 +
90724 +menu "Non-executable pages"
90725 + depends on PAX
90726 +
90727 +config PAX_NOEXEC
90728 + bool "Enforce non-executable pages"
90729 + default y if GRKERNSEC_CONFIG_AUTO
90730 + depends on ALPHA || (ARM && (CPU_V6 || CPU_V7)) || IA64 || MIPS || PARISC || PPC || S390 || SPARC || X86
90731 + help
90732 + By design some architectures do not allow for protecting memory
90733 + pages against execution or even if they do, Linux does not make
90734 + use of this feature. In practice this means that if a page is
90735 + readable (such as the stack or heap) it is also executable.
90736 +
90737 + There is a well known exploit technique that makes use of this
90738 + fact and a common programming mistake where an attacker can
90739 + introduce code of his choice somewhere in the attacked program's
90740 + memory (typically the stack or the heap) and then execute it.
90741 +
90742 + If the attacked program was running with different (typically
90743 + higher) privileges than that of the attacker, then he can elevate
90744 + his own privilege level (e.g. get a root shell, write to files for
90745 + which he does not have write access to, etc).
90746 +
90747 + Enabling this option will let you choose from various features
90748 + that prevent the injection and execution of 'foreign' code in
90749 + a program.
90750 +
90751 + This will also break programs that rely on the old behaviour and
90752 + expect that dynamically allocated memory via the malloc() family
90753 + of functions is executable (which it is not). Notable examples
90754 + are the XFree86 4.x server, the java runtime and wine.
90755 +
90756 +config PAX_PAGEEXEC
90757 + bool "Paging based non-executable pages"
90758 + default y if GRKERNSEC_CONFIG_AUTO
90759 + 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)
90760 + select S390_SWITCH_AMODE if S390
90761 + select S390_EXEC_PROTECT if S390
90762 + select ARCH_TRACK_EXEC_LIMIT if X86_32
90763 + help
90764 + This implementation is based on the paging feature of the CPU.
90765 + On i386 without hardware non-executable bit support there is a
90766 + variable but usually low performance impact, however on Intel's
90767 + P4 core based CPUs it is very high so you should not enable this
90768 + for kernels meant to be used on such CPUs.
90769 +
90770 + On alpha, avr32, ia64, parisc, sparc, sparc64, x86_64 and i386
90771 + with hardware non-executable bit support there is no performance
90772 + impact, on ppc the impact is negligible.
90773 +
90774 + Note that several architectures require various emulations due to
90775 + badly designed userland ABIs, this will cause a performance impact
90776 + but will disappear as soon as userland is fixed. For example, ppc
90777 + userland MUST have been built with secure-plt by a recent toolchain.
90778 +
90779 +config PAX_SEGMEXEC
90780 + bool "Segmentation based non-executable pages"
90781 + default y if GRKERNSEC_CONFIG_AUTO
90782 + depends on PAX_NOEXEC && X86_32
90783 + help
90784 + This implementation is based on the segmentation feature of the
90785 + CPU and has a very small performance impact, however applications
90786 + will be limited to a 1.5 GB address space instead of the normal
90787 + 3 GB.
90788 +
90789 +config PAX_EMUTRAMP
90790 + bool "Emulate trampolines" if (PAX_PAGEEXEC || PAX_SEGMEXEC) && (PARISC || X86)
90791 + default y if PARISC
90792 + help
90793 + There are some programs and libraries that for one reason or
90794 + another attempt to execute special small code snippets from
90795 + non-executable memory pages. Most notable examples are the
90796 + signal handler return code generated by the kernel itself and
90797 + the GCC trampolines.
90798 +
90799 + If you enabled CONFIG_PAX_PAGEEXEC or CONFIG_PAX_SEGMEXEC then
90800 + such programs will no longer work under your kernel.
90801 +
90802 + As a remedy you can say Y here and use the 'chpax' or 'paxctl'
90803 + utilities to enable trampoline emulation for the affected programs
90804 + yet still have the protection provided by the non-executable pages.
90805 +
90806 + On parisc you MUST enable this option and EMUSIGRT as well, otherwise
90807 + your system will not even boot.
90808 +
90809 + Alternatively you can say N here and use the 'chpax' or 'paxctl'
90810 + utilities to disable CONFIG_PAX_PAGEEXEC and CONFIG_PAX_SEGMEXEC
90811 + for the affected files.
90812 +
90813 + NOTE: enabling this feature *may* open up a loophole in the
90814 + protection provided by non-executable pages that an attacker
90815 + could abuse. Therefore the best solution is to not have any
90816 + files on your system that would require this option. This can
90817 + be achieved by not using libc5 (which relies on the kernel
90818 + signal handler return code) and not using or rewriting programs
90819 + that make use of the nested function implementation of GCC.
90820 + Skilled users can just fix GCC itself so that it implements
90821 + nested function calls in a way that does not interfere with PaX.
90822 +
90823 +config PAX_EMUSIGRT
90824 + bool "Automatically emulate sigreturn trampolines"
90825 + depends on PAX_EMUTRAMP && PARISC
90826 + default y
90827 + help
90828 + Enabling this option will have the kernel automatically detect
90829 + and emulate signal return trampolines executing on the stack
90830 + that would otherwise lead to task termination.
90831 +
90832 + This solution is intended as a temporary one for users with
90833 + legacy versions of libc (libc5, glibc 2.0, uClibc before 0.9.17,
90834 + Modula-3 runtime, etc) or executables linked to such, basically
90835 + everything that does not specify its own SA_RESTORER function in
90836 + normal executable memory like glibc 2.1+ does.
90837 +
90838 + On parisc you MUST enable this option, otherwise your system will
90839 + not even boot.
90840 +
90841 + NOTE: this feature cannot be disabled on a per executable basis
90842 + and since it *does* open up a loophole in the protection provided
90843 + by non-executable pages, the best solution is to not have any
90844 + files on your system that would require this option.
90845 +
90846 +config PAX_MPROTECT
90847 + bool "Restrict mprotect()"
90848 + default y if GRKERNSEC_CONFIG_AUTO
90849 + depends on (PAX_PAGEEXEC || PAX_SEGMEXEC)
90850 + help
90851 + Enabling this option will prevent programs from
90852 + - changing the executable status of memory pages that were
90853 + not originally created as executable,
90854 + - making read-only executable pages writable again,
90855 + - creating executable pages from anonymous memory,
90856 + - making read-only-after-relocations (RELRO) data pages writable again.
90857 +
90858 + You should say Y here to complete the protection provided by
90859 + the enforcement of non-executable pages.
90860 +
90861 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
90862 + this feature on a per file basis.
90863 +
90864 +config PAX_MPROTECT_COMPAT
90865 + bool "Use legacy/compat protection demoting (read help)"
90866 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
90867 + depends on PAX_MPROTECT
90868 + help
90869 + The current implementation of PAX_MPROTECT denies RWX allocations/mprotects
90870 + by sending the proper error code to the application. For some broken
90871 + userland, this can cause problems with Python or other applications. The
90872 + current implementation however allows for applications like clamav to
90873 + detect if JIT compilation/execution is allowed and to fall back gracefully
90874 + to an interpreter-based mode if it does not. While we encourage everyone
90875 + to use the current implementation as-is and push upstream to fix broken
90876 + userland (note that the RWX logging option can assist with this), in some
90877 + environments this may not be possible. Having to disable MPROTECT
90878 + completely on certain binaries reduces the security benefit of PaX,
90879 + so this option is provided for those environments to revert to the old
90880 + behavior.
90881 +
90882 +config PAX_ELFRELOCS
90883 + bool "Allow ELF text relocations (read help)"
90884 + depends on PAX_MPROTECT
90885 + default n
90886 + help
90887 + Non-executable pages and mprotect() restrictions are effective
90888 + in preventing the introduction of new executable code into an
90889 + attacked task's address space. There remain only two venues
90890 + for this kind of attack: if the attacker can execute already
90891 + existing code in the attacked task then he can either have it
90892 + create and mmap() a file containing his code or have it mmap()
90893 + an already existing ELF library that does not have position
90894 + independent code in it and use mprotect() on it to make it
90895 + writable and copy his code there. While protecting against
90896 + the former approach is beyond PaX, the latter can be prevented
90897 + by having only PIC ELF libraries on one's system (which do not
90898 + need to relocate their code). If you are sure this is your case,
90899 + as is the case with all modern Linux distributions, then leave
90900 + this option disabled. You should say 'n' here.
90901 +
90902 +config PAX_ETEXECRELOCS
90903 + bool "Allow ELF ET_EXEC text relocations"
90904 + depends on PAX_MPROTECT && (ALPHA || IA64 || PARISC)
90905 + select PAX_ELFRELOCS
90906 + default y
90907 + help
90908 + On some architectures there are incorrectly created applications
90909 + that require text relocations and would not work without enabling
90910 + this option. If you are an alpha, ia64 or parisc user, you should
90911 + enable this option and disable it once you have made sure that
90912 + none of your applications need it.
90913 +
90914 +config PAX_EMUPLT
90915 + bool "Automatically emulate ELF PLT"
90916 + depends on PAX_MPROTECT && (ALPHA || PARISC || SPARC)
90917 + default y
90918 + help
90919 + Enabling this option will have the kernel automatically detect
90920 + and emulate the Procedure Linkage Table entries in ELF files.
90921 + On some architectures such entries are in writable memory, and
90922 + become non-executable leading to task termination. Therefore
90923 + it is mandatory that you enable this option on alpha, parisc,
90924 + sparc and sparc64, otherwise your system would not even boot.
90925 +
90926 + NOTE: this feature *does* open up a loophole in the protection
90927 + provided by the non-executable pages, therefore the proper
90928 + solution is to modify the toolchain to produce a PLT that does
90929 + not need to be writable.
90930 +
90931 +config PAX_DLRESOLVE
90932 + bool 'Emulate old glibc resolver stub'
90933 + depends on PAX_EMUPLT && SPARC
90934 + default n
90935 + help
90936 + This option is needed if userland has an old glibc (before 2.4)
90937 + that puts a 'save' instruction into the runtime generated resolver
90938 + stub that needs special emulation.
90939 +
90940 +config PAX_KERNEXEC
90941 + bool "Enforce non-executable kernel pages"
90942 + 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))
90943 + depends on (X86 || (ARM && (CPU_V6 || CPU_V7) && !(ARM_LPAE && MODULES))) && !XEN
90944 + select PAX_PER_CPU_PGD if X86_64 || (X86_32 && X86_PAE)
90945 + select PAX_KERNEXEC_PLUGIN if X86_64
90946 + help
90947 + This is the kernel land equivalent of PAGEEXEC and MPROTECT,
90948 + that is, enabling this option will make it harder to inject
90949 + and execute 'foreign' code in kernel memory itself.
90950 +
90951 +choice
90952 + prompt "Return Address Instrumentation Method"
90953 + default PAX_KERNEXEC_PLUGIN_METHOD_BTS
90954 + depends on PAX_KERNEXEC_PLUGIN
90955 + help
90956 + Select the method used to instrument function pointer dereferences.
90957 + Note that binary modules cannot be instrumented by this approach.
90958 +
90959 + Note that the implementation requires a gcc with plugin support,
90960 + i.e., gcc 4.5 or newer. You may need to install the supporting
90961 + headers explicitly in addition to the normal gcc package.
90962 +
90963 + config PAX_KERNEXEC_PLUGIN_METHOD_BTS
90964 + bool "bts"
90965 + help
90966 + This method is compatible with binary only modules but has
90967 + a higher runtime overhead.
90968 +
90969 + config PAX_KERNEXEC_PLUGIN_METHOD_OR
90970 + bool "or"
90971 + depends on !PARAVIRT
90972 + help
90973 + This method is incompatible with binary only modules but has
90974 + a lower runtime overhead.
90975 +endchoice
90976 +
90977 +config PAX_KERNEXEC_PLUGIN_METHOD
90978 + string
90979 + default "bts" if PAX_KERNEXEC_PLUGIN_METHOD_BTS
90980 + default "or" if PAX_KERNEXEC_PLUGIN_METHOD_OR
90981 + default ""
90982 +
90983 +config PAX_KERNEXEC_MODULE_TEXT
90984 + int "Minimum amount of memory reserved for module code"
90985 + default "4" if (!GRKERNSEC_CONFIG_AUTO || GRKERNSEC_CONFIG_SERVER)
90986 + default "12" if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
90987 + depends on PAX_KERNEXEC && X86_32 && MODULES
90988 + help
90989 + Due to implementation details the kernel must reserve a fixed
90990 + amount of memory for module code at compile time that cannot be
90991 + changed at runtime. Here you can specify the minimum amount
90992 + in MB that will be reserved. Due to the same implementation
90993 + details this size will always be rounded up to the next 2/4 MB
90994 + boundary (depends on PAE) so the actually available memory for
90995 + module code will usually be more than this minimum.
90996 +
90997 + The default 4 MB should be enough for most users but if you have
90998 + an excessive number of modules (e.g., most distribution configs
90999 + compile many drivers as modules) or use huge modules such as
91000 + nvidia's kernel driver, you will need to adjust this amount.
91001 + A good rule of thumb is to look at your currently loaded kernel
91002 + modules and add up their sizes.
91003 +
91004 +endmenu
91005 +
91006 +menu "Address Space Layout Randomization"
91007 + depends on PAX
91008 +
91009 +config PAX_ASLR
91010 + bool "Address Space Layout Randomization"
91011 + default y if GRKERNSEC_CONFIG_AUTO
91012 + help
91013 + Many if not most exploit techniques rely on the knowledge of
91014 + certain addresses in the attacked program. The following options
91015 + will allow the kernel to apply a certain amount of randomization
91016 + to specific parts of the program thereby forcing an attacker to
91017 + guess them in most cases. Any failed guess will most likely crash
91018 + the attacked program which allows the kernel to detect such attempts
91019 + and react on them. PaX itself provides no reaction mechanisms,
91020 + instead it is strongly encouraged that you make use of Nergal's
91021 + segvguard (ftp://ftp.pl.openwall.com/misc/segvguard/) or grsecurity's
91022 + (http://www.grsecurity.net/) built-in crash detection features or
91023 + develop one yourself.
91024 +
91025 + By saying Y here you can choose to randomize the following areas:
91026 + - top of the task's kernel stack
91027 + - top of the task's userland stack
91028 + - base address for mmap() requests that do not specify one
91029 + (this includes all libraries)
91030 + - base address of the main executable
91031 +
91032 + It is strongly recommended to say Y here as address space layout
91033 + randomization has negligible impact on performance yet it provides
91034 + a very effective protection.
91035 +
91036 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
91037 + this feature on a per file basis.
91038 +
91039 +config PAX_RANDKSTACK
91040 + bool "Randomize kernel stack base"
91041 + default y if GRKERNSEC_CONFIG_AUTO
91042 + depends on X86_TSC && X86
91043 + help
91044 + By saying Y here the kernel will randomize every task's kernel
91045 + stack on every system call. This will not only force an attacker
91046 + to guess it but also prevent him from making use of possible
91047 + leaked information about it.
91048 +
91049 + Since the kernel stack is a rather scarce resource, randomization
91050 + may cause unexpected stack overflows, therefore you should very
91051 + carefully test your system. Note that once enabled in the kernel
91052 + configuration, this feature cannot be disabled on a per file basis.
91053 +
91054 +config PAX_RANDUSTACK
91055 + bool "Randomize user stack base"
91056 + default y if GRKERNSEC_CONFIG_AUTO
91057 + depends on PAX_ASLR
91058 + help
91059 + By saying Y here the kernel will randomize every task's userland
91060 + stack. The randomization is done in two steps where the second
91061 + one may apply a big amount of shift to the top of the stack and
91062 + cause problems for programs that want to use lots of memory (more
91063 + than 2.5 GB if SEGMEXEC is not active, or 1.25 GB when it is).
91064 + For this reason the second step can be controlled by 'chpax' or
91065 + 'paxctl' on a per file basis.
91066 +
91067 +config PAX_RANDMMAP
91068 + bool "Randomize mmap() base"
91069 + default y if GRKERNSEC_CONFIG_AUTO
91070 + depends on PAX_ASLR
91071 + help
91072 + By saying Y here the kernel will use a randomized base address for
91073 + mmap() requests that do not specify one themselves. As a result
91074 + all dynamically loaded libraries will appear at random addresses
91075 + and therefore be harder to exploit by a technique where an attacker
91076 + attempts to execute library code for his purposes (e.g. spawn a
91077 + shell from an exploited program that is running at an elevated
91078 + privilege level).
91079 +
91080 + Furthermore, if a program is relinked as a dynamic ELF file, its
91081 + base address will be randomized as well, completing the full
91082 + randomization of the address space layout. Attacking such programs
91083 + becomes a guess game. You can find an example of doing this at
91084 + http://pax.grsecurity.net/et_dyn.tar.gz and practical samples at
91085 + http://www.grsecurity.net/grsec-gcc-specs.tar.gz .
91086 +
91087 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control this
91088 + feature on a per file basis.
91089 +
91090 +endmenu
91091 +
91092 +menu "Miscellaneous hardening features"
91093 +
91094 +config PAX_MEMORY_SANITIZE
91095 + bool "Sanitize all freed memory"
91096 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
91097 + depends on !HIBERNATION
91098 + help
91099 + By saying Y here the kernel will erase memory pages as soon as they
91100 + are freed. This in turn reduces the lifetime of data stored in the
91101 + pages, making it less likely that sensitive information such as
91102 + passwords, cryptographic secrets, etc stay in memory for too long.
91103 +
91104 + This is especially useful for programs whose runtime is short, long
91105 + lived processes and the kernel itself benefit from this as long as
91106 + they operate on whole memory pages and ensure timely freeing of pages
91107 + that may hold sensitive information.
91108 +
91109 + The tradeoff is performance impact, on a single CPU system kernel
91110 + compilation sees a 3% slowdown, other systems and workloads may vary
91111 + and you are advised to test this feature on your expected workload
91112 + before deploying it.
91113 +
91114 + Note that this feature does not protect data stored in live pages,
91115 + e.g., process memory swapped to disk may stay there for a long time.
91116 +
91117 +config PAX_MEMORY_STACKLEAK
91118 + bool "Sanitize kernel stack"
91119 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
91120 + depends on X86
91121 + help
91122 + By saying Y here the kernel will erase the kernel stack before it
91123 + returns from a system call. This in turn reduces the information
91124 + that a kernel stack leak bug can reveal.
91125 +
91126 + Note that such a bug can still leak information that was put on
91127 + the stack by the current system call (the one eventually triggering
91128 + the bug) but traces of earlier system calls on the kernel stack
91129 + cannot leak anymore.
91130 +
91131 + The tradeoff is performance impact: on a single CPU system kernel
91132 + compilation sees a 1% slowdown, other systems and workloads may vary
91133 + and you are advised to test this feature on your expected workload
91134 + before deploying it.
91135 +
91136 + Note that the full feature requires a gcc with plugin support,
91137 + i.e., gcc 4.5 or newer. You may need to install the supporting
91138 + headers explicitly in addition to the normal gcc package. Using
91139 + older gcc versions means that functions with large enough stack
91140 + frames may leave uninitialized memory behind that may be exposed
91141 + to a later syscall leaking the stack.
91142 +
91143 +config PAX_MEMORY_STRUCTLEAK
91144 + bool "Forcibly initialize local variables copied to userland"
91145 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
91146 + help
91147 + By saying Y here the kernel will zero initialize some local
91148 + variables that are going to be copied to userland. This in
91149 + turn prevents unintended information leakage from the kernel
91150 + stack should later code forget to explicitly set all parts of
91151 + the copied variable.
91152 +
91153 + The tradeoff is less performance impact than PAX_MEMORY_STACKLEAK
91154 + at a much smaller coverage.
91155 +
91156 + Note that the implementation requires a gcc with plugin support,
91157 + i.e., gcc 4.5 or newer. You may need to install the supporting
91158 + headers explicitly in addition to the normal gcc package.
91159 +
91160 +config PAX_MEMORY_UDEREF
91161 + bool "Prevent invalid userland pointer dereference"
91162 + default y if GRKERNSEC_CONFIG_AUTO && !(X86_64 && GRKERNSEC_CONFIG_PRIORITY_PERF) && (GRKERNSEC_CONFIG_VIRT_NONE || GRKERNSEC_CONFIG_VIRT_EPT)
91163 + depends on (X86 || (ARM && (CPU_V6 || CPU_V7) && !ARM_LPAE)) && !UML_X86 && !XEN
91164 + select PAX_PER_CPU_PGD if X86_64
91165 + help
91166 + By saying Y here the kernel will be prevented from dereferencing
91167 + userland pointers in contexts where the kernel expects only kernel
91168 + pointers. This is both a useful runtime debugging feature and a
91169 + security measure that prevents exploiting a class of kernel bugs.
91170 +
91171 + The tradeoff is that some virtualization solutions may experience
91172 + a huge slowdown and therefore you should not enable this feature
91173 + for kernels meant to run in such environments. Whether a given VM
91174 + solution is affected or not is best determined by simply trying it
91175 + out, the performance impact will be obvious right on boot as this
91176 + mechanism engages from very early on. A good rule of thumb is that
91177 + VMs running on CPUs without hardware virtualization support (i.e.,
91178 + the majority of IA-32 CPUs) will likely experience the slowdown.
91179 +
91180 +config PAX_REFCOUNT
91181 + bool "Prevent various kernel object reference counter overflows"
91182 + default y if GRKERNSEC_CONFIG_AUTO
91183 + depends on GRKERNSEC && ((ARM && (CPU_32v6 || CPU_32v6K || CPU_32v7)) || SPARC64 || X86)
91184 + help
91185 + By saying Y here the kernel will detect and prevent overflowing
91186 + various (but not all) kinds of object reference counters. Such
91187 + overflows can normally occur due to bugs only and are often, if
91188 + not always, exploitable.
91189 +
91190 + The tradeoff is that data structures protected by an overflowed
91191 + refcount will never be freed and therefore will leak memory. Note
91192 + that this leak also happens even without this protection but in
91193 + that case the overflow can eventually trigger the freeing of the
91194 + data structure while it is still being used elsewhere, resulting
91195 + in the exploitable situation that this feature prevents.
91196 +
91197 + Since this has a negligible performance impact, you should enable
91198 + this feature.
91199 +
91200 +config PAX_CONSTIFY_PLUGIN
91201 + bool "Automatically constify eligible structures"
91202 + default y
91203 + depends on !UML && PAX_KERNEXEC
91204 + help
91205 + By saying Y here the compiler will automatically constify a class
91206 + of types that contain only function pointers. This reduces the
91207 + kernel's attack surface and also produces a better memory layout.
91208 +
91209 + Note that the implementation requires a gcc with plugin support,
91210 + i.e., gcc 4.5 or newer. You may need to install the supporting
91211 + headers explicitly in addition to the normal gcc package.
91212 +
91213 + Note that if some code really has to modify constified variables
91214 + then the source code will have to be patched to allow it. Examples
91215 + can be found in PaX itself (the no_const attribute) and for some
91216 + out-of-tree modules at http://www.grsecurity.net/~paxguy1/ .
91217 +
91218 +config PAX_USERCOPY
91219 + bool "Harden heap object copies between kernel and userland"
91220 + default y if GRKERNSEC_CONFIG_AUTO
91221 + depends on ARM || IA64 || PPC || SPARC || X86
91222 + depends on GRKERNSEC && (SLAB || SLUB || SLOB)
91223 + select PAX_USERCOPY_SLABS
91224 + help
91225 + By saying Y here the kernel will enforce the size of heap objects
91226 + when they are copied in either direction between the kernel and
91227 + userland, even if only a part of the heap object is copied.
91228 +
91229 + Specifically, this checking prevents information leaking from the
91230 + kernel heap during kernel to userland copies (if the kernel heap
91231 + object is otherwise fully initialized) and prevents kernel heap
91232 + overflows during userland to kernel copies.
91233 +
91234 + Note that the current implementation provides the strictest bounds
91235 + checks for the SLUB allocator.
91236 +
91237 + Enabling this option also enables per-slab cache protection against
91238 + data in a given cache being copied into/out of via userland
91239 + accessors. Though the whitelist of regions will be reduced over
91240 + time, it notably protects important data structures like task structs.
91241 +
91242 + If frame pointers are enabled on x86, this option will also restrict
91243 + copies into and out of the kernel stack to local variables within a
91244 + single frame.
91245 +
91246 + Since this has a negligible performance impact, you should enable
91247 + this feature.
91248 +
91249 +config PAX_USERCOPY_DEBUG
91250 + bool
91251 + depends on X86 && PAX_USERCOPY
91252 + default n
91253 +
91254 +config PAX_SIZE_OVERFLOW
91255 + bool "Prevent various integer overflows in function size parameters"
91256 + default y if GRKERNSEC_CONFIG_AUTO
91257 + depends on X86
91258 + help
91259 + By saying Y here the kernel recomputes expressions of function
91260 + arguments marked by a size_overflow attribute with double integer
91261 + precision (DImode/TImode for 32/64 bit integer types).
91262 +
91263 + The recomputed argument is checked against TYPE_MAX and an event
91264 + is logged on overflow and the triggering process is killed.
91265 +
91266 + Homepage: http://www.grsecurity.net/~ephox/overflow_plugin/
91267 +
91268 + Note that the implementation requires a gcc with plugin support,
91269 + i.e., gcc 4.5 or newer. You may need to install the supporting
91270 + headers explicitly in addition to the normal gcc package.
91271 +
91272 +config PAX_LATENT_ENTROPY
91273 + bool "Generate some entropy during boot"
91274 + default y if GRKERNSEC_CONFIG_AUTO
91275 + help
91276 + By saying Y here the kernel will instrument early boot code to
91277 + extract some entropy from both original and artificially created
91278 + program state. This will help especially embedded systems where
91279 + there is little 'natural' source of entropy normally. The cost
91280 + is some slowdown of the boot process.
91281 +
91282 + When pax_extra_latent_entropy is passed on the kernel command line,
91283 + entropy will be extracted from up to the first 4GB of RAM while the
91284 + runtime memory allocator is being initialized. This costs even more
91285 + slowdown of the boot process.
91286 +
91287 + Note that the implementation requires a gcc with plugin support,
91288 + i.e., gcc 4.5 or newer. You may need to install the supporting
91289 + headers explicitly in addition to the normal gcc package.
91290 +
91291 + Note that entropy extracted this way is not cryptographically
91292 + secure!
91293 +
91294 +endmenu
91295 +
91296 +endmenu
91297 +
91298 +source grsecurity/Kconfig
91299 +
91300 +endmenu
91301 +
91302 +endmenu
91303 +
91304 source security/keys/Kconfig
91305
91306 config SECURITY_DMESG_RESTRICT
91307 @@ -103,7 +1041,7 @@ config INTEL_TXT
91308 config LSM_MMAP_MIN_ADDR
91309 int "Low address space for LSM to protect from user allocation"
91310 depends on SECURITY && SECURITY_SELINUX
91311 - default 32768 if ARM
91312 + default 32768 if ALPHA || ARM || PARISC || SPARC32
91313 default 65536
91314 help
91315 This is the portion of low virtual memory which should be protected
91316 diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
91317 index b21830e..a7d1a17 100644
91318 --- a/security/apparmor/lsm.c
91319 +++ b/security/apparmor/lsm.c
91320 @@ -614,7 +614,7 @@ static int apparmor_task_setrlimit(struct task_struct *task,
91321 return error;
91322 }
91323
91324 -static struct security_operations apparmor_ops = {
91325 +static struct security_operations apparmor_ops __read_only = {
91326 .name = "apparmor",
91327
91328 .ptrace_access_check = apparmor_ptrace_access_check,
91329 diff --git a/security/commoncap.c b/security/commoncap.c
91330 index c44b6fe..932df30 100644
91331 --- a/security/commoncap.c
91332 +++ b/security/commoncap.c
91333 @@ -424,6 +424,32 @@ int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data
91334 return 0;
91335 }
91336
91337 +/* returns:
91338 + 1 for suid privilege
91339 + 2 for sgid privilege
91340 + 3 for fscap privilege
91341 +*/
91342 +int is_privileged_binary(const struct dentry *dentry)
91343 +{
91344 + struct cpu_vfs_cap_data capdata;
91345 + struct inode *inode = dentry->d_inode;
91346 +
91347 + if (!inode || S_ISDIR(inode->i_mode))
91348 + return 0;
91349 +
91350 + if (inode->i_mode & S_ISUID)
91351 + return 1;
91352 + if ((inode->i_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))
91353 + return 2;
91354 +
91355 + if (!get_vfs_caps_from_disk(dentry, &capdata)) {
91356 + if (!cap_isclear(capdata.inheritable) || !cap_isclear(capdata.permitted))
91357 + return 3;
91358 + }
91359 +
91360 + return 0;
91361 +}
91362 +
91363 /*
91364 * Attempt to get the on-exec apply capability sets for an executable file from
91365 * its xattrs and, if present, apply them to the proposed credentials being
91366 @@ -592,6 +618,9 @@ int cap_bprm_secureexec(struct linux_binprm *bprm)
91367 const struct cred *cred = current_cred();
91368 kuid_t root_uid = make_kuid(cred->user_ns, 0);
91369
91370 + if (gr_acl_enable_at_secure())
91371 + return 1;
91372 +
91373 if (!uid_eq(cred->uid, root_uid)) {
91374 if (bprm->cap_effective)
91375 return 1;
91376 diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
91377 index a41c9c1..83da6dd 100644
91378 --- a/security/integrity/ima/ima.h
91379 +++ b/security/integrity/ima/ima.h
91380 @@ -97,8 +97,8 @@ int ima_init_crypto(void);
91381 extern spinlock_t ima_queue_lock;
91382
91383 struct ima_h_table {
91384 - atomic_long_t len; /* number of stored measurements in the list */
91385 - atomic_long_t violations;
91386 + atomic_long_unchecked_t len; /* number of stored measurements in the list */
91387 + atomic_long_unchecked_t violations;
91388 struct hlist_head queue[IMA_MEASURE_HTABLE_SIZE];
91389 };
91390 extern struct ima_h_table ima_htable;
91391 diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
91392 index 1c03e8f1..398a941 100644
91393 --- a/security/integrity/ima/ima_api.c
91394 +++ b/security/integrity/ima/ima_api.c
91395 @@ -79,7 +79,7 @@ void ima_add_violation(struct inode *inode, const unsigned char *filename,
91396 int result;
91397
91398 /* can overflow, only indicator */
91399 - atomic_long_inc(&ima_htable.violations);
91400 + atomic_long_inc_unchecked(&ima_htable.violations);
91401
91402 entry = kmalloc(sizeof(*entry), GFP_KERNEL);
91403 if (!entry) {
91404 diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c
91405 index 38477c9..87a60c7 100644
91406 --- a/security/integrity/ima/ima_fs.c
91407 +++ b/security/integrity/ima/ima_fs.c
91408 @@ -28,12 +28,12 @@
91409 static int valid_policy = 1;
91410 #define TMPBUFLEN 12
91411 static ssize_t ima_show_htable_value(char __user *buf, size_t count,
91412 - loff_t *ppos, atomic_long_t *val)
91413 + loff_t *ppos, atomic_long_unchecked_t *val)
91414 {
91415 char tmpbuf[TMPBUFLEN];
91416 ssize_t len;
91417
91418 - len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read(val));
91419 + len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read_unchecked(val));
91420 return simple_read_from_buffer(buf, count, ppos, tmpbuf, len);
91421 }
91422
91423 diff --git a/security/integrity/ima/ima_queue.c b/security/integrity/ima/ima_queue.c
91424 index ff63fe0..809cd96 100644
91425 --- a/security/integrity/ima/ima_queue.c
91426 +++ b/security/integrity/ima/ima_queue.c
91427 @@ -80,7 +80,7 @@ static int ima_add_digest_entry(struct ima_template_entry *entry)
91428 INIT_LIST_HEAD(&qe->later);
91429 list_add_tail_rcu(&qe->later, &ima_measurements);
91430
91431 - atomic_long_inc(&ima_htable.len);
91432 + atomic_long_inc_unchecked(&ima_htable.len);
91433 key = ima_hash_key(entry->digest);
91434 hlist_add_head_rcu(&qe->hnext, &ima_htable.queue[key]);
91435 return 0;
91436 diff --git a/security/keys/compat.c b/security/keys/compat.c
91437 index d65fa7f..cbfe366 100644
91438 --- a/security/keys/compat.c
91439 +++ b/security/keys/compat.c
91440 @@ -44,7 +44,7 @@ static long compat_keyctl_instantiate_key_iov(
91441 if (ret == 0)
91442 goto no_payload_free;
91443
91444 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
91445 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
91446 err:
91447 if (iov != iovstack)
91448 kfree(iov);
91449 diff --git a/security/keys/key.c b/security/keys/key.c
91450 index 8fb7c7b..ba3610d 100644
91451 --- a/security/keys/key.c
91452 +++ b/security/keys/key.c
91453 @@ -284,7 +284,7 @@ struct key *key_alloc(struct key_type *type, const char *desc,
91454
91455 atomic_set(&key->usage, 1);
91456 init_rwsem(&key->sem);
91457 - lockdep_set_class(&key->sem, &type->lock_class);
91458 + lockdep_set_class(&key->sem, (struct lock_class_key *)&type->lock_class);
91459 key->type = type;
91460 key->user = user;
91461 key->quotalen = quotalen;
91462 @@ -1032,7 +1032,9 @@ int register_key_type(struct key_type *ktype)
91463 struct key_type *p;
91464 int ret;
91465
91466 - memset(&ktype->lock_class, 0, sizeof(ktype->lock_class));
91467 + pax_open_kernel();
91468 + memset((void *)&ktype->lock_class, 0, sizeof(ktype->lock_class));
91469 + pax_close_kernel();
91470
91471 ret = -EEXIST;
91472 down_write(&key_types_sem);
91473 @@ -1044,7 +1046,7 @@ int register_key_type(struct key_type *ktype)
91474 }
91475
91476 /* store the type */
91477 - list_add(&ktype->link, &key_types_list);
91478 + pax_list_add((struct list_head *)&ktype->link, &key_types_list);
91479
91480 pr_notice("Key type %s registered\n", ktype->name);
91481 ret = 0;
91482 @@ -1066,7 +1068,7 @@ EXPORT_SYMBOL(register_key_type);
91483 void unregister_key_type(struct key_type *ktype)
91484 {
91485 down_write(&key_types_sem);
91486 - list_del_init(&ktype->link);
91487 + pax_list_del_init((struct list_head *)&ktype->link);
91488 downgrade_write(&key_types_sem);
91489 key_gc_keytype(ktype);
91490 pr_notice("Key type %s unregistered\n", ktype->name);
91491 @@ -1084,10 +1086,10 @@ void __init key_init(void)
91492 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
91493
91494 /* add the special key types */
91495 - list_add_tail(&key_type_keyring.link, &key_types_list);
91496 - list_add_tail(&key_type_dead.link, &key_types_list);
91497 - list_add_tail(&key_type_user.link, &key_types_list);
91498 - list_add_tail(&key_type_logon.link, &key_types_list);
91499 + pax_list_add_tail((struct list_head *)&key_type_keyring.link, &key_types_list);
91500 + pax_list_add_tail((struct list_head *)&key_type_dead.link, &key_types_list);
91501 + pax_list_add_tail((struct list_head *)&key_type_user.link, &key_types_list);
91502 + pax_list_add_tail((struct list_head *)&key_type_logon.link, &key_types_list);
91503
91504 /* record the root user tracking */
91505 rb_link_node(&root_key_user.node,
91506 diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
91507 index 4b5c948..2054dc1 100644
91508 --- a/security/keys/keyctl.c
91509 +++ b/security/keys/keyctl.c
91510 @@ -986,7 +986,7 @@ static int keyctl_change_reqkey_auth(struct key *key)
91511 /*
91512 * Copy the iovec data from userspace
91513 */
91514 -static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
91515 +static long copy_from_user_iovec(void *buffer, const struct iovec __user *iov,
91516 unsigned ioc)
91517 {
91518 for (; ioc > 0; ioc--) {
91519 @@ -1008,7 +1008,7 @@ static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
91520 * If successful, 0 will be returned.
91521 */
91522 long keyctl_instantiate_key_common(key_serial_t id,
91523 - const struct iovec *payload_iov,
91524 + const struct iovec __user *payload_iov,
91525 unsigned ioc,
91526 size_t plen,
91527 key_serial_t ringid)
91528 @@ -1103,7 +1103,7 @@ long keyctl_instantiate_key(key_serial_t id,
91529 [0].iov_len = plen
91530 };
91531
91532 - return keyctl_instantiate_key_common(id, iov, 1, plen, ringid);
91533 + return keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, 1, plen, ringid);
91534 }
91535
91536 return keyctl_instantiate_key_common(id, NULL, 0, 0, ringid);
91537 @@ -1136,7 +1136,7 @@ long keyctl_instantiate_key_iov(key_serial_t id,
91538 if (ret == 0)
91539 goto no_payload_free;
91540
91541 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
91542 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
91543 err:
91544 if (iov != iovstack)
91545 kfree(iov);
91546 diff --git a/security/keys/keyring.c b/security/keys/keyring.c
91547 index 6ece7f2..ecdb55c 100644
91548 --- a/security/keys/keyring.c
91549 +++ b/security/keys/keyring.c
91550 @@ -227,16 +227,16 @@ static long keyring_read(const struct key *keyring,
91551 ret = -EFAULT;
91552
91553 for (loop = 0; loop < klist->nkeys; loop++) {
91554 + key_serial_t serial;
91555 key = rcu_deref_link_locked(klist, loop,
91556 keyring);
91557 + serial = key->serial;
91558
91559 tmp = sizeof(key_serial_t);
91560 if (tmp > buflen)
91561 tmp = buflen;
91562
91563 - if (copy_to_user(buffer,
91564 - &key->serial,
91565 - tmp) != 0)
91566 + if (copy_to_user(buffer, &serial, tmp))
91567 goto error;
91568
91569 buflen -= tmp;
91570 diff --git a/security/min_addr.c b/security/min_addr.c
91571 index f728728..6457a0c 100644
91572 --- a/security/min_addr.c
91573 +++ b/security/min_addr.c
91574 @@ -14,6 +14,7 @@ unsigned long dac_mmap_min_addr = CONFIG_DEFAULT_MMAP_MIN_ADDR;
91575 */
91576 static void update_mmap_min_addr(void)
91577 {
91578 +#ifndef SPARC
91579 #ifdef CONFIG_LSM_MMAP_MIN_ADDR
91580 if (dac_mmap_min_addr > CONFIG_LSM_MMAP_MIN_ADDR)
91581 mmap_min_addr = dac_mmap_min_addr;
91582 @@ -22,6 +23,7 @@ static void update_mmap_min_addr(void)
91583 #else
91584 mmap_min_addr = dac_mmap_min_addr;
91585 #endif
91586 +#endif
91587 }
91588
91589 /*
91590 diff --git a/security/security.c b/security/security.c
91591 index 03f248b..5710c33 100644
91592 --- a/security/security.c
91593 +++ b/security/security.c
91594 @@ -20,6 +20,7 @@
91595 #include <linux/ima.h>
91596 #include <linux/evm.h>
91597 #include <linux/fsnotify.h>
91598 +#include <linux/mm.h>
91599 #include <linux/mman.h>
91600 #include <linux/mount.h>
91601 #include <linux/personality.h>
91602 @@ -32,8 +33,8 @@
91603 static __initdata char chosen_lsm[SECURITY_NAME_MAX + 1] =
91604 CONFIG_DEFAULT_SECURITY;
91605
91606 -static struct security_operations *security_ops;
91607 -static struct security_operations default_security_ops = {
91608 +static struct security_operations *security_ops __read_only;
91609 +static struct security_operations default_security_ops __read_only = {
91610 .name = "default",
91611 };
91612
91613 @@ -74,7 +75,9 @@ int __init security_init(void)
91614
91615 void reset_security_ops(void)
91616 {
91617 + pax_open_kernel();
91618 security_ops = &default_security_ops;
91619 + pax_close_kernel();
91620 }
91621
91622 /* Save user chosen LSM */
91623 diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
91624 index 7171a95..c35e879 100644
91625 --- a/security/selinux/hooks.c
91626 +++ b/security/selinux/hooks.c
91627 @@ -96,8 +96,6 @@
91628
91629 #define NUM_SEL_MNT_OPTS 5
91630
91631 -extern struct security_operations *security_ops;
91632 -
91633 /* SECMARK reference count */
91634 static atomic_t selinux_secmark_refcount = ATOMIC_INIT(0);
91635
91636 @@ -5498,7 +5496,7 @@ static int selinux_key_getsecurity(struct key *key, char **_buffer)
91637
91638 #endif
91639
91640 -static struct security_operations selinux_ops = {
91641 +static struct security_operations selinux_ops __read_only = {
91642 .name = "selinux",
91643
91644 .ptrace_access_check = selinux_ptrace_access_check,
91645 diff --git a/security/selinux/include/xfrm.h b/security/selinux/include/xfrm.h
91646 index 65f67cb..3f141ef 100644
91647 --- a/security/selinux/include/xfrm.h
91648 +++ b/security/selinux/include/xfrm.h
91649 @@ -50,7 +50,7 @@ int selinux_xfrm_decode_session(struct sk_buff *skb, u32 *sid, int ckall);
91650
91651 static inline void selinux_xfrm_notify_policyload(void)
91652 {
91653 - atomic_inc(&flow_cache_genid);
91654 + atomic_inc_unchecked(&flow_cache_genid);
91655 rt_genid_bump(&init_net);
91656 }
91657 #else
91658 diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
91659 index fa64740..bc95b74 100644
91660 --- a/security/smack/smack_lsm.c
91661 +++ b/security/smack/smack_lsm.c
91662 @@ -3392,7 +3392,7 @@ static int smack_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
91663 return 0;
91664 }
91665
91666 -struct security_operations smack_ops = {
91667 +struct security_operations smack_ops __read_only = {
91668 .name = "smack",
91669
91670 .ptrace_access_check = smack_ptrace_access_check,
91671 diff --git a/security/tomoyo/mount.c b/security/tomoyo/mount.c
91672 index 390c646..f2f8db3 100644
91673 --- a/security/tomoyo/mount.c
91674 +++ b/security/tomoyo/mount.c
91675 @@ -118,6 +118,10 @@ static int tomoyo_mount_acl(struct tomoyo_request_info *r,
91676 type == tomoyo_mounts[TOMOYO_MOUNT_MOVE]) {
91677 need_dev = -1; /* dev_name is a directory */
91678 } else {
91679 + if (!capable(CAP_SYS_ADMIN)) {
91680 + error = -EPERM;
91681 + goto out;
91682 + }
91683 fstype = get_fs_type(type);
91684 if (!fstype) {
91685 error = -ENODEV;
91686 diff --git a/security/tomoyo/tomoyo.c b/security/tomoyo/tomoyo.c
91687 index a2ee362..5754f34 100644
91688 --- a/security/tomoyo/tomoyo.c
91689 +++ b/security/tomoyo/tomoyo.c
91690 @@ -503,7 +503,7 @@ static int tomoyo_socket_sendmsg(struct socket *sock, struct msghdr *msg,
91691 * tomoyo_security_ops is a "struct security_operations" which is used for
91692 * registering TOMOYO.
91693 */
91694 -static struct security_operations tomoyo_security_ops = {
91695 +static struct security_operations tomoyo_security_ops __read_only = {
91696 .name = "tomoyo",
91697 .cred_alloc_blank = tomoyo_cred_alloc_blank,
91698 .cred_prepare = tomoyo_cred_prepare,
91699 diff --git a/security/yama/Kconfig b/security/yama/Kconfig
91700 index 20ef514..4182bed 100644
91701 --- a/security/yama/Kconfig
91702 +++ b/security/yama/Kconfig
91703 @@ -1,6 +1,6 @@
91704 config SECURITY_YAMA
91705 bool "Yama support"
91706 - depends on SECURITY
91707 + depends on SECURITY && !GRKERNSEC
91708 select SECURITYFS
91709 select SECURITY_PATH
91710 default n
91711 diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c
91712 index 13c88fbc..f8c115e 100644
91713 --- a/security/yama/yama_lsm.c
91714 +++ b/security/yama/yama_lsm.c
91715 @@ -365,7 +365,7 @@ int yama_ptrace_traceme(struct task_struct *parent)
91716 }
91717
91718 #ifndef CONFIG_SECURITY_YAMA_STACKED
91719 -static struct security_operations yama_ops = {
91720 +static struct security_operations yama_ops __read_only = {
91721 .name = "yama",
91722
91723 .ptrace_access_check = yama_ptrace_access_check,
91724 @@ -376,28 +376,24 @@ static struct security_operations yama_ops = {
91725 #endif
91726
91727 #ifdef CONFIG_SYSCTL
91728 +static int zero __read_only;
91729 +static int max_scope __read_only = YAMA_SCOPE_NO_ATTACH;
91730 +
91731 static int yama_dointvec_minmax(struct ctl_table *table, int write,
91732 void __user *buffer, size_t *lenp, loff_t *ppos)
91733 {
91734 - int rc;
91735 + ctl_table_no_const yama_table;
91736
91737 if (write && !capable(CAP_SYS_PTRACE))
91738 return -EPERM;
91739
91740 - rc = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
91741 - if (rc)
91742 - return rc;
91743 -
91744 + yama_table = *table;
91745 /* Lock the max value if it ever gets set. */
91746 - if (write && *(int *)table->data == *(int *)table->extra2)
91747 - table->extra1 = table->extra2;
91748 -
91749 - return rc;
91750 + if (ptrace_scope == max_scope)
91751 + yama_table.extra1 = &max_scope;
91752 + return proc_dointvec_minmax(&yama_table, write, buffer, lenp, ppos);
91753 }
91754
91755 -static int zero;
91756 -static int max_scope = YAMA_SCOPE_NO_ATTACH;
91757 -
91758 struct ctl_path yama_sysctl_path[] = {
91759 { .procname = "kernel", },
91760 { .procname = "yama", },
91761 diff --git a/sound/aoa/codecs/onyx.c b/sound/aoa/codecs/onyx.c
91762 index 4cedc69..e59d8a3 100644
91763 --- a/sound/aoa/codecs/onyx.c
91764 +++ b/sound/aoa/codecs/onyx.c
91765 @@ -54,7 +54,7 @@ struct onyx {
91766 spdif_locked:1,
91767 analog_locked:1,
91768 original_mute:2;
91769 - int open_count;
91770 + local_t open_count;
91771 struct codec_info *codec_info;
91772
91773 /* mutex serializes concurrent access to the device
91774 @@ -753,7 +753,7 @@ static int onyx_open(struct codec_info_item *cii,
91775 struct onyx *onyx = cii->codec_data;
91776
91777 mutex_lock(&onyx->mutex);
91778 - onyx->open_count++;
91779 + local_inc(&onyx->open_count);
91780 mutex_unlock(&onyx->mutex);
91781
91782 return 0;
91783 @@ -765,8 +765,7 @@ static int onyx_close(struct codec_info_item *cii,
91784 struct onyx *onyx = cii->codec_data;
91785
91786 mutex_lock(&onyx->mutex);
91787 - onyx->open_count--;
91788 - if (!onyx->open_count)
91789 + if (local_dec_and_test(&onyx->open_count))
91790 onyx->spdif_locked = onyx->analog_locked = 0;
91791 mutex_unlock(&onyx->mutex);
91792
91793 diff --git a/sound/aoa/codecs/onyx.h b/sound/aoa/codecs/onyx.h
91794 index ffd2025..df062c9 100644
91795 --- a/sound/aoa/codecs/onyx.h
91796 +++ b/sound/aoa/codecs/onyx.h
91797 @@ -11,6 +11,7 @@
91798 #include <linux/i2c.h>
91799 #include <asm/pmac_low_i2c.h>
91800 #include <asm/prom.h>
91801 +#include <asm/local.h>
91802
91803 /* PCM3052 register definitions */
91804
91805 diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
91806 index 4c1cc51..16040040 100644
91807 --- a/sound/core/oss/pcm_oss.c
91808 +++ b/sound/core/oss/pcm_oss.c
91809 @@ -1189,10 +1189,10 @@ snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream, const
91810 if (in_kernel) {
91811 mm_segment_t fs;
91812 fs = snd_enter_user();
91813 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
91814 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
91815 snd_leave_user(fs);
91816 } else {
91817 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
91818 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
91819 }
91820 if (ret != -EPIPE && ret != -ESTRPIPE)
91821 break;
91822 @@ -1234,10 +1234,10 @@ snd_pcm_sframes_t snd_pcm_oss_read3(struct snd_pcm_substream *substream, char *p
91823 if (in_kernel) {
91824 mm_segment_t fs;
91825 fs = snd_enter_user();
91826 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
91827 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
91828 snd_leave_user(fs);
91829 } else {
91830 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
91831 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
91832 }
91833 if (ret == -EPIPE) {
91834 if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) {
91835 @@ -1337,7 +1337,7 @@ static ssize_t snd_pcm_oss_write2(struct snd_pcm_substream *substream, const cha
91836 struct snd_pcm_plugin_channel *channels;
91837 size_t oss_frame_bytes = (runtime->oss.plugin_first->src_width * runtime->oss.plugin_first->src_format.channels) / 8;
91838 if (!in_kernel) {
91839 - if (copy_from_user(runtime->oss.buffer, (const char __force __user *)buf, bytes))
91840 + if (copy_from_user(runtime->oss.buffer, (const char __force_user *)buf, bytes))
91841 return -EFAULT;
91842 buf = runtime->oss.buffer;
91843 }
91844 @@ -1407,7 +1407,7 @@ static ssize_t snd_pcm_oss_write1(struct snd_pcm_substream *substream, const cha
91845 }
91846 } else {
91847 tmp = snd_pcm_oss_write2(substream,
91848 - (const char __force *)buf,
91849 + (const char __force_kernel *)buf,
91850 runtime->oss.period_bytes, 0);
91851 if (tmp <= 0)
91852 goto err;
91853 @@ -1433,7 +1433,7 @@ static ssize_t snd_pcm_oss_read2(struct snd_pcm_substream *substream, char *buf,
91854 struct snd_pcm_runtime *runtime = substream->runtime;
91855 snd_pcm_sframes_t frames, frames1;
91856 #ifdef CONFIG_SND_PCM_OSS_PLUGINS
91857 - char __user *final_dst = (char __force __user *)buf;
91858 + char __user *final_dst = (char __force_user *)buf;
91859 if (runtime->oss.plugin_first) {
91860 struct snd_pcm_plugin_channel *channels;
91861 size_t oss_frame_bytes = (runtime->oss.plugin_last->dst_width * runtime->oss.plugin_last->dst_format.channels) / 8;
91862 @@ -1495,7 +1495,7 @@ static ssize_t snd_pcm_oss_read1(struct snd_pcm_substream *substream, char __use
91863 xfer += tmp;
91864 runtime->oss.buffer_used -= tmp;
91865 } else {
91866 - tmp = snd_pcm_oss_read2(substream, (char __force *)buf,
91867 + tmp = snd_pcm_oss_read2(substream, (char __force_kernel *)buf,
91868 runtime->oss.period_bytes, 0);
91869 if (tmp <= 0)
91870 goto err;
91871 @@ -1663,7 +1663,7 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file)
91872 size1);
91873 size1 /= runtime->channels; /* frames */
91874 fs = snd_enter_user();
91875 - snd_pcm_lib_write(substream, (void __force __user *)runtime->oss.buffer, size1);
91876 + snd_pcm_lib_write(substream, (void __force_user *)runtime->oss.buffer, size1);
91877 snd_leave_user(fs);
91878 }
91879 } else if (runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) {
91880 diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c
91881 index af49721..e85058e 100644
91882 --- a/sound/core/pcm_compat.c
91883 +++ b/sound/core/pcm_compat.c
91884 @@ -31,7 +31,7 @@ static int snd_pcm_ioctl_delay_compat(struct snd_pcm_substream *substream,
91885 int err;
91886
91887 fs = snd_enter_user();
91888 - err = snd_pcm_delay(substream, &delay);
91889 + err = snd_pcm_delay(substream, (snd_pcm_sframes_t __force_user *)&delay);
91890 snd_leave_user(fs);
91891 if (err < 0)
91892 return err;
91893 diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
91894 index eb560fa..69a4995 100644
91895 --- a/sound/core/pcm_native.c
91896 +++ b/sound/core/pcm_native.c
91897 @@ -2806,11 +2806,11 @@ int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream,
91898 switch (substream->stream) {
91899 case SNDRV_PCM_STREAM_PLAYBACK:
91900 result = snd_pcm_playback_ioctl1(NULL, substream, cmd,
91901 - (void __user *)arg);
91902 + (void __force_user *)arg);
91903 break;
91904 case SNDRV_PCM_STREAM_CAPTURE:
91905 result = snd_pcm_capture_ioctl1(NULL, substream, cmd,
91906 - (void __user *)arg);
91907 + (void __force_user *)arg);
91908 break;
91909 default:
91910 result = -EINVAL;
91911 diff --git a/sound/core/seq/seq_device.c b/sound/core/seq/seq_device.c
91912 index 040c60e..989a19a 100644
91913 --- a/sound/core/seq/seq_device.c
91914 +++ b/sound/core/seq/seq_device.c
91915 @@ -64,7 +64,7 @@ struct ops_list {
91916 int argsize; /* argument size */
91917
91918 /* operators */
91919 - struct snd_seq_dev_ops ops;
91920 + struct snd_seq_dev_ops *ops;
91921
91922 /* registered devices */
91923 struct list_head dev_list; /* list of devices */
91924 @@ -333,7 +333,7 @@ int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry,
91925
91926 mutex_lock(&ops->reg_mutex);
91927 /* copy driver operators */
91928 - ops->ops = *entry;
91929 + ops->ops = entry;
91930 ops->driver |= DRIVER_LOADED;
91931 ops->argsize = argsize;
91932
91933 @@ -463,7 +463,7 @@ static int init_device(struct snd_seq_device *dev, struct ops_list *ops)
91934 dev->name, ops->id, ops->argsize, dev->argsize);
91935 return -EINVAL;
91936 }
91937 - if (ops->ops.init_device(dev) >= 0) {
91938 + if (ops->ops->init_device(dev) >= 0) {
91939 dev->status = SNDRV_SEQ_DEVICE_REGISTERED;
91940 ops->num_init_devices++;
91941 } else {
91942 @@ -490,7 +490,7 @@ static int free_device(struct snd_seq_device *dev, struct ops_list *ops)
91943 dev->name, ops->id, ops->argsize, dev->argsize);
91944 return -EINVAL;
91945 }
91946 - if ((result = ops->ops.free_device(dev)) >= 0 || result == -ENXIO) {
91947 + if ((result = ops->ops->free_device(dev)) >= 0 || result == -ENXIO) {
91948 dev->status = SNDRV_SEQ_DEVICE_FREE;
91949 dev->driver_data = NULL;
91950 ops->num_init_devices--;
91951 diff --git a/sound/drivers/mts64.c b/sound/drivers/mts64.c
91952 index 4e0dd22..7a1f32c 100644
91953 --- a/sound/drivers/mts64.c
91954 +++ b/sound/drivers/mts64.c
91955 @@ -29,6 +29,7 @@
91956 #include <sound/initval.h>
91957 #include <sound/rawmidi.h>
91958 #include <sound/control.h>
91959 +#include <asm/local.h>
91960
91961 #define CARD_NAME "Miditerminal 4140"
91962 #define DRIVER_NAME "MTS64"
91963 @@ -67,7 +68,7 @@ struct mts64 {
91964 struct pardevice *pardev;
91965 int pardev_claimed;
91966
91967 - int open_count;
91968 + local_t open_count;
91969 int current_midi_output_port;
91970 int current_midi_input_port;
91971 u8 mode[MTS64_NUM_INPUT_PORTS];
91972 @@ -697,7 +698,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
91973 {
91974 struct mts64 *mts = substream->rmidi->private_data;
91975
91976 - if (mts->open_count == 0) {
91977 + if (local_read(&mts->open_count) == 0) {
91978 /* We don't need a spinlock here, because this is just called
91979 if the device has not been opened before.
91980 So there aren't any IRQs from the device */
91981 @@ -705,7 +706,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
91982
91983 msleep(50);
91984 }
91985 - ++(mts->open_count);
91986 + local_inc(&mts->open_count);
91987
91988 return 0;
91989 }
91990 @@ -715,8 +716,7 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
91991 struct mts64 *mts = substream->rmidi->private_data;
91992 unsigned long flags;
91993
91994 - --(mts->open_count);
91995 - if (mts->open_count == 0) {
91996 + if (local_dec_return(&mts->open_count) == 0) {
91997 /* We need the spinlock_irqsave here because we can still
91998 have IRQs at this point */
91999 spin_lock_irqsave(&mts->lock, flags);
92000 @@ -725,8 +725,8 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
92001
92002 msleep(500);
92003
92004 - } else if (mts->open_count < 0)
92005 - mts->open_count = 0;
92006 + } else if (local_read(&mts->open_count) < 0)
92007 + local_set(&mts->open_count, 0);
92008
92009 return 0;
92010 }
92011 diff --git a/sound/drivers/opl4/opl4_lib.c b/sound/drivers/opl4/opl4_lib.c
92012 index b953fb4..1999c01 100644
92013 --- a/sound/drivers/opl4/opl4_lib.c
92014 +++ b/sound/drivers/opl4/opl4_lib.c
92015 @@ -29,7 +29,7 @@ MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
92016 MODULE_DESCRIPTION("OPL4 driver");
92017 MODULE_LICENSE("GPL");
92018
92019 -static void inline snd_opl4_wait(struct snd_opl4 *opl4)
92020 +static inline void snd_opl4_wait(struct snd_opl4 *opl4)
92021 {
92022 int timeout = 10;
92023 while ((inb(opl4->fm_port) & OPL4_STATUS_BUSY) && --timeout > 0)
92024 diff --git a/sound/drivers/portman2x4.c b/sound/drivers/portman2x4.c
92025 index 991018d..8984740 100644
92026 --- a/sound/drivers/portman2x4.c
92027 +++ b/sound/drivers/portman2x4.c
92028 @@ -48,6 +48,7 @@
92029 #include <sound/initval.h>
92030 #include <sound/rawmidi.h>
92031 #include <sound/control.h>
92032 +#include <asm/local.h>
92033
92034 #define CARD_NAME "Portman 2x4"
92035 #define DRIVER_NAME "portman"
92036 @@ -85,7 +86,7 @@ struct portman {
92037 struct pardevice *pardev;
92038 int pardev_claimed;
92039
92040 - int open_count;
92041 + local_t open_count;
92042 int mode[PORTMAN_NUM_INPUT_PORTS];
92043 struct snd_rawmidi_substream *midi_input[PORTMAN_NUM_INPUT_PORTS];
92044 };
92045 diff --git a/sound/firewire/amdtp.c b/sound/firewire/amdtp.c
92046 index ea995af..f1bfa37 100644
92047 --- a/sound/firewire/amdtp.c
92048 +++ b/sound/firewire/amdtp.c
92049 @@ -389,7 +389,7 @@ static void queue_out_packet(struct amdtp_out_stream *s, unsigned int cycle)
92050 ptr = s->pcm_buffer_pointer + data_blocks;
92051 if (ptr >= pcm->runtime->buffer_size)
92052 ptr -= pcm->runtime->buffer_size;
92053 - ACCESS_ONCE(s->pcm_buffer_pointer) = ptr;
92054 + ACCESS_ONCE_RW(s->pcm_buffer_pointer) = ptr;
92055
92056 s->pcm_period_pointer += data_blocks;
92057 if (s->pcm_period_pointer >= pcm->runtime->period_size) {
92058 @@ -557,7 +557,7 @@ EXPORT_SYMBOL(amdtp_out_stream_pcm_pointer);
92059 */
92060 void amdtp_out_stream_update(struct amdtp_out_stream *s)
92061 {
92062 - ACCESS_ONCE(s->source_node_id_field) =
92063 + ACCESS_ONCE_RW(s->source_node_id_field) =
92064 (fw_parent_device(s->unit)->card->node_id & 0x3f) << 24;
92065 }
92066 EXPORT_SYMBOL(amdtp_out_stream_update);
92067 diff --git a/sound/firewire/amdtp.h b/sound/firewire/amdtp.h
92068 index b680c5e..061b7a0 100644
92069 --- a/sound/firewire/amdtp.h
92070 +++ b/sound/firewire/amdtp.h
92071 @@ -139,7 +139,7 @@ static inline bool amdtp_out_streaming_error(struct amdtp_out_stream *s)
92072 static inline void amdtp_out_stream_pcm_trigger(struct amdtp_out_stream *s,
92073 struct snd_pcm_substream *pcm)
92074 {
92075 - ACCESS_ONCE(s->pcm) = pcm;
92076 + ACCESS_ONCE_RW(s->pcm) = pcm;
92077 }
92078
92079 static inline bool cip_sfc_is_base_44100(enum cip_sfc sfc)
92080 diff --git a/sound/firewire/isight.c b/sound/firewire/isight.c
92081 index d428ffe..751ef78 100644
92082 --- a/sound/firewire/isight.c
92083 +++ b/sound/firewire/isight.c
92084 @@ -96,7 +96,7 @@ static void isight_update_pointers(struct isight *isight, unsigned int count)
92085 ptr += count;
92086 if (ptr >= runtime->buffer_size)
92087 ptr -= runtime->buffer_size;
92088 - ACCESS_ONCE(isight->buffer_pointer) = ptr;
92089 + ACCESS_ONCE_RW(isight->buffer_pointer) = ptr;
92090
92091 isight->period_counter += count;
92092 if (isight->period_counter >= runtime->period_size) {
92093 @@ -307,7 +307,7 @@ static int isight_hw_params(struct snd_pcm_substream *substream,
92094 if (err < 0)
92095 return err;
92096
92097 - ACCESS_ONCE(isight->pcm_active) = true;
92098 + ACCESS_ONCE_RW(isight->pcm_active) = true;
92099
92100 return 0;
92101 }
92102 @@ -340,7 +340,7 @@ static int isight_hw_free(struct snd_pcm_substream *substream)
92103 {
92104 struct isight *isight = substream->private_data;
92105
92106 - ACCESS_ONCE(isight->pcm_active) = false;
92107 + ACCESS_ONCE_RW(isight->pcm_active) = false;
92108
92109 mutex_lock(&isight->mutex);
92110 isight_stop_streaming(isight);
92111 @@ -433,10 +433,10 @@ static int isight_trigger(struct snd_pcm_substream *substream, int cmd)
92112
92113 switch (cmd) {
92114 case SNDRV_PCM_TRIGGER_START:
92115 - ACCESS_ONCE(isight->pcm_running) = true;
92116 + ACCESS_ONCE_RW(isight->pcm_running) = true;
92117 break;
92118 case SNDRV_PCM_TRIGGER_STOP:
92119 - ACCESS_ONCE(isight->pcm_running) = false;
92120 + ACCESS_ONCE_RW(isight->pcm_running) = false;
92121 break;
92122 default:
92123 return -EINVAL;
92124 diff --git a/sound/firewire/scs1x.c b/sound/firewire/scs1x.c
92125 index 844a555..985ab83 100644
92126 --- a/sound/firewire/scs1x.c
92127 +++ b/sound/firewire/scs1x.c
92128 @@ -74,7 +74,7 @@ static void scs_output_trigger(struct snd_rawmidi_substream *stream, int up)
92129 {
92130 struct scs *scs = stream->rmidi->private_data;
92131
92132 - ACCESS_ONCE(scs->output) = up ? stream : NULL;
92133 + ACCESS_ONCE_RW(scs->output) = up ? stream : NULL;
92134 if (up) {
92135 scs->output_idle = false;
92136 tasklet_schedule(&scs->tasklet);
92137 @@ -257,7 +257,7 @@ static void scs_input_trigger(struct snd_rawmidi_substream *stream, int up)
92138 {
92139 struct scs *scs = stream->rmidi->private_data;
92140
92141 - ACCESS_ONCE(scs->input) = up ? stream : NULL;
92142 + ACCESS_ONCE_RW(scs->input) = up ? stream : NULL;
92143 }
92144
92145 static void scs_input_escaped_byte(struct snd_rawmidi_substream *stream,
92146 @@ -457,8 +457,8 @@ static int scs_remove(struct device *dev)
92147
92148 snd_card_disconnect(scs->card);
92149
92150 - ACCESS_ONCE(scs->output) = NULL;
92151 - ACCESS_ONCE(scs->input) = NULL;
92152 + ACCESS_ONCE_RW(scs->output) = NULL;
92153 + ACCESS_ONCE_RW(scs->input) = NULL;
92154
92155 wait_event(scs->idle_wait, scs->output_idle);
92156
92157 diff --git a/sound/oss/sb_audio.c b/sound/oss/sb_audio.c
92158 index 048439a..3be9f6f 100644
92159 --- a/sound/oss/sb_audio.c
92160 +++ b/sound/oss/sb_audio.c
92161 @@ -904,7 +904,7 @@ sb16_copy_from_user(int dev,
92162 buf16 = (signed short *)(localbuf + localoffs);
92163 while (c)
92164 {
92165 - locallen = (c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
92166 + locallen = ((unsigned)c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
92167 if (copy_from_user(lbuf8,
92168 userbuf+useroffs + p,
92169 locallen))
92170 diff --git a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c
92171 index 7d8803a..559f8d0 100644
92172 --- a/sound/oss/swarm_cs4297a.c
92173 +++ b/sound/oss/swarm_cs4297a.c
92174 @@ -2621,7 +2621,6 @@ static int __init cs4297a_init(void)
92175 {
92176 struct cs4297a_state *s;
92177 u32 pwr, id;
92178 - mm_segment_t fs;
92179 int rval;
92180 #ifndef CONFIG_BCM_CS4297A_CSWARM
92181 u64 cfg;
92182 @@ -2711,22 +2710,23 @@ static int __init cs4297a_init(void)
92183 if (!rval) {
92184 char *sb1250_duart_present;
92185
92186 +#if 0
92187 + mm_segment_t fs;
92188 fs = get_fs();
92189 set_fs(KERNEL_DS);
92190 -#if 0
92191 val = SOUND_MASK_LINE;
92192 mixer_ioctl(s, SOUND_MIXER_WRITE_RECSRC, (unsigned long) &val);
92193 for (i = 0; i < ARRAY_SIZE(initvol); i++) {
92194 val = initvol[i].vol;
92195 mixer_ioctl(s, initvol[i].mixch, (unsigned long) &val);
92196 }
92197 + set_fs(fs);
92198 // cs4297a_write_ac97(s, 0x18, 0x0808);
92199 #else
92200 // cs4297a_write_ac97(s, 0x5e, 0x180);
92201 cs4297a_write_ac97(s, 0x02, 0x0808);
92202 cs4297a_write_ac97(s, 0x18, 0x0808);
92203 #endif
92204 - set_fs(fs);
92205
92206 list_add(&s->list, &cs4297a_devs);
92207
92208 diff --git a/sound/pci/ymfpci/ymfpci.h b/sound/pci/ymfpci/ymfpci.h
92209 index 4631a23..001ae57 100644
92210 --- a/sound/pci/ymfpci/ymfpci.h
92211 +++ b/sound/pci/ymfpci/ymfpci.h
92212 @@ -358,7 +358,7 @@ struct snd_ymfpci {
92213 spinlock_t reg_lock;
92214 spinlock_t voice_lock;
92215 wait_queue_head_t interrupt_sleep;
92216 - atomic_t interrupt_sleep_count;
92217 + atomic_unchecked_t interrupt_sleep_count;
92218 struct snd_info_entry *proc_entry;
92219 const struct firmware *dsp_microcode;
92220 const struct firmware *controller_microcode;
92221 diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
92222 index 22056c5..25d3244 100644
92223 --- a/sound/pci/ymfpci/ymfpci_main.c
92224 +++ b/sound/pci/ymfpci/ymfpci_main.c
92225 @@ -202,8 +202,8 @@ static void snd_ymfpci_hw_stop(struct snd_ymfpci *chip)
92226 if ((snd_ymfpci_readl(chip, YDSXGR_STATUS) & 2) == 0)
92227 break;
92228 }
92229 - if (atomic_read(&chip->interrupt_sleep_count)) {
92230 - atomic_set(&chip->interrupt_sleep_count, 0);
92231 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
92232 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
92233 wake_up(&chip->interrupt_sleep);
92234 }
92235 __end:
92236 @@ -787,7 +787,7 @@ static void snd_ymfpci_irq_wait(struct snd_ymfpci *chip)
92237 continue;
92238 init_waitqueue_entry(&wait, current);
92239 add_wait_queue(&chip->interrupt_sleep, &wait);
92240 - atomic_inc(&chip->interrupt_sleep_count);
92241 + atomic_inc_unchecked(&chip->interrupt_sleep_count);
92242 schedule_timeout_uninterruptible(msecs_to_jiffies(50));
92243 remove_wait_queue(&chip->interrupt_sleep, &wait);
92244 }
92245 @@ -825,8 +825,8 @@ static irqreturn_t snd_ymfpci_interrupt(int irq, void *dev_id)
92246 snd_ymfpci_writel(chip, YDSXGR_MODE, mode);
92247 spin_unlock(&chip->reg_lock);
92248
92249 - if (atomic_read(&chip->interrupt_sleep_count)) {
92250 - atomic_set(&chip->interrupt_sleep_count, 0);
92251 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
92252 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
92253 wake_up(&chip->interrupt_sleep);
92254 }
92255 }
92256 @@ -2421,7 +2421,7 @@ int snd_ymfpci_create(struct snd_card *card,
92257 spin_lock_init(&chip->reg_lock);
92258 spin_lock_init(&chip->voice_lock);
92259 init_waitqueue_head(&chip->interrupt_sleep);
92260 - atomic_set(&chip->interrupt_sleep_count, 0);
92261 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
92262 chip->card = card;
92263 chip->pci = pci;
92264 chip->irq = -1;
92265 diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
92266 index 7decbd9..d17d9d0 100644
92267 --- a/sound/soc/fsl/fsl_ssi.c
92268 +++ b/sound/soc/fsl/fsl_ssi.c
92269 @@ -643,7 +643,7 @@ static int fsl_ssi_probe(struct platform_device *pdev)
92270 {
92271 struct fsl_ssi_private *ssi_private;
92272 int ret = 0;
92273 - struct device_attribute *dev_attr = NULL;
92274 + device_attribute_no_const *dev_attr = NULL;
92275 struct device_node *np = pdev->dev.of_node;
92276 const char *p, *sprop;
92277 const uint32_t *iprop;
92278 diff --git a/tools/gcc/.gitignore b/tools/gcc/.gitignore
92279 new file mode 100644
92280 index 0000000..50f2f2f
92281 --- /dev/null
92282 +++ b/tools/gcc/.gitignore
92283 @@ -0,0 +1 @@
92284 +size_overflow_hash.h
92285 diff --git a/tools/gcc/Makefile b/tools/gcc/Makefile
92286 new file mode 100644
92287 index 0000000..144dbee
92288 --- /dev/null
92289 +++ b/tools/gcc/Makefile
92290 @@ -0,0 +1,45 @@
92291 +#CC := gcc
92292 +#PLUGIN_SOURCE_FILES := pax_plugin.c
92293 +#PLUGIN_OBJECT_FILES := $(patsubst %.c,%.o,$(PLUGIN_SOURCE_FILES))
92294 +GCCPLUGINS_DIR := $(shell $(CC) -print-file-name=plugin)
92295 +#CFLAGS += -I$(GCCPLUGINS_DIR)/include -fPIC -O2 -Wall -W -std=gnu99
92296 +
92297 +ifeq ($(PLUGINCC),$(HOSTCC))
92298 +HOSTLIBS := hostlibs
92299 +HOST_EXTRACFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu99 -ggdb
92300 +else
92301 +HOSTLIBS := hostcxxlibs
92302 +HOST_EXTRACXXFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu++98 -ggdb -Wno-unused-parameter
92303 +endif
92304 +
92305 +$(HOSTLIBS)-$(CONFIG_PAX_CONSTIFY_PLUGIN) := constify_plugin.so
92306 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STACKLEAK) += stackleak_plugin.so
92307 +$(HOSTLIBS)-$(CONFIG_KALLOCSTAT_PLUGIN) += kallocstat_plugin.so
92308 +$(HOSTLIBS)-$(CONFIG_PAX_KERNEXEC_PLUGIN) += kernexec_plugin.so
92309 +$(HOSTLIBS)-$(CONFIG_CHECKER_PLUGIN) += checker_plugin.so
92310 +$(HOSTLIBS)-y += colorize_plugin.so
92311 +$(HOSTLIBS)-$(CONFIG_PAX_SIZE_OVERFLOW) += size_overflow_plugin.so
92312 +$(HOSTLIBS)-$(CONFIG_PAX_LATENT_ENTROPY) += latent_entropy_plugin.so
92313 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STRUCTLEAK) += structleak_plugin.so
92314 +
92315 +always := $($(HOSTLIBS)-y)
92316 +
92317 +constify_plugin-objs := constify_plugin.o
92318 +stackleak_plugin-objs := stackleak_plugin.o
92319 +kallocstat_plugin-objs := kallocstat_plugin.o
92320 +kernexec_plugin-objs := kernexec_plugin.o
92321 +checker_plugin-objs := checker_plugin.o
92322 +colorize_plugin-objs := colorize_plugin.o
92323 +size_overflow_plugin-objs := size_overflow_plugin.o
92324 +latent_entropy_plugin-objs := latent_entropy_plugin.o
92325 +structleak_plugin-objs := structleak_plugin.o
92326 +
92327 +$(obj)/size_overflow_plugin.o: $(objtree)/$(obj)/size_overflow_hash.h
92328 +
92329 +quiet_cmd_build_size_overflow_hash = GENHASH $@
92330 + cmd_build_size_overflow_hash = \
92331 + $(CONFIG_SHELL) $(srctree)/$(src)/generate_size_overflow_hash.sh -d $< -o $@
92332 +$(objtree)/$(obj)/size_overflow_hash.h: $(src)/size_overflow_hash.data FORCE
92333 + $(call if_changed,build_size_overflow_hash)
92334 +
92335 +targets += size_overflow_hash.h
92336 diff --git a/tools/gcc/checker_plugin.c b/tools/gcc/checker_plugin.c
92337 new file mode 100644
92338 index 0000000..d41b5af
92339 --- /dev/null
92340 +++ b/tools/gcc/checker_plugin.c
92341 @@ -0,0 +1,171 @@
92342 +/*
92343 + * Copyright 2011 by the PaX Team <pageexec@freemail.hu>
92344 + * Licensed under the GPL v2
92345 + *
92346 + * Note: the choice of the license means that the compilation process is
92347 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
92348 + * but for the kernel it doesn't matter since it doesn't link against
92349 + * any of the gcc libraries
92350 + *
92351 + * gcc plugin to implement various sparse (source code checker) features
92352 + *
92353 + * TODO:
92354 + * - define separate __iomem, __percpu and __rcu address spaces (lots of code to patch)
92355 + *
92356 + * BUGS:
92357 + * - none known
92358 + */
92359 +#include "gcc-plugin.h"
92360 +#include "config.h"
92361 +#include "system.h"
92362 +#include "coretypes.h"
92363 +#include "tree.h"
92364 +#include "tree-pass.h"
92365 +#include "flags.h"
92366 +#include "intl.h"
92367 +#include "toplev.h"
92368 +#include "plugin.h"
92369 +//#include "expr.h" where are you...
92370 +#include "diagnostic.h"
92371 +#include "plugin-version.h"
92372 +#include "tm.h"
92373 +#include "function.h"
92374 +#include "basic-block.h"
92375 +#include "gimple.h"
92376 +#include "rtl.h"
92377 +#include "emit-rtl.h"
92378 +#include "tree-flow.h"
92379 +#include "target.h"
92380 +
92381 +extern void c_register_addr_space (const char *str, addr_space_t as);
92382 +extern enum machine_mode default_addr_space_pointer_mode (addr_space_t);
92383 +extern enum machine_mode default_addr_space_address_mode (addr_space_t);
92384 +extern bool default_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as);
92385 +extern bool default_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as);
92386 +extern rtx default_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as);
92387 +
92388 +extern void print_gimple_stmt(FILE *, gimple, int, int);
92389 +extern rtx emit_move_insn(rtx x, rtx y);
92390 +
92391 +int plugin_is_GPL_compatible;
92392 +
92393 +static struct plugin_info checker_plugin_info = {
92394 + .version = "201111150100",
92395 +};
92396 +
92397 +#define ADDR_SPACE_KERNEL 0
92398 +#define ADDR_SPACE_FORCE_KERNEL 1
92399 +#define ADDR_SPACE_USER 2
92400 +#define ADDR_SPACE_FORCE_USER 3
92401 +#define ADDR_SPACE_IOMEM 0
92402 +#define ADDR_SPACE_FORCE_IOMEM 0
92403 +#define ADDR_SPACE_PERCPU 0
92404 +#define ADDR_SPACE_FORCE_PERCPU 0
92405 +#define ADDR_SPACE_RCU 0
92406 +#define ADDR_SPACE_FORCE_RCU 0
92407 +
92408 +static enum machine_mode checker_addr_space_pointer_mode(addr_space_t addrspace)
92409 +{
92410 + return default_addr_space_pointer_mode(ADDR_SPACE_GENERIC);
92411 +}
92412 +
92413 +static enum machine_mode checker_addr_space_address_mode(addr_space_t addrspace)
92414 +{
92415 + return default_addr_space_address_mode(ADDR_SPACE_GENERIC);
92416 +}
92417 +
92418 +static bool checker_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as)
92419 +{
92420 + return default_addr_space_valid_pointer_mode(mode, as);
92421 +}
92422 +
92423 +static bool checker_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as)
92424 +{
92425 + return default_addr_space_legitimate_address_p(mode, mem, strict, ADDR_SPACE_GENERIC);
92426 +}
92427 +
92428 +static rtx checker_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as)
92429 +{
92430 + return default_addr_space_legitimize_address(x, oldx, mode, as);
92431 +}
92432 +
92433 +static bool checker_addr_space_subset_p(addr_space_t subset, addr_space_t superset)
92434 +{
92435 + if (subset == ADDR_SPACE_FORCE_KERNEL && superset == ADDR_SPACE_KERNEL)
92436 + return true;
92437 +
92438 + if (subset == ADDR_SPACE_FORCE_USER && superset == ADDR_SPACE_USER)
92439 + return true;
92440 +
92441 + if (subset == ADDR_SPACE_FORCE_IOMEM && superset == ADDR_SPACE_IOMEM)
92442 + return true;
92443 +
92444 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_USER)
92445 + return true;
92446 +
92447 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_IOMEM)
92448 + return true;
92449 +
92450 + if (subset == ADDR_SPACE_USER && superset == ADDR_SPACE_FORCE_KERNEL)
92451 + return true;
92452 +
92453 + if (subset == ADDR_SPACE_IOMEM && superset == ADDR_SPACE_FORCE_KERNEL)
92454 + return true;
92455 +
92456 + return subset == superset;
92457 +}
92458 +
92459 +static rtx checker_addr_space_convert(rtx op, tree from_type, tree to_type)
92460 +{
92461 +// addr_space_t from_as = TYPE_ADDR_SPACE(TREE_TYPE(from_type));
92462 +// addr_space_t to_as = TYPE_ADDR_SPACE(TREE_TYPE(to_type));
92463 +
92464 + return op;
92465 +}
92466 +
92467 +static void register_checker_address_spaces(void *event_data, void *data)
92468 +{
92469 + c_register_addr_space("__kernel", ADDR_SPACE_KERNEL);
92470 + c_register_addr_space("__force_kernel", ADDR_SPACE_FORCE_KERNEL);
92471 + c_register_addr_space("__user", ADDR_SPACE_USER);
92472 + c_register_addr_space("__force_user", ADDR_SPACE_FORCE_USER);
92473 +// c_register_addr_space("__iomem", ADDR_SPACE_IOMEM);
92474 +// c_register_addr_space("__force_iomem", ADDR_SPACE_FORCE_IOMEM);
92475 +// c_register_addr_space("__percpu", ADDR_SPACE_PERCPU);
92476 +// c_register_addr_space("__force_percpu", ADDR_SPACE_FORCE_PERCPU);
92477 +// c_register_addr_space("__rcu", ADDR_SPACE_RCU);
92478 +// c_register_addr_space("__force_rcu", ADDR_SPACE_FORCE_RCU);
92479 +
92480 + targetm.addr_space.pointer_mode = checker_addr_space_pointer_mode;
92481 + targetm.addr_space.address_mode = checker_addr_space_address_mode;
92482 + targetm.addr_space.valid_pointer_mode = checker_addr_space_valid_pointer_mode;
92483 + targetm.addr_space.legitimate_address_p = checker_addr_space_legitimate_address_p;
92484 +// targetm.addr_space.legitimize_address = checker_addr_space_legitimize_address;
92485 + targetm.addr_space.subset_p = checker_addr_space_subset_p;
92486 + targetm.addr_space.convert = checker_addr_space_convert;
92487 +}
92488 +
92489 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
92490 +{
92491 + const char * const plugin_name = plugin_info->base_name;
92492 + const int argc = plugin_info->argc;
92493 + const struct plugin_argument * const argv = plugin_info->argv;
92494 + int i;
92495 +
92496 + if (!plugin_default_version_check(version, &gcc_version)) {
92497 + error(G_("incompatible gcc/plugin versions"));
92498 + return 1;
92499 + }
92500 +
92501 + register_callback(plugin_name, PLUGIN_INFO, NULL, &checker_plugin_info);
92502 +
92503 + for (i = 0; i < argc; ++i)
92504 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
92505 +
92506 + if (TARGET_64BIT == 0)
92507 + return 0;
92508 +
92509 + register_callback(plugin_name, PLUGIN_PRAGMAS, register_checker_address_spaces, NULL);
92510 +
92511 + return 0;
92512 +}
92513 diff --git a/tools/gcc/colorize_plugin.c b/tools/gcc/colorize_plugin.c
92514 new file mode 100644
92515 index 0000000..414fe5e
92516 --- /dev/null
92517 +++ b/tools/gcc/colorize_plugin.c
92518 @@ -0,0 +1,151 @@
92519 +/*
92520 + * Copyright 2012-2013 by PaX Team <pageexec@freemail.hu>
92521 + * Licensed under the GPL v2
92522 + *
92523 + * Note: the choice of the license means that the compilation process is
92524 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
92525 + * but for the kernel it doesn't matter since it doesn't link against
92526 + * any of the gcc libraries
92527 + *
92528 + * gcc plugin to colorize diagnostic output
92529 + *
92530 + */
92531 +
92532 +#include "gcc-plugin.h"
92533 +#include "config.h"
92534 +#include "system.h"
92535 +#include "coretypes.h"
92536 +#include "tree.h"
92537 +#include "tree-pass.h"
92538 +#include "flags.h"
92539 +#include "intl.h"
92540 +#include "toplev.h"
92541 +#include "plugin.h"
92542 +#include "diagnostic.h"
92543 +#include "plugin-version.h"
92544 +#include "tm.h"
92545 +
92546 +int plugin_is_GPL_compatible;
92547 +
92548 +static struct plugin_info colorize_plugin_info = {
92549 + .version = "201302112000",
92550 + .help = NULL,
92551 +};
92552 +
92553 +#define GREEN "\033[32m\033[2m"
92554 +#define LIGHTGREEN "\033[32m\033[1m"
92555 +#define YELLOW "\033[33m\033[2m"
92556 +#define LIGHTYELLOW "\033[33m\033[1m"
92557 +#define RED "\033[31m\033[2m"
92558 +#define LIGHTRED "\033[31m\033[1m"
92559 +#define BLUE "\033[34m\033[2m"
92560 +#define LIGHTBLUE "\033[34m\033[1m"
92561 +#define BRIGHT "\033[m\033[1m"
92562 +#define NORMAL "\033[m"
92563 +
92564 +static diagnostic_starter_fn old_starter;
92565 +static diagnostic_finalizer_fn old_finalizer;
92566 +
92567 +static void start_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
92568 +{
92569 + const char *color;
92570 + char *newprefix;
92571 +
92572 + switch (diagnostic->kind) {
92573 + case DK_NOTE:
92574 + color = LIGHTBLUE;
92575 + break;
92576 +
92577 + case DK_PEDWARN:
92578 + case DK_WARNING:
92579 + color = LIGHTYELLOW;
92580 + break;
92581 +
92582 + case DK_ERROR:
92583 + case DK_FATAL:
92584 + case DK_ICE:
92585 + case DK_PERMERROR:
92586 + case DK_SORRY:
92587 + color = LIGHTRED;
92588 + break;
92589 +
92590 + default:
92591 + color = NORMAL;
92592 + }
92593 +
92594 + old_starter(context, diagnostic);
92595 + if (-1 == asprintf(&newprefix, "%s%s" NORMAL, color, context->printer->prefix))
92596 + return;
92597 + pp_destroy_prefix(context->printer);
92598 + pp_set_prefix(context->printer, newprefix);
92599 +}
92600 +
92601 +static void finalize_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
92602 +{
92603 + old_finalizer(context, diagnostic);
92604 +}
92605 +
92606 +static void colorize_arm(void)
92607 +{
92608 + old_starter = diagnostic_starter(global_dc);
92609 + old_finalizer = diagnostic_finalizer(global_dc);
92610 +
92611 + diagnostic_starter(global_dc) = start_colorize;
92612 + diagnostic_finalizer(global_dc) = finalize_colorize;
92613 +}
92614 +
92615 +static unsigned int execute_colorize_rearm(void)
92616 +{
92617 + if (diagnostic_starter(global_dc) == start_colorize)
92618 + return 0;
92619 +
92620 + colorize_arm();
92621 + return 0;
92622 +}
92623 +
92624 +struct simple_ipa_opt_pass pass_ipa_colorize_rearm = {
92625 + .pass = {
92626 + .type = SIMPLE_IPA_PASS,
92627 + .name = "colorize_rearm",
92628 +#if BUILDING_GCC_VERSION >= 4008
92629 + .optinfo_flags = OPTGROUP_NONE,
92630 +#endif
92631 + .gate = NULL,
92632 + .execute = execute_colorize_rearm,
92633 + .sub = NULL,
92634 + .next = NULL,
92635 + .static_pass_number = 0,
92636 + .tv_id = TV_NONE,
92637 + .properties_required = 0,
92638 + .properties_provided = 0,
92639 + .properties_destroyed = 0,
92640 + .todo_flags_start = 0,
92641 + .todo_flags_finish = 0
92642 + }
92643 +};
92644 +
92645 +static void colorize_start_unit(void *gcc_data, void *user_data)
92646 +{
92647 + colorize_arm();
92648 +}
92649 +
92650 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
92651 +{
92652 + const char * const plugin_name = plugin_info->base_name;
92653 + struct register_pass_info colorize_rearm_pass_info = {
92654 + .pass = &pass_ipa_colorize_rearm.pass,
92655 + .reference_pass_name = "*free_lang_data",
92656 + .ref_pass_instance_number = 1,
92657 + .pos_op = PASS_POS_INSERT_AFTER
92658 + };
92659 +
92660 + if (!plugin_default_version_check(version, &gcc_version)) {
92661 + error(G_("incompatible gcc/plugin versions"));
92662 + return 1;
92663 + }
92664 +
92665 + register_callback(plugin_name, PLUGIN_INFO, NULL, &colorize_plugin_info);
92666 + register_callback(plugin_name, PLUGIN_START_UNIT, &colorize_start_unit, NULL);
92667 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &colorize_rearm_pass_info);
92668 + return 0;
92669 +}
92670 diff --git a/tools/gcc/constify_plugin.c b/tools/gcc/constify_plugin.c
92671 new file mode 100644
92672 index 0000000..c17312d
92673 --- /dev/null
92674 +++ b/tools/gcc/constify_plugin.c
92675 @@ -0,0 +1,560 @@
92676 +/*
92677 + * Copyright 2011 by Emese Revfy <re.emese@gmail.com>
92678 + * Copyright 2011-2013 by PaX Team <pageexec@freemail.hu>
92679 + * Licensed under the GPL v2, or (at your option) v3
92680 + *
92681 + * This gcc plugin constifies all structures which contain only function pointers or are explicitly marked for constification.
92682 + *
92683 + * Homepage:
92684 + * http://www.grsecurity.net/~ephox/const_plugin/
92685 + *
92686 + * Usage:
92687 + * $ gcc -I`gcc -print-file-name=plugin`/include -fPIC -shared -O2 -o constify_plugin.so constify_plugin.c
92688 + * $ gcc -fplugin=constify_plugin.so test.c -O2
92689 + */
92690 +
92691 +#include "gcc-plugin.h"
92692 +#include "config.h"
92693 +#include "system.h"
92694 +#include "coretypes.h"
92695 +#include "tree.h"
92696 +#include "tree-pass.h"
92697 +#include "flags.h"
92698 +#include "intl.h"
92699 +#include "toplev.h"
92700 +#include "plugin.h"
92701 +#include "diagnostic.h"
92702 +#include "plugin-version.h"
92703 +#include "tm.h"
92704 +#include "function.h"
92705 +#include "basic-block.h"
92706 +#include "gimple.h"
92707 +#include "rtl.h"
92708 +#include "emit-rtl.h"
92709 +#include "tree-flow.h"
92710 +#include "target.h"
92711 +#include "langhooks.h"
92712 +
92713 +// should come from c-tree.h if only it were installed for gcc 4.5...
92714 +#define C_TYPE_FIELDS_READONLY(TYPE) TREE_LANG_FLAG_1(TYPE)
92715 +
92716 +// unused type flag in all versions 4.5-4.8
92717 +#define TYPE_CONSTIFY_VISITED(TYPE) TYPE_LANG_FLAG_4(TYPE)
92718 +
92719 +int plugin_is_GPL_compatible;
92720 +
92721 +static struct plugin_info const_plugin_info = {
92722 + .version = "201305231310",
92723 + .help = "no-constify\tturn off constification\n",
92724 +};
92725 +
92726 +typedef struct {
92727 + bool has_fptr_field;
92728 + bool has_writable_field;
92729 + bool has_do_const_field;
92730 + bool has_no_const_field;
92731 +} constify_info;
92732 +
92733 +static const_tree get_field_type(const_tree field)
92734 +{
92735 + return strip_array_types(TREE_TYPE(field));
92736 +}
92737 +
92738 +static bool is_fptr(const_tree field)
92739 +{
92740 + const_tree ptr = get_field_type(field);
92741 +
92742 + if (TREE_CODE(ptr) != POINTER_TYPE)
92743 + return false;
92744 +
92745 + return TREE_CODE(TREE_TYPE(ptr)) == FUNCTION_TYPE;
92746 +}
92747 +
92748 +/*
92749 + * determine whether the given structure type meets the requirements for automatic constification,
92750 + * including the constification attributes on nested structure types
92751 + */
92752 +static void constifiable(const_tree node, constify_info *cinfo)
92753 +{
92754 + const_tree field;
92755 +
92756 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
92757 +
92758 + // e.g., pointer to structure fields while still constructing the structure type
92759 + if (TYPE_FIELDS(node) == NULL_TREE)
92760 + return;
92761 +
92762 + for (field = TYPE_FIELDS(node); field; field = TREE_CHAIN(field)) {
92763 + const_tree type = get_field_type(field);
92764 + enum tree_code code = TREE_CODE(type);
92765 +
92766 + if (node == type)
92767 + continue;
92768 +
92769 + if (is_fptr(field))
92770 + cinfo->has_fptr_field = true;
92771 + else if (!TREE_READONLY(field))
92772 + cinfo->has_writable_field = true;
92773 +
92774 + if (code == RECORD_TYPE || code == UNION_TYPE) {
92775 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
92776 + cinfo->has_do_const_field = true;
92777 + else if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type)))
92778 + cinfo->has_no_const_field = true;
92779 + else
92780 + constifiable(type, cinfo);
92781 + }
92782 + }
92783 +}
92784 +
92785 +static bool constified(const_tree node)
92786 +{
92787 + constify_info cinfo = {
92788 + .has_fptr_field = false,
92789 + .has_writable_field = false,
92790 + .has_do_const_field = false,
92791 + .has_no_const_field = false
92792 + };
92793 +
92794 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
92795 +
92796 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(node))) {
92797 + gcc_assert(!TYPE_READONLY(node));
92798 + return false;
92799 + }
92800 +
92801 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(node))) {
92802 + gcc_assert(TYPE_READONLY(node));
92803 + return true;
92804 + }
92805 +
92806 + constifiable(node, &cinfo);
92807 + if ((!cinfo.has_fptr_field || cinfo.has_writable_field) && !cinfo.has_do_const_field)
92808 + return false;
92809 +
92810 + return TYPE_READONLY(node);
92811 +}
92812 +
92813 +static void deconstify_tree(tree node);
92814 +
92815 +static void deconstify_type(tree type)
92816 +{
92817 + tree field;
92818 +
92819 + gcc_assert(TREE_CODE(type) == RECORD_TYPE || TREE_CODE(type) == UNION_TYPE);
92820 +
92821 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
92822 + const_tree fieldtype = get_field_type(field);
92823 +
92824 + // special case handling of simple ptr-to-same-array-type members
92825 + if (TREE_CODE(TREE_TYPE(field)) == POINTER_TYPE) {
92826 + const_tree ptrtype = TREE_TYPE(TREE_TYPE(field));
92827 +
92828 + if (TREE_CODE(ptrtype) != RECORD_TYPE && TREE_CODE(ptrtype) != UNION_TYPE)
92829 + continue;
92830 + if (TREE_TYPE(TREE_TYPE(field)) == type)
92831 + continue;
92832 + if (TYPE_MAIN_VARIANT(ptrtype) == TYPE_MAIN_VARIANT(type)) {
92833 + TREE_TYPE(field) = copy_node(TREE_TYPE(field));
92834 + TREE_TYPE(TREE_TYPE(field)) = type;
92835 + }
92836 + continue;
92837 + }
92838 + if (TREE_CODE(fieldtype) != RECORD_TYPE && TREE_CODE(fieldtype) != UNION_TYPE)
92839 + continue;
92840 + if (!constified(fieldtype))
92841 + continue;
92842 +
92843 + deconstify_tree(field);
92844 + TREE_READONLY(field) = 0;
92845 + }
92846 + TYPE_READONLY(type) = 0;
92847 + C_TYPE_FIELDS_READONLY(type) = 0;
92848 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
92849 + TYPE_ATTRIBUTES(type) = remove_attribute("do_const", TYPE_ATTRIBUTES(type));
92850 +}
92851 +
92852 +static void deconstify_tree(tree node)
92853 +{
92854 + tree old_type, new_type, field;
92855 +
92856 + old_type = TREE_TYPE(node);
92857 + while (TREE_CODE(old_type) == ARRAY_TYPE && TREE_CODE(TREE_TYPE(old_type)) != ARRAY_TYPE) {
92858 + node = TREE_TYPE(node) = copy_node(old_type);
92859 + old_type = TREE_TYPE(old_type);
92860 + }
92861 +
92862 + gcc_assert(TREE_CODE(old_type) == RECORD_TYPE || TREE_CODE(old_type) == UNION_TYPE);
92863 + gcc_assert(TYPE_READONLY(old_type) && (TYPE_QUALS(old_type) & TYPE_QUAL_CONST));
92864 +
92865 + new_type = build_qualified_type(old_type, TYPE_QUALS(old_type) & ~TYPE_QUAL_CONST);
92866 + TYPE_FIELDS(new_type) = copy_list(TYPE_FIELDS(new_type));
92867 + for (field = TYPE_FIELDS(new_type); field; field = TREE_CHAIN(field))
92868 + DECL_FIELD_CONTEXT(field) = new_type;
92869 +
92870 + deconstify_type(new_type);
92871 +
92872 + TREE_TYPE(node) = new_type;
92873 +}
92874 +
92875 +static tree handle_no_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
92876 +{
92877 + tree type;
92878 + constify_info cinfo = {
92879 + .has_fptr_field = false,
92880 + .has_writable_field = false,
92881 + .has_do_const_field = false,
92882 + .has_no_const_field = false
92883 + };
92884 +
92885 + *no_add_attrs = true;
92886 + if (TREE_CODE(*node) == FUNCTION_DECL) {
92887 + error("%qE attribute does not apply to functions", name);
92888 + return NULL_TREE;
92889 + }
92890 +
92891 + if (TREE_CODE(*node) == PARM_DECL) {
92892 + error("%qE attribute does not apply to function parameters", name);
92893 + return NULL_TREE;
92894 + }
92895 +
92896 + if (TREE_CODE(*node) == VAR_DECL) {
92897 + error("%qE attribute does not apply to variables", name);
92898 + return NULL_TREE;
92899 + }
92900 +
92901 + if (TYPE_P(*node)) {
92902 + *no_add_attrs = false;
92903 + type = *node;
92904 + } else {
92905 + gcc_assert(TREE_CODE(*node) == TYPE_DECL);
92906 + type = TREE_TYPE(*node);
92907 + }
92908 +
92909 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE) {
92910 + error("%qE attribute applies to struct and union types only", name);
92911 + return NULL_TREE;
92912 + }
92913 +
92914 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(type))) {
92915 + error("%qE attribute is already applied to the type", name);
92916 + return NULL_TREE;
92917 + }
92918 +
92919 + if (TYPE_P(*node)) {
92920 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
92921 + error("%qE attribute is incompatible with 'do_const'", name);
92922 + return NULL_TREE;
92923 + }
92924 +
92925 + constifiable(type, &cinfo);
92926 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
92927 + deconstify_tree(*node);
92928 + TYPE_CONSTIFY_VISITED(TREE_TYPE(*node)) = 1;
92929 + return NULL_TREE;
92930 + }
92931 +
92932 + error("%qE attribute used on type that is not constified", name);
92933 + return NULL_TREE;
92934 +}
92935 +
92936 +static void constify_type(tree type)
92937 +{
92938 + TYPE_READONLY(type) = 1;
92939 + C_TYPE_FIELDS_READONLY(type) = 1;
92940 + TYPE_CONSTIFY_VISITED(type) = 1;
92941 +// TYPE_ATTRIBUTES(type) = tree_cons(get_identifier("do_const"), NULL_TREE, TYPE_ATTRIBUTES(type));
92942 +}
92943 +
92944 +static tree handle_do_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
92945 +{
92946 + *no_add_attrs = true;
92947 + if (!TYPE_P(*node)) {
92948 + error("%qE attribute applies to types only", name);
92949 + return NULL_TREE;
92950 + }
92951 +
92952 + if (TREE_CODE(*node) != RECORD_TYPE && TREE_CODE(*node) != UNION_TYPE) {
92953 + error("%qE attribute applies to struct and union types only", name);
92954 + return NULL_TREE;
92955 + }
92956 +
92957 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(*node))) {
92958 + error("%qE attribute is already applied to the type", name);
92959 + return NULL_TREE;
92960 + }
92961 +
92962 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(*node))) {
92963 + error("%qE attribute is incompatible with 'no_const'", name);
92964 + return NULL_TREE;
92965 + }
92966 +
92967 + *no_add_attrs = false;
92968 + return NULL_TREE;
92969 +}
92970 +
92971 +static struct attribute_spec no_const_attr = {
92972 + .name = "no_const",
92973 + .min_length = 0,
92974 + .max_length = 0,
92975 + .decl_required = false,
92976 + .type_required = false,
92977 + .function_type_required = false,
92978 + .handler = handle_no_const_attribute,
92979 +#if BUILDING_GCC_VERSION >= 4007
92980 + .affects_type_identity = true
92981 +#endif
92982 +};
92983 +
92984 +static struct attribute_spec do_const_attr = {
92985 + .name = "do_const",
92986 + .min_length = 0,
92987 + .max_length = 0,
92988 + .decl_required = false,
92989 + .type_required = false,
92990 + .function_type_required = false,
92991 + .handler = handle_do_const_attribute,
92992 +#if BUILDING_GCC_VERSION >= 4007
92993 + .affects_type_identity = true
92994 +#endif
92995 +};
92996 +
92997 +static void register_attributes(void *event_data, void *data)
92998 +{
92999 + register_attribute(&no_const_attr);
93000 + register_attribute(&do_const_attr);
93001 +}
93002 +
93003 +static void finish_type(void *event_data, void *data)
93004 +{
93005 + tree type = (tree)event_data;
93006 + constify_info cinfo = {
93007 + .has_fptr_field = false,
93008 + .has_writable_field = false,
93009 + .has_do_const_field = false,
93010 + .has_no_const_field = false
93011 + };
93012 +
93013 + if (type == NULL_TREE || type == error_mark_node)
93014 + return;
93015 +
93016 + if (TYPE_FIELDS(type) == NULL_TREE || TYPE_CONSTIFY_VISITED(type))
93017 + return;
93018 +
93019 + constifiable(type, &cinfo);
93020 +
93021 + if (TYPE_READONLY(type) && C_TYPE_FIELDS_READONLY(type)) {
93022 + if (!lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
93023 + return;
93024 + if (cinfo.has_writable_field)
93025 + return;
93026 + error("'do_const' attribute used on type that is%sconstified", cinfo.has_fptr_field ? " " : " not ");
93027 + return;
93028 + }
93029 +
93030 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type))) {
93031 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || cinfo.has_do_const_field) {
93032 + deconstify_type(type);
93033 + TYPE_CONSTIFY_VISITED(type) = 1;
93034 + } else
93035 + error("'no_const' attribute used on type that is not constified");
93036 + return;
93037 + }
93038 +
93039 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
93040 + constify_type(type);
93041 + return;
93042 + }
93043 +
93044 + if (cinfo.has_fptr_field && !cinfo.has_writable_field) {
93045 + constify_type(type);
93046 + return;
93047 + }
93048 +
93049 + deconstify_type(type);
93050 + TYPE_CONSTIFY_VISITED(type) = 1;
93051 +}
93052 +
93053 +static void check_global_variables(void)
93054 +{
93055 + struct varpool_node *node;
93056 +
93057 +#if BUILDING_GCC_VERSION <= 4007
93058 + for (node = varpool_nodes; node; node = node->next) {
93059 + tree var = node->decl;
93060 +#else
93061 + FOR_EACH_VARIABLE(node) {
93062 + tree var = node->symbol.decl;
93063 +#endif
93064 + tree type = TREE_TYPE(var);
93065 +
93066 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
93067 + continue;
93068 +
93069 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
93070 + continue;
93071 +
93072 + if (!TYPE_CONSTIFY_VISITED(type))
93073 + continue;
93074 +
93075 + if (DECL_EXTERNAL(var))
93076 + continue;
93077 +
93078 + if (DECL_INITIAL(var))
93079 + continue;
93080 +
93081 + // this works around a gcc bug/feature where uninitialized globals
93082 + // are moved into the .bss section regardless of any constification
93083 + DECL_INITIAL(var) = build_constructor(type, NULL);
93084 +// inform(DECL_SOURCE_LOCATION(var), "constified variable %qE moved into .rodata", var);
93085 + }
93086 +}
93087 +
93088 +static unsigned int check_local_variables(void)
93089 +{
93090 + unsigned int ret = 0;
93091 + tree var;
93092 +
93093 +#if BUILDING_GCC_VERSION == 4005
93094 + tree vars;
93095 +#else
93096 + unsigned int i;
93097 +#endif
93098 +
93099 +#if BUILDING_GCC_VERSION == 4005
93100 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
93101 + var = TREE_VALUE(vars);
93102 +#else
93103 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
93104 +#endif
93105 + tree type = TREE_TYPE(var);
93106 +
93107 + gcc_assert(DECL_P(var));
93108 + if (is_global_var(var))
93109 + continue;
93110 +
93111 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
93112 + continue;
93113 +
93114 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
93115 + continue;
93116 +
93117 + if (!TYPE_CONSTIFY_VISITED(type))
93118 + continue;
93119 +
93120 + error_at(DECL_SOURCE_LOCATION(var), "constified variable %qE cannot be local", var);
93121 + ret = 1;
93122 + }
93123 + return ret;
93124 +}
93125 +
93126 +static unsigned int check_variables(void)
93127 +{
93128 + check_global_variables();
93129 + return check_local_variables();
93130 +}
93131 +
93132 + unsigned int ret = 0;
93133 +static struct gimple_opt_pass pass_local_variable = {
93134 + {
93135 + .type = GIMPLE_PASS,
93136 + .name = "check_variables",
93137 +#if BUILDING_GCC_VERSION >= 4008
93138 + .optinfo_flags = OPTGROUP_NONE,
93139 +#endif
93140 + .gate = NULL,
93141 + .execute = check_variables,
93142 + .sub = NULL,
93143 + .next = NULL,
93144 + .static_pass_number = 0,
93145 + .tv_id = TV_NONE,
93146 + .properties_required = 0,
93147 + .properties_provided = 0,
93148 + .properties_destroyed = 0,
93149 + .todo_flags_start = 0,
93150 + .todo_flags_finish = 0
93151 + }
93152 +};
93153 +
93154 +static struct {
93155 + const char *name;
93156 + const char *asm_op;
93157 +} sections[] = {
93158 + {".init.rodata", "\t.section\t.init.rodata,\"a\""},
93159 + {".ref.rodata", "\t.section\t.ref.rodata,\"a\""},
93160 + {".devinit.rodata", "\t.section\t.devinit.rodata,\"a\""},
93161 + {".devexit.rodata", "\t.section\t.devexit.rodata,\"a\""},
93162 + {".cpuinit.rodata", "\t.section\t.cpuinit.rodata,\"a\""},
93163 + {".cpuexit.rodata", "\t.section\t.cpuexit.rodata,\"a\""},
93164 + {".meminit.rodata", "\t.section\t.meminit.rodata,\"a\""},
93165 + {".memexit.rodata", "\t.section\t.memexit.rodata,\"a\""},
93166 + {".data..read_only", "\t.section\t.data..read_only,\"a\""},
93167 +};
93168 +
93169 +static unsigned int (*old_section_type_flags)(tree decl, const char *name, int reloc);
93170 +
93171 +static unsigned int constify_section_type_flags(tree decl, const char *name, int reloc)
93172 +{
93173 + size_t i;
93174 +
93175 + for (i = 0; i < ARRAY_SIZE(sections); i++)
93176 + if (!strcmp(sections[i].name, name))
93177 + return 0;
93178 + return old_section_type_flags(decl, name, reloc);
93179 +}
93180 +
93181 +static void constify_start_unit(void *gcc_data, void *user_data)
93182 +{
93183 +// size_t i;
93184 +
93185 +// for (i = 0; i < ARRAY_SIZE(sections); i++)
93186 +// sections[i].section = get_unnamed_section(0, output_section_asm_op, sections[i].asm_op);
93187 +// sections[i].section = get_section(sections[i].name, 0, NULL);
93188 +
93189 + old_section_type_flags = targetm.section_type_flags;
93190 + targetm.section_type_flags = constify_section_type_flags;
93191 +}
93192 +
93193 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
93194 +{
93195 + const char * const plugin_name = plugin_info->base_name;
93196 + const int argc = plugin_info->argc;
93197 + const struct plugin_argument * const argv = plugin_info->argv;
93198 + int i;
93199 + bool constify = true;
93200 +
93201 + struct register_pass_info local_variable_pass_info = {
93202 + .pass = &pass_local_variable.pass,
93203 + .reference_pass_name = "ssa",
93204 + .ref_pass_instance_number = 1,
93205 + .pos_op = PASS_POS_INSERT_BEFORE
93206 + };
93207 +
93208 + if (!plugin_default_version_check(version, &gcc_version)) {
93209 + error(G_("incompatible gcc/plugin versions"));
93210 + return 1;
93211 + }
93212 +
93213 + for (i = 0; i < argc; ++i) {
93214 + if (!(strcmp(argv[i].key, "no-constify"))) {
93215 + constify = false;
93216 + continue;
93217 + }
93218 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
93219 + }
93220 +
93221 + if (strcmp(lang_hooks.name, "GNU C")) {
93222 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
93223 + constify = false;
93224 + }
93225 +
93226 + register_callback(plugin_name, PLUGIN_INFO, NULL, &const_plugin_info);
93227 + if (constify) {
93228 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
93229 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &local_variable_pass_info);
93230 + register_callback(plugin_name, PLUGIN_START_UNIT, constify_start_unit, NULL);
93231 + }
93232 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
93233 +
93234 + return 0;
93235 +}
93236 diff --git a/tools/gcc/generate_size_overflow_hash.sh b/tools/gcc/generate_size_overflow_hash.sh
93237 new file mode 100644
93238 index 0000000..e518932
93239 --- /dev/null
93240 +++ b/tools/gcc/generate_size_overflow_hash.sh
93241 @@ -0,0 +1,94 @@
93242 +#!/bin/bash
93243 +
93244 +# This script generates the hash table (size_overflow_hash.h) for the size_overflow gcc plugin (size_overflow_plugin.c).
93245 +
93246 +header1="size_overflow_hash.h"
93247 +database="size_overflow_hash.data"
93248 +n=65536
93249 +
93250 +usage() {
93251 +cat <<EOF
93252 +usage: $0 options
93253 +OPTIONS:
93254 + -h|--help help
93255 + -o header file
93256 + -d database file
93257 + -n hash array size
93258 +EOF
93259 + return 0
93260 +}
93261 +
93262 +while true
93263 +do
93264 + case "$1" in
93265 + -h|--help) usage && exit 0;;
93266 + -n) n=$2; shift 2;;
93267 + -o) header1="$2"; shift 2;;
93268 + -d) database="$2"; shift 2;;
93269 + --) shift 1; break ;;
93270 + *) break ;;
93271 + esac
93272 +done
93273 +
93274 +create_defines() {
93275 + for i in `seq 0 31`
93276 + do
93277 + echo -e "#define PARAM"$i" (1U << "$i")" >> "$header1"
93278 + done
93279 + echo >> "$header1"
93280 +}
93281 +
93282 +create_structs() {
93283 + rm -f "$header1"
93284 +
93285 + create_defines
93286 +
93287 + cat "$database" | while read data
93288 + do
93289 + data_array=($data)
93290 + struct_hash_name="${data_array[0]}"
93291 + funcn="${data_array[1]}"
93292 + params="${data_array[2]}"
93293 + next="${data_array[4]}"
93294 +
93295 + echo "const struct size_overflow_hash $struct_hash_name = {" >> "$header1"
93296 +
93297 + echo -e "\t.next\t= $next,\n\t.name\t= \"$funcn\"," >> "$header1"
93298 + echo -en "\t.param\t= " >> "$header1"
93299 + line=
93300 + for param_num in ${params//-/ };
93301 + do
93302 + line="${line}PARAM"$param_num"|"
93303 + done
93304 +
93305 + echo -e "${line%?},\n};\n" >> "$header1"
93306 + done
93307 +}
93308 +
93309 +create_headers() {
93310 + echo "const struct size_overflow_hash * const size_overflow_hash[$n] = {" >> "$header1"
93311 +}
93312 +
93313 +create_array_elements() {
93314 + index=0
93315 + grep -v "nohasharray" $database | sort -n -k 4 | while read data
93316 + do
93317 + data_array=($data)
93318 + i="${data_array[3]}"
93319 + hash="${data_array[0]}"
93320 + while [[ $index -lt $i ]]
93321 + do
93322 + echo -e "\t["$index"]\t= NULL," >> "$header1"
93323 + index=$(($index + 1))
93324 + done
93325 + index=$(($index + 1))
93326 + echo -e "\t["$i"]\t= &"$hash"," >> "$header1"
93327 + done
93328 + echo '};' >> $header1
93329 +}
93330 +
93331 +create_structs
93332 +create_headers
93333 +create_array_elements
93334 +
93335 +exit 0
93336 diff --git a/tools/gcc/kallocstat_plugin.c b/tools/gcc/kallocstat_plugin.c
93337 new file mode 100644
93338 index 0000000..568b360
93339 --- /dev/null
93340 +++ b/tools/gcc/kallocstat_plugin.c
93341 @@ -0,0 +1,170 @@
93342 +/*
93343 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
93344 + * Licensed under the GPL v2
93345 + *
93346 + * Note: the choice of the license means that the compilation process is
93347 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
93348 + * but for the kernel it doesn't matter since it doesn't link against
93349 + * any of the gcc libraries
93350 + *
93351 + * gcc plugin to find the distribution of k*alloc sizes
93352 + *
93353 + * TODO:
93354 + *
93355 + * BUGS:
93356 + * - none known
93357 + */
93358 +#include "gcc-plugin.h"
93359 +#include "config.h"
93360 +#include "system.h"
93361 +#include "coretypes.h"
93362 +#include "tree.h"
93363 +#include "tree-pass.h"
93364 +#include "flags.h"
93365 +#include "intl.h"
93366 +#include "toplev.h"
93367 +#include "plugin.h"
93368 +//#include "expr.h" where are you...
93369 +#include "diagnostic.h"
93370 +#include "plugin-version.h"
93371 +#include "tm.h"
93372 +#include "function.h"
93373 +#include "basic-block.h"
93374 +#include "gimple.h"
93375 +#include "rtl.h"
93376 +#include "emit-rtl.h"
93377 +
93378 +extern void print_gimple_stmt(FILE *, gimple, int, int);
93379 +
93380 +int plugin_is_GPL_compatible;
93381 +
93382 +static const char * const kalloc_functions[] = {
93383 + "__kmalloc",
93384 + "kmalloc",
93385 + "kmalloc_large",
93386 + "kmalloc_node",
93387 + "kmalloc_order",
93388 + "kmalloc_order_trace",
93389 + "kmalloc_slab",
93390 + "kzalloc",
93391 + "kzalloc_node",
93392 +};
93393 +
93394 +static struct plugin_info kallocstat_plugin_info = {
93395 + .version = "201302112000",
93396 +};
93397 +
93398 +static unsigned int execute_kallocstat(void);
93399 +
93400 +static struct gimple_opt_pass kallocstat_pass = {
93401 + .pass = {
93402 + .type = GIMPLE_PASS,
93403 + .name = "kallocstat",
93404 +#if BUILDING_GCC_VERSION >= 4008
93405 + .optinfo_flags = OPTGROUP_NONE,
93406 +#endif
93407 + .gate = NULL,
93408 + .execute = execute_kallocstat,
93409 + .sub = NULL,
93410 + .next = NULL,
93411 + .static_pass_number = 0,
93412 + .tv_id = TV_NONE,
93413 + .properties_required = 0,
93414 + .properties_provided = 0,
93415 + .properties_destroyed = 0,
93416 + .todo_flags_start = 0,
93417 + .todo_flags_finish = 0
93418 + }
93419 +};
93420 +
93421 +static bool is_kalloc(const char *fnname)
93422 +{
93423 + size_t i;
93424 +
93425 + for (i = 0; i < ARRAY_SIZE(kalloc_functions); i++)
93426 + if (!strcmp(fnname, kalloc_functions[i]))
93427 + return true;
93428 + return false;
93429 +}
93430 +
93431 +static unsigned int execute_kallocstat(void)
93432 +{
93433 + basic_block bb;
93434 +
93435 + // 1. loop through BBs and GIMPLE statements
93436 + FOR_EACH_BB(bb) {
93437 + gimple_stmt_iterator gsi;
93438 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
93439 + // gimple match:
93440 + tree fndecl, size;
93441 + gimple call_stmt;
93442 + const char *fnname;
93443 +
93444 + // is it a call
93445 + call_stmt = gsi_stmt(gsi);
93446 + if (!is_gimple_call(call_stmt))
93447 + continue;
93448 + fndecl = gimple_call_fndecl(call_stmt);
93449 + if (fndecl == NULL_TREE)
93450 + continue;
93451 + if (TREE_CODE(fndecl) != FUNCTION_DECL)
93452 + continue;
93453 +
93454 + // is it a call to k*alloc
93455 + fnname = IDENTIFIER_POINTER(DECL_NAME(fndecl));
93456 + if (!is_kalloc(fnname))
93457 + continue;
93458 +
93459 + // is the size arg the result of a simple const assignment
93460 + size = gimple_call_arg(call_stmt, 0);
93461 + while (true) {
93462 + gimple def_stmt;
93463 + expanded_location xloc;
93464 + size_t size_val;
93465 +
93466 + if (TREE_CODE(size) != SSA_NAME)
93467 + break;
93468 + def_stmt = SSA_NAME_DEF_STMT(size);
93469 + if (!def_stmt || !is_gimple_assign(def_stmt))
93470 + break;
93471 + if (gimple_num_ops(def_stmt) != 2)
93472 + break;
93473 + size = gimple_assign_rhs1(def_stmt);
93474 + if (!TREE_CONSTANT(size))
93475 + continue;
93476 + xloc = expand_location(gimple_location(def_stmt));
93477 + if (!xloc.file)
93478 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
93479 + size_val = TREE_INT_CST_LOW(size);
93480 + fprintf(stderr, "kallocsize: %8zu %8zx %s %s:%u\n", size_val, size_val, fnname, xloc.file, xloc.line);
93481 + break;
93482 + }
93483 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
93484 +//debug_tree(gimple_call_fn(call_stmt));
93485 +//print_node(stderr, "pax", fndecl, 4);
93486 + }
93487 + }
93488 +
93489 + return 0;
93490 +}
93491 +
93492 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
93493 +{
93494 + const char * const plugin_name = plugin_info->base_name;
93495 + struct register_pass_info kallocstat_pass_info = {
93496 + .pass = &kallocstat_pass.pass,
93497 + .reference_pass_name = "ssa",
93498 + .ref_pass_instance_number = 1,
93499 + .pos_op = PASS_POS_INSERT_AFTER
93500 + };
93501 +
93502 + if (!plugin_default_version_check(version, &gcc_version)) {
93503 + error(G_("incompatible gcc/plugin versions"));
93504 + return 1;
93505 + }
93506 +
93507 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kallocstat_plugin_info);
93508 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kallocstat_pass_info);
93509 +
93510 + return 0;
93511 +}
93512 diff --git a/tools/gcc/kernexec_plugin.c b/tools/gcc/kernexec_plugin.c
93513 new file mode 100644
93514 index 0000000..0408e06
93515 --- /dev/null
93516 +++ b/tools/gcc/kernexec_plugin.c
93517 @@ -0,0 +1,465 @@
93518 +/*
93519 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
93520 + * Licensed under the GPL v2
93521 + *
93522 + * Note: the choice of the license means that the compilation process is
93523 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
93524 + * but for the kernel it doesn't matter since it doesn't link against
93525 + * any of the gcc libraries
93526 + *
93527 + * gcc plugin to make KERNEXEC/amd64 almost as good as it is on i386
93528 + *
93529 + * TODO:
93530 + *
93531 + * BUGS:
93532 + * - none known
93533 + */
93534 +#include "gcc-plugin.h"
93535 +#include "config.h"
93536 +#include "system.h"
93537 +#include "coretypes.h"
93538 +#include "tree.h"
93539 +#include "tree-pass.h"
93540 +#include "flags.h"
93541 +#include "intl.h"
93542 +#include "toplev.h"
93543 +#include "plugin.h"
93544 +//#include "expr.h" where are you...
93545 +#include "diagnostic.h"
93546 +#include "plugin-version.h"
93547 +#include "tm.h"
93548 +#include "function.h"
93549 +#include "basic-block.h"
93550 +#include "gimple.h"
93551 +#include "rtl.h"
93552 +#include "emit-rtl.h"
93553 +#include "tree-flow.h"
93554 +
93555 +extern void print_gimple_stmt(FILE *, gimple, int, int);
93556 +extern rtx emit_move_insn(rtx x, rtx y);
93557 +
93558 +#if BUILDING_GCC_VERSION <= 4006
93559 +#define ANY_RETURN_P(rtx) (GET_CODE(rtx) == RETURN)
93560 +#endif
93561 +
93562 +#if BUILDING_GCC_VERSION >= 4008
93563 +#define TODO_dump_func 0
93564 +#endif
93565 +
93566 +int plugin_is_GPL_compatible;
93567 +
93568 +static struct plugin_info kernexec_plugin_info = {
93569 + .version = "201302112000",
93570 + .help = "method=[bts|or]\tinstrumentation method\n"
93571 +};
93572 +
93573 +static unsigned int execute_kernexec_reload(void);
93574 +static unsigned int execute_kernexec_fptr(void);
93575 +static unsigned int execute_kernexec_retaddr(void);
93576 +static bool kernexec_cmodel_check(void);
93577 +
93578 +static void (*kernexec_instrument_fptr)(gimple_stmt_iterator *);
93579 +static void (*kernexec_instrument_retaddr)(rtx);
93580 +
93581 +static struct gimple_opt_pass kernexec_reload_pass = {
93582 + .pass = {
93583 + .type = GIMPLE_PASS,
93584 + .name = "kernexec_reload",
93585 +#if BUILDING_GCC_VERSION >= 4008
93586 + .optinfo_flags = OPTGROUP_NONE,
93587 +#endif
93588 + .gate = kernexec_cmodel_check,
93589 + .execute = execute_kernexec_reload,
93590 + .sub = NULL,
93591 + .next = NULL,
93592 + .static_pass_number = 0,
93593 + .tv_id = TV_NONE,
93594 + .properties_required = 0,
93595 + .properties_provided = 0,
93596 + .properties_destroyed = 0,
93597 + .todo_flags_start = 0,
93598 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
93599 + }
93600 +};
93601 +
93602 +static struct gimple_opt_pass kernexec_fptr_pass = {
93603 + .pass = {
93604 + .type = GIMPLE_PASS,
93605 + .name = "kernexec_fptr",
93606 +#if BUILDING_GCC_VERSION >= 4008
93607 + .optinfo_flags = OPTGROUP_NONE,
93608 +#endif
93609 + .gate = kernexec_cmodel_check,
93610 + .execute = execute_kernexec_fptr,
93611 + .sub = NULL,
93612 + .next = NULL,
93613 + .static_pass_number = 0,
93614 + .tv_id = TV_NONE,
93615 + .properties_required = 0,
93616 + .properties_provided = 0,
93617 + .properties_destroyed = 0,
93618 + .todo_flags_start = 0,
93619 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
93620 + }
93621 +};
93622 +
93623 +static struct rtl_opt_pass kernexec_retaddr_pass = {
93624 + .pass = {
93625 + .type = RTL_PASS,
93626 + .name = "kernexec_retaddr",
93627 +#if BUILDING_GCC_VERSION >= 4008
93628 + .optinfo_flags = OPTGROUP_NONE,
93629 +#endif
93630 + .gate = kernexec_cmodel_check,
93631 + .execute = execute_kernexec_retaddr,
93632 + .sub = NULL,
93633 + .next = NULL,
93634 + .static_pass_number = 0,
93635 + .tv_id = TV_NONE,
93636 + .properties_required = 0,
93637 + .properties_provided = 0,
93638 + .properties_destroyed = 0,
93639 + .todo_flags_start = 0,
93640 + .todo_flags_finish = TODO_dump_func | TODO_ggc_collect
93641 + }
93642 +};
93643 +
93644 +static bool kernexec_cmodel_check(void)
93645 +{
93646 + tree section;
93647 +
93648 + if (ix86_cmodel != CM_KERNEL)
93649 + return false;
93650 +
93651 + section = lookup_attribute("section", DECL_ATTRIBUTES(current_function_decl));
93652 + if (!section || !TREE_VALUE(section))
93653 + return true;
93654 +
93655 + section = TREE_VALUE(TREE_VALUE(section));
93656 + if (strncmp(TREE_STRING_POINTER(section), ".vsyscall_", 10))
93657 + return true;
93658 +
93659 + return false;
93660 +}
93661 +
93662 +/*
93663 + * add special KERNEXEC instrumentation: reload %r10 after it has been clobbered
93664 + */
93665 +static void kernexec_reload_fptr_mask(gimple_stmt_iterator *gsi)
93666 +{
93667 + gimple asm_movabs_stmt;
93668 +
93669 + // build asm volatile("movabs $0x8000000000000000, %%r10\n\t" : : : );
93670 + asm_movabs_stmt = gimple_build_asm_vec("movabs $0x8000000000000000, %%r10\n\t", NULL, NULL, NULL, NULL);
93671 + gimple_asm_set_volatile(asm_movabs_stmt, true);
93672 + gsi_insert_after(gsi, asm_movabs_stmt, GSI_CONTINUE_LINKING);
93673 + update_stmt(asm_movabs_stmt);
93674 +}
93675 +
93676 +/*
93677 + * find all asm() stmts that clobber r10 and add a reload of r10
93678 + */
93679 +static unsigned int execute_kernexec_reload(void)
93680 +{
93681 + basic_block bb;
93682 +
93683 + // 1. loop through BBs and GIMPLE statements
93684 + FOR_EACH_BB(bb) {
93685 + gimple_stmt_iterator gsi;
93686 +
93687 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
93688 + // gimple match: __asm__ ("" : : : "r10");
93689 + gimple asm_stmt;
93690 + size_t nclobbers;
93691 +
93692 + // is it an asm ...
93693 + asm_stmt = gsi_stmt(gsi);
93694 + if (gimple_code(asm_stmt) != GIMPLE_ASM)
93695 + continue;
93696 +
93697 + // ... clobbering r10
93698 + nclobbers = gimple_asm_nclobbers(asm_stmt);
93699 + while (nclobbers--) {
93700 + tree op = gimple_asm_clobber_op(asm_stmt, nclobbers);
93701 + if (strcmp(TREE_STRING_POINTER(TREE_VALUE(op)), "r10"))
93702 + continue;
93703 + kernexec_reload_fptr_mask(&gsi);
93704 +//print_gimple_stmt(stderr, asm_stmt, 0, TDF_LINENO);
93705 + break;
93706 + }
93707 + }
93708 + }
93709 +
93710 + return 0;
93711 +}
93712 +
93713 +/*
93714 + * add special KERNEXEC instrumentation: force MSB of fptr to 1, which will produce
93715 + * a non-canonical address from a userland ptr and will just trigger a GPF on dereference
93716 + */
93717 +static void kernexec_instrument_fptr_bts(gimple_stmt_iterator *gsi)
93718 +{
93719 + gimple assign_intptr, assign_new_fptr, call_stmt;
93720 + tree intptr, old_fptr, new_fptr, kernexec_mask;
93721 +
93722 + call_stmt = gsi_stmt(*gsi);
93723 + old_fptr = gimple_call_fn(call_stmt);
93724 +
93725 + // create temporary unsigned long variable used for bitops and cast fptr to it
93726 + intptr = create_tmp_var(long_unsigned_type_node, "kernexec_bts");
93727 +#if BUILDING_GCC_VERSION <= 4007
93728 + add_referenced_var(intptr);
93729 + mark_sym_for_renaming(intptr);
93730 +#endif
93731 + assign_intptr = gimple_build_assign(intptr, fold_convert(long_unsigned_type_node, old_fptr));
93732 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
93733 + update_stmt(assign_intptr);
93734 +
93735 + // apply logical or to temporary unsigned long and bitmask
93736 + kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0x8000000000000000LL);
93737 +// kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0xffffffff80000000LL);
93738 + assign_intptr = gimple_build_assign(intptr, fold_build2(BIT_IOR_EXPR, long_long_unsigned_type_node, intptr, kernexec_mask));
93739 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
93740 + update_stmt(assign_intptr);
93741 +
93742 + // cast temporary unsigned long back to a temporary fptr variable
93743 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_fptr");
93744 +#if BUILDING_GCC_VERSION <= 4007
93745 + add_referenced_var(new_fptr);
93746 + mark_sym_for_renaming(new_fptr);
93747 +#endif
93748 + assign_new_fptr = gimple_build_assign(new_fptr, fold_convert(TREE_TYPE(old_fptr), intptr));
93749 + gsi_insert_before(gsi, assign_new_fptr, GSI_SAME_STMT);
93750 + update_stmt(assign_new_fptr);
93751 +
93752 + // replace call stmt fn with the new fptr
93753 + gimple_call_set_fn(call_stmt, new_fptr);
93754 + update_stmt(call_stmt);
93755 +}
93756 +
93757 +static void kernexec_instrument_fptr_or(gimple_stmt_iterator *gsi)
93758 +{
93759 + gimple asm_or_stmt, call_stmt;
93760 + tree old_fptr, new_fptr, input, output;
93761 +#if BUILDING_GCC_VERSION <= 4007
93762 + VEC(tree, gc) *inputs = NULL;
93763 + VEC(tree, gc) *outputs = NULL;
93764 +#else
93765 + vec<tree, va_gc> *inputs = NULL;
93766 + vec<tree, va_gc> *outputs = NULL;
93767 +#endif
93768 +
93769 + call_stmt = gsi_stmt(*gsi);
93770 + old_fptr = gimple_call_fn(call_stmt);
93771 +
93772 + // create temporary fptr variable
93773 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_or");
93774 +#if BUILDING_GCC_VERSION <= 4007
93775 + add_referenced_var(new_fptr);
93776 + mark_sym_for_renaming(new_fptr);
93777 +#endif
93778 +
93779 + // build asm volatile("orq %%r10, %0\n\t" : "=r"(new_fptr) : "0"(old_fptr));
93780 + input = build_tree_list(NULL_TREE, build_string(2, "0"));
93781 + input = chainon(NULL_TREE, build_tree_list(input, old_fptr));
93782 + output = build_tree_list(NULL_TREE, build_string(3, "=r"));
93783 + output = chainon(NULL_TREE, build_tree_list(output, new_fptr));
93784 +#if BUILDING_GCC_VERSION <= 4007
93785 + VEC_safe_push(tree, gc, inputs, input);
93786 + VEC_safe_push(tree, gc, outputs, output);
93787 +#else
93788 + vec_safe_push(inputs, input);
93789 + vec_safe_push(outputs, output);
93790 +#endif
93791 + asm_or_stmt = gimple_build_asm_vec("orq %%r10, %0\n\t", inputs, outputs, NULL, NULL);
93792 + gimple_asm_set_volatile(asm_or_stmt, true);
93793 + gsi_insert_before(gsi, asm_or_stmt, GSI_SAME_STMT);
93794 + update_stmt(asm_or_stmt);
93795 +
93796 + // replace call stmt fn with the new fptr
93797 + gimple_call_set_fn(call_stmt, new_fptr);
93798 + update_stmt(call_stmt);
93799 +}
93800 +
93801 +/*
93802 + * find all C level function pointer dereferences and forcibly set the highest bit of the pointer
93803 + */
93804 +static unsigned int execute_kernexec_fptr(void)
93805 +{
93806 + basic_block bb;
93807 +
93808 + // 1. loop through BBs and GIMPLE statements
93809 + FOR_EACH_BB(bb) {
93810 + gimple_stmt_iterator gsi;
93811 +
93812 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
93813 + // gimple match: h_1 = get_fptr (); D.2709_3 = h_1 (x_2(D));
93814 + tree fn;
93815 + gimple call_stmt;
93816 +
93817 + // is it a call ...
93818 + call_stmt = gsi_stmt(gsi);
93819 + if (!is_gimple_call(call_stmt))
93820 + continue;
93821 + fn = gimple_call_fn(call_stmt);
93822 + if (TREE_CODE(fn) == ADDR_EXPR)
93823 + continue;
93824 + if (TREE_CODE(fn) != SSA_NAME)
93825 + gcc_unreachable();
93826 +
93827 + // ... through a function pointer
93828 + if (SSA_NAME_VAR(fn) != NULL_TREE) {
93829 + fn = SSA_NAME_VAR(fn);
93830 + if (TREE_CODE(fn) != VAR_DECL && TREE_CODE(fn) != PARM_DECL) {
93831 + debug_tree(fn);
93832 + gcc_unreachable();
93833 + }
93834 + }
93835 + fn = TREE_TYPE(fn);
93836 + if (TREE_CODE(fn) != POINTER_TYPE)
93837 + continue;
93838 + fn = TREE_TYPE(fn);
93839 + if (TREE_CODE(fn) != FUNCTION_TYPE)
93840 + continue;
93841 +
93842 + kernexec_instrument_fptr(&gsi);
93843 +
93844 +//debug_tree(gimple_call_fn(call_stmt));
93845 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
93846 + }
93847 + }
93848 +
93849 + return 0;
93850 +}
93851 +
93852 +// add special KERNEXEC instrumentation: btsq $63,(%rsp) just before retn
93853 +static void kernexec_instrument_retaddr_bts(rtx insn)
93854 +{
93855 + rtx btsq;
93856 + rtvec argvec, constraintvec, labelvec;
93857 + int line;
93858 +
93859 + // create asm volatile("btsq $63,(%%rsp)":::)
93860 + argvec = rtvec_alloc(0);
93861 + constraintvec = rtvec_alloc(0);
93862 + labelvec = rtvec_alloc(0);
93863 + line = expand_location(RTL_LOCATION(insn)).line;
93864 + btsq = gen_rtx_ASM_OPERANDS(VOIDmode, "btsq $63,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
93865 + MEM_VOLATILE_P(btsq) = 1;
93866 +// RTX_FRAME_RELATED_P(btsq) = 1; // not for ASM_OPERANDS
93867 + emit_insn_before(btsq, insn);
93868 +}
93869 +
93870 +// add special KERNEXEC instrumentation: orq %r10,(%rsp) just before retn
93871 +static void kernexec_instrument_retaddr_or(rtx insn)
93872 +{
93873 + rtx orq;
93874 + rtvec argvec, constraintvec, labelvec;
93875 + int line;
93876 +
93877 + // create asm volatile("orq %%r10,(%%rsp)":::)
93878 + argvec = rtvec_alloc(0);
93879 + constraintvec = rtvec_alloc(0);
93880 + labelvec = rtvec_alloc(0);
93881 + line = expand_location(RTL_LOCATION(insn)).line;
93882 + orq = gen_rtx_ASM_OPERANDS(VOIDmode, "orq %%r10,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
93883 + MEM_VOLATILE_P(orq) = 1;
93884 +// RTX_FRAME_RELATED_P(orq) = 1; // not for ASM_OPERANDS
93885 + emit_insn_before(orq, insn);
93886 +}
93887 +
93888 +/*
93889 + * find all asm level function returns and forcibly set the highest bit of the return address
93890 + */
93891 +static unsigned int execute_kernexec_retaddr(void)
93892 +{
93893 + rtx insn;
93894 +
93895 + // 1. find function returns
93896 + for (insn = get_insns(); insn; insn = NEXT_INSN(insn)) {
93897 + // rtl match: (jump_insn 41 40 42 2 (return) fptr.c:42 634 {return_internal} (nil))
93898 + // (jump_insn 12 9 11 2 (parallel [ (return) (unspec [ (0) ] UNSPEC_REP) ]) fptr.c:46 635 {return_internal_long} (nil))
93899 + // (jump_insn 97 96 98 6 (simple_return) fptr.c:50 -1 (nil) -> simple_return)
93900 + rtx body;
93901 +
93902 + // is it a retn
93903 + if (!JUMP_P(insn))
93904 + continue;
93905 + body = PATTERN(insn);
93906 + if (GET_CODE(body) == PARALLEL)
93907 + body = XVECEXP(body, 0, 0);
93908 + if (!ANY_RETURN_P(body))
93909 + continue;
93910 + kernexec_instrument_retaddr(insn);
93911 + }
93912 +
93913 +// print_simple_rtl(stderr, get_insns());
93914 +// print_rtl(stderr, get_insns());
93915 +
93916 + return 0;
93917 +}
93918 +
93919 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
93920 +{
93921 + const char * const plugin_name = plugin_info->base_name;
93922 + const int argc = plugin_info->argc;
93923 + const struct plugin_argument * const argv = plugin_info->argv;
93924 + int i;
93925 + struct register_pass_info kernexec_reload_pass_info = {
93926 + .pass = &kernexec_reload_pass.pass,
93927 + .reference_pass_name = "ssa",
93928 + .ref_pass_instance_number = 1,
93929 + .pos_op = PASS_POS_INSERT_AFTER
93930 + };
93931 + struct register_pass_info kernexec_fptr_pass_info = {
93932 + .pass = &kernexec_fptr_pass.pass,
93933 + .reference_pass_name = "ssa",
93934 + .ref_pass_instance_number = 1,
93935 + .pos_op = PASS_POS_INSERT_AFTER
93936 + };
93937 + struct register_pass_info kernexec_retaddr_pass_info = {
93938 + .pass = &kernexec_retaddr_pass.pass,
93939 + .reference_pass_name = "pro_and_epilogue",
93940 + .ref_pass_instance_number = 1,
93941 + .pos_op = PASS_POS_INSERT_AFTER
93942 + };
93943 +
93944 + if (!plugin_default_version_check(version, &gcc_version)) {
93945 + error(G_("incompatible gcc/plugin versions"));
93946 + return 1;
93947 + }
93948 +
93949 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kernexec_plugin_info);
93950 +
93951 + if (TARGET_64BIT == 0)
93952 + return 0;
93953 +
93954 + for (i = 0; i < argc; ++i) {
93955 + if (!strcmp(argv[i].key, "method")) {
93956 + if (!argv[i].value) {
93957 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
93958 + continue;
93959 + }
93960 + if (!strcmp(argv[i].value, "bts")) {
93961 + kernexec_instrument_fptr = kernexec_instrument_fptr_bts;
93962 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_bts;
93963 + } else if (!strcmp(argv[i].value, "or")) {
93964 + kernexec_instrument_fptr = kernexec_instrument_fptr_or;
93965 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_or;
93966 + fix_register("r10", 1, 1);
93967 + } else
93968 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
93969 + continue;
93970 + }
93971 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
93972 + }
93973 + if (!kernexec_instrument_fptr || !kernexec_instrument_retaddr)
93974 + error(G_("no instrumentation method was selected via '-fplugin-arg-%s-method'"), plugin_name);
93975 +
93976 + if (kernexec_instrument_fptr == kernexec_instrument_fptr_or)
93977 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_reload_pass_info);
93978 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_fptr_pass_info);
93979 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_retaddr_pass_info);
93980 +
93981 + return 0;
93982 +}
93983 diff --git a/tools/gcc/latent_entropy_plugin.c b/tools/gcc/latent_entropy_plugin.c
93984 new file mode 100644
93985 index 0000000..b5395ba
93986 --- /dev/null
93987 +++ b/tools/gcc/latent_entropy_plugin.c
93988 @@ -0,0 +1,327 @@
93989 +/*
93990 + * Copyright 2012-2013 by the PaX Team <pageexec@freemail.hu>
93991 + * Licensed under the GPL v2
93992 + *
93993 + * Note: the choice of the license means that the compilation process is
93994 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
93995 + * but for the kernel it doesn't matter since it doesn't link against
93996 + * any of the gcc libraries
93997 + *
93998 + * gcc plugin to help generate a little bit of entropy from program state,
93999 + * used during boot in the kernel
94000 + *
94001 + * TODO:
94002 + * - add ipa pass to identify not explicitly marked candidate functions
94003 + * - mix in more program state (function arguments/return values, loop variables, etc)
94004 + * - more instrumentation control via attribute parameters
94005 + *
94006 + * BUGS:
94007 + * - LTO needs -flto-partition=none for now
94008 + */
94009 +#include "gcc-plugin.h"
94010 +#include "config.h"
94011 +#include "system.h"
94012 +#include "coretypes.h"
94013 +#include "tree.h"
94014 +#include "tree-pass.h"
94015 +#include "flags.h"
94016 +#include "intl.h"
94017 +#include "toplev.h"
94018 +#include "plugin.h"
94019 +//#include "expr.h" where are you...
94020 +#include "diagnostic.h"
94021 +#include "plugin-version.h"
94022 +#include "tm.h"
94023 +#include "function.h"
94024 +#include "basic-block.h"
94025 +#include "gimple.h"
94026 +#include "rtl.h"
94027 +#include "emit-rtl.h"
94028 +#include "tree-flow.h"
94029 +#include "langhooks.h"
94030 +
94031 +#if BUILDING_GCC_VERSION >= 4008
94032 +#define TODO_dump_func 0
94033 +#endif
94034 +
94035 +int plugin_is_GPL_compatible;
94036 +
94037 +static tree latent_entropy_decl;
94038 +
94039 +static struct plugin_info latent_entropy_plugin_info = {
94040 + .version = "201303102320",
94041 + .help = NULL
94042 +};
94043 +
94044 +static unsigned int execute_latent_entropy(void);
94045 +static bool gate_latent_entropy(void);
94046 +
94047 +static struct gimple_opt_pass latent_entropy_pass = {
94048 + .pass = {
94049 + .type = GIMPLE_PASS,
94050 + .name = "latent_entropy",
94051 +#if BUILDING_GCC_VERSION >= 4008
94052 + .optinfo_flags = OPTGROUP_NONE,
94053 +#endif
94054 + .gate = gate_latent_entropy,
94055 + .execute = execute_latent_entropy,
94056 + .sub = NULL,
94057 + .next = NULL,
94058 + .static_pass_number = 0,
94059 + .tv_id = TV_NONE,
94060 + .properties_required = PROP_gimple_leh | PROP_cfg,
94061 + .properties_provided = 0,
94062 + .properties_destroyed = 0,
94063 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
94064 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
94065 + }
94066 +};
94067 +
94068 +static tree handle_latent_entropy_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
94069 +{
94070 + if (TREE_CODE(*node) != FUNCTION_DECL) {
94071 + *no_add_attrs = true;
94072 + error("%qE attribute only applies to functions", name);
94073 + }
94074 + return NULL_TREE;
94075 +}
94076 +
94077 +static struct attribute_spec latent_entropy_attr = {
94078 + .name = "latent_entropy",
94079 + .min_length = 0,
94080 + .max_length = 0,
94081 + .decl_required = true,
94082 + .type_required = false,
94083 + .function_type_required = false,
94084 + .handler = handle_latent_entropy_attribute,
94085 +#if BUILDING_GCC_VERSION >= 4007
94086 + .affects_type_identity = false
94087 +#endif
94088 +};
94089 +
94090 +static void register_attributes(void *event_data, void *data)
94091 +{
94092 + register_attribute(&latent_entropy_attr);
94093 +}
94094 +
94095 +static bool gate_latent_entropy(void)
94096 +{
94097 + tree latent_entropy_attr;
94098 +
94099 + latent_entropy_attr = lookup_attribute("latent_entropy", DECL_ATTRIBUTES(current_function_decl));
94100 + return latent_entropy_attr != NULL_TREE;
94101 +}
94102 +
94103 +static unsigned HOST_WIDE_INT seed;
94104 +static unsigned HOST_WIDE_INT get_random_const(void)
94105 +{
94106 + seed = (seed >> 1U) ^ (-(seed & 1ULL) & 0xD800000000000000ULL);
94107 + return seed;
94108 +}
94109 +
94110 +static enum tree_code get_op(tree *rhs)
94111 +{
94112 + static enum tree_code op;
94113 + unsigned HOST_WIDE_INT random_const;
94114 +
94115 + random_const = get_random_const();
94116 +
94117 + switch (op) {
94118 + case BIT_XOR_EXPR:
94119 + op = PLUS_EXPR;
94120 + break;
94121 +
94122 + case PLUS_EXPR:
94123 + if (rhs) {
94124 + op = LROTATE_EXPR;
94125 + random_const &= HOST_BITS_PER_WIDE_INT - 1;
94126 + break;
94127 + }
94128 +
94129 + case LROTATE_EXPR:
94130 + default:
94131 + op = BIT_XOR_EXPR;
94132 + break;
94133 + }
94134 + if (rhs)
94135 + *rhs = build_int_cstu(unsigned_intDI_type_node, random_const);
94136 + return op;
94137 +}
94138 +
94139 +static void perturb_local_entropy(basic_block bb, tree local_entropy)
94140 +{
94141 + gimple_stmt_iterator gsi;
94142 + gimple assign;
94143 + tree addxorrol, rhs;
94144 + enum tree_code op;
94145 +
94146 + op = get_op(&rhs);
94147 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, op, unsigned_intDI_type_node, local_entropy, rhs);
94148 + assign = gimple_build_assign(local_entropy, addxorrol);
94149 +#if BUILDING_GCC_VERSION <= 4007
94150 + find_referenced_vars_in(assign);
94151 +#endif
94152 +//debug_bb(bb);
94153 + gsi = gsi_after_labels(bb);
94154 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
94155 + update_stmt(assign);
94156 +}
94157 +
94158 +static void perturb_latent_entropy(basic_block bb, tree rhs)
94159 +{
94160 + gimple_stmt_iterator gsi;
94161 + gimple assign;
94162 + tree addxorrol, temp;
94163 +
94164 + // 1. create temporary copy of latent_entropy
94165 + temp = create_tmp_var(unsigned_intDI_type_node, "temp_latent_entropy");
94166 +#if BUILDING_GCC_VERSION <= 4007
94167 + add_referenced_var(temp);
94168 + mark_sym_for_renaming(temp);
94169 +#endif
94170 +
94171 + // 2. read...
94172 + assign = gimple_build_assign(temp, latent_entropy_decl);
94173 +#if BUILDING_GCC_VERSION <= 4007
94174 + find_referenced_vars_in(assign);
94175 +#endif
94176 + gsi = gsi_after_labels(bb);
94177 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
94178 + update_stmt(assign);
94179 +
94180 + // 3. ...modify...
94181 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, get_op(NULL), unsigned_intDI_type_node, temp, rhs);
94182 + assign = gimple_build_assign(temp, addxorrol);
94183 +#if BUILDING_GCC_VERSION <= 4007
94184 + find_referenced_vars_in(assign);
94185 +#endif
94186 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
94187 + update_stmt(assign);
94188 +
94189 + // 4. ...write latent_entropy
94190 + assign = gimple_build_assign(latent_entropy_decl, temp);
94191 +#if BUILDING_GCC_VERSION <= 4007
94192 + find_referenced_vars_in(assign);
94193 +#endif
94194 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
94195 + update_stmt(assign);
94196 +}
94197 +
94198 +static unsigned int execute_latent_entropy(void)
94199 +{
94200 + basic_block bb;
94201 + gimple assign;
94202 + gimple_stmt_iterator gsi;
94203 + tree local_entropy;
94204 +
94205 + if (!latent_entropy_decl) {
94206 + struct varpool_node *node;
94207 +
94208 +#if BUILDING_GCC_VERSION <= 4007
94209 + for (node = varpool_nodes; node; node = node->next) {
94210 + tree var = node->decl;
94211 +#else
94212 + FOR_EACH_VARIABLE(node) {
94213 + tree var = node->symbol.decl;
94214 +#endif
94215 + if (strcmp(IDENTIFIER_POINTER(DECL_NAME(var)), "latent_entropy"))
94216 + continue;
94217 + latent_entropy_decl = var;
94218 +// debug_tree(var);
94219 + break;
94220 + }
94221 + if (!latent_entropy_decl) {
94222 +// debug_tree(current_function_decl);
94223 + return 0;
94224 + }
94225 + }
94226 +
94227 +//fprintf(stderr, "latent_entropy: %s\n", IDENTIFIER_POINTER(DECL_NAME(current_function_decl)));
94228 +
94229 + // 1. create local entropy variable
94230 + local_entropy = create_tmp_var(unsigned_intDI_type_node, "local_entropy");
94231 +#if BUILDING_GCC_VERSION <= 4007
94232 + add_referenced_var(local_entropy);
94233 + mark_sym_for_renaming(local_entropy);
94234 +#endif
94235 +
94236 + // 2. initialize local entropy variable
94237 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
94238 + if (dom_info_available_p(CDI_DOMINATORS))
94239 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
94240 + gsi = gsi_start_bb(bb);
94241 +
94242 + assign = gimple_build_assign(local_entropy, build_int_cstu(unsigned_intDI_type_node, get_random_const()));
94243 +// gimple_set_location(assign, loc);
94244 +#if BUILDING_GCC_VERSION <= 4007
94245 + find_referenced_vars_in(assign);
94246 +#endif
94247 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
94248 + update_stmt(assign);
94249 + bb = bb->next_bb;
94250 +
94251 + // 3. instrument each BB with an operation on the local entropy variable
94252 + while (bb != EXIT_BLOCK_PTR) {
94253 + perturb_local_entropy(bb, local_entropy);
94254 + bb = bb->next_bb;
94255 + };
94256 +
94257 + // 4. mix local entropy into the global entropy variable
94258 + perturb_latent_entropy(EXIT_BLOCK_PTR->prev_bb, local_entropy);
94259 + return 0;
94260 +}
94261 +
94262 +static void start_unit_callback(void *gcc_data, void *user_data)
94263 +{
94264 + tree latent_entropy_type;
94265 +
94266 +#if BUILDING_GCC_VERSION >= 4007
94267 + seed = get_random_seed(false);
94268 +#else
94269 + sscanf(get_random_seed(false), "%" HOST_WIDE_INT_PRINT "x", &seed);
94270 + seed *= seed;
94271 +#endif
94272 +
94273 + if (in_lto_p)
94274 + return;
94275 +
94276 + // extern volatile u64 latent_entropy
94277 + gcc_assert(TYPE_PRECISION(long_long_unsigned_type_node) == 64);
94278 + latent_entropy_type = build_qualified_type(long_long_unsigned_type_node, TYPE_QUALS(long_long_unsigned_type_node) | TYPE_QUAL_VOLATILE);
94279 + latent_entropy_decl = build_decl(UNKNOWN_LOCATION, VAR_DECL, get_identifier("latent_entropy"), latent_entropy_type);
94280 +
94281 + TREE_STATIC(latent_entropy_decl) = 1;
94282 + TREE_PUBLIC(latent_entropy_decl) = 1;
94283 + TREE_USED(latent_entropy_decl) = 1;
94284 + TREE_THIS_VOLATILE(latent_entropy_decl) = 1;
94285 + DECL_EXTERNAL(latent_entropy_decl) = 1;
94286 + DECL_ARTIFICIAL(latent_entropy_decl) = 1;
94287 + DECL_INITIAL(latent_entropy_decl) = NULL;
94288 + lang_hooks.decls.pushdecl(latent_entropy_decl);
94289 +// DECL_ASSEMBLER_NAME(latent_entropy_decl);
94290 +// varpool_finalize_decl(latent_entropy_decl);
94291 +// varpool_mark_needed_node(latent_entropy_decl);
94292 +}
94293 +
94294 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
94295 +{
94296 + const char * const plugin_name = plugin_info->base_name;
94297 + struct register_pass_info latent_entropy_pass_info = {
94298 + .pass = &latent_entropy_pass.pass,
94299 + .reference_pass_name = "optimized",
94300 + .ref_pass_instance_number = 1,
94301 + .pos_op = PASS_POS_INSERT_BEFORE
94302 + };
94303 +
94304 + if (!plugin_default_version_check(version, &gcc_version)) {
94305 + error(G_("incompatible gcc/plugin versions"));
94306 + return 1;
94307 + }
94308 +
94309 + register_callback(plugin_name, PLUGIN_INFO, NULL, &latent_entropy_plugin_info);
94310 + register_callback ("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
94311 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &latent_entropy_pass_info);
94312 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
94313 +
94314 + return 0;
94315 +}
94316 diff --git a/tools/gcc/size_overflow_hash.data b/tools/gcc/size_overflow_hash.data
94317 new file mode 100644
94318 index 0000000..7982a0c
94319 --- /dev/null
94320 +++ b/tools/gcc/size_overflow_hash.data
94321 @@ -0,0 +1,5893 @@
94322 +intel_fake_agp_alloc_by_type_1 intel_fake_agp_alloc_by_type 1 1 NULL
94323 +batadv_orig_node_del_if_4 batadv_orig_node_del_if 2 4 NULL
94324 +storvsc_connect_to_vsp_22 storvsc_connect_to_vsp 2 22 NULL
94325 +compat_sock_setsockopt_23 compat_sock_setsockopt 5 23 NULL
94326 +carl9170_alloc_27 carl9170_alloc 1 27 NULL
94327 +sel_read_policyvers_55 sel_read_policyvers 3 55 NULL nohasharray
94328 +padzero_55 padzero 1 55 &sel_read_policyvers_55
94329 +cfg80211_disconnected_57 cfg80211_disconnected 4 57 NULL
94330 +__skb_to_sgvec_72 __skb_to_sgvec 0 72 NULL
94331 +crypto_authenc_setkey_80 crypto_authenc_setkey 3 80 NULL
94332 +snd_korg1212_copy_to_92 snd_korg1212_copy_to 6 92 NULL
94333 +load_msg_95 load_msg 2 95 NULL
94334 +device_flush_iotlb_115 device_flush_iotlb 2-3 115 NULL
94335 +init_q_132 init_q 4 132 NULL
94336 +memstick_alloc_host_142 memstick_alloc_host 1 142 NULL
94337 +hva_to_gfn_memslot_149 hva_to_gfn_memslot 0-1 149 NULL
94338 +tracing_trace_options_write_153 tracing_trace_options_write 3 153 NULL
94339 +nvme_create_queue_170 nvme_create_queue 3 170 NULL
94340 +xfs_buf_item_get_format_189 xfs_buf_item_get_format 2 189 NULL
94341 +iscsi_session_setup_196 iscsi_session_setup 4-5 196 NULL
94342 +virtblk_add_req_197 virtblk_add_req 2-3 197 NULL
94343 +proc_scsi_write_proc_267 proc_scsi_write_proc 3 267 NULL
94344 +br_port_info_size_268 br_port_info_size 0 268 NULL
94345 +generic_file_direct_write_291 generic_file_direct_write 0 291 NULL
94346 +read_file_war_stats_292 read_file_war_stats 3 292 NULL
94347 +syslog_print_307 syslog_print 2 307 NULL
94348 +platform_device_add_data_310 platform_device_add_data 3 310 NULL
94349 +dn_setsockopt_314 dn_setsockopt 5 314 NULL
94350 +next_node_allowed_318 next_node_allowed 1 318 NULL
94351 +compat_sys_ioctl_333 compat_sys_ioctl 3 333 NULL
94352 +btmrvl_txdnldready_read_413 btmrvl_txdnldready_read 3 413 NULL
94353 +lbs_rdmac_read_418 lbs_rdmac_read 3 418 NULL
94354 +snd_ca0106_ptr_read_467 snd_ca0106_ptr_read 0 467 NULL
94355 +_alloc_get_attr_desc_470 _alloc_get_attr_desc 2 470 NULL
94356 +dccp_manip_pkt_476 dccp_manip_pkt 4 476 NULL
94357 +pidlist_resize_496 pidlist_resize 2 496 NULL
94358 +read_vbt_r0_503 read_vbt_r0 1 503 NULL
94359 +rx_rx_defrag_end_read_505 rx_rx_defrag_end_read 3 505 NULL
94360 +ocfs2_validate_meta_ecc_bhs_527 ocfs2_validate_meta_ecc_bhs 0 527 NULL
94361 +zlib_deflate_workspacesize_537 zlib_deflate_workspacesize 0 537 NULL
94362 +iwl_dbgfs_wowlan_sram_read_540 iwl_dbgfs_wowlan_sram_read 3 540 NULL
94363 +dle_count_543 dle_count 0 543 NULL
94364 +devres_alloc_551 devres_alloc 2 551 NULL
94365 +snd_aw2_saa7146_get_hw_ptr_playback_558 snd_aw2_saa7146_get_hw_ptr_playback 0 558 NULL
94366 +dev_hard_header_565 dev_hard_header 0 565 NULL nohasharray
94367 +start_isoc_chain_565 start_isoc_chain 2 565 &dev_hard_header_565
94368 +compat_sys_preadv_583 compat_sys_preadv 3 583 NULL
94369 +smk_write_load_self2_591 smk_write_load_self2 3 591 NULL
94370 +ni_gpct_device_construct_610 ni_gpct_device_construct 5 610 NULL
94371 +fuse_request_alloc_nofs_617 fuse_request_alloc_nofs 1 617 NULL
94372 +compat_sys_shmat_620 compat_sys_shmat 3 620 NULL
94373 +isp1760_register_628 isp1760_register 1-2 628 NULL
94374 +clone_split_bio_633 clone_split_bio 6 633 NULL
94375 +remap_to_cache_640 remap_to_cache 3 640 NULL
94376 +drbd_bm_find_next_643 drbd_bm_find_next 2 643 NULL
94377 +unlink_queued_645 unlink_queued 3-4 645 NULL
94378 +dtim_interval_read_654 dtim_interval_read 3 654 NULL
94379 +mem_rx_free_mem_blks_read_675 mem_rx_free_mem_blks_read 3 675 NULL
94380 +rtl8169_try_rx_copy_705 rtl8169_try_rx_copy 3 705 NULL
94381 +persistent_ram_vmap_709 persistent_ram_vmap 1-2 709 NULL
94382 +ipath_resize_cq_712 ipath_resize_cq 2 712 NULL
94383 +disk_max_parts_719 disk_max_parts 0 719 NULL
94384 +sctp_setsockopt_peer_addr_params_734 sctp_setsockopt_peer_addr_params 3 734 NULL
94385 +dvb_video_write_754 dvb_video_write 3 754 NULL
94386 +if_writecmd_815 if_writecmd 2 815 NULL
94387 +aac_change_queue_depth_825 aac_change_queue_depth 2 825 NULL
94388 +read_fifo_826 read_fifo 3 826 NULL
94389 +um_idi_read_850 um_idi_read 3 850 NULL
94390 +ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz_856 ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz 3 856 NULL
94391 +o2net_send_message_vec_879 o2net_send_message_vec 4 879 NULL nohasharray
94392 +iwl_dbgfs_fh_reg_read_879 iwl_dbgfs_fh_reg_read 3 879 &o2net_send_message_vec_879
94393 +snd_pcm_action_single_905 snd_pcm_action_single 0 905 NULL
94394 +btmrvl_hsstate_read_920 btmrvl_hsstate_read 3 920 NULL
94395 +carl9170_cmd_buf_950 carl9170_cmd_buf 3 950 NULL
94396 +get_ramdisk_size_954 get_ramdisk_size 0 954 NULL
94397 +__nodes_weight_956 __nodes_weight 2-0 956 NULL
94398 +sys_msgrcv_959 sys_msgrcv 3 959 NULL
94399 +pte_prefetch_gfn_to_pfn_997 pte_prefetch_gfn_to_pfn 2 997 NULL nohasharray
94400 +hdlcdev_rx_997 hdlcdev_rx 3 997 &pte_prefetch_gfn_to_pfn_997
94401 +dm_cache_set_dirty_1016 dm_cache_set_dirty 2 1016 NULL
94402 +smk_write_cipso2_1021 smk_write_cipso2 3 1021 NULL
94403 +gigaset_initdriver_1060 gigaset_initdriver 2 1060 NULL
94404 +Read_hfc16_1070 Read_hfc16 0 1070 NULL
94405 +mce_request_packet_1073 mce_request_packet 3 1073 NULL
94406 +agp_create_memory_1075 agp_create_memory 1 1075 NULL
94407 +_scsih_adjust_queue_depth_1083 _scsih_adjust_queue_depth 2 1083 NULL
94408 +nfs_pgarray_set_1085 nfs_pgarray_set 2 1085 NULL
94409 +llcp_sock_sendmsg_1092 llcp_sock_sendmsg 4 1092 NULL
94410 +nfs4_init_nonuniform_client_string_1097 nfs4_init_nonuniform_client_string 3 1097 NULL
94411 +sys_mremap_1107 sys_mremap 5-1-2 1107 NULL
94412 +cfg80211_report_obss_beacon_1133 cfg80211_report_obss_beacon 3 1133 NULL
94413 +vmalloc_32_1135 vmalloc_32 1 1135 NULL
94414 +i2400m_rx_ctl_1157 i2400m_rx_ctl 4 1157 NULL
94415 +ipc_alloc_1192 ipc_alloc 1 1192 NULL
94416 +ib_create_send_mad_1196 ib_create_send_mad 5 1196 NULL
94417 +i2400m_rx_ctl_ack_1199 i2400m_rx_ctl_ack 3 1199 NULL
94418 +dgrp_dpa_read_1204 dgrp_dpa_read 3 1204 NULL
94419 +i2cdev_read_1206 i2cdev_read 3 1206 NULL
94420 +ipw_packet_received_skb_1230 ipw_packet_received_skb 2 1230 NULL
94421 +acpi_battery_write_alarm_1240 acpi_battery_write_alarm 3 1240 NULL
94422 +nested_get_page_1252 nested_get_page 2 1252 NULL
94423 +ocfs2_extend_file_1266 ocfs2_extend_file 3 1266 NULL
94424 +qla4xxx_change_queue_depth_1268 qla4xxx_change_queue_depth 2 1268 NULL
94425 +ioctl_private_iw_point_1273 ioctl_private_iw_point 7 1273 NULL
94426 +batadv_tt_prepare_packet_buff_1280 batadv_tt_prepare_packet_buff 4 1280 NULL
94427 +tx_frag_in_process_called_read_1290 tx_frag_in_process_called_read 3 1290 NULL
94428 +wm_adsp_buf_alloc_1317 wm_adsp_buf_alloc 2 1317 NULL
94429 +compat_put_u64_1319 compat_put_u64 1 1319 NULL
94430 +ffs_1322 ffs 0 1322 NULL
94431 +carl9170_rx_stream_1334 carl9170_rx_stream 3 1334 NULL
94432 +btrfs_submit_compressed_write_1347 btrfs_submit_compressed_write 5 1347 NULL
94433 +gen_pool_best_fit_1348 gen_pool_best_fit 2-3-4 1348 NULL
94434 +io_mapping_create_wc_1354 io_mapping_create_wc 1-2 1354 NULL
94435 +snd_pcm_lib_write1_1358 snd_pcm_lib_write1 0-3 1358 NULL
94436 +ipx_sendmsg_1362 ipx_sendmsg 4 1362 NULL
94437 +iov_num_pages_1364 iov_num_pages 0 1364 NULL
94438 +fw_stats_raw_read_1369 fw_stats_raw_read 3 1369 NULL
94439 +ocfs2_prepare_inode_for_write_1372 ocfs2_prepare_inode_for_write 3 1372 NULL
94440 +sctp_setsockopt_initmsg_1383 sctp_setsockopt_initmsg 3 1383 NULL
94441 +do_msgsnd_1387 do_msgsnd 4 1387 NULL
94442 +zone_page_state_1393 zone_page_state 0 1393 NULL
94443 +file_read_actor_1401 file_read_actor 4 1401 NULL
94444 +vb2_dc_get_user_pages_1442 vb2_dc_get_user_pages 1-3 1442 NULL
94445 +stack_max_size_read_1445 stack_max_size_read 3 1445 NULL
94446 +tx_queue_len_read_1463 tx_queue_len_read 3 1463 NULL
94447 +xprt_alloc_1475 xprt_alloc 2 1475 NULL
94448 +sta_num_ps_buf_frames_read_1488 sta_num_ps_buf_frames_read 3 1488 NULL
94449 +posix_acl_permission_1495 posix_acl_permission 0 1495 NULL
94450 +tomoyo_round2_1518 tomoyo_round2 0 1518 NULL
94451 +__vfio_dma_map_1523 __vfio_dma_map 3 1523 NULL
94452 +alloc_perm_bits_1532 alloc_perm_bits 2 1532 NULL
94453 +ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime_1589 ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime 3 1589 NULL
94454 +fc_frame_alloc_1596 fc_frame_alloc 2 1596 NULL
94455 +packet_buffer_init_1607 packet_buffer_init 2 1607 NULL
94456 +btmrvl_hscmd_read_1614 btmrvl_hscmd_read 3 1614 NULL
94457 +v9fs_fid_xattr_get_1618 v9fs_fid_xattr_get 0 1618 NULL
94458 +btmrvl_hsmode_read_1647 btmrvl_hsmode_read 3 1647 NULL
94459 +ikconfig_read_current_1658 ikconfig_read_current 3 1658 NULL
94460 +netdev_feature_string_1667 netdev_feature_string 0 1667 NULL
94461 +compat_x25_ioctl_1674 compat_x25_ioctl 3 1674 NULL
94462 +rmap_add_1677 rmap_add 3 1677 NULL
94463 +configfs_read_file_1683 configfs_read_file 3 1683 NULL
94464 +coda_psdev_write_1711 coda_psdev_write 3 1711 NULL
94465 +btrfs_dir_data_len_1714 btrfs_dir_data_len 0 1714 NULL
94466 +dma_memcpy_pg_to_iovec_1725 dma_memcpy_pg_to_iovec 6 1725 NULL
94467 +tx_frag_called_read_1748 tx_frag_called_read 3 1748 NULL
94468 +compat_cdrom_generic_command_1756 compat_cdrom_generic_command 4 1756 NULL
94469 +ieee80211_new_mesh_header_1761 ieee80211_new_mesh_header 0 1761 NULL
94470 +ebt_size_mwt_1768 ebt_size_mwt 0 1768 NULL
94471 +cosa_write_1774 cosa_write 3 1774 NULL
94472 +update_macheader_1775 update_macheader 7 1775 NULL
94473 +fcoe_ctlr_device_add_1793 fcoe_ctlr_device_add 3 1793 NULL
94474 +__nodelist_scnprintf_1815 __nodelist_scnprintf 0-2-4 1815 NULL
94475 +alloc_pages_exact_1892 alloc_pages_exact 1 1892 NULL
94476 +rx_defrag_called_read_1897 rx_defrag_called_read 3 1897 NULL
94477 +nfs_parse_server_name_1899 nfs_parse_server_name 2 1899 NULL
94478 +tx_tx_retry_data_read_1926 tx_tx_retry_data_read 3 1926 NULL
94479 +memblock_alloc_base_1938 memblock_alloc_base 1-2 1938 NULL
94480 +cyttsp_probe_1940 cyttsp_probe 4 1940 NULL
94481 +ieee80211_if_fmt_dot11MeshConfirmTimeout_1945 ieee80211_if_fmt_dot11MeshConfirmTimeout 3 1945 NULL
94482 +read_swap_header_1957 read_swap_header 0 1957 NULL
94483 +ivtv_v4l2_read_1964 ivtv_v4l2_read 3 1964 NULL
94484 +sel_read_avc_hash_stats_1984 sel_read_avc_hash_stats 3 1984 NULL
94485 +__alloc_bootmem_node_1992 __alloc_bootmem_node 2-3 1992 NULL
94486 +atomic_read_unchecked_1995 atomic_read_unchecked 0 1995 NULL
94487 +batadv_tt_commit_changes_2008 batadv_tt_commit_changes 4 2008 NULL
94488 +sep_prepare_input_dma_table_2009 sep_prepare_input_dma_table 2-3 2009 NULL
94489 +rx_rx_defrag_read_2010 rx_rx_defrag_read 3 2010 NULL
94490 +ocfs2_global_qinit_alloc_2018 ocfs2_global_qinit_alloc 0 2018 NULL
94491 +write_flush_pipefs_2021 write_flush_pipefs 3 2021 NULL
94492 +BcmCopySection_2035 BcmCopySection 5 2035 NULL
94493 +devm_ioremap_nocache_2036 devm_ioremap_nocache 2-3 2036 NULL
94494 +ath6kl_fwlog_mask_read_2050 ath6kl_fwlog_mask_read 3 2050 NULL
94495 +ocfs2_expand_inline_dir_2063 ocfs2_expand_inline_dir 3 2063 NULL
94496 +subbuf_read_actor_2071 subbuf_read_actor 3 2071 NULL
94497 +iwl_dbgfs_current_sleep_command_read_2081 iwl_dbgfs_current_sleep_command_read 3 2081 NULL
94498 +idetape_chrdev_read_2097 idetape_chrdev_read 3 2097 NULL
94499 +audit_expand_2098 audit_expand 2 2098 NULL
94500 +num_pages_spanned_2105 num_pages_spanned 0 2105 NULL
94501 +iwl_dbgfs_log_event_read_2107 iwl_dbgfs_log_event_read 3 2107 NULL
94502 +ecryptfs_encrypt_and_encode_filename_2109 ecryptfs_encrypt_and_encode_filename 6 2109 NULL
94503 +__find_xattr_2117 __find_xattr 6 2117 NULL nohasharray
94504 +enable_read_2117 enable_read 3 2117 &__find_xattr_2117
94505 +pcf50633_write_block_2124 pcf50633_write_block 2-3 2124 NULL
94506 +check_load_and_stores_2143 check_load_and_stores 2 2143 NULL
94507 +lp_gpio_irq_map_2149 lp_gpio_irq_map 2 2149 NULL
94508 +mlx4_init_icm_table_2151 mlx4_init_icm_table 5-4 2151 NULL
94509 +iov_iter_count_2152 iov_iter_count 0 2152 NULL
94510 +_ore_get_io_state_2166 _ore_get_io_state 3-4-5 2166 NULL
94511 +ssb_bus_ssbbus_register_2217 ssb_bus_ssbbus_register 2 2217 NULL
94512 +u32_array_read_2219 u32_array_read 3 2219 NULL
94513 +vhci_write_2224 vhci_write 3 2224 NULL
94514 +efx_tsoh_page_count_2225 efx_tsoh_page_count 0 2225 NULL
94515 +lowpan_get_mac_header_length_2231 lowpan_get_mac_header_length 0 2231 NULL
94516 +ieee80211_if_read_dot11MeshHWMPRannInterval_2249 ieee80211_if_read_dot11MeshHWMPRannInterval 3 2249 NULL
94517 +netlbl_secattr_catmap_walk_2255 netlbl_secattr_catmap_walk 0-2 2255 NULL
94518 +sel_write_avc_cache_threshold_2256 sel_write_avc_cache_threshold 3 2256 NULL
94519 +do_update_counters_2259 do_update_counters 4 2259 NULL
94520 +ath6kl_wmi_bssinfo_event_rx_2275 ath6kl_wmi_bssinfo_event_rx 3 2275 NULL
94521 +debug_debug5_read_2291 debug_debug5_read 3 2291 NULL
94522 +kvm_clear_guest_page_2308 kvm_clear_guest_page 4-2 2308 NULL
94523 +intel_sdvo_set_value_2311 intel_sdvo_set_value 4 2311 NULL
94524 +picolcd_fb_write_2318 picolcd_fb_write 3 2318 NULL
94525 +gart_map_page_2325 gart_map_page 3-4 2325 NULL
94526 +__erst_read_to_erange_2341 __erst_read_to_erange 0 2341 NULL
94527 +zr364xx_read_2354 zr364xx_read 3 2354 NULL
94528 +viafb_iga2_odev_proc_write_2363 viafb_iga2_odev_proc_write 3 2363 NULL
94529 +xfs_buf_map_from_irec_2368 xfs_buf_map_from_irec 5 2368 NULL
94530 +il_dbgfs_sensitivity_read_2370 il_dbgfs_sensitivity_read 3 2370 NULL
94531 +rtl_port_map_2385 rtl_port_map 1-2 2385 NULL
94532 +rxpipe_rx_prep_beacon_drop_read_2403 rxpipe_rx_prep_beacon_drop_read 3 2403 NULL
94533 +isdn_v110_open_2418 isdn_v110_open 3 2418 NULL
94534 +raid1_size_2419 raid1_size 0-2 2419 NULL
94535 +roccat_common2_send_2422 roccat_common2_send 4 2422 NULL
94536 +hfcpci_empty_fifo_2427 hfcpci_empty_fifo 4 2427 NULL
94537 +ioremap_nocache_2439 ioremap_nocache 1-2 2439 NULL
94538 +tty_buffer_find_2443 tty_buffer_find 2 2443 NULL
94539 +ath6kl_usb_bmi_write_2454 ath6kl_usb_bmi_write 3 2454 NULL
94540 +b43legacy_debugfs_read_2473 b43legacy_debugfs_read 3 2473 NULL
94541 +update_pmkid_2481 update_pmkid 4 2481 NULL
94542 +wiphy_new_2482 wiphy_new 2 2482 NULL
94543 +bio_alloc_bioset_2484 bio_alloc_bioset 2 2484 NULL
94544 +lookup_cache_entry_2494 lookup_cache_entry 2 2494 NULL
94545 +squashfs_read_fragment_index_table_2506 squashfs_read_fragment_index_table 4 2506 NULL
94546 +dm_write_2513 dm_write 3 2513 NULL
94547 +v9fs_cached_file_read_2514 v9fs_cached_file_read 3 2514 NULL
94548 +ext4_get_inode_loc_2516 ext4_get_inode_loc 0 2516 NULL
94549 +gspca_dev_probe_2570 gspca_dev_probe 4 2570 NULL
94550 +i915_next_seqno_write_2572 i915_next_seqno_write 3 2572 NULL
94551 +pcm_sanity_check_2574 pcm_sanity_check 0 2574 NULL
94552 +smk_write_logging_2618 smk_write_logging 3 2618 NULL
94553 +kvm_gfn_to_hva_cache_init_2636 kvm_gfn_to_hva_cache_init 3 2636 NULL
94554 +lro_gen_skb_2644 lro_gen_skb 6 2644 NULL
94555 +nfc_llcp_send_ui_frame_2702 nfc_llcp_send_ui_frame 5 2702 NULL
94556 +memcpy_fromiovecend_2707 memcpy_fromiovecend 3-4 2707 NULL
94557 +__xip_file_write_2733 __xip_file_write 4-3 2733 NULL
94558 +hid_report_raw_event_2762 hid_report_raw_event 4 2762 NULL
94559 +mon_bin_ioctl_2771 mon_bin_ioctl 3 2771 NULL
94560 +__next_cpu_2782 __next_cpu 1 2782 NULL
94561 +set_msr_hyperv_pw_2785 set_msr_hyperv_pw 3 2785 NULL
94562 +sel_read_enforce_2828 sel_read_enforce 3 2828 NULL
94563 +vb2_dc_get_userptr_2829 vb2_dc_get_userptr 2-3 2829 NULL
94564 +wait_for_avail_2847 wait_for_avail 0 2847 NULL
94565 +ufs_free_fragments_2857 ufs_free_fragments 2 2857 NULL
94566 +sfq_alloc_2861 sfq_alloc 1 2861 NULL
94567 +move_addr_to_user_2868 move_addr_to_user 2 2868 NULL
94568 +mq_map_2871 mq_map 2 2871 NULL
94569 +nla_padlen_2883 nla_padlen 1 2883 NULL
94570 +cmm_write_2896 cmm_write 3 2896 NULL
94571 +alloc_page_cgroup_2919 alloc_page_cgroup 1 2919 NULL
94572 +xfs_trans_get_buf_map_2927 xfs_trans_get_buf_map 4 2927 NULL
94573 +nes_read_indexed_2946 nes_read_indexed 0 2946 NULL
94574 +tm6000_i2c_recv_regs16_2949 tm6000_i2c_recv_regs16 5 2949 NULL
94575 +ppp_cp_event_2965 ppp_cp_event 6 2965 NULL
94576 +do_strnlen_user_2976 do_strnlen_user 0-2 2976 NULL
94577 +p9_nr_pages_2992 p9_nr_pages 0-2 2992 NULL
94578 +do_dmabuf_dirty_sou_3017 do_dmabuf_dirty_sou 7 3017 NULL
94579 +depth_write_3021 depth_write 3 3021 NULL
94580 +snd_azf3328_codec_inl_3022 snd_azf3328_codec_inl 0 3022 NULL
94581 +xfrm_dst_alloc_copy_3034 xfrm_dst_alloc_copy 3 3034 NULL
94582 +iwl_dbgfs_sleep_level_override_read_3038 iwl_dbgfs_sleep_level_override_read 3 3038 NULL
94583 +nr_free_buffer_pages_3044 nr_free_buffer_pages 0 3044 NULL
94584 +il3945_ucode_rx_stats_read_3048 il3945_ucode_rx_stats_read 3 3048 NULL
94585 +qp_alloc_ppn_set_3068 qp_alloc_ppn_set 2-4 3068 NULL
94586 +__blk_end_bidi_request_3070 __blk_end_bidi_request 3-4 3070 NULL
94587 +dac960_user_command_proc_write_3071 dac960_user_command_proc_write 3 3071 NULL
94588 +free_coherent_3082 free_coherent 4-2 3082 NULL
94589 +clone_bio_3100 clone_bio 6 3100 NULL nohasharray
94590 +ttusb2_msg_3100 ttusb2_msg 4 3100 &clone_bio_3100
94591 +rb_alloc_3102 rb_alloc 1 3102 NULL
94592 +simple_write_to_buffer_3122 simple_write_to_buffer 5-2 3122 NULL
94593 +print_time_3132 print_time 0 3132 NULL
94594 +fill_write_buffer_3142 fill_write_buffer 3 3142 NULL
94595 +CIFSSMBSetPosixACL_3154 CIFSSMBSetPosixACL 5 3154 NULL
94596 +compat_sys_migrate_pages_3157 compat_sys_migrate_pages 2 3157 NULL
94597 +uv_num_possible_blades_3177 uv_num_possible_blades 0 3177 NULL
94598 +uvc_video_stats_dump_3181 uvc_video_stats_dump 3 3181 NULL
94599 +compat_do_ip6t_set_ctl_3184 compat_do_ip6t_set_ctl 4 3184 NULL
94600 +mempool_create_node_3191 mempool_create_node 1 3191 NULL
94601 +alloc_context_3194 alloc_context 1 3194 NULL
94602 +shmem_pread_slow_3198 shmem_pread_slow 3 3198 NULL
94603 +kimage_crash_alloc_3233 kimage_crash_alloc 3 3233 NULL
94604 +do_read_log_to_user_3236 do_read_log_to_user 4 3236 NULL
94605 +ext3_xattr_find_entry_3237 ext3_xattr_find_entry 0 3237 NULL
94606 +key_key_read_3241 key_key_read 3 3241 NULL
94607 +number_3243 number 0 3243 NULL
94608 +check_vendor_extension_3254 check_vendor_extension 1 3254 NULL
94609 +__ilog2_u64_3284 __ilog2_u64 0 3284 NULL
94610 +arvo_sysfs_write_3311 arvo_sysfs_write 6 3311 NULL
94611 +dbDiscardAG_3322 dbDiscardAG 3 3322 NULL
94612 +compat_sys_setsockopt_3326 compat_sys_setsockopt 5 3326 NULL
94613 +aac_rkt_ioremap_3333 aac_rkt_ioremap 2 3333 NULL
94614 +read_from_oldmem_3337 read_from_oldmem 2 3337 NULL
94615 +tty_port_register_device_attr_3341 tty_port_register_device_attr 3 3341 NULL
94616 +il_dbgfs_interrupt_read_3351 il_dbgfs_interrupt_read 3 3351 NULL
94617 +gsm_control_rls_3353 gsm_control_rls 3 3353 NULL
94618 +scnprintf_3360 scnprintf 0-2 3360 NULL
94619 +x86_emulate_instruction_3389 x86_emulate_instruction 2 3389 NULL
94620 +mtdchar_writeoob_3393 mtdchar_writeoob 4 3393 NULL
94621 +send_stream_3397 send_stream 4 3397 NULL
94622 +isdn_readbchan_3401 isdn_readbchan 0-5 3401 NULL
94623 +msix_map_region_3411 msix_map_region 3 3411 NULL
94624 +mei_io_cb_alloc_resp_buf_3414 mei_io_cb_alloc_resp_buf 2 3414 NULL
94625 +pci_add_cap_save_buffer_3426 pci_add_cap_save_buffer 3 3426 NULL
94626 +crystalhd_create_dio_pool_3427 crystalhd_create_dio_pool 2 3427 NULL
94627 +pipe_iov_copy_to_user_3447 pipe_iov_copy_to_user 3 3447 NULL
94628 +percpu_modalloc_3448 percpu_modalloc 2-3 3448 NULL
94629 +map_single_3449 map_single 0-2 3449 NULL
94630 +jffs2_acl_setxattr_3464 jffs2_acl_setxattr 4 3464 NULL nohasharray
94631 +snd_pcm_lib_readv_transfer_3464 snd_pcm_lib_readv_transfer 4-2-5 3464 &jffs2_acl_setxattr_3464
94632 +alloc_skb_fclone_3467 alloc_skb_fclone 1 3467 NULL
94633 +security_context_to_sid_default_3492 security_context_to_sid_default 2 3492 NULL
94634 +xfrm_migrate_msgsize_3496 xfrm_migrate_msgsize 1 3496 NULL
94635 +kvm_handle_bad_page_3503 kvm_handle_bad_page 2 3503 NULL
94636 +mem_tx_free_mem_blks_read_3521 mem_tx_free_mem_blks_read 3 3521 NULL nohasharray
94637 +ieee80211_wx_set_gen_ie_rsl_3521 ieee80211_wx_set_gen_ie_rsl 3 3521 &mem_tx_free_mem_blks_read_3521
94638 +btrfs_dir_name_len_3549 btrfs_dir_name_len 0 3549 NULL
94639 +b43legacy_read16_3561 b43legacy_read16 0 3561 NULL
94640 +alloc_smp_resp_3566 alloc_smp_resp 1 3566 NULL
94641 +evtchn_read_3569 evtchn_read 3 3569 NULL
94642 +vc_resize_3585 vc_resize 2-3 3585 NULL
94643 +compat_sys_semtimedop_3606 compat_sys_semtimedop 3 3606 NULL
94644 +sctp_getsockopt_events_3607 sctp_getsockopt_events 2 3607 NULL
94645 +edac_mc_alloc_3611 edac_mc_alloc 4 3611 NULL
94646 +tx_tx_starts_read_3617 tx_tx_starts_read 3 3617 NULL
94647 +aligned_kmalloc_3628 aligned_kmalloc 1 3628 NULL
94648 +cm_copy_private_data_3649 cm_copy_private_data 2 3649 NULL
94649 +ath6kl_disconnect_timeout_read_3650 ath6kl_disconnect_timeout_read 3 3650 NULL
94650 +i915_compat_ioctl_3656 i915_compat_ioctl 2 3656 NULL
94651 +create_irq_3703 create_irq 0 3703 NULL nohasharray
94652 +btmrvl_psmode_write_3703 btmrvl_psmode_write 3 3703 &create_irq_3703 nohasharray
94653 +snd_m3_assp_read_3703 snd_m3_assp_read 0 3703 &btmrvl_psmode_write_3703
94654 +videobuf_pages_to_sg_3708 videobuf_pages_to_sg 2 3708 NULL
94655 +ci_ll_write_3740 ci_ll_write 4 3740 NULL nohasharray
94656 +ath6kl_mgmt_tx_3740 ath6kl_mgmt_tx 7 3740 &ci_ll_write_3740
94657 +sctp_setsockopt_auth_key_3793 sctp_setsockopt_auth_key 3 3793 NULL
94658 +ncp_file_write_3813 ncp_file_write 3 3813 NULL
94659 +read_file_tx_chainmask_3829 read_file_tx_chainmask 3 3829 NULL
94660 +stringify_nodemap_3842 stringify_nodemap 2 3842 NULL
94661 +ubi_eba_read_leb_3847 ubi_eba_read_leb 0 3847 NULL
94662 +create_one_cdev_3852 create_one_cdev 2 3852 NULL
94663 +smk_read_onlycap_3855 smk_read_onlycap 3 3855 NULL
94664 +get_fd_set_3866 get_fd_set 1 3866 NULL
94665 +garp_attr_create_3883 garp_attr_create 3 3883 NULL
94666 +uea_send_modem_cmd_3888 uea_send_modem_cmd 3 3888 NULL
94667 +efivarfs_file_read_3893 efivarfs_file_read 3 3893 NULL
94668 +nvram_write_3894 nvram_write 3 3894 NULL
94669 +pipeline_pre_proc_swi_read_3898 pipeline_pre_proc_swi_read 3 3898 NULL
94670 +comedi_buf_read_n_available_3899 comedi_buf_read_n_available 0 3899 NULL
94671 +vcs_write_3910 vcs_write 3 3910 NULL
94672 +atalk_compat_ioctl_3991 atalk_compat_ioctl 3 3991 NULL
94673 +do_add_counters_3992 do_add_counters 3 3992 NULL
94674 +userspace_status_4004 userspace_status 4 4004 NULL
94675 +mei_write_4005 mei_write 3 4005 NULL nohasharray
94676 +xfs_check_block_4005 xfs_check_block 4 4005 &mei_write_4005
94677 +snd_hdsp_capture_copy_4011 snd_hdsp_capture_copy 5 4011 NULL
94678 +mm_populate_4016 mm_populate 1 4016 NULL
94679 +blk_end_request_4024 blk_end_request 3 4024 NULL
94680 +ext4_xattr_find_entry_4025 ext4_xattr_find_entry 0 4025 NULL
94681 +usbnet_write_cmd_async_4035 usbnet_write_cmd_async 7 4035 NULL
94682 +read_file_queues_4078 read_file_queues 3 4078 NULL
94683 +fbcon_do_set_font_4079 fbcon_do_set_font 2-3 4079 NULL
94684 +da9052_free_irq_4090 da9052_free_irq 2 4090 NULL
94685 +ntb_netdev_change_mtu_4147 ntb_netdev_change_mtu 2 4147 NULL
94686 +tm6000_read_4151 tm6000_read 3 4151 NULL
94687 +mpt_raid_phys_disk_get_num_paths_4155 mpt_raid_phys_disk_get_num_paths 0 4155 NULL
94688 +msg_bits_4158 msg_bits 0-3-4 4158 NULL
94689 +get_alua_req_4166 get_alua_req 3 4166 NULL
94690 +blk_dropped_read_4168 blk_dropped_read 3 4168 NULL
94691 +read_file_bool_4180 read_file_bool 3 4180 NULL
94692 +f1x_determine_channel_4202 f1x_determine_channel 2 4202 NULL
94693 +_osd_req_list_objects_4204 _osd_req_list_objects 6 4204 NULL
94694 +__snd_gf1_read_addr_4210 __snd_gf1_read_addr 0 4210 NULL
94695 +goldfish_audio_write_4284 goldfish_audio_write 3 4284 NULL
94696 +paging32_page_fault_4288 paging32_page_fault 2 4288 NULL
94697 +xt_compat_add_offset_4289 xt_compat_add_offset 0 4289 NULL
94698 +__usbnet_read_cmd_4299 __usbnet_read_cmd 7 4299 NULL
94699 +dvb_ringbuffer_pkt_read_user_4303 dvb_ringbuffer_pkt_read_user 3-2-5 4303 NULL
94700 +nouveau_fifo_create__4327 nouveau_fifo_create_ 5-6 4327 NULL
94701 +snd_rawmidi_kernel_read_4328 snd_rawmidi_kernel_read 3 4328 NULL
94702 +__copy_from_user_inatomic_4365 __copy_from_user_inatomic 3 4365 NULL
94703 +sys_setdomainname_4373 sys_setdomainname 2 4373 NULL
94704 +irda_sendmsg_4388 irda_sendmsg 4 4388 NULL
94705 +access_process_vm_4412 access_process_vm 0-2-4 4412 NULL nohasharray
94706 +cxacru_cm_get_array_4412 cxacru_cm_get_array 4 4412 &access_process_vm_4412
94707 +libfc_vport_create_4415 libfc_vport_create 2 4415 NULL
94708 +do_pages_stat_4437 do_pages_stat 2 4437 NULL
94709 +memparse_4444 memparse 0 4444 NULL
94710 +at76_set_card_command_4471 at76_set_card_command 4 4471 NULL
94711 +snd_seq_expand_var_event_4481 snd_seq_expand_var_event 0-5 4481 NULL
94712 +sys_semtimedop_4486 sys_semtimedop 3 4486 NULL
94713 +vmbus_establish_gpadl_4495 vmbus_establish_gpadl 3 4495 NULL
94714 +set_link_security_4502 set_link_security 4 4502 NULL
94715 +dm_cache_remove_mapping_4513 dm_cache_remove_mapping 2 4513 NULL
94716 +__gfn_to_pfn_memslot_4530 __gfn_to_pfn_memslot 2 4530 NULL
94717 +sys_llistxattr_4532 sys_llistxattr 3 4532 NULL
94718 +da9052_group_write_4534 da9052_group_write 2-3 4534 NULL
94719 +tty_register_device_4544 tty_register_device 2 4544 NULL
94720 +videobuf_vmalloc_to_sg_4548 videobuf_vmalloc_to_sg 2 4548 NULL
94721 +btrfs_file_extent_inline_item_len_4575 btrfs_file_extent_inline_item_len 0 4575 NULL
94722 +xfs_buf_get_maps_4581 xfs_buf_get_maps 2 4581 NULL
94723 +bch_alloc_4593 bch_alloc 1 4593 NULL
94724 +__wb_force_remove_mapping_4622 __wb_force_remove_mapping 2 4622 NULL
94725 +iwl_dbgfs_tx_queue_read_4635 iwl_dbgfs_tx_queue_read 3 4635 NULL
94726 +skb_add_data_nocache_4682 skb_add_data_nocache 4 4682 NULL
94727 +cx18_read_pos_4683 cx18_read_pos 3 4683 NULL
94728 +short_retry_limit_read_4687 short_retry_limit_read 3 4687 NULL
94729 +kone_receive_4690 kone_receive 4 4690 NULL
94730 +round_pipe_size_4701 round_pipe_size 0 4701 NULL
94731 +cxgbi_alloc_big_mem_4707 cxgbi_alloc_big_mem 1 4707 NULL
94732 +btmrvl_gpiogap_read_4718 btmrvl_gpiogap_read 3 4718 NULL
94733 +ati_create_gatt_pages_4722 ati_create_gatt_pages 1 4722 NULL nohasharray
94734 +show_header_4722 show_header 3 4722 &ati_create_gatt_pages_4722
94735 +__find_free_cblock_4741 __find_free_cblock 2 4741 NULL
94736 +memblock_find_in_range_4759 memblock_find_in_range 3-4 4759 NULL
94737 +pwr_rcvd_bcns_cnt_read_4774 pwr_rcvd_bcns_cnt_read 3 4774 NULL
94738 +create_subvol_4791 create_subvol 4 4791 NULL
94739 +ncp__vol2io_4804 ncp__vol2io 5 4804 NULL
94740 +repair_io_failure_4815 repair_io_failure 4 4815 NULL
94741 +gigaset_if_receive_4861 gigaset_if_receive 3 4861 NULL
94742 +key_tx_spec_read_4862 key_tx_spec_read 3 4862 NULL
94743 +ocfs2_defrag_extent_4873 ocfs2_defrag_extent 3 4873 NULL
94744 +hid_register_field_4874 hid_register_field 2-3 4874 NULL
94745 +vga_arb_read_4886 vga_arb_read 3 4886 NULL
94746 +sys_ipc_4889 sys_ipc 3 4889 NULL
94747 +sys_process_vm_writev_4928 sys_process_vm_writev 3-5 4928 NULL
94748 +ntfs_rl_insert_4931 ntfs_rl_insert 2-4 4931 NULL
94749 +ieee80211_if_fmt_ave_beacon_4941 ieee80211_if_fmt_ave_beacon 3 4941 NULL
94750 +devm_kzalloc_4966 devm_kzalloc 2 4966 NULL
94751 +compat_rawv6_setsockopt_4967 compat_rawv6_setsockopt 5 4967 NULL
94752 +skb_network_header_len_4971 skb_network_header_len 0 4971 NULL
94753 +ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval_4976 ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval 3 4976 NULL
94754 +vmw_surface_define_size_4993 vmw_surface_define_size 0 4993 NULL
94755 +qla82xx_pci_mem_write_direct_5008 qla82xx_pci_mem_write_direct 2 5008 NULL
94756 +do_mincore_5018 do_mincore 0-1 5018 NULL
94757 +mtd_device_parse_register_5024 mtd_device_parse_register 5 5024 NULL
94758 +ocfs2_check_range_for_holes_5066 ocfs2_check_range_for_holes 2-3 5066 NULL
94759 +snd_mixart_BA1_read_5082 snd_mixart_BA1_read 5 5082 NULL
94760 +snd_emu10k1_ptr20_read_5087 snd_emu10k1_ptr20_read 0 5087 NULL
94761 +get_random_bytes_5091 get_random_bytes 2 5091 NULL nohasharray
94762 +kfifo_copy_from_user_5091 kfifo_copy_from_user 3 5091 &get_random_bytes_5091 nohasharray
94763 +blk_rq_sectors_5091 blk_rq_sectors 0 5091 &kfifo_copy_from_user_5091
94764 +mpol_to_str_5093 mpol_to_str 2 5093 NULL
94765 +sound_write_5102 sound_write 3 5102 NULL
94766 +clear_dirty_5105 clear_dirty 3 5105 NULL
94767 +ufs_add_fragments_5144 ufs_add_fragments 2 5144 NULL
94768 +compat_ptr_5159 compat_ptr 0-1 5159 NULL
94769 +__uwb_addr_print_5161 __uwb_addr_print 2 5161 NULL
94770 +iwl_dbgfs_status_read_5171 iwl_dbgfs_status_read 3 5171 NULL
94771 +acpi_pcc_get_sqty_5176 acpi_pcc_get_sqty 0 5176 NULL
94772 +sfi_map_memory_5183 sfi_map_memory 1-2 5183 NULL
94773 +skb_network_header_5203 skb_network_header 0 5203 NULL
94774 +pipe_set_size_5204 pipe_set_size 2 5204 NULL
94775 +ppp_cp_parse_cr_5214 ppp_cp_parse_cr 4 5214 NULL
94776 +ath6kl_debug_roam_tbl_event_5224 ath6kl_debug_roam_tbl_event 3 5224 NULL
94777 +ssb_ioremap_5228 ssb_ioremap 2 5228 NULL
94778 +isdn_ppp_skb_push_5236 isdn_ppp_skb_push 2 5236 NULL
94779 +do_atmif_sioc_5247 do_atmif_sioc 3 5247 NULL
94780 +gfn_to_hva_memslot_5265 gfn_to_hva_memslot 2 5265 NULL
94781 +alloc_cache_blocks_with_hash_5285 alloc_cache_blocks_with_hash 2 5285 NULL
94782 +__gfn_to_hva_memslot_5304 __gfn_to_hva_memslot 0-2 5304 NULL
94783 +sbc_get_write_same_sectors_5317 sbc_get_write_same_sectors 0 5317 NULL
94784 +pwr_elp_enter_read_5324 pwr_elp_enter_read 3 5324 NULL
94785 +allocate_cnodes_5329 allocate_cnodes 1 5329 NULL
94786 +ps_pspoll_utilization_read_5361 ps_pspoll_utilization_read 3 5361 NULL
94787 +cciss_allocate_sg_chain_blocks_5368 cciss_allocate_sg_chain_blocks 3-2 5368 NULL
94788 +kvm_pin_pages_5369 kvm_pin_pages 2 5369 NULL
94789 +bitmap_fold_5396 bitmap_fold 4 5396 NULL
94790 +nilfs_palloc_entries_per_group_5418 nilfs_palloc_entries_per_group 0 5418 NULL
94791 +sfi_map_table_5462 sfi_map_table 1 5462 NULL
94792 +xfs_efd_init_5463 xfs_efd_init 3 5463 NULL
94793 +xfs_efi_init_5476 xfs_efi_init 2 5476 NULL
94794 +ubi_leb_write_5478 ubi_leb_write 4-5 5478 NULL
94795 +cifs_security_flags_proc_write_5484 cifs_security_flags_proc_write 3 5484 NULL
94796 +tty_write_5494 tty_write 3 5494 NULL
94797 +tomoyo_update_domain_5498 tomoyo_update_domain 2 5498 NULL nohasharray
94798 +ieee80211_if_fmt_last_beacon_5498 ieee80211_if_fmt_last_beacon 3 5498 &tomoyo_update_domain_5498
94799 +__max_nr_grant_frames_5505 __max_nr_grant_frames 0 5505 NULL
94800 +spidev_message_5518 spidev_message 3 5518 NULL
94801 +ieee80211_if_fmt_auto_open_plinks_5534 ieee80211_if_fmt_auto_open_plinks 3 5534 NULL
94802 +brcmu_pkt_buf_get_skb_5556 brcmu_pkt_buf_get_skb 1 5556 NULL
94803 +le_readq_5557 le_readq 0 5557 NULL
94804 +inw_5558 inw 0 5558 NULL
94805 +fir16_create_5574 fir16_create 3 5574 NULL
94806 +bioset_create_5580 bioset_create 1 5580 NULL
94807 +oz_ep_alloc_5587 oz_ep_alloc 2 5587 NULL
94808 +usb_dump_device_descriptor_5599 usb_dump_device_descriptor 0 5599 NULL
94809 +ldm_frag_add_5611 ldm_frag_add 2 5611 NULL
94810 +compat_copy_entries_5617 compat_copy_entries 0 5617 NULL
94811 +ext4_xattr_get_5661 ext4_xattr_get 0 5661 NULL
94812 +posix_clock_register_5662 posix_clock_register 2 5662 NULL
94813 +mthca_map_reg_5664 mthca_map_reg 2-3 5664 NULL
94814 +__videobuf_alloc_vb_5665 __videobuf_alloc_vb 1 5665 NULL
94815 +wb_clear_dirty_5684 wb_clear_dirty 2 5684 NULL
94816 +get_arg_5694 get_arg 3 5694 NULL
94817 +vmw_kms_readback_5727 vmw_kms_readback 6 5727 NULL
94818 +reexecute_instruction_5733 reexecute_instruction 2 5733 NULL
94819 +rts51x_transfer_data_partial_5735 rts51x_transfer_data_partial 6 5735 NULL
94820 +ubi_cdev_compat_ioctl_5746 ubi_cdev_compat_ioctl 3 5746 NULL
94821 +sctp_setsockopt_autoclose_5775 sctp_setsockopt_autoclose 3 5775 NULL
94822 +compat_sys_writev_5784 compat_sys_writev 3 5784 NULL
94823 +__vxge_hw_blockpool_malloc_5786 __vxge_hw_blockpool_malloc 2 5786 NULL
94824 +skb_copy_datagram_iovec_5806 skb_copy_datagram_iovec 2-4 5806 NULL
94825 +nv50_disp_pioc_create__5812 nv50_disp_pioc_create_ 5 5812 NULL
94826 +ceph_x_encrypt_buflen_5829 ceph_x_encrypt_buflen 0-1 5829 NULL
94827 +autofs4_root_compat_ioctl_5838 autofs4_root_compat_ioctl 3 5838 NULL
94828 +ceph_msg_new_5846 ceph_msg_new 2 5846 NULL
94829 +ixgb_check_copybreak_5847 ixgb_check_copybreak 3 5847 NULL
94830 +setup_req_5848 setup_req 3 5848 NULL
94831 +rx_filter_max_arp_queue_dep_read_5851 rx_filter_max_arp_queue_dep_read 3 5851 NULL
94832 +compat_sys_move_pages_5861 compat_sys_move_pages 2 5861 NULL nohasharray
94833 +uinput_compat_ioctl_5861 uinput_compat_ioctl 3 5861 &compat_sys_move_pages_5861
94834 +paging64_walk_addr_5887 paging64_walk_addr 3 5887 NULL
94835 +port_show_regs_5904 port_show_regs 3 5904 NULL
94836 +uhci_debug_read_5911 uhci_debug_read 3 5911 NULL
94837 +qla82xx_pci_mem_read_2M_5912 qla82xx_pci_mem_read_2M 2 5912 NULL
94838 +ttm_bo_kmap_ttm_5922 ttm_bo_kmap_ttm 3 5922 NULL
94839 +lbs_highsnr_read_5931 lbs_highsnr_read 3 5931 NULL
94840 +ps_poll_ps_poll_timeouts_read_5934 ps_poll_ps_poll_timeouts_read 3 5934 NULL
94841 +edac_device_alloc_ctl_info_5941 edac_device_alloc_ctl_info 1 5941 NULL
94842 +tipc_subseq_alloc_5957 tipc_subseq_alloc 1 5957 NULL
94843 +__apu_get_register_5967 __apu_get_register 0 5967 NULL
94844 +ieee80211_if_fmt_rc_rateidx_mask_5ghz_5971 ieee80211_if_fmt_rc_rateidx_mask_5ghz 3 5971 NULL
94845 +native_pte_val_5978 native_pte_val 0 5978 NULL
94846 +ntfs_rl_append_6037 ntfs_rl_append 2-4 6037 NULL
94847 +da9052_request_irq_6058 da9052_request_irq 2 6058 NULL
94848 +sctp_setsockopt_connectx_6073 sctp_setsockopt_connectx 3 6073 NULL
94849 +rts51x_ms_rw_multi_sector_6076 rts51x_ms_rw_multi_sector 3-4 6076 NULL
94850 +ipmi_addr_length_6110 ipmi_addr_length 0 6110 NULL
94851 +dfs_global_file_write_6112 dfs_global_file_write 3 6112 NULL
94852 +matrix_keypad_build_keymap_6129 matrix_keypad_build_keymap 3 6129 NULL
94853 +nouveau_parent_create__6131 nouveau_parent_create_ 7 6131 NULL
94854 +ivtv_copy_buf_to_user_6159 ivtv_copy_buf_to_user 4 6159 NULL
94855 +vdma_mem_alloc_6171 vdma_mem_alloc 1 6171 NULL
94856 +wl1251_cmd_template_set_6172 wl1251_cmd_template_set 4 6172 NULL
94857 +paging64_walk_addr_generic_6180 paging64_walk_addr_generic 4 6180 NULL
94858 +qp_host_get_user_memory_6189 qp_host_get_user_memory 1-2 6189 NULL
94859 +mxt_show_instance_6207 mxt_show_instance 2-0 6207 NULL
94860 +v4l2_ctrl_new_std_menu_6221 v4l2_ctrl_new_std_menu 4 6221 NULL
94861 +mqueue_read_file_6228 mqueue_read_file 3 6228 NULL
94862 +f_hidg_read_6238 f_hidg_read 3 6238 NULL
94863 +fbcon_prepare_logo_6246 fbcon_prepare_logo 5 6246 NULL
94864 +pcpu_next_pop_6277 pcpu_next_pop 4 6277 NULL
94865 +tx_tx_start_null_frame_read_6281 tx_tx_start_null_frame_read 3 6281 NULL
94866 +snd_hda_override_conn_list_6282 snd_hda_override_conn_list 3 6282 NULL nohasharray
94867 +xenbus_file_write_6282 xenbus_file_write 3 6282 &snd_hda_override_conn_list_6282
94868 +posix_acl_fix_xattr_to_user_6283 posix_acl_fix_xattr_to_user 2 6283 NULL
94869 +paging64_gva_to_gpa_nested_6287 paging64_gva_to_gpa_nested 2 6287 NULL
94870 +nf_nat_ipv6_manip_pkt_6289 nf_nat_ipv6_manip_pkt 2 6289 NULL
94871 +nf_nat_sack_adjust_6297 nf_nat_sack_adjust 2 6297 NULL
94872 +mid_get_vbt_data_r10_6308 mid_get_vbt_data_r10 2 6308 NULL
94873 +ucs2_strnlen_6342 ucs2_strnlen 0 6342 NULL
94874 +_proc_do_string_6376 _proc_do_string 2 6376 NULL
94875 +osd_req_read_sg_kern_6378 osd_req_read_sg_kern 5 6378 NULL
94876 +posix_acl_fix_xattr_userns_6420 posix_acl_fix_xattr_userns 4 6420 NULL
94877 +ipr_change_queue_depth_6431 ipr_change_queue_depth 2 6431 NULL
94878 +__alloc_bootmem_node_nopanic_6432 __alloc_bootmem_node_nopanic 2-3 6432 NULL
94879 +paging32_gva_to_gpa_nested_6442 paging32_gva_to_gpa_nested 2 6442 NULL
94880 +mlx4_ib_reg_user_mr_6471 mlx4_ib_reg_user_mr 2-3 6471 NULL nohasharray
94881 +ext4_compat_ioctl_6471 ext4_compat_ioctl 3 6471 &mlx4_ib_reg_user_mr_6471
94882 +ieee80211_if_fmt_dot11MeshMaxRetries_6476 ieee80211_if_fmt_dot11MeshMaxRetries 3 6476 NULL
94883 +qp_memcpy_from_queue_6479 qp_memcpy_from_queue 4-5 6479 NULL
94884 +cipso_v4_map_lvl_hton_6490 cipso_v4_map_lvl_hton 0 6490 NULL
94885 +dbg_intr_buf_6501 dbg_intr_buf 2 6501 NULL
94886 +mei_read_6507 mei_read 3 6507 NULL
94887 +read_file_disable_ani_6536 read_file_disable_ani 3 6536 NULL
94888 +rndis_set_oid_6547 rndis_set_oid 4 6547 NULL
94889 +wdm_read_6549 wdm_read 3 6549 NULL
94890 +fb_alloc_cmap_6554 fb_alloc_cmap 2 6554 NULL
94891 +snmp_mib_init_6604 snmp_mib_init 2-3 6604 NULL
94892 +ecryptfs_filldir_6622 ecryptfs_filldir 3 6622 NULL
94893 +virtscsi_alloc_tgt_6643 virtscsi_alloc_tgt 2 6643 NULL
94894 +aac_srcv_ioremap_6659 aac_srcv_ioremap 2 6659 NULL
94895 +process_rcvd_data_6679 process_rcvd_data 3 6679 NULL
94896 +ql_process_mac_rx_skb_6689 ql_process_mac_rx_skb 4 6689 NULL
94897 +btrfs_lookup_csums_range_6696 btrfs_lookup_csums_range 2 6696 NULL
94898 +ps_pspoll_max_apturn_read_6699 ps_pspoll_max_apturn_read 3 6699 NULL
94899 +bnad_debugfs_write_regrd_6706 bnad_debugfs_write_regrd 3 6706 NULL
94900 +mpeg_read_6708 mpeg_read 3 6708 NULL
94901 +set_orig_insn_6712 set_orig_insn 3 6712 NULL
94902 +video_proc_write_6724 video_proc_write 3 6724 NULL
94903 +posix_acl_xattr_count_6725 posix_acl_xattr_count 0-1 6725 NULL
94904 +rds_rdma_pages_6735 rds_rdma_pages 0 6735 NULL
94905 +sfi_check_table_6772 sfi_check_table 1 6772 NULL
94906 +iwl_dbgfs_channels_read_6784 iwl_dbgfs_channels_read 3 6784 NULL
94907 +ieee80211_if_read_6785 ieee80211_if_read 3 6785 NULL
94908 +hdlcdrv_register_6792 hdlcdrv_register 2 6792 NULL
94909 +tx_tx_done_data_read_6799 tx_tx_done_data_read 3 6799 NULL
94910 +make_8259A_irq_6828 make_8259A_irq 1 6828 NULL
94911 +calc_pages_for_6838 calc_pages_for 0-1-2 6838 NULL
94912 +mon_bin_read_6841 mon_bin_read 3 6841 NULL
94913 +snd_cs4281_BA0_read_6847 snd_cs4281_BA0_read 5 6847 NULL
94914 +ieee80211_if_fmt_path_refresh_time_6888 ieee80211_if_fmt_path_refresh_time 3 6888 NULL nohasharray
94915 +raw_seticmpfilter_6888 raw_seticmpfilter 3 6888 &ieee80211_if_fmt_path_refresh_time_6888
94916 +dlmfs_file_write_6892 dlmfs_file_write 3 6892 NULL
94917 +spi_show_regs_6911 spi_show_regs 3 6911 NULL nohasharray
94918 +proc_sessionid_read_6911 proc_sessionid_read 3 6911 &spi_show_regs_6911 nohasharray
94919 +acm_alloc_minor_6911 acm_alloc_minor 0 6911 &proc_sessionid_read_6911
94920 +__kfifo_dma_in_finish_r_6913 __kfifo_dma_in_finish_r 2-3 6913 NULL
94921 +do_msgrcv_6921 do_msgrcv 3 6921 NULL
94922 +cache_do_downcall_6926 cache_do_downcall 3 6926 NULL
94923 +qsfp_cks_6945 qsfp_cks 0-2 6945 NULL
94924 +pch_uart_hal_read_6961 pch_uart_hal_read 0 6961 NULL
94925 +videobuf_dma_init_kernel_6963 videobuf_dma_init_kernel 3 6963 NULL
94926 +rsa_extract_mpi_6973 rsa_extract_mpi 5 6973 NULL
94927 +crypto_authenc_esn_setkey_6985 crypto_authenc_esn_setkey 3 6985 NULL
94928 +request_key_async_6990 request_key_async 4 6990 NULL
94929 +r871x_set_wpa_ie_7000 r871x_set_wpa_ie 3 7000 NULL
94930 +cipso_v4_gentag_enum_7006 cipso_v4_gentag_enum 0 7006 NULL
94931 +tracing_cpumask_read_7010 tracing_cpumask_read 3 7010 NULL
94932 +wimax_msg_7030 wimax_msg 4 7030 NULL
94933 +ipath_get_base_info_7043 ipath_get_base_info 3 7043 NULL
94934 +snd_pcm_oss_bytes_7051 snd_pcm_oss_bytes 2 7051 NULL
94935 +event_enable_read_7074 event_enable_read 3 7074 NULL
94936 +beacon_interval_read_7091 beacon_interval_read 3 7091 NULL
94937 +lp_compat_ioctl_7098 lp_compat_ioctl 3 7098 NULL
94938 +pipeline_enc_rx_stat_fifo_int_read_7107 pipeline_enc_rx_stat_fifo_int_read 3 7107 NULL
94939 +check_header_7108 check_header 0 7108 NULL
94940 +qlcnic_enable_msix_7144 qlcnic_enable_msix 2 7144 NULL
94941 +__alloc_objio_seg_7203 __alloc_objio_seg 1 7203 NULL
94942 +sys32_ipc_7238 sys32_ipc 3-5-6 7238 NULL
94943 +get_param_h_7247 get_param_h 0 7247 NULL
94944 +af_alg_make_sg_7254 af_alg_make_sg 3 7254 NULL
94945 +vm_mmap_pgoff_7259 vm_mmap_pgoff 0 7259 NULL
94946 +dma_ops_alloc_addresses_7272 dma_ops_alloc_addresses 3-4-5 7272 NULL
94947 +rx_rate_rx_frames_per_rates_read_7282 rx_rate_rx_frames_per_rates_read 3 7282 NULL
94948 +wb_remove_mapping_7307 wb_remove_mapping 2 7307 NULL
94949 +mgmt_control_7349 mgmt_control 3 7349 NULL
94950 +ext3_free_blocks_7362 ext3_free_blocks 3-4 7362 NULL
94951 +ieee80211_if_read_dot11MeshHWMPactivePathTimeout_7368 ieee80211_if_read_dot11MeshHWMPactivePathTimeout 3 7368 NULL
94952 +hweight_long_7388 hweight_long 0-1 7388 NULL
94953 +vhost_scsi_compat_ioctl_7393 vhost_scsi_compat_ioctl 3 7393 NULL
94954 +sl_change_mtu_7396 sl_change_mtu 2 7396 NULL
94955 +readb_7401 readb 0 7401 NULL
94956 +drm_property_create_blob_7414 drm_property_create_blob 2 7414 NULL
94957 +ip_options_get_alloc_7448 ip_options_get_alloc 1 7448 NULL
94958 +numa_emulation_7466 numa_emulation 2 7466 NULL
94959 +__mutex_lock_common_7469 __mutex_lock_common 0 7469 NULL
94960 +garp_request_join_7471 garp_request_join 4 7471 NULL
94961 +compat_sys_msgrcv_7482 compat_sys_msgrcv 2 7482 NULL
94962 +snd_pcm_lib_read1_7491 snd_pcm_lib_read1 0-3 7491 NULL
94963 +sdhci_alloc_host_7509 sdhci_alloc_host 2 7509 NULL nohasharray
94964 +ahash_instance_headroom_7509 ahash_instance_headroom 0 7509 &sdhci_alloc_host_7509
94965 +array_zalloc_7519 array_zalloc 1-2 7519 NULL
94966 +goal_in_my_reservation_7553 goal_in_my_reservation 3 7553 NULL
94967 +smk_read_mapped_7562 smk_read_mapped 3 7562 NULL
94968 +ext3_try_to_allocate_7590 ext3_try_to_allocate 5-3 7590 NULL
94969 +groups_alloc_7614 groups_alloc 1 7614 NULL
94970 +sg_virt_7616 sg_virt 0 7616 NULL
94971 +skb_copy_expand_7685 skb_copy_expand 2-3 7685 NULL nohasharray
94972 +acpi_ex_allocate_name_string_7685 acpi_ex_allocate_name_string 2-1 7685 &skb_copy_expand_7685
94973 +acpi_ns_get_pathname_length_7699 acpi_ns_get_pathname_length 0 7699 NULL
94974 +dev_write_7708 dev_write 3 7708 NULL
94975 +brcmf_sdcard_send_buf_7713 brcmf_sdcard_send_buf 6 7713 NULL
94976 +set_bypass_pwup_pfs_7742 set_bypass_pwup_pfs 3 7742 NULL
94977 +vxge_device_register_7752 vxge_device_register 4 7752 NULL
94978 +osdv2_attr_list_elem_size_7763 osdv2_attr_list_elem_size 0-1 7763 NULL
94979 +ubi_io_read_vid_hdr_7766 ubi_io_read_vid_hdr 0 7766 NULL
94980 +ioread32be_7773 ioread32be 0 7773 NULL
94981 +alloc_candev_7776 alloc_candev 1-2 7776 NULL
94982 +dfs_global_file_read_7787 dfs_global_file_read 3 7787 NULL
94983 +bnx2_nvram_write_7790 bnx2_nvram_write 4-2 7790 NULL
94984 +diva_os_copy_from_user_7792 diva_os_copy_from_user 4 7792 NULL
94985 +ubifs_leb_read_7828 ubifs_leb_read 0 7828 NULL
94986 +dvb_dmxdev_read_sec_7892 dvb_dmxdev_read_sec 4 7892 NULL
94987 +xfs_trans_get_efi_7898 xfs_trans_get_efi 2 7898 NULL
94988 +gfs2_tune_get_i_7903 gfs2_tune_get_i 0 7903 NULL
94989 +ext3_group_extend_7911 ext3_group_extend 3 7911 NULL
94990 +libfc_host_alloc_7917 libfc_host_alloc 2 7917 NULL
94991 +f_hidg_write_7932 f_hidg_write 3 7932 NULL
94992 +io_apic_setup_irq_pin_once_7934 io_apic_setup_irq_pin_once 1 7934 NULL
94993 +integrity_digsig_verify_7956 integrity_digsig_verify 3 7956 NULL
94994 +smk_write_load_self_7958 smk_write_load_self 3 7958 NULL
94995 +sys_mbind_7990 sys_mbind 5 7990 NULL
94996 +tt3650_ci_msg_locked_8013 tt3650_ci_msg_locked 4 8013 NULL
94997 +vcs_read_8017 vcs_read 3 8017 NULL
94998 +normalize_up_8037 normalize_up 0-1-2 8037 NULL
94999 +vhost_add_used_and_signal_n_8038 vhost_add_used_and_signal_n 4 8038 NULL
95000 +ms_read_multiple_pages_8052 ms_read_multiple_pages 5-4 8052 NULL
95001 +dgrp_mon_read_8065 dgrp_mon_read 3 8065 NULL
95002 +leb_read_lock_8070 leb_read_lock 0 8070 NULL
95003 +alloc_targets_8074 alloc_targets 2 8074 NULL nohasharray
95004 +qla4xxx_post_ping_evt_work_8074 qla4xxx_post_ping_evt_work 4 8074 &alloc_targets_8074
95005 +venus_lookup_8121 venus_lookup 4 8121 NULL
95006 +ieee80211_if_fmt_num_buffered_multicast_8127 ieee80211_if_fmt_num_buffered_multicast 3 8127 NULL
95007 +dma_map_area_8178 dma_map_area 5-2-3 8178 NULL
95008 +__sk_mem_schedule_8185 __sk_mem_schedule 2 8185 NULL
95009 +ieee80211_if_fmt_dot11MeshHoldingTimeout_8187 ieee80211_if_fmt_dot11MeshHoldingTimeout 3 8187 NULL
95010 +recent_mt_proc_write_8206 recent_mt_proc_write 3 8206 NULL
95011 +rt2x00debug_write_bbp_8212 rt2x00debug_write_bbp 3 8212 NULL
95012 +ad7879_spi_multi_read_8218 ad7879_spi_multi_read 3 8218 NULL
95013 +play_iframe_8219 play_iframe 3 8219 NULL
95014 +create_log_8225 create_log 2 8225 NULL nohasharray
95015 +kvm_mmu_page_set_gfn_8225 kvm_mmu_page_set_gfn 2 8225 &create_log_8225
95016 +sctp_ssnmap_size_8228 sctp_ssnmap_size 0-1-2 8228 NULL
95017 +bnx2x_iov_get_max_queue_count_8235 bnx2x_iov_get_max_queue_count 0 8235 NULL
95018 +check_xattr_ref_inode_8244 check_xattr_ref_inode 0 8244 NULL
95019 +add_rx_skb_8257 add_rx_skb 3 8257 NULL
95020 +t3_init_l2t_8261 t3_init_l2t 1 8261 NULL
95021 +init_cdev_8274 init_cdev 1 8274 NULL
95022 +rproc_recovery_write_8281 rproc_recovery_write 3 8281 NULL
95023 +qib_decode_7220_err_8315 qib_decode_7220_err 3 8315 NULL
95024 +construct_key_and_link_8321 construct_key_and_link 4 8321 NULL
95025 +ipwireless_send_packet_8328 ipwireless_send_packet 4 8328 NULL
95026 +tracing_entries_read_8345 tracing_entries_read 3 8345 NULL
95027 +ieee80211_if_fmt_ht_opmode_8347 ieee80211_if_fmt_ht_opmode 3 8347 NULL
95028 +ping_getfrag_8360 ping_getfrag 4-3 8360 NULL
95029 +uvc_v4l2_compat_ioctl32_8375 uvc_v4l2_compat_ioctl32 3 8375 NULL
95030 +xdi_copy_from_user_8395 xdi_copy_from_user 4 8395 NULL
95031 +zd_rf_scnprint_id_8406 zd_rf_scnprint_id 0-3 8406 NULL
95032 +uvc_v4l2_ioctl_8411 uvc_v4l2_ioctl 2 8411 NULL
95033 +pca953x_gpio_to_irq_8424 pca953x_gpio_to_irq 2 8424 NULL
95034 +snd_usb_ctl_msg_8436 snd_usb_ctl_msg 8 8436 NULL
95035 +irq_create_mapping_8437 irq_create_mapping 2 8437 NULL
95036 +afs_cell_lookup_8482 afs_cell_lookup 2 8482 NULL
95037 +batadv_tt_len_8502 batadv_tt_len 0-1 8502 NULL
95038 +dev_config_8506 dev_config 3 8506 NULL
95039 +ACL_to_cifs_posix_8509 ACL_to_cifs_posix 3 8509 NULL
95040 +opticon_process_data_packet_8524 opticon_process_data_packet 3 8524 NULL
95041 +pnp_resource_len_8532 pnp_resource_len 0 8532 NULL
95042 +alloc_pg_vec_8533 alloc_pg_vec 2 8533 NULL
95043 +ocfs2_read_virt_blocks_8538 ocfs2_read_virt_blocks 2-3 8538 NULL
95044 +profile_remove_8556 profile_remove 3 8556 NULL
95045 +cache_slow_downcall_8570 cache_slow_downcall 2 8570 NULL
95046 +mga_ioremap_8571 mga_ioremap 1-2 8571 NULL
95047 +isr_dma0_done_read_8574 isr_dma0_done_read 3 8574 NULL
95048 +tower_write_8580 tower_write 3 8580 NULL
95049 +rtllib_MFIE_rate_len_8606 rtllib_MFIE_rate_len 0 8606 NULL
95050 +shash_setkey_unaligned_8620 shash_setkey_unaligned 3 8620 NULL
95051 +it821x_firmware_command_8628 it821x_firmware_command 3 8628 NULL
95052 +scsi_dma_map_8632 scsi_dma_map 0 8632 NULL
95053 +fuse_send_write_pages_8636 fuse_send_write_pages 0 8636 NULL
95054 +generic_acl_set_8658 generic_acl_set 4 8658 NULL
95055 +dio_bio_alloc_8677 dio_bio_alloc 5 8677 NULL
95056 +lbs_bcnmiss_read_8678 lbs_bcnmiss_read 3 8678 NULL
95057 +tc3589x_gpio_irq_unmap_8680 tc3589x_gpio_irq_unmap 2 8680 NULL
95058 +rproc_trace_read_8686 rproc_trace_read 3 8686 NULL
95059 +skb_frag_size_8695 skb_frag_size 0 8695 NULL
95060 +arcfb_write_8702 arcfb_write 3 8702 NULL
95061 +i_size_read_8703 i_size_read 0 8703 NULL nohasharray
95062 +init_header_8703 init_header 0 8703 &i_size_read_8703
95063 +ctrl_out_8712 ctrl_out 3-5 8712 NULL
95064 +jffs2_acl_count_8729 jffs2_acl_count 0-1 8729 NULL
95065 +f_dupfd_8730 f_dupfd 1 8730 NULL
95066 +__create_irqs_8733 __create_irqs 2-1 8733 NULL
95067 +pca953x_gpio_irq_map_8737 pca953x_gpio_irq_map 2 8737 NULL
95068 +tx_tx_exch_expiry_read_8749 tx_tx_exch_expiry_read 3 8749 NULL
95069 +joydev_compat_ioctl_8765 joydev_compat_ioctl 2 8765 NULL
95070 +sys_prctl_8766 sys_prctl 4 8766 NULL
95071 +x32_arch_ptrace_8767 x32_arch_ptrace 3-4 8767 NULL
95072 +paging32_prefetch_gpte_8783 paging32_prefetch_gpte 4 8783 NULL
95073 +ext4_try_to_write_inline_data_8785 ext4_try_to_write_inline_data 3-4 8785 NULL
95074 +__bitmap_weight_8796 __bitmap_weight 0-2 8796 NULL
95075 +cpuset_common_file_read_8800 cpuset_common_file_read 5 8800 NULL
95076 +metronomefb_write_8823 metronomefb_write 3 8823 NULL
95077 +icmpv6_manip_pkt_8833 icmpv6_manip_pkt 4 8833 NULL nohasharray
95078 +get_queue_depth_8833 get_queue_depth 0 8833 &icmpv6_manip_pkt_8833
95079 +dvb_ringbuffer_pkt_next_8834 dvb_ringbuffer_pkt_next 0-2 8834 NULL
95080 +usb_ep_queue_8839 usb_ep_queue 0 8839 NULL
95081 +clear_bitset_8840 clear_bitset 2 8840 NULL
95082 +debug_debug1_read_8856 debug_debug1_read 3 8856 NULL
95083 +wa_nep_queue_8858 wa_nep_queue 2 8858 NULL
95084 +compressed_bio_size_8887 compressed_bio_size 0-2 8887 NULL
95085 +tracing_max_lat_read_8890 tracing_max_lat_read 3 8890 NULL
95086 +sdio_max_byte_size_8907 sdio_max_byte_size 0 8907 NULL
95087 +layout_commit_8926 layout_commit 3 8926 NULL
95088 +adjust_priv_size_8935 adjust_priv_size 0-1 8935 NULL
95089 +driver_stats_read_8944 driver_stats_read 3 8944 NULL
95090 +read_file_tgt_stats_8959 read_file_tgt_stats 3 8959 NULL
95091 +seq_bitmap_list_8963 seq_bitmap_list 3 8963 NULL
95092 +usb_allocate_stream_buffers_8964 usb_allocate_stream_buffers 3 8964 NULL
95093 +qib_qsfp_dump_8966 qib_qsfp_dump 0-3 8966 NULL
95094 +venus_mkdir_8967 venus_mkdir 4 8967 NULL
95095 +vol_cdev_read_8968 vol_cdev_read 3 8968 NULL nohasharray
95096 +seq_open_net_8968 seq_open_net 4 8968 &vol_cdev_read_8968
95097 +bio_integrity_get_tag_8974 bio_integrity_get_tag 3 8974 NULL
95098 +snd_emu10k1_ptr_read_9026 snd_emu10k1_ptr_read 0-2 9026 NULL
95099 +__pskb_copy_9038 __pskb_copy 2 9038 NULL
95100 +nla_put_9042 nla_put 3 9042 NULL
95101 +snd_emu10k1_synth_copy_from_user_9061 snd_emu10k1_synth_copy_from_user 3-5 9061 NULL
95102 +snd_gus_dram_peek_9062 snd_gus_dram_peek 4 9062 NULL
95103 +fib_info_hash_alloc_9075 fib_info_hash_alloc 1 9075 NULL
95104 +string_9080 string 0 9080 NULL
95105 +create_queues_9088 create_queues 2-3 9088 NULL
95106 +ftdi_prepare_write_buffer_9093 ftdi_prepare_write_buffer 3 9093 NULL
95107 +caif_stream_sendmsg_9110 caif_stream_sendmsg 4 9110 NULL nohasharray
95108 +gfn_to_rmap_9110 gfn_to_rmap 2-3 9110 &caif_stream_sendmsg_9110
95109 +pmcraid_change_queue_depth_9116 pmcraid_change_queue_depth 2 9116 NULL
95110 +mq_remove_mapping_9124 mq_remove_mapping 2 9124 NULL
95111 +mlx4_alloc_resize_umem_9132 mlx4_alloc_resize_umem 3 9132 NULL
95112 +ext4_list_backups_9138 ext4_list_backups 0 9138 NULL
95113 +dbg_command_buf_9165 dbg_command_buf 2 9165 NULL
95114 +isr_irqs_read_9181 isr_irqs_read 3 9181 NULL
95115 +count_leading_zeros_9183 count_leading_zeros 0 9183 NULL
95116 +alloc_group_attrs_9194 alloc_group_attrs 2 9194 NULL nohasharray
95117 +altera_swap_ir_9194 altera_swap_ir 2 9194 &alloc_group_attrs_9194
95118 +gx1_gx_base_9198 gx1_gx_base 0 9198 NULL
95119 +snd_m3_get_pointer_9206 snd_m3_get_pointer 0 9206 NULL
95120 +get_pfn_9207 get_pfn 1 9207 NULL
95121 +tx_tx_prepared_descs_read_9221 tx_tx_prepared_descs_read 3 9221 NULL
95122 +sctp_getsockopt_delayed_ack_9232 sctp_getsockopt_delayed_ack 2 9232 NULL
95123 +ocfs2_clear_ext_refcount_9256 ocfs2_clear_ext_refcount 4 9256 NULL
95124 +tcf_csum_ipv4_icmp_9258 tcf_csum_ipv4_icmp 3 9258 NULL
95125 +sparse_early_usemaps_alloc_node_9269 sparse_early_usemaps_alloc_node 4 9269 NULL
95126 +hdpvr_read_9273 hdpvr_read 3 9273 NULL
95127 +flakey_status_9274 flakey_status 5 9274 NULL
95128 +qla82xx_pci_set_window_9303 qla82xx_pci_set_window 0-2 9303 NULL
95129 +iwl_dbgfs_stations_read_9309 iwl_dbgfs_stations_read 3 9309 NULL
95130 +ceph_sync_setxattr_9310 ceph_sync_setxattr 4 9310 NULL
95131 +memblock_find_in_range_node_9328 memblock_find_in_range_node 0-3-4 9328 NULL
95132 +ieee80211_if_fmt_txpower_9334 ieee80211_if_fmt_txpower 3 9334 NULL
95133 +ocfs2_orphan_for_truncate_9342 ocfs2_orphan_for_truncate 4 9342 NULL
95134 +read_9397 read 3 9397 NULL
95135 +nf_nat_sip_expect_9418 nf_nat_sip_expect 8 9418 NULL
95136 +bm_realloc_pages_9431 bm_realloc_pages 2 9431 NULL
95137 +ffs_ep0_write_9438 ffs_ep0_write 3 9438 NULL
95138 +kmalloc_array_9444 kmalloc_array 1-2 9444 NULL
95139 +ieee80211_if_fmt_fwded_unicast_9454 ieee80211_if_fmt_fwded_unicast 3 9454 NULL
95140 +mcs_unwrap_mir_9455 mcs_unwrap_mir 3 9455 NULL
95141 +ext3_xattr_set_acl_9467 ext3_xattr_set_acl 4 9467 NULL
95142 +agp_generic_alloc_user_9470 agp_generic_alloc_user 1 9470 NULL
95143 +__alloc_preds_9492 __alloc_preds 2 9492 NULL nohasharray
95144 +crypt_status_9492 crypt_status 5 9492 &__alloc_preds_9492
95145 +lp_write_9511 lp_write 3 9511 NULL
95146 +xen_remap_exchanged_ptes_9513 xen_remap_exchanged_ptes 1 9513 NULL
95147 +scsi_tgt_kspace_exec_9522 scsi_tgt_kspace_exec 8 9522 NULL
95148 +read_file_dma_9530 read_file_dma 3 9530 NULL
95149 +ext3_alloc_branch_9534 ext3_alloc_branch 5 9534 NULL
95150 +audit_log_n_untrustedstring_9548 audit_log_n_untrustedstring 3 9548 NULL
95151 +fw_node_create_9559 fw_node_create 2 9559 NULL
95152 +ipath_get_user_pages_9561 ipath_get_user_pages 1-2 9561 NULL
95153 +kobj_map_9566 kobj_map 2-3 9566 NULL
95154 +f2fs_read_data_pages_9574 f2fs_read_data_pages 4 9574 NULL
95155 +biovec_create_pools_9575 biovec_create_pools 2 9575 NULL
95156 +ieee80211_tdls_mgmt_9581 ieee80211_tdls_mgmt 8 9581 NULL
95157 +do_sync_9604 do_sync 1 9604 NULL
95158 +snd_emu10k1_fx8010_read_9605 snd_emu10k1_fx8010_read 5-6 9605 NULL
95159 +saa7164_buffer_alloc_user_9627 saa7164_buffer_alloc_user 2 9627 NULL
95160 +ceph_copy_user_to_page_vector_9635 ceph_copy_user_to_page_vector 4-3 9635 NULL
95161 +compat_sys_keyctl_9639 compat_sys_keyctl 4-2-3 9639 NULL
95162 +ocfs2_xattr_get_rec_9652 ocfs2_xattr_get_rec 0 9652 NULL
95163 +uvc_alloc_buffers_9656 uvc_alloc_buffers 2-3 9656 NULL
95164 +queue_received_packet_9657 queue_received_packet 5 9657 NULL
95165 +snd_opl4_mem_proc_write_9670 snd_opl4_mem_proc_write 5 9670 NULL
95166 +ks8842_read16_9676 ks8842_read16 0 9676 NULL nohasharray
95167 +dns_query_9676 dns_query 3 9676 &ks8842_read16_9676
95168 +qib_7322_handle_hwerrors_9678 qib_7322_handle_hwerrors 3 9678 NULL
95169 +__erst_read_from_storage_9690 __erst_read_from_storage 0 9690 NULL
95170 +is_hole_9694 is_hole 2 9694 NULL nohasharray
95171 +x25_asy_compat_ioctl_9694 x25_asy_compat_ioctl 4 9694 &is_hole_9694
95172 +fnb_9703 fnb 2-3 9703 NULL
95173 +fuse_iter_npages_9705 fuse_iter_npages 0 9705 NULL nohasharray
95174 +ieee80211_if_read_aid_9705 ieee80211_if_read_aid 3 9705 &fuse_iter_npages_9705
95175 +ieee80211_if_fmt_num_mcast_sta_9738 ieee80211_if_fmt_num_mcast_sta 3 9738 NULL
95176 +ddb_input_read_9743 ddb_input_read 3 9743 NULL
95177 +sta_last_ack_signal_read_9751 sta_last_ack_signal_read 3 9751 NULL
95178 +btrfs_super_root_9763 btrfs_super_root 0 9763 NULL
95179 +__alloc_percpu_9764 __alloc_percpu 1-2 9764 NULL
95180 +__blk_queue_init_tags_9778 __blk_queue_init_tags 2 9778 NULL
95181 +snd_mem_proc_write_9786 snd_mem_proc_write 3 9786 NULL
95182 +ttm_bo_fbdev_io_9805 ttm_bo_fbdev_io 4 9805 NULL
95183 +ieee80211_if_read_state_9813 ieee80211_if_read_state 3 9813 NULL
95184 +pnp_mem_start_9817 pnp_mem_start 0 9817 NULL
95185 +kernel_physical_mapping_init_9818 kernel_physical_mapping_init 0-2-1 9818 NULL
95186 +dvb_dvr_set_buffer_size_9840 dvb_dvr_set_buffer_size 2 9840 NULL
95187 +cfg80211_send_deauth_9862 cfg80211_send_deauth 3 9862 NULL
95188 +pmcraid_alloc_sglist_9864 pmcraid_alloc_sglist 1 9864 NULL
95189 +btrfs_free_reserved_extent_9867 btrfs_free_reserved_extent 2 9867 NULL
95190 +f1x_translate_sysaddr_to_cs_9868 f1x_translate_sysaddr_to_cs 2 9868 NULL
95191 +mlx4_bitmap_alloc_range_9876 mlx4_bitmap_alloc_range 2-3 9876 NULL
95192 +wil_read_file_ioblob_9878 wil_read_file_ioblob 3 9878 NULL
95193 +bm_register_write_9893 bm_register_write 3 9893 NULL nohasharray
95194 +snd_midi_event_new_9893 snd_midi_event_new 1 9893 &bm_register_write_9893
95195 +snd_gf1_pcm_playback_copy_9895 snd_gf1_pcm_playback_copy 3-5 9895 NULL
95196 +nonpaging_page_fault_9908 nonpaging_page_fault 2 9908 NULL
95197 +gen6_get_total_gtt_size_9913 gen6_get_total_gtt_size 0-1 9913 NULL
95198 +pstore_ftrace_knob_read_9947 pstore_ftrace_knob_read 3 9947 NULL
95199 +read_file_misc_9948 read_file_misc 3 9948 NULL
95200 +set_rxd_buffer_pointer_9950 set_rxd_buffer_pointer 8 9950 NULL
95201 +ext2_new_blocks_9954 ext2_new_blocks 2 9954 NULL
95202 +csum_partial_copy_fromiovecend_9957 csum_partial_copy_fromiovecend 3-4 9957 NULL
95203 +get_free_serial_index_9969 get_free_serial_index 0 9969 NULL
95204 +btrfs_add_link_9973 btrfs_add_link 5 9973 NULL
95205 +ath6kl_usb_submit_ctrl_out_9978 ath6kl_usb_submit_ctrl_out 6 9978 NULL
95206 +aat2870_dump_reg_10019 aat2870_dump_reg 0 10019 NULL
95207 +handle_request_10024 handle_request 9 10024 NULL
95208 +batadv_orig_hash_add_if_10033 batadv_orig_hash_add_if 2 10033 NULL
95209 +ieee80211_probereq_get_10040 ieee80211_probereq_get 4-5 10040 NULL
95210 +xen_destroy_contiguous_region_10054 xen_destroy_contiguous_region 1 10054 NULL
95211 +ieee80211_set_probe_resp_10077 ieee80211_set_probe_resp 3 10077 NULL
95212 +ufs_bitmap_search_10105 ufs_bitmap_search 0-3 10105 NULL
95213 +get_elem_size_10110 get_elem_size 0-2 10110 NULL nohasharray
95214 +dynamic_ps_timeout_read_10110 dynamic_ps_timeout_read 3 10110 &get_elem_size_10110
95215 +jbd_alloc_10112 jbd_alloc 0 10112 NULL nohasharray
95216 +gfs2_meta_read_10112 gfs2_meta_read 0 10112 &jbd_alloc_10112
95217 +offset_to_bit_10134 offset_to_bit 0 10134 NULL
95218 +aes_decrypt_packets_read_10155 aes_decrypt_packets_read 3 10155 NULL
95219 +rx_out_of_mem_read_10157 rx_out_of_mem_read 3 10157 NULL
95220 +hidg_alloc_ep_req_10159 hidg_alloc_ep_req 2 10159 NULL nohasharray
95221 +ol_chunk_entries_10159 ol_chunk_entries 0 10159 &hidg_alloc_ep_req_10159
95222 +stmpe_irq_unmap_10164 stmpe_irq_unmap 2 10164 NULL
95223 +asd_store_update_bios_10165 asd_store_update_bios 4 10165 NULL
95224 +proc_pid_attr_read_10173 proc_pid_attr_read 3 10173 NULL
95225 +jffs2_user_setxattr_10182 jffs2_user_setxattr 4 10182 NULL
95226 +do_ioctl_trans_10194 do_ioctl_trans 3 10194 NULL
95227 +cciss_proc_write_10259 cciss_proc_write 3 10259 NULL
95228 +snd_rme9652_capture_copy_10287 snd_rme9652_capture_copy 5 10287 NULL
95229 +ubi_leb_change_10289 ubi_leb_change 4 10289 NULL
95230 +read_emulate_10310 read_emulate 2-4 10310 NULL
95231 +read_file_spectral_count_10320 read_file_spectral_count 3 10320 NULL
95232 +ttm_object_device_init_10321 ttm_object_device_init 2 10321 NULL
95233 +ubi_leb_read_10328 ubi_leb_read 0 10328 NULL
95234 +tun_sendmsg_10337 tun_sendmsg 4 10337 NULL
95235 +get_dump_page_10338 get_dump_page 1 10338 NULL
95236 +ufx_alloc_urb_list_10349 ufx_alloc_urb_list 3 10349 NULL
95237 +dbAllocAny_10354 dbAllocAny 0 10354 NULL
95238 +ath6kl_listen_int_read_10355 ath6kl_listen_int_read 3 10355 NULL
95239 +ms_write_multiple_pages_10362 ms_write_multiple_pages 6-5 10362 NULL
95240 +sta_ht_capa_read_10366 sta_ht_capa_read 3 10366 NULL
95241 +ecryptfs_decode_and_decrypt_filename_10379 ecryptfs_decode_and_decrypt_filename 5 10379 NULL
95242 +do_compat_pselect_10398 do_compat_pselect 1 10398 NULL
95243 +fwtty_rx_10434 fwtty_rx 3 10434 NULL
95244 +event_phy_transmit_error_read_10471 event_phy_transmit_error_read 3 10471 NULL
95245 +ca91cx42_alloc_resource_10502 ca91cx42_alloc_resource 2 10502 NULL
95246 +qib_alloc_fast_reg_page_list_10507 qib_alloc_fast_reg_page_list 2 10507 NULL
95247 +sel_write_disable_10511 sel_write_disable 3 10511 NULL
95248 +osd_req_write_sg_kern_10514 osd_req_write_sg_kern 5 10514 NULL
95249 +rds_message_alloc_10517 rds_message_alloc 1 10517 NULL
95250 +ocfs2_add_refcounted_extent_10526 ocfs2_add_refcounted_extent 6 10526 NULL
95251 +get_vm_area_caller_10527 get_vm_area_caller 1 10527 NULL
95252 +snd_pcm_lib_read_10536 snd_pcm_lib_read 0-3 10536 NULL
95253 +ieee80211_send_probe_req_10539 ieee80211_send_probe_req 4-6 10539 NULL
95254 +ext4_write_begin_10576 ext4_write_begin 3-4 10576 NULL
95255 +scrub_remap_extent_10588 scrub_remap_extent 2 10588 NULL
95256 +otp_read_10594 otp_read 2-4-5 10594 NULL
95257 +supply_map_read_file_10608 supply_map_read_file 3 10608 NULL
95258 +ima_show_htable_violations_10619 ima_show_htable_violations 3 10619 NULL
95259 +alloc_coherent_10632 alloc_coherent 2 10632 NULL
95260 +nfs_idmap_lookup_id_10660 nfs_idmap_lookup_id 2 10660 NULL
95261 +parport_write_10669 parport_write 0 10669 NULL
95262 +inl_10708 inl 0 10708 NULL nohasharray
95263 +selinux_inode_setxattr_10708 selinux_inode_setxattr 4 10708 &inl_10708
95264 +pvr2_ioread_read_10720 pvr2_ioread_read 3 10720 NULL nohasharray
95265 +shash_async_setkey_10720 shash_async_setkey 3 10720 &pvr2_ioread_read_10720
95266 +spi_sync_10731 spi_sync 0 10731 NULL
95267 +sctp_getsockopt_maxseg_10737 sctp_getsockopt_maxseg 2 10737 NULL nohasharray
95268 +apu_get_register_10737 apu_get_register 0 10737 &sctp_getsockopt_maxseg_10737
95269 +compat_sys_msgsnd_10738 compat_sys_msgsnd 2 10738 NULL
95270 +sys_syslog_10746 sys_syslog 3 10746 NULL
95271 +alloc_one_pg_vec_page_10747 alloc_one_pg_vec_page 1 10747 NULL
95272 +vhost_add_used_n_10760 vhost_add_used_n 3 10760 NULL
95273 +kvm_read_guest_atomic_10765 kvm_read_guest_atomic 4-2 10765 NULL
95274 +wb_set_dirty_10778 wb_set_dirty 2 10778 NULL
95275 +__qp_memcpy_to_queue_10779 __qp_memcpy_to_queue 2-4 10779 NULL
95276 +sys_bind_10799 sys_bind 3 10799 NULL
95277 +compat_put_int_10828 compat_put_int 1 10828 NULL
95278 +lbs_sleepparams_read_10840 lbs_sleepparams_read 3 10840 NULL
95279 +ida_get_new_above_10853 ida_get_new_above 2 10853 NULL
95280 +fuse_conn_max_background_read_10855 fuse_conn_max_background_read 3 10855 NULL
95281 +ol_chunk_blocks_10864 ol_chunk_blocks 0 10864 NULL
95282 +snd_pcm_oss_write1_10872 snd_pcm_oss_write1 3 10872 NULL
95283 +mid_get_vbt_data_r0_10876 mid_get_vbt_data_r0 2 10876 NULL
95284 +bl_mark_for_commit_10879 bl_mark_for_commit 2-3 10879 NULL
95285 +get_scq_10897 get_scq 2 10897 NULL
95286 +cgroup_write_string_10900 cgroup_write_string 5 10900 NULL
95287 +tifm_alloc_adapter_10903 tifm_alloc_adapter 1 10903 NULL
95288 +__copy_from_user_10918 __copy_from_user 3 10918 NULL
95289 +da9052_map_irq_10952 da9052_map_irq 2 10952 NULL
95290 +bm_entry_read_10976 bm_entry_read 3 10976 NULL
95291 +i915_min_freq_write_10981 i915_min_freq_write 3 10981 NULL
95292 +sched_autogroup_write_10984 sched_autogroup_write 3 10984 NULL
95293 +__hci_num_ctrl_10985 __hci_num_ctrl 0 10985 NULL
95294 +xfrm_hash_alloc_10997 xfrm_hash_alloc 1 10997 NULL
95295 +rx_filter_accum_arp_pend_requests_read_11003 rx_filter_accum_arp_pend_requests_read 3 11003 NULL
95296 +SetLineNumber_11023 SetLineNumber 0 11023 NULL
95297 +mb_find_next_bit_11037 mb_find_next_bit 2-3-0 11037 NULL
95298 +tda10048_writeregbulk_11050 tda10048_writeregbulk 4 11050 NULL
95299 +tcp_send_mss_11079 tcp_send_mss 0 11079 NULL
95300 +count_argc_11083 count_argc 0 11083 NULL
95301 +kvm_write_guest_cached_11106 kvm_write_guest_cached 4 11106 NULL
95302 +stmpe_gpio_to_irq_11110 stmpe_gpio_to_irq 2 11110 NULL
95303 +tw_change_queue_depth_11116 tw_change_queue_depth 2 11116 NULL
95304 +page_offset_11120 page_offset 0 11120 NULL
95305 +tracing_buffers_read_11124 tracing_buffers_read 3 11124 NULL
95306 +acpi_os_map_memory_11161 acpi_os_map_memory 1-2 11161 NULL
95307 +ioat2_alloc_ring_11172 ioat2_alloc_ring 2 11172 NULL nohasharray
95308 +snd_gf1_pcm_playback_silence_11172 snd_gf1_pcm_playback_silence 3-4 11172 &ioat2_alloc_ring_11172
95309 +__swab16p_11220 __swab16p 0 11220 NULL
95310 +il_dbgfs_rx_queue_read_11221 il_dbgfs_rx_queue_read 3 11221 NULL
95311 +mmap_region_11247 mmap_region 0-2 11247 NULL
95312 +ubifs_write_node_11258 ubifs_write_node 5-3 11258 NULL
95313 +dm_cache_discard_bitset_resize_11262 dm_cache_discard_bitset_resize 3 11262 NULL
95314 +hugetlbfs_read_11268 hugetlbfs_read 3 11268 NULL
95315 +cru_detect_11272 cru_detect 1 11272 NULL
95316 +ext4_xattr_check_names_11314 ext4_xattr_check_names 0 11314 NULL
95317 +tcp_send_rcvq_11316 tcp_send_rcvq 3 11316 NULL
95318 +construct_key_11329 construct_key 3 11329 NULL nohasharray
95319 +__kfifo_out_peek_11329 __kfifo_out_peek 0-3 11329 &construct_key_11329
95320 +next_segment_11330 next_segment 0-2-1 11330 NULL
95321 +persistent_ram_buffer_map_11332 persistent_ram_buffer_map 1-2 11332 NULL
95322 +ext4_get_inline_size_11349 ext4_get_inline_size 0 11349 NULL
95323 +i915_max_freq_write_11350 i915_max_freq_write 3 11350 NULL
95324 +sel_write_create_11353 sel_write_create 3 11353 NULL
95325 +handle_unit_11355 handle_unit 0-1 11355 NULL
95326 +batadv_skb_head_push_11360 batadv_skb_head_push 2 11360 NULL
95327 +drm_vblank_init_11362 drm_vblank_init 2 11362 NULL
95328 +qib_get_base_info_11369 qib_get_base_info 3 11369 NULL
95329 +dev_irnet_write_11398 dev_irnet_write 3 11398 NULL
95330 +___alloc_bootmem_11410 ___alloc_bootmem 1-2 11410 NULL
95331 +str_to_user_11411 str_to_user 2 11411 NULL
95332 +mem_fw_gen_free_mem_blks_read_11413 mem_fw_gen_free_mem_blks_read 3 11413 NULL
95333 +ath6kl_wmi_test_rx_11414 ath6kl_wmi_test_rx 3 11414 NULL
95334 +adis16480_show_firmware_revision_11417 adis16480_show_firmware_revision 3 11417 NULL
95335 +trace_options_read_11419 trace_options_read 3 11419 NULL
95336 +xd_read_multiple_pages_11422 xd_read_multiple_pages 5-4 11422 NULL
95337 +prepare_image_11424 prepare_image 0 11424 NULL
95338 +vring_size_11426 vring_size 0-1-2 11426 NULL
95339 +bttv_read_11432 bttv_read 3 11432 NULL
95340 +create_zero_mask_11453 create_zero_mask 0-1 11453 NULL
95341 +swp_offset_11475 swp_offset 0 11475 NULL
95342 +sca3000_read_first_n_hw_rb_11479 sca3000_read_first_n_hw_rb 2 11479 NULL
95343 +xfs_file_buffered_aio_write_11492 xfs_file_buffered_aio_write 4 11492 NULL
95344 +sd_do_mode_sense_11507 sd_do_mode_sense 5 11507 NULL
95345 +kmem_zalloc_11510 kmem_zalloc 1 11510 NULL
95346 +twl_direction_in_11527 twl_direction_in 2 11527 NULL
95347 +setup_IO_APIC_irq_extra_11537 setup_IO_APIC_irq_extra 1 11537 NULL
95348 +skb_cow_data_11565 skb_cow_data 0-2 11565 NULL
95349 +mlx4_init_cmpt_table_11569 mlx4_init_cmpt_table 3 11569 NULL
95350 +oprofilefs_ulong_to_user_11582 oprofilefs_ulong_to_user 3 11582 NULL
95351 +snd_pcm_action_11589 snd_pcm_action 0 11589 NULL
95352 +fw_device_op_ioctl_11595 fw_device_op_ioctl 2 11595 NULL
95353 +sisusb_send_bridge_packet_11649 sisusb_send_bridge_packet 2 11649 NULL
95354 +nla_total_size_11658 nla_total_size 0-1 11658 NULL
95355 +ide_queue_pc_tail_11673 ide_queue_pc_tail 5 11673 NULL
95356 +btrfs_alloc_delayed_item_11678 btrfs_alloc_delayed_item 1 11678 NULL
95357 +dsp_buffer_alloc_11684 dsp_buffer_alloc 2 11684 NULL
95358 +sctp_setsockopt_hmac_ident_11687 sctp_setsockopt_hmac_ident 3 11687 NULL
95359 +split_11691 split 2 11691 NULL
95360 +snd_ctl_elem_user_tlv_11695 snd_ctl_elem_user_tlv 3 11695 NULL
95361 +blk_rq_cur_bytes_11723 blk_rq_cur_bytes 0 11723 NULL
95362 +tcf_csum_ipv6_icmp_11738 tcf_csum_ipv6_icmp 4 11738 NULL
95363 +nfsd4_get_drc_mem_11748 nfsd4_get_drc_mem 0-1-2 11748 NULL
95364 +dm_bio_prison_create_11749 dm_bio_prison_create 1 11749 NULL
95365 +iwl_dbgfs_qos_read_11753 iwl_dbgfs_qos_read 3 11753 NULL
95366 +ps_pspoll_timeouts_read_11776 ps_pspoll_timeouts_read 3 11776 NULL
95367 +ebt_buf_add_11779 ebt_buf_add 0 11779 NULL
95368 +btrfs_key_blockptr_11786 btrfs_key_blockptr 0 11786 NULL
95369 +pcpu_fc_alloc_11818 pcpu_fc_alloc 2-3 11818 NULL
95370 +zerocopy_sg_from_iovec_11828 zerocopy_sg_from_iovec 3 11828 NULL
95371 +sctp_setsockopt_maxseg_11829 sctp_setsockopt_maxseg 3 11829 NULL
95372 +rts51x_read_status_11830 rts51x_read_status 4 11830 NULL
95373 +unix_stream_connect_11844 unix_stream_connect 3 11844 NULL
95374 +nf_nat_sdp_media_11863 nf_nat_sdp_media 9 11863 NULL
95375 +ecryptfs_copy_filename_11868 ecryptfs_copy_filename 4 11868 NULL
95376 +ieee80211_rx_bss_info_11887 ieee80211_rx_bss_info 3 11887 NULL
95377 +kmalloc_slab_11917 kmalloc_slab 1 11917 NULL
95378 +fs_devrw_entry_11924 fs_devrw_entry 3 11924 NULL
95379 +bitmap_remap_11929 bitmap_remap 5 11929 NULL
95380 +atomic_sub_return_11939 atomic_sub_return 0-1 11939 NULL
95381 +dccp_feat_clone_sp_val_11942 dccp_feat_clone_sp_val 3 11942 NULL
95382 +f1x_swap_interleaved_region_11970 f1x_swap_interleaved_region 0-2 11970 NULL
95383 +atmel_read16_11981 atmel_read16 0 11981 NULL
95384 +read_and_add_raw_conns_11987 read_and_add_raw_conns 0 11987 NULL
95385 +ftdi_elan_total_command_size_12045 ftdi_elan_total_command_size 0 12045 NULL
95386 +ieee80211_if_read_user_power_level_12050 ieee80211_if_read_user_power_level 3 12050 NULL
95387 +il4965_ucode_tx_stats_read_12064 il4965_ucode_tx_stats_read 3 12064 NULL
95388 +ptc_proc_write_12076 ptc_proc_write 3 12076 NULL
95389 +ubifs_recover_log_leb_12079 ubifs_recover_log_leb 3 12079 NULL
95390 +pse36_gfn_delta_12087 pse36_gfn_delta 0-1 12087 NULL
95391 +alloc_bulk_urbs_generic_12127 alloc_bulk_urbs_generic 5 12127 NULL
95392 +set_powered_12129 set_powered 4 12129 NULL
95393 +nfs_writedata_alloc_12133 nfs_writedata_alloc 2 12133 NULL
95394 +ramoops_init_prz_12134 ramoops_init_prz 5 12134 NULL
95395 +xfs_handle_to_dentry_12135 xfs_handle_to_dentry 3 12135 NULL
95396 +batadv_add_packet_12136 batadv_add_packet 3 12136 NULL
95397 +rawv6_seticmpfilter_12137 rawv6_seticmpfilter 5 12137 NULL
95398 +vmw_fifo_reserve_12141 vmw_fifo_reserve 2 12141 NULL
95399 +get_idx_gc_leb_12148 get_idx_gc_leb 0 12148 NULL
95400 +btmrvl_sdio_host_to_card_12152 btmrvl_sdio_host_to_card 3 12152 NULL
95401 +vmbus_open_12154 vmbus_open 2-3 12154 NULL
95402 +wil_rxdesc_phy_length_12165 wil_rxdesc_phy_length 0 12165 NULL
95403 +dma_memcpy_to_iovec_12173 dma_memcpy_to_iovec 5 12173 NULL
95404 +ddp_make_gl_12179 ddp_make_gl 1 12179 NULL
95405 +compat_do_arpt_set_ctl_12184 compat_do_arpt_set_ctl 4 12184 NULL
95406 +ip_generic_getfrag_12187 ip_generic_getfrag 3-4 12187 NULL
95407 +bl_is_sector_init_12199 bl_is_sector_init 2 12199 NULL
95408 +free_initrd_mem_12203 free_initrd_mem 1 12203 NULL
95409 +receive_copy_12216 receive_copy 3 12216 NULL
95410 +snd_pcm_kernel_ioctl_12219 snd_pcm_kernel_ioctl 0 12219 NULL
95411 +fuse_get_req_12221 fuse_get_req 2 12221 NULL nohasharray
95412 +aat2870_reg_read_file_12221 aat2870_reg_read_file 3 12221 &fuse_get_req_12221
95413 +__alloc_bootmem_low_nopanic_12235 __alloc_bootmem_low_nopanic 1-2 12235 NULL
95414 +ib_uverbs_unmarshall_recv_12251 ib_uverbs_unmarshall_recv 5 12251 NULL
95415 +ath_descdma_setup_12257 ath_descdma_setup 5 12257 NULL
95416 +shash_compat_setkey_12267 shash_compat_setkey 3 12267 NULL
95417 +add_sctp_bind_addr_12269 add_sctp_bind_addr 3 12269 NULL
95418 +note_last_dentry_12285 note_last_dentry 3 12285 NULL
95419 +roundup_to_multiple_of_64_12288 roundup_to_multiple_of_64 0-1 12288 NULL nohasharray
95420 +il_dbgfs_nvm_read_12288 il_dbgfs_nvm_read 3 12288 &roundup_to_multiple_of_64_12288
95421 +vxge_get_num_vfs_12302 vxge_get_num_vfs 0 12302 NULL
95422 +tipc_msg_build_12326 tipc_msg_build 4 12326 NULL
95423 +pcbit_writecmd_12332 pcbit_writecmd 2 12332 NULL
95424 +mptctl_ioctl_12355 mptctl_ioctl 2 12355 NULL
95425 +paging32_walk_addr_12359 paging32_walk_addr 3 12359 NULL
95426 +__nf_ct_ext_add_length_12364 __nf_ct_ext_add_length 3 12364 NULL
95427 +xfs_iext_inline_to_direct_12384 xfs_iext_inline_to_direct 2 12384 NULL
95428 +btrfs_file_extent_ram_bytes_12391 btrfs_file_extent_ram_bytes 0 12391 NULL
95429 +ieee80211_if_read_num_mcast_sta_12419 ieee80211_if_read_num_mcast_sta 3 12419 NULL
95430 +skb_do_copy_data_nocache_12465 skb_do_copy_data_nocache 5 12465 NULL
95431 +qla4_82xx_pci_mem_write_direct_12479 qla4_82xx_pci_mem_write_direct 2 12479 NULL
95432 +x25_sendmsg_12487 x25_sendmsg 4 12487 NULL
95433 +rtllib_auth_challenge_12493 rtllib_auth_challenge 3 12493 NULL
95434 +fnic_trace_ctrl_read_12497 fnic_trace_ctrl_read 3 12497 NULL
95435 +nfs_readdir_make_qstr_12509 nfs_readdir_make_qstr 3 12509 NULL
95436 +qib_alloc_fast_reg_mr_12526 qib_alloc_fast_reg_mr 2 12526 NULL
95437 +kvm_setup_async_pf_12555 kvm_setup_async_pf 3 12555 NULL
95438 +ib_umem_get_12557 ib_umem_get 2-3 12557 NULL
95439 +hvc_alloc_12579 hvc_alloc 4 12579 NULL
95440 +snd_pcm_plugin_alloc_12580 snd_pcm_plugin_alloc 2 12580 NULL
95441 +macvtap_compat_ioctl_12587 macvtap_compat_ioctl 3 12587 NULL
95442 +pcpu_extend_area_map_12589 pcpu_extend_area_map 2 12589 NULL
95443 +ipv6_get_l4proto_12600 ipv6_get_l4proto 2 12600 NULL
95444 +vhci_put_user_12604 vhci_put_user 4 12604 NULL
95445 +fc_fcp_frame_alloc_12624 fc_fcp_frame_alloc 2 12624 NULL
95446 +pwr_rcvd_awake_bcns_cnt_read_12632 pwr_rcvd_awake_bcns_cnt_read 3 12632 NULL
95447 +ctrl_cdev_compat_ioctl_12634 ctrl_cdev_compat_ioctl 3 12634 NULL
95448 +pn_sendmsg_12640 pn_sendmsg 4 12640 NULL
95449 +wb_create_12651 wb_create 1 12651 NULL
95450 +ocfs2_read_block_12659 ocfs2_read_block 0 12659 NULL
95451 +sel_read_class_12669 sel_read_class 3 12669 NULL nohasharray
95452 +sparse_mem_maps_populate_node_12669 sparse_mem_maps_populate_node 4 12669 &sel_read_class_12669
95453 +ieee80211_if_read_num_buffered_multicast_12716 ieee80211_if_read_num_buffered_multicast 3 12716 NULL
95454 +ivtv_write_12721 ivtv_write 3 12721 NULL
95455 +key_rx_spec_read_12736 key_rx_spec_read 3 12736 NULL
95456 +__videobuf_alloc_cached_12740 __videobuf_alloc_cached 1 12740 NULL
95457 +ieee80211_if_read_dot11MeshMaxRetries_12756 ieee80211_if_read_dot11MeshMaxRetries 3 12756 NULL
95458 +listxattr_12769 listxattr 3 12769 NULL
95459 +sctp_ssnmap_init_12772 sctp_ssnmap_init 2-3 12772 NULL
95460 +ieee80211_rx_mgmt_beacon_12780 ieee80211_rx_mgmt_beacon 3 12780 NULL
95461 +platform_create_bundle_12785 platform_create_bundle 4-6 12785 NULL
95462 +scsi_adjust_queue_depth_12802 scsi_adjust_queue_depth 3 12802 NULL
95463 +xfs_inumbers_fmt_12817 xfs_inumbers_fmt 3 12817 NULL
95464 +readq_12825 readq 0 12825 NULL
95465 +TSS_authhmac_12839 TSS_authhmac 3 12839 NULL
95466 +spidev_sync_12842 spidev_sync 0 12842 NULL nohasharray
95467 +ath6kl_wmi_add_wow_pattern_cmd_12842 ath6kl_wmi_add_wow_pattern_cmd 4 12842 &spidev_sync_12842
95468 +spidev_ioctl_12846 spidev_ioctl 2 12846 NULL
95469 +get_leb_cnt_12892 get_leb_cnt 0-2 12892 NULL
95470 +ocfs2_hamming_encode_block_12904 ocfs2_hamming_encode_block 2 12904 NULL
95471 +get_virtual_node_size_12908 get_virtual_node_size 0 12908 NULL
95472 +rds_pages_in_vec_12922 rds_pages_in_vec 0 12922 NULL
95473 +ci_ll_init_12930 ci_ll_init 3 12930 NULL
95474 +do_inode_permission_12946 do_inode_permission 0 12946 NULL
95475 +bm_status_write_12964 bm_status_write 3 12964 NULL
95476 +_drbd_md_first_sector_12984 _drbd_md_first_sector 0 12984 NULL
95477 +raid56_parity_recover_12987 raid56_parity_recover 5 12987 NULL
95478 +acpi_tb_install_table_12988 acpi_tb_install_table 1 12988 NULL
95479 +TransmitTcb_12989 TransmitTcb 4 12989 NULL
95480 +sk_peek_offset_12991 sk_peek_offset 0 12991 NULL
95481 +subsystem_filter_write_13022 subsystem_filter_write 3 13022 NULL
95482 +generic_segment_checks_13041 generic_segment_checks 0 13041 NULL
95483 +ocfs2_write_begin_13045 ocfs2_write_begin 3-4 13045 NULL
95484 +__dn_setsockopt_13060 __dn_setsockopt 5 13060 NULL
95485 +irq_set_chip_and_handler_13088 irq_set_chip_and_handler 1 13088 NULL
95486 +xattr_getsecurity_13090 xattr_getsecurity 0 13090 NULL
95487 +blk_rq_map_sg_13092 blk_rq_map_sg 0 13092 NULL
95488 +mb_find_next_zero_bit_13100 mb_find_next_zero_bit 2-3 13100 NULL
95489 +ubifs_compat_ioctl_13108 ubifs_compat_ioctl 3 13108 NULL
95490 +snd_rme96_playback_copy_13111 snd_rme96_playback_copy 5 13111 NULL
95491 +xen_allocate_irq_dynamic_13116 xen_allocate_irq_dynamic 0 13116 NULL
95492 +bfad_debugfs_read_13119 bfad_debugfs_read 3 13119 NULL
95493 +blk_update_request_13146 blk_update_request 3 13146 NULL
95494 +caif_stream_recvmsg_13173 caif_stream_recvmsg 4 13173 NULL
95495 +pwr_disable_ps_read_13176 pwr_disable_ps_read 3 13176 NULL
95496 +ucs2_strlen_13178 ucs2_strlen 0 13178 NULL
95497 +dgrp_net_ioctl_13183 dgrp_net_ioctl 2 13183 NULL
95498 +create_trace_uprobe_13184 create_trace_uprobe 1 13184 NULL
95499 +compat_put_ulong_13186 compat_put_ulong 1 13186 NULL
95500 +__cmpxchg64_13187 __cmpxchg64 0 13187 NULL
95501 +comedi_read_13199 comedi_read 3 13199 NULL
95502 +mmc_ext_csd_read_13205 mmc_ext_csd_read 3 13205 NULL
95503 +__nodes_fold_13215 __nodes_fold 4 13215 NULL
95504 +svm_msrpm_offset_13220 svm_msrpm_offset 0-1 13220 NULL
95505 +fnic_trace_ctrl_write_13229 fnic_trace_ctrl_write 3 13229 NULL
95506 +asix_read_cmd_13245 asix_read_cmd 5 13245 NULL
95507 +fw_download_code_13249 fw_download_code 3 13249 NULL nohasharray
95508 +kvm_lapic_enable_pv_eoi_13249 kvm_lapic_enable_pv_eoi 2 13249 &fw_download_code_13249
95509 +init_tid_tabs_13252 init_tid_tabs 2-3-4 13252 NULL
95510 +hostap_80211_get_hdrlen_13255 hostap_80211_get_hdrlen 0 13255 NULL
95511 +bio_integrity_trim_13259 bio_integrity_trim 3 13259 NULL
95512 +c4iw_reg_user_mr_13269 c4iw_reg_user_mr 2-3 13269 NULL
95513 +carl9170_rx_13272 carl9170_rx 3 13272 NULL
95514 +pmcraid_notify_aen_13274 pmcraid_notify_aen 3 13274 NULL
95515 +il4965_stats_flag_13281 il4965_stats_flag 0-3 13281 NULL
95516 +lpfc_idiag_mbxacc_get_setup_13282 lpfc_idiag_mbxacc_get_setup 0 13282 NULL
95517 +platform_device_add_resources_13289 platform_device_add_resources 3 13289 NULL
95518 +i915_drop_caches_write_13308 i915_drop_caches_write 3 13308 NULL
95519 +us122l_ctl_msg_13330 us122l_ctl_msg 8 13330 NULL
95520 +__clone_and_map_data_bio_13334 __clone_and_map_data_bio 4-8 13334 NULL
95521 +kvm_read_nested_guest_page_13337 kvm_read_nested_guest_page 5-2 13337 NULL
95522 +cache_ctr_13364 cache_ctr 2 13364 NULL
95523 +mthca_alloc_mtt_range_13371 mthca_alloc_mtt_range 2 13371 NULL
95524 +iso_sched_alloc_13377 iso_sched_alloc 1 13377 NULL nohasharray
95525 +wep_key_not_found_read_13377 wep_key_not_found_read 3 13377 &iso_sched_alloc_13377
95526 +carl9170_rx_untie_data_13405 carl9170_rx_untie_data 3 13405 NULL
95527 +sky2_receive_13407 sky2_receive 2 13407 NULL
95528 +netxen_alloc_sds_rings_13417 netxen_alloc_sds_rings 2 13417 NULL
95529 +keyring_read_13438 keyring_read 3 13438 NULL
95530 +sctp_setsockopt_peer_primary_addr_13440 sctp_setsockopt_peer_primary_addr 3 13440 NULL nohasharray
95531 +set_tap_pwup_pfs_13440 set_tap_pwup_pfs 3 13440 &sctp_setsockopt_peer_primary_addr_13440
95532 +ath6kl_cfg80211_connect_event_13443 ath6kl_cfg80211_connect_event 8-9-7 13443 NULL
95533 +mthca_buddy_alloc_13454 mthca_buddy_alloc 2 13454 NULL
95534 +ocfs2_align_bytes_to_blocks_13512 ocfs2_align_bytes_to_blocks 2 13512 NULL
95535 +core_status_13515 core_status 4 13515 NULL
95536 +smk_write_mapped_13519 smk_write_mapped 3 13519 NULL
95537 +bm_init_13529 bm_init 2 13529 NULL
95538 +non_atomic_pte_lookup_13540 non_atomic_pte_lookup 2 13540 NULL
95539 +ieee80211_if_read_ap_power_level_13558 ieee80211_if_read_ap_power_level 3 13558 NULL
95540 +ubifs_get_idx_gc_leb_13566 ubifs_get_idx_gc_leb 0 13566 NULL
95541 +sys_madvise_13569 sys_madvise 1 13569 NULL
95542 +read_file_antenna_13574 read_file_antenna 3 13574 NULL
95543 +cache_write_13589 cache_write 3 13589 NULL
95544 +mpt_lan_receive_post_turbo_13592 mpt_lan_receive_post_turbo 2 13592 NULL
95545 +aac_sa_ioremap_13596 aac_sa_ioremap 2 13596 NULL nohasharray
95546 +irias_new_octseq_value_13596 irias_new_octseq_value 2 13596 &aac_sa_ioremap_13596
95547 +usb_dump_interface_descriptor_13603 usb_dump_interface_descriptor 0 13603 NULL
95548 +swap_cgroup_swapon_13614 swap_cgroup_swapon 2 13614 NULL
95549 +wm8994_bulk_write_13615 wm8994_bulk_write 2-3 13615 NULL
95550 +pmcraid_get_minor_13619 pmcraid_get_minor 0 13619 NULL
95551 +iio_device_add_event_sysfs_13627 iio_device_add_event_sysfs 0 13627 NULL
95552 +packet_snd_13634 packet_snd 3 13634 NULL
95553 +blk_msg_write_13655 blk_msg_write 3 13655 NULL
95554 +cache_downcall_13666 cache_downcall 3 13666 NULL
95555 +fw_iso_buffer_alloc_13704 fw_iso_buffer_alloc 2 13704 NULL
95556 +audit_unpack_string_13748 audit_unpack_string 3 13748 NULL
95557 +ufs_dtog_13750 ufs_dtog 0-2 13750 NULL
95558 +ieee802154_alloc_device_13767 ieee802154_alloc_device 1 13767 NULL
95559 +fb_sys_read_13778 fb_sys_read 3 13778 NULL
95560 +ath6kl_mgmt_powersave_ap_13791 ath6kl_mgmt_powersave_ap 6 13791 NULL
95561 +random_read_13815 random_read 3 13815 NULL
95562 +hsi_register_board_info_13820 hsi_register_board_info 2 13820 NULL
95563 +evdev_ioctl_compat_13851 evdev_ioctl_compat 2-3 13851 NULL
95564 +compat_ip_setsockopt_13870 compat_ip_setsockopt 5 13870 NULL nohasharray
95565 +alloc_trace_uprobe_13870 alloc_trace_uprobe 3 13870 &compat_ip_setsockopt_13870
95566 +qp_memcpy_to_queue_13886 qp_memcpy_to_queue 2-5 13886 NULL
95567 +snd_pcm_aio_read_13900 snd_pcm_aio_read 3 13900 NULL
95568 +ext3_xattr_block_get_13936 ext3_xattr_block_get 0 13936 NULL
95569 +ieee80211_if_read_dot11MeshForwarding_13940 ieee80211_if_read_dot11MeshForwarding 3 13940 NULL nohasharray
95570 +ocfs2_xa_value_truncate_13940 ocfs2_xa_value_truncate 2 13940 &ieee80211_if_read_dot11MeshForwarding_13940
95571 +iwl_dbgfs_protection_mode_read_13943 iwl_dbgfs_protection_mode_read 3 13943 NULL
95572 +compat_chaninfo_13945 compat_chaninfo 2 13945 NULL
95573 +ieee80211_if_read_min_discovery_timeout_13946 ieee80211_if_read_min_discovery_timeout 3 13946 NULL
95574 +lpfc_idiag_queacc_read_13950 lpfc_idiag_queacc_read 3 13950 NULL
95575 +snd_pcm_plug_slave_size_13967 snd_pcm_plug_slave_size 0-2 13967 NULL
95576 +com90xx_found_13974 com90xx_found 3 13974 NULL
95577 +qcam_read_13977 qcam_read 3 13977 NULL
95578 +dsp_read_13980 dsp_read 2 13980 NULL
95579 +bm_block_bits_13981 bm_block_bits 0 13981 NULL nohasharray
95580 +dvb_demux_read_13981 dvb_demux_read 3 13981 &bm_block_bits_13981
95581 +btrfs_get_blocks_direct_14016 btrfs_get_blocks_direct 2 14016 NULL
95582 +_rtl92s_firmware_downloadcode_14021 _rtl92s_firmware_downloadcode 3 14021 NULL
95583 +dvb_usercopy_14036 dvb_usercopy 2 14036 NULL
95584 +read_def_modal_eeprom_14041 read_def_modal_eeprom 3 14041 NULL
95585 +ieee80211_if_fmt_aid_14055 ieee80211_if_fmt_aid 3 14055 NULL
95586 +sta_agg_status_read_14058 sta_agg_status_read 3 14058 NULL
95587 +i915_drop_caches_read_14060 i915_drop_caches_read 3 14060 NULL
95588 +do_proc_readlink_14096 do_proc_readlink 3 14096 NULL
95589 +compat_sys_pselect6_14105 compat_sys_pselect6 1 14105 NULL
95590 +nlmsg_len_14115 nlmsg_len 0 14115 NULL
95591 +vfio_fops_compat_ioctl_14130 vfio_fops_compat_ioctl 3 14130 NULL
95592 +ntfs_rl_replace_14136 ntfs_rl_replace 2-4 14136 NULL
95593 +em_canid_change_14150 em_canid_change 3 14150 NULL
95594 +gsm_dlci_data_14155 gsm_dlci_data 3 14155 NULL
95595 +print_input_mask_14168 print_input_mask 3-0 14168 NULL
95596 +ocfs2_xattr_value_truncate_14183 ocfs2_xattr_value_truncate 3 14183 NULL
95597 +alloc_async_14208 alloc_async 1 14208 NULL
95598 +sys_kexec_load_14222 sys_kexec_load 2 14222 NULL
95599 +ieee80211_if_write_uapsd_max_sp_len_14233 ieee80211_if_write_uapsd_max_sp_len 3 14233 NULL
95600 +dma_declare_coherent_memory_14244 dma_declare_coherent_memory 4-2 14244 NULL
95601 +snd_soc_hw_bulk_write_raw_14245 snd_soc_hw_bulk_write_raw 2-4 14245 NULL
95602 +reiserfs_compat_ioctl_14265 reiserfs_compat_ioctl 3 14265 NULL
95603 +ath6kl_connect_event_14267 ath6kl_connect_event 8-9-7 14267 NULL
95604 +add_numbered_child_14273 add_numbered_child 5 14273 NULL
95605 +OS_mem_token_alloc_14276 OS_mem_token_alloc 1 14276 NULL
95606 +snd_seq_oss_readq_new_14283 snd_seq_oss_readq_new 2 14283 NULL
95607 +rr_status_14293 rr_status 5 14293 NULL
95608 +read_default_ldt_14302 read_default_ldt 2 14302 NULL
95609 +oo_objects_14319 oo_objects 0 14319 NULL
95610 +p9_client_zc_rpc_14345 p9_client_zc_rpc 7 14345 NULL
95611 +scsi2int_14358 scsi2int 0 14358 NULL
95612 +snd_pcm_lib_readv_14363 snd_pcm_lib_readv 0-3 14363 NULL
95613 +acpi_get_override_irq_14381 acpi_get_override_irq 1 14381 NULL
95614 +ath6kl_regdump_read_14393 ath6kl_regdump_read 3 14393 NULL
95615 +smk_write_onlycap_14400 smk_write_onlycap 3 14400 NULL
95616 +mtd_concat_create_14416 mtd_concat_create 2 14416 NULL
95617 +get_kcore_size_14425 get_kcore_size 0 14425 NULL
95618 +check_lpt_crc_14442 check_lpt_crc 0 14442 NULL
95619 +block_size_14443 block_size 0 14443 NULL
95620 +ci13xxx_add_device_14456 ci13xxx_add_device 3 14456 NULL
95621 +snd_emu10k1_proc_spdif_status_14457 snd_emu10k1_proc_spdif_status 4-5 14457 NULL
95622 +udplite_getfrag_14479 udplite_getfrag 3-4 14479 NULL
95623 +ieee80211_if_read_dot11MeshGateAnnouncementProtocol_14486 ieee80211_if_read_dot11MeshGateAnnouncementProtocol 3 14486 NULL
95624 +ocfs2_debug_read_14507 ocfs2_debug_read 3 14507 NULL
95625 +dataflash_read_user_otp_14536 dataflash_read_user_otp 2-3 14536 NULL nohasharray
95626 +ep0_write_14536 ep0_write 3 14536 &dataflash_read_user_otp_14536
95627 +picolcd_debug_eeprom_read_14549 picolcd_debug_eeprom_read 3 14549 NULL
95628 +drm_vmalloc_dma_14550 drm_vmalloc_dma 1 14550 NULL
95629 +usb_dump_desc_14553 usb_dump_desc 0 14553 NULL
95630 +qp_host_alloc_queue_14566 qp_host_alloc_queue 1 14566 NULL
95631 +remap_to_origin_then_cache_14583 remap_to_origin_then_cache 3 14583 NULL
95632 +idmap_pipe_downcall_14591 idmap_pipe_downcall 3 14591 NULL
95633 +ceph_osdc_alloc_request_14597 ceph_osdc_alloc_request 3 14597 NULL
95634 +ocfs2_trim_group_14641 ocfs2_trim_group 4-3 14641 NULL
95635 +dbJoin_14644 dbJoin 0 14644 NULL
95636 +profile_replace_14652 profile_replace 3 14652 NULL
95637 +pipeline_enc_tx_stat_fifo_int_read_14680 pipeline_enc_tx_stat_fifo_int_read 3 14680 NULL
95638 +ieee80211_if_fmt_rc_rateidx_mask_2ghz_14683 ieee80211_if_fmt_rc_rateidx_mask_2ghz 3 14683 NULL
95639 +tsi148_master_set_14685 tsi148_master_set 4 14685 NULL
95640 +u_audio_playback_14709 u_audio_playback 3 14709 NULL
95641 +get_bio_block_14714 get_bio_block 0 14714 NULL
95642 +vfd_write_14717 vfd_write 3 14717 NULL
95643 +__blk_end_request_14729 __blk_end_request 3 14729 NULL
95644 +raid1_resize_14740 raid1_resize 2 14740 NULL
95645 +btrfs_inode_extref_name_len_14752 btrfs_inode_extref_name_len 0 14752 NULL
95646 +rx_rx_cmplt_read_14753 rx_rx_cmplt_read 3 14753 NULL
95647 +qla82xx_pci_mem_write_2M_14765 qla82xx_pci_mem_write_2M 2 14765 NULL
95648 +regmap_range_read_file_14775 regmap_range_read_file 3 14775 NULL
95649 +sta_dev_read_14782 sta_dev_read 3 14782 NULL
95650 +ext4_kvmalloc_14796 ext4_kvmalloc 1 14796 NULL
95651 +hpet_readl_14801 hpet_readl 0 14801 NULL nohasharray
95652 +snd_als300_gcr_read_14801 snd_als300_gcr_read 0 14801 &hpet_readl_14801
95653 +bcma_scan_read32_14802 bcma_scan_read32 0 14802 NULL
95654 +__mutex_fastpath_lock_retval_14844 __mutex_fastpath_lock_retval 0 14844 NULL
95655 +mrp_attr_create_14853 mrp_attr_create 3 14853 NULL
95656 +lcd_write_14857 lcd_write 3 14857 NULL nohasharray
95657 +__krealloc_14857 __krealloc 2 14857 &lcd_write_14857
95658 +get_user_cpu_mask_14861 get_user_cpu_mask 2 14861 NULL
95659 +sriov_enable_migration_14889 sriov_enable_migration 2 14889 NULL
95660 +acpi_os_allocate_14892 acpi_os_allocate 1 14892 NULL
95661 +unifi_read_14899 unifi_read 3 14899 NULL
95662 +krealloc_14908 krealloc 2 14908 NULL
95663 +regmap_irq_get_virq_14910 regmap_irq_get_virq 2 14910 NULL
95664 +__arch_hweight64_14923 __arch_hweight64 0 14923 NULL nohasharray
95665 +qp_memcpy_to_queue_iov_14923 qp_memcpy_to_queue_iov 2-5 14923 &__arch_hweight64_14923
95666 +ocfs2_expand_nonsparse_inode_14936 ocfs2_expand_nonsparse_inode 3-4 14936 NULL
95667 +queue_cnt_14951 queue_cnt 0 14951 NULL
95668 +videobuf_read_stream_14956 videobuf_read_stream 3 14956 NULL
95669 +mce_flush_rx_buffer_14976 mce_flush_rx_buffer 2 14976 NULL
95670 +setkey_14987 setkey 3 14987 NULL nohasharray
95671 +gpio_twl4030_write_14987 gpio_twl4030_write 1 14987 &setkey_14987
95672 +vmap_15025 vmap 2 15025 NULL
95673 +blk_integrity_tuple_size_15027 blk_integrity_tuple_size 0 15027 NULL
95674 +irq_get_next_irq_15053 irq_get_next_irq 1 15053 NULL
95675 +cld_pipe_downcall_15058 cld_pipe_downcall 3 15058 NULL
95676 +ieee80211_if_read_uapsd_max_sp_len_15067 ieee80211_if_read_uapsd_max_sp_len 3 15067 NULL
95677 +nfs4_write_cached_acl_15070 nfs4_write_cached_acl 4 15070 NULL
95678 +ntfs_copy_from_user_15072 ntfs_copy_from_user 3-5 15072 NULL
95679 +hex_dump_to_buffer_15121 hex_dump_to_buffer 6 15121 NULL
95680 +start_port_15124 start_port 0 15124 NULL
95681 +memchr_15126 memchr 0 15126 NULL
95682 +ipwireless_ppp_mru_15153 ipwireless_ppp_mru 0 15153 NULL
95683 +self_check_not_bad_15175 self_check_not_bad 0 15175 NULL
95684 +iscsi_create_endpoint_15193 iscsi_create_endpoint 1 15193 NULL
95685 +reserve_resources_15194 reserve_resources 3 15194 NULL
95686 +bfad_debugfs_write_regrd_15218 bfad_debugfs_write_regrd 3 15218 NULL
95687 +il_dbgfs_rx_stats_read_15243 il_dbgfs_rx_stats_read 3 15243 NULL
95688 +compat_raw_ioctl_15290 compat_raw_ioctl 3 15290 NULL
95689 +sys_connect_15291 sys_connect 3 15291 NULL nohasharray
95690 +xlate_dev_mem_ptr_15291 xlate_dev_mem_ptr 1 15291 &sys_connect_15291
95691 +arch_enable_uv_irq_15294 arch_enable_uv_irq 2 15294 NULL
95692 +acpi_ev_create_gpe_block_15297 acpi_ev_create_gpe_block 5 15297 NULL
95693 +tpm_tis_init_15304 tpm_tis_init 2-3 15304 NULL
95694 +fcoe_ctlr_send_keep_alive_15308 fcoe_ctlr_send_keep_alive 3 15308 NULL
95695 +__ocfs2_remove_xattr_range_15330 __ocfs2_remove_xattr_range 4-5-3 15330 NULL
95696 +kovaplus_sysfs_read_15337 kovaplus_sysfs_read 6 15337 NULL
95697 +ioread16_15342 ioread16 0 15342 NULL
95698 +alloc_ring_15345 alloc_ring 2-4 15345 NULL
95699 +acpi_ut_create_string_object_15360 acpi_ut_create_string_object 1 15360 NULL
95700 +graph_depth_read_15371 graph_depth_read 3 15371 NULL
95701 +compat_sys_process_vm_readv_15374 compat_sys_process_vm_readv 3-5 15374 NULL
95702 +fq_codel_zalloc_15378 fq_codel_zalloc 1 15378 NULL
95703 +domain_flush_pages_15379 domain_flush_pages 2-3 15379 NULL
95704 +alloc_fddidev_15382 alloc_fddidev 1 15382 NULL
95705 +btrfs_level_size_15392 btrfs_level_size 0 15392 NULL
95706 +pipeline_csum_to_rx_xfer_swi_read_15403 pipeline_csum_to_rx_xfer_swi_read 3 15403 NULL
95707 +get_modalias_15406 get_modalias 2 15406 NULL
95708 +dm_cache_resize_15422 dm_cache_resize 2 15422 NULL
95709 +__videobuf_copy_to_user_15423 __videobuf_copy_to_user 4 15423 NULL
95710 +tcp_mtu_to_mss_15438 tcp_mtu_to_mss 2 15438 NULL
95711 +hpsa_change_queue_depth_15449 hpsa_change_queue_depth 2 15449 NULL
95712 +memweight_15450 memweight 2 15450 NULL
95713 +vmalloc_15464 vmalloc 1 15464 NULL
95714 +zd_chip_is_zd1211b_15518 zd_chip_is_zd1211b 0 15518 NULL
95715 +da9052_bat_irq_15533 da9052_bat_irq 1 15533 NULL
95716 +p9_check_zc_errors_15534 p9_check_zc_errors 4 15534 NULL
95717 +ql_process_mac_rx_page_15543 ql_process_mac_rx_page 4 15543 NULL
95718 +ieee80211_amsdu_to_8023s_15561 ieee80211_amsdu_to_8023s 5 15561 NULL
95719 +persistent_status_15574 persistent_status 4 15574 NULL
95720 +bnx2fc_process_unsol_compl_15576 bnx2fc_process_unsol_compl 2 15576 NULL
95721 +vme_user_write_15587 vme_user_write 3 15587 NULL
95722 +ocfs2_truncate_rec_15595 ocfs2_truncate_rec 7 15595 NULL
95723 +sx150x_install_irq_chip_15609 sx150x_install_irq_chip 3 15609 NULL
95724 +iommu_device_max_index_15620 iommu_device_max_index 0-3-2-1 15620 NULL nohasharray
95725 +compat_fillonedir_15620 compat_fillonedir 3 15620 &iommu_device_max_index_15620
95726 +set_dis_tap_pfs_15621 set_dis_tap_pfs 3 15621 NULL
95727 +proc_loginuid_read_15631 proc_loginuid_read 3 15631 NULL
95728 +tomoyo_scan_bprm_15642 tomoyo_scan_bprm 2-4 15642 NULL nohasharray
95729 +sk_memory_allocated_add_15642 sk_memory_allocated_add 2 15642 &tomoyo_scan_bprm_15642 nohasharray
95730 +pipeline_hs_tx_stat_fifo_int_read_15642 pipeline_hs_tx_stat_fifo_int_read 3 15642 &sk_memory_allocated_add_15642
95731 +fs_path_add_15648 fs_path_add 3 15648 NULL
95732 +xsd_read_15653 xsd_read 3 15653 NULL
95733 +compat_sys_fcntl_15654 compat_sys_fcntl 3 15654 NULL
95734 +unix_bind_15668 unix_bind 3 15668 NULL
95735 +dm_read_15674 dm_read 3 15674 NULL
95736 +pstore_mkfile_15675 pstore_mkfile 6 15675 NULL
95737 +uf_sme_queue_message_15697 uf_sme_queue_message 3 15697 NULL
95738 +ocfs2_split_tree_15716 ocfs2_split_tree 5 15716 NULL
95739 +HiSax_readstatus_15752 HiSax_readstatus 2 15752 NULL
95740 +bitmap_search_next_usable_block_15762 bitmap_search_next_usable_block 3-1 15762 NULL
95741 +do_test_15766 do_test 1 15766 NULL
95742 +set_std_nic_pfs_15792 set_std_nic_pfs 3 15792 NULL
95743 +smk_read_direct_15803 smk_read_direct 3 15803 NULL
95744 +snd_pcm_ioctl_compat_15804 snd_pcm_ioctl_compat 3 15804 NULL
95745 +gx1_read_conf_reg_15817 gx1_read_conf_reg 0 15817 NULL nohasharray
95746 +nameseq_list_15817 nameseq_list 3 15817 &gx1_read_conf_reg_15817 nohasharray
95747 +gnttab_expand_15817 gnttab_expand 1 15817 &nameseq_list_15817
95748 +afs_proc_rootcell_write_15822 afs_proc_rootcell_write 3 15822 NULL
95749 +brcmf_sdbrcm_died_dump_15841 brcmf_sdbrcm_died_dump 3 15841 NULL
95750 +table_size_15851 table_size 0-1-2 15851 NULL
95751 +ubi_io_write_15870 ubi_io_write 5-4 15870 NULL nohasharray
95752 +media_entity_init_15870 media_entity_init 2-4 15870 &ubi_io_write_15870
95753 +__mptctl_ioctl_15875 __mptctl_ioctl 2 15875 NULL
95754 +nfs_map_group_to_gid_15892 nfs_map_group_to_gid 3 15892 NULL
95755 +native_read_msr_15905 native_read_msr 0 15905 NULL
95756 +parse_audio_stream_data_15937 parse_audio_stream_data 3 15937 NULL
95757 +power_read_15939 power_read 3 15939 NULL
95758 +lpfc_idiag_drbacc_read_15948 lpfc_idiag_drbacc_read 3 15948 NULL
95759 +snd_pcm_lib_read_transfer_15952 snd_pcm_lib_read_transfer 4-2-5 15952 NULL
95760 +remap_pci_mem_15966 remap_pci_mem 1-2 15966 NULL
95761 +frame_alloc_15981 frame_alloc 4 15981 NULL
95762 +alloc_vm_area_15989 alloc_vm_area 1 15989 NULL
95763 +hdpvr_register_videodev_16010 hdpvr_register_videodev 3 16010 NULL
95764 +viafb_vt1636_proc_write_16018 viafb_vt1636_proc_write 3 16018 NULL
95765 +got_frame_16028 got_frame 2 16028 NULL
95766 +read_file_spectral_period_16057 read_file_spectral_period 3 16057 NULL
95767 +isr_tx_exch_complete_read_16103 isr_tx_exch_complete_read 3 16103 NULL
95768 +dma_tx_requested_read_16110 dma_tx_requested_read 3 16110 NULL nohasharray
95769 +isr_hw_pm_mode_changes_read_16110 isr_hw_pm_mode_changes_read 3 16110 &dma_tx_requested_read_16110
95770 +irq_set_chip_and_handler_name_16111 irq_set_chip_and_handler_name 1 16111 NULL
95771 +snd_dma_pointer_16126 snd_dma_pointer 0-2 16126 NULL
95772 +compat_sys_select_16131 compat_sys_select 1 16131 NULL
95773 +fsm_init_16134 fsm_init 2 16134 NULL
95774 +hysdn_rx_netpkt_16136 hysdn_rx_netpkt 3 16136 NULL
95775 +ext4_xattr_block_get_16148 ext4_xattr_block_get 0 16148 NULL
95776 +bnx2i_get_cid_num_16166 bnx2i_get_cid_num 0 16166 NULL
95777 +mapping_level_16188 mapping_level 2 16188 NULL
95778 +cipso_v4_map_cat_rng_hton_16203 cipso_v4_map_cat_rng_hton 0 16203 NULL
95779 +create_table_16213 create_table 2 16213 NULL
95780 +atomic_read_file_16227 atomic_read_file 3 16227 NULL
95781 +BcmGetSectionValStartOffset_16235 BcmGetSectionValStartOffset 0 16235 NULL
95782 +swiotlb_sync_single_for_device_16247 swiotlb_sync_single_for_device 2 16247 NULL nohasharray
95783 +btrfs_dev_extent_chunk_offset_16247 btrfs_dev_extent_chunk_offset 0 16247 &swiotlb_sync_single_for_device_16247
95784 +mark_written_sectors_16262 mark_written_sectors 2 16262 NULL
95785 +reiserfs_acl_count_16265 reiserfs_acl_count 0-1 16265 NULL
95786 +set_disc_pfs_16270 set_disc_pfs 3 16270 NULL
95787 +mq_force_mapping_16277 mq_force_mapping 2 16277 NULL
95788 +ocfs2_xattr_bucket_value_truncate_16279 ocfs2_xattr_bucket_value_truncate 4 16279 NULL
95789 +drbd_setsockopt_16280 drbd_setsockopt 5 16280 NULL nohasharray
95790 +nand_bch_init_16280 nand_bch_init 3-2 16280 &drbd_setsockopt_16280
95791 +account_16283 account 0-2-4 16283 NULL nohasharray
95792 +mirror_status_16283 mirror_status 5 16283 &account_16283
95793 +retry_instruction_16285 retry_instruction 2 16285 NULL
95794 +stk_allocate_buffers_16291 stk_allocate_buffers 2 16291 NULL
95795 +rsc_mgr_init_16299 rsc_mgr_init 3 16299 NULL
95796 +wb_map_16301 wb_map 2 16301 NULL
95797 +vmw_cursor_update_image_16332 vmw_cursor_update_image 3-4 16332 NULL
95798 +total_ps_buffered_read_16365 total_ps_buffered_read 3 16365 NULL
95799 +iscsi_tcp_conn_setup_16376 iscsi_tcp_conn_setup 2 16376 NULL
95800 +nl80211_send_unprot_deauth_16378 nl80211_send_unprot_deauth 4 16378 NULL
95801 +diva_os_malloc_16406 diva_os_malloc 2 16406 NULL
95802 +ieee80211_if_read_tsf_16420 ieee80211_if_read_tsf 3 16420 NULL
95803 +rxrpc_server_keyring_16431 rxrpc_server_keyring 3 16431 NULL
95804 +netlink_change_ngroups_16457 netlink_change_ngroups 2 16457 NULL
95805 +tracing_readme_read_16493 tracing_readme_read 3 16493 NULL
95806 +snd_interval_max_16529 snd_interval_max 0 16529 NULL
95807 +raid10_resize_16537 raid10_resize 2 16537 NULL
95808 +tcp_manip_pkt_16563 tcp_manip_pkt 4 16563 NULL
95809 +lpfc_debugfs_read_16566 lpfc_debugfs_read 3 16566 NULL
95810 +agp_allocate_memory_wrap_16576 agp_allocate_memory_wrap 1 16576 NULL
95811 +virt_to_scatterlist_16582 virt_to_scatterlist 2 16582 NULL
95812 +palmas_irq_get_virq_16613 palmas_irq_get_virq 2 16613 NULL
95813 +btrfs_get_token_32_16651 btrfs_get_token_32 0 16651 NULL
95814 +mfd_add_devices_16668 mfd_add_devices 4 16668 NULL
95815 +ax88179_write_cmd_async_16671 ax88179_write_cmd_async 5 16671 NULL
95816 +arcmsr_adjust_disk_queue_depth_16756 arcmsr_adjust_disk_queue_depth 2 16756 NULL
95817 +compat_blkdev_driver_ioctl_16769 compat_blkdev_driver_ioctl 4 16769 NULL
95818 +blk_rq_map_user_iov_16772 blk_rq_map_user_iov 5 16772 NULL
95819 +i2o_parm_issue_16790 i2o_parm_issue 0 16790 NULL
95820 +get_server_iovec_16804 get_server_iovec 2 16804 NULL
95821 +tipc_send2name_16809 tipc_send2name 6 16809 NULL
95822 +dm_vcalloc_16814 dm_vcalloc 1-2 16814 NULL
95823 +drm_malloc_ab_16831 drm_malloc_ab 1-2 16831 NULL
95824 +scsi_mode_sense_16835 scsi_mode_sense 5 16835 NULL
95825 +hfsplus_min_io_size_16859 hfsplus_min_io_size 0 16859 NULL
95826 +alloc_idx_lebs_16872 alloc_idx_lebs 2 16872 NULL
95827 +carl9170_debugfs_ampdu_state_read_16873 carl9170_debugfs_ampdu_state_read 3 16873 NULL
95828 +st_write_16874 st_write 3 16874 NULL
95829 +__kfifo_peek_n_16877 __kfifo_peek_n 0 16877 NULL
95830 +idx_to_pfn_16919 idx_to_pfn 0 16919 NULL
95831 +psb_unlocked_ioctl_16926 psb_unlocked_ioctl 2 16926 NULL nohasharray
95832 +snd_gf1_mem_proc_dump_16926 snd_gf1_mem_proc_dump 5 16926 &psb_unlocked_ioctl_16926
95833 +_sp2d_alloc_16944 _sp2d_alloc 1-2-3 16944 NULL
95834 +squashfs_read_table_16945 squashfs_read_table 3 16945 NULL
95835 +cfg80211_send_unprot_disassoc_16951 cfg80211_send_unprot_disassoc 3 16951 NULL
95836 +keyctl_instantiate_key_iov_16969 keyctl_instantiate_key_iov 3 16969 NULL
95837 +ceph_read_dir_17005 ceph_read_dir 3 17005 NULL
95838 +copy_counters_to_user_17027 copy_counters_to_user 5 17027 NULL
95839 +jffs2_trusted_setxattr_17048 jffs2_trusted_setxattr 4 17048 NULL
95840 +__arch_hweight32_17060 __arch_hweight32 0 17060 NULL
95841 +dvb_dvr_read_17073 dvb_dvr_read 3 17073 NULL
95842 +simple_transaction_read_17076 simple_transaction_read 3 17076 NULL
95843 +__kmalloc_reserve_17080 __kmalloc_reserve 1 17080 NULL
95844 +carl9170_debugfs_mem_usage_read_17084 carl9170_debugfs_mem_usage_read 3 17084 NULL
95845 +mac_address_string_17091 mac_address_string 0 17091 NULL
95846 +entry_length_17093 entry_length 0 17093 NULL
95847 +sys_preadv_17100 sys_preadv 3 17100 NULL
95848 +pvr2_hdw_state_report_17121 pvr2_hdw_state_report 3 17121 NULL
95849 +mwifiex_get_common_rates_17131 mwifiex_get_common_rates 3 17131 NULL
95850 +nouveau_instobj_create__17144 nouveau_instobj_create_ 4 17144 NULL
95851 +sep_read_17161 sep_read 3 17161 NULL
95852 +befs_nls2utf_17163 befs_nls2utf 3 17163 NULL
95853 +tx_tx_start_templates_read_17164 tx_tx_start_templates_read 3 17164 NULL
95854 +UniStrnlen_17169 UniStrnlen 0 17169 NULL
95855 +access_remote_vm_17189 access_remote_vm 0-2-4 17189 NULL
95856 +driver_state_read_17194 driver_state_read 3 17194 NULL nohasharray
95857 +iscsit_find_cmd_from_itt_or_dump_17194 iscsit_find_cmd_from_itt_or_dump 3 17194 &driver_state_read_17194
95858 +dn_recvmsg_17213 dn_recvmsg 4 17213 NULL
95859 +to_oblock_17254 to_oblock 0-1 17254 NULL
95860 +unpack_value_17259 unpack_value 1 17259 NULL
95861 +__be16_to_cpup_17261 __be16_to_cpup 0 17261 NULL
95862 +error_error_frame_cts_nul_flid_read_17262 error_error_frame_cts_nul_flid_read 3 17262 NULL
95863 +alloc_ep_17269 alloc_ep 1 17269 NULL
95864 +pg_read_17276 pg_read 3 17276 NULL
95865 +raw_recvmsg_17277 raw_recvmsg 4 17277 NULL
95866 +hmac_sha256_17278 hmac_sha256 2 17278 NULL
95867 +neigh_hash_grow_17283 neigh_hash_grow 2 17283 NULL
95868 +minstrel_stats_read_17290 minstrel_stats_read 3 17290 NULL
95869 +install_breakpoint_17292 install_breakpoint 4 17292 NULL
95870 +ieee80211_if_fmt_dot11MeshForwarding_17301 ieee80211_if_fmt_dot11MeshForwarding 3 17301 NULL
95871 +skb_pad_17302 skb_pad 2 17302 NULL
95872 +mb_cache_create_17307 mb_cache_create 2 17307 NULL
95873 +gnttab_map_frames_v2_17314 gnttab_map_frames_v2 2 17314 NULL
95874 +ata_host_alloc_pinfo_17325 ata_host_alloc_pinfo 3 17325 NULL
95875 +ieee80211_if_read_dot11MeshHWMPperrMinInterval_17346 ieee80211_if_read_dot11MeshHWMPperrMinInterval 3 17346 NULL
95876 +ath6kl_wmi_send_mgmt_cmd_17347 ath6kl_wmi_send_mgmt_cmd 7 17347 NULL
95877 +_fd_dma_mem_free_17406 _fd_dma_mem_free 1 17406 NULL
95878 +lpfc_debugfs_dif_err_write_17424 lpfc_debugfs_dif_err_write 3 17424 NULL
95879 +sta_connected_time_read_17435 sta_connected_time_read 3 17435 NULL
95880 +nla_get_u32_17455 nla_get_u32 0 17455 NULL
95881 +__ref_totlen_17461 __ref_totlen 0 17461 NULL
95882 +compat_cmd_17465 compat_cmd 2 17465 NULL
95883 +probe_bios_17467 probe_bios 1 17467 NULL
95884 +probe_kernel_write_17481 probe_kernel_write 3 17481 NULL
95885 +__alloc_session_17485 __alloc_session 2-1 17485 NULL
95886 +TSS_rawhmac_17486 TSS_rawhmac 3 17486 NULL
95887 +bitmap_pos_to_ord_17503 bitmap_pos_to_ord 3 17503 NULL
95888 +__copy_to_user_17551 __copy_to_user 0-3 17551 NULL
95889 +copy_from_user_17559 copy_from_user 3 17559 NULL
95890 +acpi_ut_create_package_object_17594 acpi_ut_create_package_object 1 17594 NULL
95891 +neigh_hash_alloc_17595 neigh_hash_alloc 1 17595 NULL
95892 +rts51x_write_mem_17598 rts51x_write_mem 4 17598 NULL
95893 +iwl_dump_nic_event_log_17601 iwl_dump_nic_event_log 0 17601 NULL
95894 +wm8994_gpio_to_irq_17604 wm8994_gpio_to_irq 2 17604 NULL
95895 +osst_execute_17607 osst_execute 7-6 17607 NULL
95896 +ocfs2_mark_extent_written_17615 ocfs2_mark_extent_written 6 17615 NULL
95897 +ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout_17618 ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout 3 17618 NULL
95898 +twl4030_set_gpio_direction_17645 twl4030_set_gpio_direction 1 17645 NULL
95899 +packet_setsockopt_17662 packet_setsockopt 5 17662 NULL nohasharray
95900 +ubi_io_read_data_17662 ubi_io_read_data 0 17662 &packet_setsockopt_17662
95901 +pwr_enable_ps_read_17686 pwr_enable_ps_read 3 17686 NULL
95902 +gfn_to_pfn_memslot_17693 gfn_to_pfn_memslot 2 17693 NULL
95903 +__einj_error_trigger_17707 __einj_error_trigger 1 17707 NULL nohasharray
95904 +venus_rename_17707 venus_rename 5-4 17707 &__einj_error_trigger_17707
95905 +exofs_read_lookup_dev_table_17733 exofs_read_lookup_dev_table 3 17733 NULL
95906 +sctpprobe_read_17741 sctpprobe_read 3 17741 NULL
95907 +mark_unsafe_pages_17759 mark_unsafe_pages 0 17759 NULL
95908 +brcmf_usb_attach_17766 brcmf_usb_attach 2-3 17766 NULL
95909 +ubifs_leb_change_17789 ubifs_leb_change 4 17789 NULL
95910 +_snd_pcm_lib_alloc_vmalloc_buffer_17820 _snd_pcm_lib_alloc_vmalloc_buffer 2 17820 NULL
95911 +gnet_stats_copy_app_17821 gnet_stats_copy_app 3 17821 NULL
95912 +cipso_v4_gentag_rbm_17836 cipso_v4_gentag_rbm 0 17836 NULL
95913 +count_leafs_17842 count_leafs 0 17842 NULL
95914 +sisusb_send_bulk_msg_17864 sisusb_send_bulk_msg 3 17864 NULL
95915 +alloc_sja1000dev_17868 alloc_sja1000dev 1 17868 NULL
95916 +ray_cs_essid_proc_write_17875 ray_cs_essid_proc_write 3 17875 NULL
95917 +orinoco_set_key_17878 orinoco_set_key 5-7 17878 NULL
95918 +init_per_cpu_17880 init_per_cpu 1 17880 NULL
95919 +ieee80211_if_fmt_dot11MeshMaxPeerLinks_17883 ieee80211_if_fmt_dot11MeshMaxPeerLinks 3 17883 NULL
95920 +compat_sys_pwritev_17886 compat_sys_pwritev 3 17886 NULL
95921 +ieee80211_if_fmt_dot11MeshHWMPRootMode_17890 ieee80211_if_fmt_dot11MeshHWMPRootMode 3 17890 NULL
95922 +ocfs2_clusters_to_blocks_17896 ocfs2_clusters_to_blocks 0-2 17896 NULL
95923 +recover_head_17904 recover_head 3 17904 NULL
95924 +dccp_feat_register_sp_17914 dccp_feat_register_sp 5 17914 NULL
95925 +xfs_buf_associate_memory_17915 xfs_buf_associate_memory 3 17915 NULL
95926 +srp_iu_pool_alloc_17920 srp_iu_pool_alloc 2 17920 NULL
95927 +scsi_bufflen_17933 scsi_bufflen 0 17933 NULL
95928 +ufs_free_blocks_17963 ufs_free_blocks 2-3 17963 NULL
95929 +calc_nr_buckets_17976 calc_nr_buckets 0 17976 NULL
95930 +smk_write_cipso_17989 smk_write_cipso 3 17989 NULL
95931 +gnttab_max_grant_frames_17993 gnttab_max_grant_frames 0 17993 NULL
95932 +ext4_num_overhead_clusters_18001 ext4_num_overhead_clusters 2 18001 NULL
95933 +pvr2_v4l2_read_18006 pvr2_v4l2_read 3 18006 NULL
95934 +alloc_rx_desc_ring_18016 alloc_rx_desc_ring 2 18016 NULL
95935 +fill_read_18019 fill_read 0 18019 NULL
95936 +o2hb_highest_node_18034 o2hb_highest_node 2 18034 NULL
95937 +cryptd_alloc_instance_18048 cryptd_alloc_instance 2-3 18048 NULL
95938 +find_next_inuse_18051 find_next_inuse 2-3 18051 NULL
95939 +ddebug_proc_write_18055 ddebug_proc_write 3 18055 NULL
95940 +lua_sysfs_read_18062 lua_sysfs_read 6 18062 NULL
95941 +hex_byte_pack_18064 hex_byte_pack 0 18064 NULL
95942 +packet_came_18072 packet_came 3 18072 NULL
95943 +kvm_read_guest_page_18074 kvm_read_guest_page 5-2 18074 NULL
95944 +get_vm_area_18080 get_vm_area 1 18080 NULL
95945 +mpi_alloc_18094 mpi_alloc 1 18094 NULL
95946 +dfs_file_read_18116 dfs_file_read 3 18116 NULL
95947 +svc_getnl_18120 svc_getnl 0 18120 NULL
95948 +paging32_gpte_to_gfn_lvl_18131 paging32_gpte_to_gfn_lvl 0-1-2 18131 NULL
95949 +vmw_surface_dma_size_18132 vmw_surface_dma_size 0 18132 NULL
95950 +selinux_inode_setsecurity_18148 selinux_inode_setsecurity 4 18148 NULL
95951 +_has_tag_18169 _has_tag 2 18169 NULL
95952 +pccard_store_cis_18176 pccard_store_cis 6 18176 NULL
95953 +orinoco_add_extscan_result_18207 orinoco_add_extscan_result 3 18207 NULL
95954 +gsm_control_message_18209 gsm_control_message 4 18209 NULL
95955 +do_ipv6_setsockopt_18215 do_ipv6_setsockopt 5 18215 NULL
95956 +gnttab_alloc_grant_references_18240 gnttab_alloc_grant_references 1 18240 NULL
95957 +snd_ctl_ioctl_compat_18250 snd_ctl_ioctl_compat 3 18250 NULL
95958 +qdisc_class_hash_alloc_18262 qdisc_class_hash_alloc 1 18262 NULL
95959 +gfs2_alloc_sort_buffer_18275 gfs2_alloc_sort_buffer 1 18275 NULL
95960 +alloc_ring_18278 alloc_ring 2-4 18278 NULL
95961 +find_dirty_idx_leb_18280 find_dirty_idx_leb 0 18280 NULL
95962 +nouveau_subdev_create__18281 nouveau_subdev_create_ 7 18281 NULL nohasharray
95963 +bio_phys_segments_18281 bio_phys_segments 0 18281 &nouveau_subdev_create__18281
95964 +ext4_readpages_18283 ext4_readpages 4 18283 NULL
95965 +mmc_send_bus_test_18285 mmc_send_bus_test 4 18285 NULL
95966 +um_idi_write_18293 um_idi_write 3 18293 NULL
95967 +nouveau_disp_create__18305 nouveau_disp_create_ 4-7 18305 NULL
95968 +ip6ip6_err_18308 ip6ip6_err 5 18308 NULL
95969 +vga_r_18310 vga_r 0 18310 NULL
95970 +ecryptfs_send_message_18322 ecryptfs_send_message 2 18322 NULL
95971 +bio_integrity_advance_18324 bio_integrity_advance 2 18324 NULL
95972 +pwr_power_save_off_read_18355 pwr_power_save_off_read 3 18355 NULL
95973 +xlbd_reserve_minors_18365 xlbd_reserve_minors 1-2 18365 NULL
95974 +ep_io_18367 ep_io 0 18367 NULL
95975 +qib_user_sdma_num_pages_18371 qib_user_sdma_num_pages 0 18371 NULL
95976 +__video_register_device_18399 __video_register_device 3 18399 NULL
95977 +adis16136_show_serial_18402 adis16136_show_serial 3 18402 NULL
95978 +crystalhd_user_data_18407 crystalhd_user_data 3 18407 NULL
95979 +usbnet_write_cmd_nopm_18426 usbnet_write_cmd_nopm 7 18426 NULL
95980 +batadv_orig_node_add_if_18433 batadv_orig_node_add_if 2 18433 NULL
95981 +snd_hda_get_connections_18437 snd_hda_get_connections 0 18437 NULL
95982 +fuse_perform_write_18457 fuse_perform_write 4 18457 NULL
95983 +regset_tls_set_18459 regset_tls_set 4 18459 NULL
95984 +dma_alloc_from_contiguous_18466 dma_alloc_from_contiguous 3-2 18466 NULL
95985 +pci_vpd_lrdt_size_18479 pci_vpd_lrdt_size 0 18479 NULL
95986 +udpv6_setsockopt_18487 udpv6_setsockopt 5 18487 NULL
95987 +snd_gus_dram_poke_18525 snd_gus_dram_poke 4 18525 NULL
95988 +nouveau_fifo_channel_create__18530 nouveau_fifo_channel_create_ 5-6-9 18530 NULL
95989 +seq_copy_in_user_18543 seq_copy_in_user 3 18543 NULL
95990 +acpi_register_gsi_ioapic_18550 acpi_register_gsi_ioapic 2 18550 NULL
95991 +sas_change_queue_depth_18555 sas_change_queue_depth 2 18555 NULL
95992 +smk_write_rules_list_18565 smk_write_rules_list 3 18565 NULL
95993 +debug_output_18575 debug_output 3 18575 NULL
95994 +check_lpt_type_18577 check_lpt_type 0 18577 NULL
95995 +__netdev_alloc_skb_18595 __netdev_alloc_skb 2 18595 NULL
95996 +filemap_fdatawait_range_18600 filemap_fdatawait_range 0 18600 NULL
95997 +iowarrior_write_18604 iowarrior_write 3 18604 NULL
95998 +batadv_arp_get_type_18609 batadv_arp_get_type 3 18609 NULL
95999 +from_buffer_18625 from_buffer 3 18625 NULL
96000 +snd_pcm_oss_write3_18657 snd_pcm_oss_write3 0-3 18657 NULL
96001 +ieee80211_if_fmt_rssi_threshold_18664 ieee80211_if_fmt_rssi_threshold 3 18664 NULL
96002 +unmap_page_18665 unmap_page 2-3 18665 NULL
96003 +xfs_iext_insert_18667 xfs_iext_insert 3 18667 NULL
96004 +replay_log_leb_18704 replay_log_leb 3 18704 NULL
96005 +iwl_dbgfs_rx_handlers_read_18708 iwl_dbgfs_rx_handlers_read 3 18708 NULL
96006 +ceph_alloc_page_vector_18710 ceph_alloc_page_vector 1 18710 NULL
96007 +ocfs2_trim_extent_18711 ocfs2_trim_extent 4-3 18711 NULL
96008 +blk_rq_bytes_18715 blk_rq_bytes 0 18715 NULL
96009 +snd_als4k_gcr_read_addr_18741 snd_als4k_gcr_read_addr 0 18741 NULL
96010 +o2hb_debug_create_18744 o2hb_debug_create 4 18744 NULL
96011 +__erst_read_to_erange_from_nvram_18748 __erst_read_to_erange_from_nvram 0 18748 NULL
96012 +wep_packets_read_18751 wep_packets_read 3 18751 NULL
96013 +md_compat_ioctl_18764 md_compat_ioctl 4 18764 NULL
96014 +read_file_dump_nfcal_18766 read_file_dump_nfcal 3 18766 NULL
96015 +ffs_epfile_read_18775 ffs_epfile_read 3 18775 NULL
96016 +alloc_fcdev_18780 alloc_fcdev 1 18780 NULL
96017 +fat_compat_dir_ioctl_18800 fat_compat_dir_ioctl 3 18800 NULL
96018 +ieee80211_auth_challenge_18810 ieee80211_auth_challenge 3 18810 NULL
96019 +madvise_hwpoison_18812 madvise_hwpoison 2 18812 NULL
96020 +setup_ioapic_irq_18813 setup_ioapic_irq 1 18813 NULL
96021 +sys_modify_ldt_18824 sys_modify_ldt 3 18824 NULL
96022 +mtf_test_write_18844 mtf_test_write 3 18844 NULL
96023 +drm_ht_create_18853 drm_ht_create 2 18853 NULL
96024 +sctp_setsockopt_events_18862 sctp_setsockopt_events 3 18862 NULL
96025 +ieee80211_if_read_element_ttl_18869 ieee80211_if_read_element_ttl 3 18869 NULL
96026 +xlog_find_verify_log_record_18870 xlog_find_verify_log_record 2 18870 NULL
96027 +___alloc_bootmem_node_18882 ___alloc_bootmem_node 2-3 18882 NULL
96028 +width_to_agaw_18883 width_to_agaw 0-1 18883 NULL
96029 +ceph_setxattr_18913 ceph_setxattr 4 18913 NULL
96030 +mangle_packet_18920 mangle_packet 7-9 18920 NULL
96031 +snapshot_write_next_18937 snapshot_write_next 0 18937 NULL
96032 +__nla_reserve_18974 __nla_reserve 3 18974 NULL
96033 +gfn_to_pfn_atomic_18981 gfn_to_pfn_atomic 2 18981 NULL
96034 +find_dirtiest_idx_leb_19001 find_dirtiest_idx_leb 0 19001 NULL
96035 +layout_in_gaps_19006 layout_in_gaps 2 19006 NULL
96036 +huge_page_size_19008 huge_page_size 0 19008 NULL
96037 +usbdev_compat_ioctl_19026 usbdev_compat_ioctl 3 19026 NULL
96038 +prepare_highmem_image_19028 prepare_highmem_image 0 19028 NULL
96039 +revalidate_19043 revalidate 2 19043 NULL
96040 +drm_fb_helper_init_19044 drm_fb_helper_init 3-4 19044 NULL
96041 +create_gpadl_header_19064 create_gpadl_header 2 19064 NULL
96042 +ieee80211_key_alloc_19065 ieee80211_key_alloc 3 19065 NULL
96043 +sys_process_vm_readv_19090 sys_process_vm_readv 3-5 19090 NULL nohasharray
96044 +brcmf_usbdev_qinit_19090 brcmf_usbdev_qinit 2 19090 &sys_process_vm_readv_19090
96045 +sta_last_seq_ctrl_read_19106 sta_last_seq_ctrl_read 3 19106 NULL
96046 +cifs_readv_from_socket_19109 cifs_readv_from_socket 3 19109 NULL
96047 +skb_gro_offset_19123 skb_gro_offset 0 19123 NULL
96048 +ext4_inode_table_19125 ext4_inode_table 0 19125 NULL
96049 +snd_als4k_iobase_readl_19136 snd_als4k_iobase_readl 0 19136 NULL
96050 +alloc_irdadev_19140 alloc_irdadev 1 19140 NULL
96051 +sleep_auth_read_19159 sleep_auth_read 3 19159 NULL
96052 +smk_write_access2_19170 smk_write_access2 3 19170 NULL
96053 +iwl_dbgfs_reply_tx_error_read_19205 iwl_dbgfs_reply_tx_error_read 3 19205 NULL
96054 +vmw_unlocked_ioctl_19212 vmw_unlocked_ioctl 2 19212 NULL
96055 +__copy_to_user_inatomic_19214 __copy_to_user_inatomic 3 19214 NULL
96056 +dev_counters_read_19216 dev_counters_read 3 19216 NULL
96057 +wbcir_tx_19219 wbcir_tx 3 19219 NULL
96058 +gsi_to_irq_19220 gsi_to_irq 0-1 19220 NULL
96059 +snd_mask_max_19224 snd_mask_max 0 19224 NULL
96060 +bio_alloc_mddev_19238 bio_alloc_mddev 2 19238 NULL
96061 +sys_fcntl_19267 sys_fcntl 3 19267 NULL
96062 +il_dbgfs_rxon_filter_flags_read_19281 il_dbgfs_rxon_filter_flags_read 3 19281 NULL
96063 +io_mapping_map_wc_19284 io_mapping_map_wc 2 19284 NULL
96064 +qc_capture_19298 qc_capture 3 19298 NULL
96065 +ocfs2_prepare_inode_for_refcount_19303 ocfs2_prepare_inode_for_refcount 3-4 19303 NULL
96066 +event_tx_stuck_read_19305 event_tx_stuck_read 3 19305 NULL
96067 +gfn_to_gpa_19320 gfn_to_gpa 0-1 19320 NULL
96068 +debug_read_19322 debug_read 3 19322 NULL
96069 +cfg80211_inform_bss_19332 cfg80211_inform_bss 8 19332 NULL
96070 +read_zero_19366 read_zero 3 19366 NULL
96071 +interpret_user_input_19393 interpret_user_input 2 19393 NULL
96072 +get_n_events_by_type_19401 get_n_events_by_type 0 19401 NULL
96073 +dvbdmx_write_19423 dvbdmx_write 3 19423 NULL
96074 +__phys_addr_19434 __phys_addr 0 19434 NULL
96075 +xfrm_alg_auth_len_19454 xfrm_alg_auth_len 0 19454 NULL
96076 +hpet_compat_ioctl_19455 hpet_compat_ioctl 3 19455 NULL
96077 +gnet_stats_copy_19458 gnet_stats_copy 4 19458 NULL
96078 +sky2_read16_19475 sky2_read16 0 19475 NULL
96079 +efivar_create_sysfs_entry_19485 efivar_create_sysfs_entry 2 19485 NULL
96080 +ext4_add_new_descs_19509 ext4_add_new_descs 3 19509 NULL
96081 +skb_realloc_headroom_19516 skb_realloc_headroom 2 19516 NULL
96082 +dev_alloc_skb_19517 dev_alloc_skb 1 19517 NULL
96083 +nfc_llcp_build_tlv_19536 nfc_llcp_build_tlv 3 19536 NULL
96084 +gfn_to_index_19558 gfn_to_index 0-1-3-2 19558 NULL
96085 +ocfs2_control_message_19564 ocfs2_control_message 3 19564 NULL
96086 +ieee80211_if_read_tkip_mic_test_19565 ieee80211_if_read_tkip_mic_test 3 19565 NULL nohasharray
96087 +wlcore_hw_get_rx_packet_len_19565 wlcore_hw_get_rx_packet_len 0 19565 &ieee80211_if_read_tkip_mic_test_19565
96088 +nfsd_read_19568 nfsd_read 5 19568 NULL
96089 +cgroup_read_s64_19570 cgroup_read_s64 5 19570 NULL
96090 +bm_status_read_19583 bm_status_read 3 19583 NULL
96091 +batadv_tt_update_orig_19586 batadv_tt_update_orig 4 19586 NULL
96092 +load_xattr_datum_19594 load_xattr_datum 0 19594 NULL
96093 +usbvision_rvmalloc_19655 usbvision_rvmalloc 1 19655 NULL
96094 +LoadBitmap_19658 LoadBitmap 2 19658 NULL
96095 +usbnet_write_cmd_19679 usbnet_write_cmd 7 19679 NULL
96096 +bio_detain_19690 bio_detain 2 19690 NULL
96097 +read_reg_19723 read_reg 0 19723 NULL
96098 +wm8350_block_write_19727 wm8350_block_write 3-2 19727 NULL
96099 +memcpy_toiovecend_19736 memcpy_toiovecend 4-3 19736 NULL
96100 +snd_es1968_get_dma_ptr_19747 snd_es1968_get_dma_ptr 0 19747 NULL
96101 +p9_client_read_19750 p9_client_read 5 19750 NULL
96102 +pnpbios_proc_write_19758 pnpbios_proc_write 3 19758 NULL
96103 +ocfs2_readpages_19759 ocfs2_readpages 4 19759 NULL
96104 +jffs2_acl_from_medium_19762 jffs2_acl_from_medium 2 19762 NULL
96105 +__set_print_fmt_19776 __set_print_fmt 0 19776 NULL
96106 +saa7146_vmalloc_build_pgtable_19780 saa7146_vmalloc_build_pgtable 2 19780 NULL
96107 +irda_setsockopt_19824 irda_setsockopt 5 19824 NULL
96108 +pcpu_next_unpop_19831 pcpu_next_unpop 4 19831 NULL
96109 +vfs_getxattr_19832 vfs_getxattr 0 19832 NULL
96110 +security_context_to_sid_19839 security_context_to_sid 2 19839 NULL
96111 +crypt_alloc_buffer_19846 crypt_alloc_buffer 2 19846 NULL
96112 +cfg80211_mlme_register_mgmt_19852 cfg80211_mlme_register_mgmt 5 19852 NULL
96113 +__nla_put_19857 __nla_put 3 19857 NULL
96114 +ip6gre_err_19869 ip6gre_err 5 19869 NULL
96115 +mrp_request_join_19882 mrp_request_join 4 19882 NULL
96116 +aes_decrypt_interrupt_read_19910 aes_decrypt_interrupt_read 3 19910 NULL
96117 +ps_upsd_max_apturn_read_19918 ps_upsd_max_apturn_read 3 19918 NULL
96118 +cgroup_task_count_19930 cgroup_task_count 0 19930 NULL
96119 +iwl_dbgfs_rx_queue_read_19943 iwl_dbgfs_rx_queue_read 3 19943 NULL
96120 +attach_hdlc_protocol_19986 attach_hdlc_protocol 3 19986 NULL
96121 +diva_um_idi_read_20003 diva_um_idi_read 0 20003 NULL
96122 +split_scan_timeout_read_20029 split_scan_timeout_read 3 20029 NULL
96123 +alloc_ieee80211_20063 alloc_ieee80211 1 20063 NULL
96124 +rawv6_sendmsg_20080 rawv6_sendmsg 4 20080 NULL
96125 +fuse_conn_limit_read_20084 fuse_conn_limit_read 3 20084 NULL
96126 +team_options_register_20091 team_options_register 3 20091 NULL
96127 +qla2x00_adjust_sdev_qdepth_up_20097 qla2x00_adjust_sdev_qdepth_up 2 20097 NULL
96128 +hptiop_adjust_disk_queue_depth_20122 hptiop_adjust_disk_queue_depth 2 20122 NULL
96129 +tomoyo_commit_ok_20167 tomoyo_commit_ok 2 20167 NULL
96130 +read_flush_pipefs_20171 read_flush_pipefs 3 20171 NULL
96131 +wep_addr_key_count_read_20174 wep_addr_key_count_read 3 20174 NULL
96132 +create_trace_probe_20175 create_trace_probe 1 20175 NULL
96133 +crystalhd_map_dio_20181 crystalhd_map_dio 3 20181 NULL
96134 +udf_bitmap_new_block_20214 udf_bitmap_new_block 4 20214 NULL
96135 +pvr2_ctrl_value_to_sym_20229 pvr2_ctrl_value_to_sym 5 20229 NULL
96136 +rose_sendmsg_20249 rose_sendmsg 4 20249 NULL
96137 +tm6000_i2c_send_regs_20250 tm6000_i2c_send_regs 5 20250 NULL
96138 +pcpu_alloc_20255 pcpu_alloc 1-2 20255 NULL
96139 +_rtl92s_get_h2c_cmdlen_20312 _rtl92s_get_h2c_cmdlen 0 20312 NULL
96140 +tx_tx_burst_programmed_read_20320 tx_tx_burst_programmed_read 3 20320 NULL
96141 +snd_cs4281_BA1_read_20323 snd_cs4281_BA1_read 5 20323 NULL
96142 +gfs2_glock_nq_m_20347 gfs2_glock_nq_m 1 20347 NULL
96143 +handle_arr_calc_size_20355 handle_arr_calc_size 0-1 20355 NULL
96144 +qla82xx_pci_mem_read_direct_20368 qla82xx_pci_mem_read_direct 2 20368 NULL
96145 +smk_set_cipso_20379 smk_set_cipso 3 20379 NULL
96146 +u64_to_uptr_20384 u64_to_uptr 1 20384 NULL
96147 +snd_nm256_readl_20394 snd_nm256_readl 0 20394 NULL
96148 +__kfifo_from_user_20399 __kfifo_from_user 3 20399 NULL
96149 +xen_create_contiguous_region_20457 xen_create_contiguous_region 1 20457 NULL
96150 +nfs3_setxattr_20458 nfs3_setxattr 4 20458 NULL
96151 +compat_ipv6_setsockopt_20468 compat_ipv6_setsockopt 5 20468 NULL
96152 +read_buf_20469 read_buf 2 20469 NULL
96153 +btrfs_get_32_20476 btrfs_get_32 0 20476 NULL
96154 +fast_user_write_20494 fast_user_write 5 20494 NULL
96155 +ocfs2_db_frozen_trigger_20503 ocfs2_db_frozen_trigger 4 20503 NULL nohasharray
96156 +hidraw_report_event_20503 hidraw_report_event 3 20503 &ocfs2_db_frozen_trigger_20503
96157 +pcpu_alloc_area_20511 pcpu_alloc_area 0-3 20511 NULL
96158 +pcpu_depopulate_chunk_20517 pcpu_depopulate_chunk 2-3 20517 NULL
96159 +xfs_iext_realloc_direct_20521 xfs_iext_realloc_direct 2 20521 NULL
96160 +drbd_bm_resize_20522 drbd_bm_resize 2 20522 NULL
96161 +amd_create_gatt_pages_20537 amd_create_gatt_pages 1 20537 NULL
96162 +scsi_report_opcode_20551 scsi_report_opcode 3 20551 NULL
96163 +venus_create_20555 venus_create 4 20555 NULL
96164 +btrfs_super_log_root_20565 btrfs_super_log_root 0 20565 NULL
96165 +crypto_ahash_reqsize_20569 crypto_ahash_reqsize 0 20569 NULL
96166 +i915_max_freq_read_20581 i915_max_freq_read 3 20581 NULL
96167 +batadv_tt_append_diff_20588 batadv_tt_append_diff 4 20588 NULL
96168 +lirc_write_20604 lirc_write 3 20604 NULL
96169 +qib_qsfp_write_20614 qib_qsfp_write 0-4-2 20614 NULL
96170 +snd_pcm_oss_prepare_20641 snd_pcm_oss_prepare 0 20641 NULL
96171 +kfifo_copy_to_user_20646 kfifo_copy_to_user 3 20646 NULL
96172 +cpulist_scnprintf_20648 cpulist_scnprintf 0-2 20648 NULL
96173 +oz_add_farewell_20652 oz_add_farewell 5 20652 NULL
96174 +oz_cdev_read_20659 oz_cdev_read 3 20659 NULL
96175 +snd_hdsp_playback_copy_20676 snd_hdsp_playback_copy 5 20676 NULL
96176 +get_user_page_nowait_20682 get_user_page_nowait 3 20682 NULL nohasharray
96177 +dvb_dmxdev_buffer_read_20682 dvb_dmxdev_buffer_read 0-4 20682 &get_user_page_nowait_20682
96178 +cpumask_size_20683 cpumask_size 0 20683 NULL
96179 +btrfs_node_blockptr_20685 btrfs_node_blockptr 0 20685 NULL
96180 +gru_vtop_20689 gru_vtop 2 20689 NULL
96181 +read_file_tgt_int_stats_20697 read_file_tgt_int_stats 3 20697 NULL
96182 +__maestro_read_20700 __maestro_read 0 20700 NULL
96183 +cipso_v4_gentag_rng_20703 cipso_v4_gentag_rng 0 20703 NULL
96184 +pcpu_page_first_chunk_20712 pcpu_page_first_chunk 1 20712 NULL
96185 +ocfs2_read_xattr_bucket_20722 ocfs2_read_xattr_bucket 0 20722 NULL
96186 +security_context_to_sid_force_20724 security_context_to_sid_force 2 20724 NULL
96187 +vring_add_indirect_20737 vring_add_indirect 3-4 20737 NULL
96188 +io_apic_set_pci_routing_20740 io_apic_set_pci_routing 2 20740 NULL
96189 +vol_cdev_direct_write_20751 vol_cdev_direct_write 3 20751 NULL
96190 +ocfs2_align_bytes_to_clusters_20754 ocfs2_align_bytes_to_clusters 2 20754 NULL
96191 +brcmf_p2p_escan_20763 brcmf_p2p_escan 2 20763 NULL
96192 +ubi_io_read_20767 ubi_io_read 0 20767 NULL
96193 +fb_alloc_cmap_gfp_20792 fb_alloc_cmap_gfp 2 20792 NULL
96194 +iommu_range_alloc_20794 iommu_range_alloc 3 20794 NULL
96195 +iwl_dbgfs_rxon_flags_read_20795 iwl_dbgfs_rxon_flags_read 3 20795 NULL
96196 +sys_sendto_20809 sys_sendto 6 20809 NULL
96197 +strndup_user_20819 strndup_user 2 20819 NULL
96198 +calc_layout_20829 calc_layout 3 20829 NULL
96199 +wl1271_format_buffer_20834 wl1271_format_buffer 2 20834 NULL
96200 +uvc_alloc_entity_20836 uvc_alloc_entity 3-4 20836 NULL
96201 +snd_pcm_capture_avail_20867 snd_pcm_capture_avail 0 20867 NULL
96202 +ocfs2_bmap_20874 ocfs2_bmap 2 20874 NULL
96203 +skb_tail_pointer_20878 skb_tail_pointer 0 20878 NULL
96204 +sisusb_send_packet_20891 sisusb_send_packet 2 20891 NULL
96205 +key_icverrors_read_20895 key_icverrors_read 3 20895 NULL
96206 +vfio_msi_enable_20906 vfio_msi_enable 2 20906 NULL
96207 +compat_sys_readv_20911 compat_sys_readv 3 20911 NULL
96208 +htable_bits_20933 htable_bits 0 20933 NULL
96209 +altera_set_ir_post_20948 altera_set_ir_post 2 20948 NULL
96210 +rx_rx_phy_hdr_read_20950 rx_rx_phy_hdr_read 3 20950 NULL
96211 +nfs_map_name_to_uid_20962 nfs_map_name_to_uid 3 20962 NULL
96212 +snd_rme9652_playback_copy_20970 snd_rme9652_playback_copy 5 20970 NULL
96213 +brcmf_tx_frame_20978 brcmf_tx_frame 3 20978 NULL
96214 +alg_setsockopt_20985 alg_setsockopt 5 20985 NULL
96215 +ocfs2_free_clusters_21001 ocfs2_free_clusters 4 21001 NULL
96216 +ceph_osdc_new_request_21017 ceph_osdc_new_request 14-4 21017 NULL
96217 +btrfs_inode_ref_name_len_21024 btrfs_inode_ref_name_len 0 21024 NULL
96218 +rx_defrag_tkip_called_read_21031 rx_defrag_tkip_called_read 3 21031 NULL
96219 +lbs_threshold_read_21046 lbs_threshold_read 5 21046 NULL
96220 +proc_fault_inject_write_21058 proc_fault_inject_write 3 21058 NULL
96221 +event_calibration_read_21083 event_calibration_read 3 21083 NULL
96222 +compat_sock_ioctl_trans_21092 compat_sock_ioctl_trans 4 21092 NULL
96223 +multipath_status_21094 multipath_status 5 21094 NULL
96224 +__cfg80211_send_disassoc_21096 __cfg80211_send_disassoc 3 21096 NULL
96225 +ext2_valid_block_bitmap_21101 ext2_valid_block_bitmap 3 21101 NULL
96226 +ath6kl_send_go_probe_resp_21113 ath6kl_send_go_probe_resp 3 21113 NULL
96227 +bitset_size_in_bytes_21124 bitset_size_in_bytes 0-1 21124 NULL
96228 +i2400m_rx_trace_21127 i2400m_rx_trace 3 21127 NULL
96229 +tps6586x_irq_init_21144 tps6586x_irq_init 3 21144 NULL
96230 +ocfs2_block_check_validate_21149 ocfs2_block_check_validate 2 21149 NULL
96231 +cx18_v4l2_read_21196 cx18_v4l2_read 3 21196 NULL
96232 +ipc_rcu_alloc_21208 ipc_rcu_alloc 1 21208 NULL
96233 +_ocfs2_free_clusters_21220 _ocfs2_free_clusters 4 21220 NULL
96234 +get_numpages_21227 get_numpages 0-1-2 21227 NULL
96235 +input_ff_create_21240 input_ff_create 2 21240 NULL
96236 +cfg80211_notify_new_peer_candidate_21242 cfg80211_notify_new_peer_candidate 4 21242 NULL
96237 +ocfs2_blocks_for_bytes_21268 ocfs2_blocks_for_bytes 0-2 21268 NULL
96238 +ip_vs_icmp_xmit_21269 ip_vs_icmp_xmit 4 21269 NULL
96239 +make_alloc_exact_21279 make_alloc_exact 1-3 21279 NULL
96240 +vmw_gmr2_bind_21305 vmw_gmr2_bind 3 21305 NULL
96241 +do_msg_fill_21307 do_msg_fill 3 21307 NULL
96242 +add_res_range_21310 add_res_range 4 21310 NULL
96243 +get_zeroed_page_21322 get_zeroed_page 0 21322 NULL
96244 +ftrace_profile_read_21327 ftrace_profile_read 3 21327 NULL
96245 +gfs2_ea_get_copy_21353 gfs2_ea_get_copy 0 21353 NULL
96246 +max77693_irq_domain_map_21357 max77693_irq_domain_map 2 21357 NULL
96247 +alloc_orinocodev_21371 alloc_orinocodev 1 21371 NULL
96248 +video_ioctl2_21380 video_ioctl2 2 21380 NULL
96249 +diva_get_driver_dbg_mask_21399 diva_get_driver_dbg_mask 0 21399 NULL
96250 +snd_m3_inw_21406 snd_m3_inw 0 21406 NULL
96251 +snapshot_read_next_21426 snapshot_read_next 0 21426 NULL
96252 +tcp_bound_to_half_wnd_21429 tcp_bound_to_half_wnd 0-2 21429 NULL
96253 +tracing_saved_cmdlines_read_21434 tracing_saved_cmdlines_read 3 21434 NULL
96254 +aggr_size_tx_agg_vs_rate_read_21438 aggr_size_tx_agg_vs_rate_read 3 21438 NULL
96255 +__ertm_hdr_size_21450 __ertm_hdr_size 0 21450 NULL
96256 +concat_writev_21451 concat_writev 3 21451 NULL
96257 +read_file_xmit_21487 read_file_xmit 3 21487 NULL
96258 +mmc_alloc_sg_21504 mmc_alloc_sg 1 21504 NULL
96259 +btrfs_file_aio_write_21520 btrfs_file_aio_write 4 21520 NULL
96260 +il_dbgfs_stations_read_21532 il_dbgfs_stations_read 3 21532 NULL
96261 +cipso_v4_map_cat_enum_hton_21540 cipso_v4_map_cat_enum_hton 0 21540 NULL
96262 +rxrpc_send_data_21553 rxrpc_send_data 5 21553 NULL
96263 +rx_rx_beacon_early_term_read_21559 rx_rx_beacon_early_term_read 3 21559 NULL
96264 +xfs_buf_read_uncached_21585 xfs_buf_read_uncached 3 21585 NULL
96265 +ocfs2_acl_from_xattr_21604 ocfs2_acl_from_xattr 2 21604 NULL
96266 +__jfs_getxattr_21631 __jfs_getxattr 0 21631 NULL
96267 +validate_nnode_21638 validate_nnode 0 21638 NULL
96268 +__irq_alloc_descs_21639 __irq_alloc_descs 2-1-3 21639 NULL
96269 +carl9170_rx_copy_data_21656 carl9170_rx_copy_data 2 21656 NULL
96270 +atalk_sendmsg_21677 atalk_sendmsg 4 21677 NULL
96271 +ocfs2_xattr_get_nolock_21678 ocfs2_xattr_get_nolock 0 21678 NULL
96272 +regmap_register_patch_21681 regmap_register_patch 3 21681 NULL
96273 +rtllib_alloc_txb_21687 rtllib_alloc_txb 1-2 21687 NULL
96274 +evdev_ioctl_handler_21705 evdev_ioctl_handler 2 21705 NULL
96275 +reiserfs_allocate_list_bitmaps_21732 reiserfs_allocate_list_bitmaps 3 21732 NULL
96276 +vm_brk_21739 vm_brk 1 21739 NULL
96277 +__nf_nat_mangle_tcp_packet_21744 __nf_nat_mangle_tcp_packet 8-6 21744 NULL
96278 +mthca_alloc_init_21754 mthca_alloc_init 2 21754 NULL
96279 +gen_pool_add_21776 gen_pool_add 3 21776 NULL
96280 +xfs_da_grow_inode_int_21785 xfs_da_grow_inode_int 3 21785 NULL
96281 +__ioremap_caller_21800 __ioremap_caller 1-2 21800 NULL
96282 +min_odd_21802 min_odd 0 21802 NULL
96283 +dvb_generic_ioctl_21810 dvb_generic_ioctl 2 21810 NULL
96284 +wm8994_request_irq_21822 wm8994_request_irq 2 21822 NULL
96285 +oom_adj_read_21847 oom_adj_read 3 21847 NULL
96286 +acpi_tb_check_xsdt_21862 acpi_tb_check_xsdt 1 21862 NULL
96287 +lpfc_idiag_extacc_avail_get_21865 lpfc_idiag_extacc_avail_get 0-3 21865 NULL
96288 +brcms_debugfs_hardware_read_21867 brcms_debugfs_hardware_read 3 21867 NULL
96289 +sisusbcon_bmove_21873 sisusbcon_bmove 6-5-7 21873 NULL nohasharray
96290 +tcp_cookie_size_check_21873 tcp_cookie_size_check 0-1 21873 &sisusbcon_bmove_21873
96291 +xen_swiotlb_map_page_21886 xen_swiotlb_map_page 3 21886 NULL
96292 +__alloc_reserved_percpu_21895 __alloc_reserved_percpu 1-2 21895 NULL
96293 +rio_destid_first_21900 rio_destid_first 0 21900 NULL
96294 +dbAllocCtl_21911 dbAllocCtl 0 21911 NULL
96295 +qsfp_1_read_21915 qsfp_1_read 3 21915 NULL
96296 +security_mmap_addr_21970 security_mmap_addr 0 21970 NULL
96297 +alloc_ldt_21972 alloc_ldt 2 21972 NULL
96298 +rxpipe_descr_host_int_trig_rx_data_read_22001 rxpipe_descr_host_int_trig_rx_data_read 3 22001 NULL nohasharray
96299 +compat_rw_copy_check_uvector_22001 compat_rw_copy_check_uvector 0-3 22001 &rxpipe_descr_host_int_trig_rx_data_read_22001
96300 +btrfs_get_16_22023 btrfs_get_16 0 22023 NULL
96301 +zd_usb_read_fw_22049 zd_usb_read_fw 4 22049 NULL
96302 +ieee80211_if_fmt_dropped_frames_ttl_22054 ieee80211_if_fmt_dropped_frames_ttl 3 22054 NULL
96303 +btrfs_reloc_clone_csums_22077 btrfs_reloc_clone_csums 2 22077 NULL
96304 +write_opcode_22082 write_opcode 2 22082 NULL
96305 +mem_rw_22085 mem_rw 3 22085 NULL
96306 +is_swbp_at_addr_22089 is_swbp_at_addr 2 22089 NULL
96307 +lowpan_fragment_xmit_22095 lowpan_fragment_xmit 3-4 22095 NULL
96308 +sys_remap_file_pages_22124 sys_remap_file_pages 1 22124 NULL
96309 +__bitmap_size_22138 __bitmap_size 0 22138 NULL
96310 +compat_insn_22142 compat_insn 2 22142 NULL
96311 +do_tcp_sendpages_22155 do_tcp_sendpages 4 22155 NULL
96312 +__kfifo_alloc_22173 __kfifo_alloc 3 22173 NULL
96313 +fls_22210 fls 0 22210 NULL
96314 +mem_write_22232 mem_write 3 22232 NULL
96315 +p9_virtio_zc_request_22240 p9_virtio_zc_request 6-5 22240 NULL
96316 +atomic64_xchg_22246 atomic64_xchg 0 22246 NULL
96317 +compat_process_vm_rw_22254 compat_process_vm_rw 3-5 22254 NULL
96318 +__btrfs_direct_write_22273 __btrfs_direct_write 4 22273 NULL
96319 +queue_max_sectors_22280 queue_max_sectors 0 22280 NULL
96320 +pci_vpd_srdt_size_22300 pci_vpd_srdt_size 0 22300 NULL nohasharray
96321 +__tun_chr_ioctl_22300 __tun_chr_ioctl 4 22300 &pci_vpd_srdt_size_22300
96322 +extend_brk_22301 extend_brk 0 22301 NULL
96323 +mesh_table_alloc_22305 mesh_table_alloc 1 22305 NULL
96324 +get_segment_base_22324 get_segment_base 0 22324 NULL
96325 +radix_tree_find_next_bit_22334 radix_tree_find_next_bit 2-3 22334 NULL
96326 +atomic_read_22342 atomic_read 0 22342 NULL
96327 +mlx4_db_alloc_22358 mlx4_db_alloc 3 22358 NULL
96328 +irq_reserve_irq_22360 irq_reserve_irq 1 22360 NULL nohasharray
96329 +memcg_size_22360 memcg_size 0 22360 &irq_reserve_irq_22360
96330 +snd_pcm_alsa_frames_22363 snd_pcm_alsa_frames 2 22363 NULL
96331 +tps6586x_gpio_to_irq_22365 tps6586x_gpio_to_irq 2 22365 NULL
96332 +evdev_ioctl_22371 evdev_ioctl 2 22371 NULL
96333 +alloc_large_system_hash_22391 alloc_large_system_hash 2 22391 NULL
96334 +btmrvl_psmode_read_22395 btmrvl_psmode_read 3 22395 NULL
96335 +crash_shrink_memory_22401 crash_shrink_memory 1 22401 NULL
96336 +zoran_write_22404 zoran_write 3 22404 NULL
96337 +queue_reply_22416 queue_reply 3 22416 NULL
96338 +__set_enter_print_fmt_22431 __set_enter_print_fmt 0 22431 NULL
96339 +queue_max_segments_22441 queue_max_segments 0 22441 NULL
96340 +handle_received_packet_22457 handle_received_packet 3 22457 NULL
96341 +mem_cgroup_read_22461 mem_cgroup_read 5 22461 NULL
96342 +batadv_check_unicast_packet_22468 batadv_check_unicast_packet 3 22468 NULL
96343 +cache_write_procfs_22491 cache_write_procfs 3 22491 NULL
96344 +mp_find_ioapic_pin_22499 mp_find_ioapic_pin 0-2 22499 NULL
96345 +mutex_lock_interruptible_22505 mutex_lock_interruptible 0 22505 NULL
96346 +ip4_addr_string_22511 ip4_addr_string 0 22511 NULL
96347 +swiotlb_tbl_unmap_single_22522 swiotlb_tbl_unmap_single 2 22522 NULL nohasharray
96348 +usb_dump_config_descriptor_22522 usb_dump_config_descriptor 0 22522 &swiotlb_tbl_unmap_single_22522
96349 +pskb_may_pull_22546 pskb_may_pull 2 22546 NULL
96350 +ocfs2_read_extent_block_22550 ocfs2_read_extent_block 0 22550 NULL
96351 +atomic_long_read_unchecked_22551 atomic_long_read_unchecked 0 22551 NULL
96352 +agp_alloc_page_array_22554 agp_alloc_page_array 1 22554 NULL
96353 +dbFindCtl_22587 dbFindCtl 0 22587 NULL
96354 +snapshot_read_22601 snapshot_read 3 22601 NULL
96355 +remove_breakpoint_22628 remove_breakpoint 3 22628 NULL
96356 +sctp_setsockopt_connectx_old_22631 sctp_setsockopt_connectx_old 3 22631 NULL
96357 +ide_core_cp_entry_22636 ide_core_cp_entry 3 22636 NULL
96358 +wl1271_rx_filter_get_fields_size_22638 wl1271_rx_filter_get_fields_size 0 22638 NULL
96359 +pwr_wake_on_timer_exp_read_22640 pwr_wake_on_timer_exp_read 3 22640 NULL
96360 +iwl_dbgfs_calib_disabled_read_22649 iwl_dbgfs_calib_disabled_read 3 22649 NULL
96361 +ubifs_leb_write_22679 ubifs_leb_write 4-5 22679 NULL
96362 +ocfs2_get_block_22687 ocfs2_get_block 2 22687 NULL
96363 +compat_fd_ioctl_22694 compat_fd_ioctl 4 22694 NULL
96364 +map_22700 map 2 22700 NULL
96365 +alloc_libipw_22708 alloc_libipw 1 22708 NULL
96366 +brcmf_sdbrcm_read_control_22721 brcmf_sdbrcm_read_control 3 22721 NULL
96367 +cx18_copy_buf_to_user_22735 cx18_copy_buf_to_user 4 22735 NULL
96368 +ceph_decode_32_22738 ceph_decode_32 0 22738 NULL
96369 +iio_debugfs_write_reg_22742 iio_debugfs_write_reg 3 22742 NULL
96370 +print_frame_22769 print_frame 0 22769 NULL
96371 +ftrace_arch_read_dyn_info_22773 ftrace_arch_read_dyn_info 0 22773 NULL
96372 +compat_blkdev_ioctl_22841 compat_blkdev_ioctl 3 22841 NULL
96373 +clone_bio_integrity_22842 clone_bio_integrity 4 22842 NULL
96374 +read_file_rcstat_22854 read_file_rcstat 3 22854 NULL
96375 +do_atm_iobuf_22857 do_atm_iobuf 3 22857 NULL
96376 +create_attr_set_22861 create_attr_set 1 22861 NULL
96377 +vmw_execbuf_process_22885 vmw_execbuf_process 5 22885 NULL
96378 +usblp_new_writeurb_22894 usblp_new_writeurb 2 22894 NULL
96379 +mdc800_device_read_22896 mdc800_device_read 3 22896 NULL
96380 +policy_emit_config_values_22900 policy_emit_config_values 3 22900 NULL
96381 +pcpu_mem_zalloc_22948 pcpu_mem_zalloc 1 22948 NULL
96382 +alloc_sglist_22960 alloc_sglist 1-2-3 22960 NULL
96383 +caif_seqpkt_sendmsg_22961 caif_seqpkt_sendmsg 4 22961 NULL
96384 +vme_get_size_22964 vme_get_size 0 22964 NULL
96385 +tx_frag_key_not_found_read_22971 tx_frag_key_not_found_read 3 22971 NULL
96386 +page_table_range_init_count_22977 page_table_range_init_count 0 22977 NULL
96387 +usb_get_langid_22983 usb_get_langid 0 22983 NULL
96388 +set_msr_hyperv_22985 set_msr_hyperv 3 22985 NULL
96389 +remote_settings_file_write_22987 remote_settings_file_write 3 22987 NULL
96390 +viafb_dvp0_proc_write_23023 viafb_dvp0_proc_write 3 23023 NULL
96391 +cifs_local_to_utf16_bytes_23025 cifs_local_to_utf16_bytes 0 23025 NULL
96392 +st_status_23032 st_status 5 23032 NULL
96393 +nv50_disp_chan_create__23056 nv50_disp_chan_create_ 5 23056 NULL
96394 +reiserfs_add_entry_23062 reiserfs_add_entry 4 23062 NULL
96395 +kvm_mmu_gva_to_gpa_write_23075 kvm_mmu_gva_to_gpa_write 0 23075 NULL
96396 +vm_map_ram_23078 vm_map_ram 2 23078 NULL nohasharray
96397 +raw_sendmsg_23078 raw_sendmsg 4 23078 &vm_map_ram_23078
96398 +qla4_82xx_pci_mem_read_2M_23081 qla4_82xx_pci_mem_read_2M 2 23081 NULL
96399 +isr_tx_procs_read_23084 isr_tx_procs_read 3 23084 NULL
96400 +lnw_gpio_irq_map_23087 lnw_gpio_irq_map 2 23087 NULL
96401 +rt2x00debug_write_eeprom_23091 rt2x00debug_write_eeprom 3 23091 NULL
96402 +fls_long_23096 fls_long 0 23096 NULL
96403 +ntfs_ucstonls_23097 ntfs_ucstonls 3-5 23097 NULL
96404 +pipe_iov_copy_from_user_23102 pipe_iov_copy_from_user 3 23102 NULL
96405 +mwl8k_cmd_set_beacon_23110 mwl8k_cmd_set_beacon 4 23110 NULL
96406 +nl80211_send_rx_auth_23111 nl80211_send_rx_auth 4 23111 NULL
96407 +__clear_user_23118 __clear_user 0 23118 NULL
96408 +dm_write_async_23120 dm_write_async 3 23120 NULL
96409 +drm_mode_create_tv_properties_23122 drm_mode_create_tv_properties 2 23122 NULL
96410 +ca91cx42_master_set_23146 ca91cx42_master_set 4 23146 NULL
96411 +read_file_ani_23161 read_file_ani 3 23161 NULL
96412 +ioremap_23172 ioremap 1-2 23172 NULL
96413 +usblp_write_23178 usblp_write 3 23178 NULL
96414 +msnd_fifo_alloc_23179 msnd_fifo_alloc 2 23179 NULL
96415 +gss_pipe_downcall_23182 gss_pipe_downcall 3 23182 NULL
96416 +ieee80211_get_mesh_hdrlen_23183 ieee80211_get_mesh_hdrlen 0 23183 NULL
96417 +fix_unclean_leb_23188 fix_unclean_leb 3 23188 NULL
96418 +mpi_alloc_limb_space_23190 mpi_alloc_limb_space 1 23190 NULL
96419 +convert_ip_to_linear_23198 convert_ip_to_linear 0 23198 NULL
96420 +pm80x_free_irq_23210 pm80x_free_irq 2 23210 NULL nohasharray
96421 +compat_rawv6_ioctl_23210 compat_rawv6_ioctl 3 23210 &pm80x_free_irq_23210
96422 +tty_buffer_request_room_23228 tty_buffer_request_room 2 23228 NULL
96423 +xlog_get_bp_23229 xlog_get_bp 2 23229 NULL
96424 +rxrpc_client_sendmsg_23236 rxrpc_client_sendmsg 5 23236 NULL
96425 +__gfn_to_rmap_23240 __gfn_to_rmap 1-2 23240 NULL
96426 +uwb_dev_addr_print_23282 uwb_dev_addr_print 2 23282 NULL
96427 +ipv6_skip_exthdr_23283 ipv6_skip_exthdr 0-2 23283 NULL
96428 +doc_probe_23285 doc_probe 1 23285 NULL
96429 +diva_get_trace_filter_23286 diva_get_trace_filter 0 23286 NULL
96430 +perf_mmap_free_page_23302 perf_mmap_free_page 1 23302 NULL
96431 +i2cdev_write_23310 i2cdev_write 3 23310 NULL
96432 +mc13xxx_get_num_regulators_dt_23344 mc13xxx_get_num_regulators_dt 0 23344 NULL
96433 +page_readlink_23346 page_readlink 3 23346 NULL
96434 +get_dst_timing_23358 get_dst_timing 0 23358 NULL
96435 +fd_setup_write_same_buf_23369 fd_setup_write_same_buf 3 23369 NULL
96436 +iscsi_change_queue_depth_23416 iscsi_change_queue_depth 2 23416 NULL
96437 +vga_mm_r_23419 vga_mm_r 0 23419 NULL
96438 +vzalloc_node_23424 vzalloc_node 1 23424 NULL
96439 +ocfs2_zero_tail_23447 ocfs2_zero_tail 3 23447 NULL
96440 +hidraw_send_report_23449 hidraw_send_report 3 23449 NULL
96441 +linear_conf_23485 linear_conf 2 23485 NULL nohasharray
96442 +divasa_remap_pci_bar_23485 divasa_remap_pci_bar 3-4 23485 &linear_conf_23485
96443 +event_filter_read_23494 event_filter_read 3 23494 NULL
96444 +__gfn_to_hva_many_23508 __gfn_to_hva_many 0-2 23508 NULL
96445 +ima_show_measurements_count_23536 ima_show_measurements_count 3 23536 NULL
96446 +xen_allocate_irq_gsi_23546 xen_allocate_irq_gsi 1-0 23546 NULL
96447 +tcp_current_mss_23552 tcp_current_mss 0 23552 NULL
96448 +dbg_leb_change_23555 dbg_leb_change 4 23555 NULL
96449 +venus_symlink_23570 venus_symlink 4-6 23570 NULL
96450 +iwl_dbgfs_interrupt_read_23574 iwl_dbgfs_interrupt_read 3 23574 NULL
96451 +snd_interval_min_23590 snd_interval_min 0 23590 NULL
96452 +do_mmap_pgoff_23600 do_mmap_pgoff 0 23600 NULL
96453 +_alloc_cdb_cont_23609 _alloc_cdb_cont 2 23609 NULL
96454 +islpci_mgt_transaction_23610 islpci_mgt_transaction 5 23610 NULL
96455 +__i2400mu_send_barker_23652 __i2400mu_send_barker 3 23652 NULL
96456 +ext3_compat_ioctl_23659 ext3_compat_ioctl 3 23659 NULL
96457 +sInW_23663 sInW 0 23663 NULL
96458 +proc_ioctl_compat_23682 proc_ioctl_compat 2 23682 NULL
96459 +nftl_partscan_23688 nftl_partscan 0 23688 NULL
96460 +cx18_read_23699 cx18_read 3 23699 NULL
96461 +mp_config_acpi_gsi_23728 mp_config_acpi_gsi 2 23728 NULL
96462 +pack_sg_list_p_23739 pack_sg_list_p 0-2 23739 NULL
96463 +rx_rx_dropped_frame_read_23748 rx_rx_dropped_frame_read 3 23748 NULL
96464 +__kfifo_max_r_23768 __kfifo_max_r 0-2-1 23768 NULL
96465 +security_inode_getxattr_23781 security_inode_getxattr 0 23781 NULL
96466 +diva_alloc_dma_map_23798 diva_alloc_dma_map 2 23798 NULL
96467 +rx_path_reset_read_23801 rx_path_reset_read 3 23801 NULL
96468 +__earlyonly_bootmem_alloc_23824 __earlyonly_bootmem_alloc 2-3 23824 NULL
96469 +ceph_copy_page_vector_to_user_23829 ceph_copy_page_vector_to_user 3-4 23829 NULL
96470 +xfs_dir2_leaf_getdents_23841 xfs_dir2_leaf_getdents 3 23841 NULL
96471 +pgdat_end_pfn_23842 pgdat_end_pfn 0 23842 NULL
96472 +iwl_dbgfs_nvm_read_23845 iwl_dbgfs_nvm_read 3 23845 NULL
96473 +p54_init_common_23850 p54_init_common 1 23850 NULL
96474 +gart_alloc_coherent_23852 gart_alloc_coherent 2 23852 NULL
96475 +bin_to_hex_dup_23853 bin_to_hex_dup 2 23853 NULL
96476 +ocfs2_xattr_get_clusters_23857 ocfs2_xattr_get_clusters 0 23857 NULL
96477 +ieee80211_if_read_dot11MeshMaxPeerLinks_23878 ieee80211_if_read_dot11MeshMaxPeerLinks 3 23878 NULL
96478 +nes_alloc_resource_23891 nes_alloc_resource 3 23891 NULL
96479 +tipc_snprintf_23893 tipc_snprintf 2 23893 NULL
96480 +add_new_gdb_meta_bg_23911 add_new_gdb_meta_bg 3 23911 NULL nohasharray
96481 +ieee80211_if_read_hw_queues_23911 ieee80211_if_read_hw_queues 3 23911 &add_new_gdb_meta_bg_23911
96482 +f2fs_getxattr_23917 f2fs_getxattr 0 23917 NULL
96483 +ipath_reg_phys_mr_23918 ipath_reg_phys_mr 3 23918 NULL nohasharray
96484 +mpihelp_mul_karatsuba_case_23918 mpihelp_mul_karatsuba_case 5-3 23918 &ipath_reg_phys_mr_23918
96485 +kvm_read_guest_23928 kvm_read_guest 4-2 23928 NULL
96486 +__alloc_skb_23940 __alloc_skb 1 23940 NULL
96487 +uvc_endpoint_max_bpi_23944 uvc_endpoint_max_bpi 0 23944 NULL
96488 +cifs_setxattr_23957 cifs_setxattr 4 23957 NULL
96489 +zd_usb_iowrite16v_async_23984 zd_usb_iowrite16v_async 3 23984 NULL
96490 +cxgb_alloc_mem_24007 cxgb_alloc_mem 1 24007 NULL
96491 +dgrp_send_24028 dgrp_send 0-2 24028 NULL
96492 +ocfs2_mark_extent_refcounted_24035 ocfs2_mark_extent_refcounted 6 24035 NULL
96493 +adis16400_show_serial_number_24037 adis16400_show_serial_number 3 24037 NULL
96494 +afs_cell_alloc_24052 afs_cell_alloc 2 24052 NULL
96495 +blkcipher_copy_iv_24075 blkcipher_copy_iv 3 24075 NULL
96496 +vb2_fop_read_24080 vb2_fop_read 3 24080 NULL
96497 +pipeline_post_proc_swi_read_24108 pipeline_post_proc_swi_read 3 24108 NULL
96498 +request_key_auth_read_24109 request_key_auth_read 3 24109 NULL
96499 +mpu401_read_24126 mpu401_read 3 24126 NULL
96500 +irnet_ctrl_write_24139 irnet_ctrl_write 3 24139 NULL
96501 +trim_bitmaps_24158 trim_bitmaps 3 24158 NULL
96502 +set_discard_24162 set_discard 2 24162 NULL
96503 +adu_read_24177 adu_read 3 24177 NULL
96504 +safe_prepare_write_buffer_24187 safe_prepare_write_buffer 3 24187 NULL
96505 +ieee80211_if_read_dot11MeshHWMPpreqMinInterval_24208 ieee80211_if_read_dot11MeshHWMPpreqMinInterval 3 24208 NULL
96506 +efx_vf_size_24213 efx_vf_size 0 24213 NULL
96507 +tcpprobe_sprint_24222 tcpprobe_sprint 0-2 24222 NULL
96508 +pcpu_embed_first_chunk_24224 pcpu_embed_first_chunk 1-2-3 24224 NULL nohasharray
96509 +mei_amthif_read_24224 mei_amthif_read 4 24224 &pcpu_embed_first_chunk_24224
96510 +pci_num_vf_24235 pci_num_vf 0 24235 NULL
96511 +sel_read_bool_24236 sel_read_bool 3 24236 NULL
96512 +dm_cache_save_hint_24257 dm_cache_save_hint 2 24257 NULL
96513 +em28xx_alloc_urbs_24260 em28xx_alloc_urbs 4-6 24260 NULL
96514 +thin_status_24278 thin_status 5 24278 NULL
96515 +compat_sys_preadv64_24283 compat_sys_preadv64 3 24283 NULL
96516 +msg_size_24288 msg_size 0 24288 NULL
96517 +ext2_free_blocks_24292 ext2_free_blocks 2-3 24292 NULL
96518 +map_page_24298 map_page 3-4 24298 NULL
96519 +btmrvl_pscmd_read_24308 btmrvl_pscmd_read 3 24308 NULL
96520 +ath6kl_add_bss_if_needed_24317 ath6kl_add_bss_if_needed 6 24317 NULL
96521 +ocfs2_direct_IO_get_blocks_24333 ocfs2_direct_IO_get_blocks 2 24333 NULL
96522 +kzalloc_node_24352 kzalloc_node 1 24352 NULL
96523 +qla2x00_handle_queue_full_24365 qla2x00_handle_queue_full 2 24365 NULL
96524 +cfi_read_pri_24366 cfi_read_pri 3 24366 NULL
96525 +btrfs_item_size_nr_24367 btrfs_item_size_nr 0 24367 NULL
96526 +igetword_24373 igetword 0 24373 NULL
96527 +pvr2_v4l2_ioctl_24398 pvr2_v4l2_ioctl 2 24398 NULL nohasharray
96528 +getxattr_24398 getxattr 4 24398 &pvr2_v4l2_ioctl_24398
96529 +blk_update_bidi_request_24415 blk_update_bidi_request 3-4 24415 NULL
96530 +b43_debugfs_read_24425 b43_debugfs_read 3 24425 NULL
96531 +iwl_nvm_read_section_24438 iwl_nvm_read_section 0 24438 NULL
96532 +ixgbe_alloc_q_vector_24439 ixgbe_alloc_q_vector 4-6 24439 NULL
96533 +smk_user_access_24440 smk_user_access 3 24440 NULL
96534 +page_address_24444 page_address 0 24444 NULL
96535 +evdev_do_ioctl_24459 evdev_do_ioctl 2 24459 NULL
96536 +ocfs2_write_cluster_by_desc_24466 ocfs2_write_cluster_by_desc 5-6 24466 NULL
96537 +read_file_spec_scan_ctl_24491 read_file_spec_scan_ctl 3 24491 NULL
96538 +pd_video_read_24510 pd_video_read 3 24510 NULL
96539 +request_key_with_auxdata_24515 request_key_with_auxdata 4 24515 NULL
96540 +xfs_buf_get_map_24522 xfs_buf_get_map 3 24522 NULL
96541 +named_prepare_buf_24532 named_prepare_buf 2 24532 NULL
96542 +do_mpage_readpage_24536 do_mpage_readpage 3 24536 NULL
96543 +write_cache_pages_24562 write_cache_pages 0 24562 NULL
96544 +tsi148_alloc_resource_24563 tsi148_alloc_resource 2 24563 NULL
96545 +udf_compute_nr_groups_24594 udf_compute_nr_groups 0 24594 NULL
96546 +count_preds_24600 count_preds 0 24600 NULL
96547 +sensor_hub_get_physical_device_count_24605 sensor_hub_get_physical_device_count 0 24605 NULL
96548 +kvm_pv_enable_async_pf_24637 kvm_pv_enable_async_pf 2 24637 NULL
96549 +context_alloc_24645 context_alloc 3 24645 NULL
96550 +blk_rq_err_bytes_24650 blk_rq_err_bytes 0 24650 NULL
96551 +unifi_net_data_malloc_24716 unifi_net_data_malloc 3 24716 NULL
96552 +read_fs_24717 read_fs 0 24717 NULL
96553 +simple_attr_read_24738 simple_attr_read 3 24738 NULL
96554 +qla2x00_change_queue_depth_24742 qla2x00_change_queue_depth 2 24742 NULL
96555 +ath_rxbuf_alloc_24745 ath_rxbuf_alloc 2 24745 NULL
96556 +get_dma_residue_24749 get_dma_residue 0 24749 NULL
96557 +kgdb_hex2mem_24755 kgdb_hex2mem 3 24755 NULL
96558 +nfsd4_sanitize_slot_size_24756 nfsd4_sanitize_slot_size 0-1 24756 NULL
96559 +i915_cache_sharing_read_24775 i915_cache_sharing_read 3 24775 NULL
96560 +ocfs2_read_blocks_24777 ocfs2_read_blocks 0 24777 NULL
96561 +skb_make_writable_24783 skb_make_writable 2 24783 NULL
96562 +datablob_hmac_verify_24786 datablob_hmac_verify 4 24786 NULL
96563 +cache_read_24790 cache_read 3 24790 NULL
96564 +unpack_str_24798 unpack_str 0 24798 NULL
96565 +__next_cpu_nr_24805 __next_cpu_nr 1 24805 NULL
96566 +comedi_buf_alloc_24822 comedi_buf_alloc 3 24822 NULL
96567 +snd_als4k_gcr_read_24840 snd_als4k_gcr_read 0 24840 NULL
96568 +snd_pcm_lib_buffer_bytes_24865 snd_pcm_lib_buffer_bytes 0 24865 NULL
96569 +pnp_alloc_24869 pnp_alloc 1 24869 NULL nohasharray
96570 +l2cap_create_basic_pdu_24869 l2cap_create_basic_pdu 3 24869 &pnp_alloc_24869
96571 +setup_buffering_24872 setup_buffering 3 24872 NULL
96572 +bnx2fc_cmd_mgr_alloc_24873 bnx2fc_cmd_mgr_alloc 3-2 24873 NULL
96573 +queues_read_24877 queues_read 3 24877 NULL
96574 +codec_list_read_file_24910 codec_list_read_file 3 24910 NULL
96575 +v4l2_ctrl_new_24927 v4l2_ctrl_new 7 24927 NULL
96576 +next_token_24929 next_token 0 24929 NULL
96577 +uf_create_device_nodes_24948 uf_create_device_nodes 2 24948 NULL
96578 +ocfs2_fiemap_24949 ocfs2_fiemap 3-4 24949 NULL
96579 +packet_sendmsg_24954 packet_sendmsg 4 24954 NULL
96580 +sys_rt_sigpending_24961 sys_rt_sigpending 2 24961 NULL
96581 +ensure_wear_leveling_24971 ensure_wear_leveling 0 24971 NULL
96582 +twl_i2c_write_u8_24976 twl_i2c_write_u8 3 24976 NULL
96583 +nf_nat_sdp_port_24977 nf_nat_sdp_port 7 24977 NULL
96584 +llc_ui_sendmsg_24987 llc_ui_sendmsg 4 24987 NULL
96585 +key_conf_hw_key_idx_read_25003 key_conf_hw_key_idx_read 3 25003 NULL
96586 +il_dbgfs_channels_read_25005 il_dbgfs_channels_read 3 25005 NULL
96587 +ni_660x_num_counters_25031 ni_660x_num_counters 0 25031 NULL
96588 +nfs_dns_resolve_name_25036 nfs_dns_resolve_name 3 25036 NULL
96589 +gs_buf_alloc_25067 gs_buf_alloc 2 25067 NULL
96590 +ceph_osdc_writepages_25085 ceph_osdc_writepages 5 25085 NULL
96591 +snd_rawmidi_kernel_write_25106 snd_rawmidi_kernel_write 3 25106 NULL
96592 +sys_fgetxattr_25166 sys_fgetxattr 4 25166 NULL
96593 +ipath_init_qp_table_25167 ipath_init_qp_table 2 25167 NULL
96594 +sctp_getsockopt_local_addrs_25178 sctp_getsockopt_local_addrs 2 25178 NULL
96595 +ks8851_rdreg32_25187 ks8851_rdreg32 0 25187 NULL
96596 +ocfs2_block_check_compute_25223 ocfs2_block_check_compute 2 25223 NULL
96597 +free_memcg_kmem_pages_25228 free_memcg_kmem_pages 1 25228 NULL
96598 +mon_stat_read_25238 mon_stat_read 3 25238 NULL
96599 +tcf_csum_ipv6_udp_25241 tcf_csum_ipv6_udp 4 25241 NULL
96600 +nilfs_palloc_find_available_slot_25245 nilfs_palloc_find_available_slot 3-5 25245 NULL
96601 +stripe_status_25259 stripe_status 5 25259 NULL
96602 +snd_pcm_start_25273 snd_pcm_start 0 25273 NULL
96603 +crypto_alloc_instance2_25277 crypto_alloc_instance2 3 25277 NULL
96604 +vfs_writev_25278 vfs_writev 3 25278 NULL
96605 +l2tp_session_create_25286 l2tp_session_create 1 25286 NULL
96606 +snd_seq_ioctl_compat_25307 snd_seq_ioctl_compat 3 25307 NULL
96607 +help_25316 help 5 25316 NULL nohasharray
96608 +ath9k_debugfs_read_buf_25316 ath9k_debugfs_read_buf 3 25316 &help_25316
96609 +rng_buffer_size_25348 rng_buffer_size 0 25348 NULL
96610 +rio_destid_next_25368 rio_destid_next 2 25368 NULL nohasharray
96611 +unix_mkname_25368 unix_mkname 0-2 25368 &rio_destid_next_25368
96612 +sel_read_mls_25369 sel_read_mls 3 25369 NULL
96613 +tc3589x_gpio_to_irq_25371 tc3589x_gpio_to_irq 2 25371 NULL
96614 +ebt_buf_add_pad_25413 ebt_buf_add_pad 0 25413 NULL
96615 +dai_list_read_file_25421 dai_list_read_file 3 25421 NULL
96616 +ath6kl_wmi_beginscan_cmd_25462 ath6kl_wmi_beginscan_cmd 8 25462 NULL
96617 +generic_file_buffered_write_25464 generic_file_buffered_write 4 25464 NULL
96618 +crypto_hash_digestsize_25469 crypto_hash_digestsize 0 25469 NULL
96619 +ocfs2_hamming_encode_25501 ocfs2_hamming_encode 3 25501 NULL
96620 +ivtv_buf_copy_from_user_25502 ivtv_buf_copy_from_user 4 25502 NULL
96621 +snd_pcm_plugin_build_25505 snd_pcm_plugin_build 5 25505 NULL
96622 +sb_permission_25523 sb_permission 0 25523 NULL
96623 +ext3_get_inode_loc_25542 ext3_get_inode_loc 0 25542 NULL
96624 +ieee80211_if_read_path_refresh_time_25545 ieee80211_if_read_path_refresh_time 3 25545 NULL
96625 +wimax_addr_scnprint_25548 wimax_addr_scnprint 2 25548 NULL
96626 +ht_print_chan_25556 ht_print_chan 0 25556 NULL
96627 +skb_tailroom_25567 skb_tailroom 0 25567 NULL
96628 +find_extend_vma_25597 find_extend_vma 2 25597 NULL
96629 +__devres_alloc_25598 __devres_alloc 2 25598 NULL
96630 +copy_user_generic_25611 copy_user_generic 0 25611 NULL
96631 +proc_coredump_filter_write_25625 proc_coredump_filter_write 3 25625 NULL
96632 +__get_user_pages_25628 __get_user_pages 0-3-4 25628 NULL nohasharray
96633 +befs_utf2nls_25628 befs_utf2nls 3 25628 &__get_user_pages_25628
96634 +__direct_map_25647 __direct_map 5-6 25647 NULL
96635 +ext2_try_to_allocate_25667 ext2_try_to_allocate 4-2 25667 NULL
96636 +aircable_prepare_write_buffer_25669 aircable_prepare_write_buffer 3 25669 NULL
96637 +sta_inactive_ms_read_25690 sta_inactive_ms_read 3 25690 NULL
96638 +ebitmap_start_positive_25703 ebitmap_start_positive 0 25703 NULL
96639 +rx_filter_mc_filter_read_25712 rx_filter_mc_filter_read 3 25712 NULL
96640 +ibmasm_new_command_25714 ibmasm_new_command 2 25714 NULL
96641 +sel_write_context_25726 sel_write_context 3 25726 NULL nohasharray
96642 +__alloc_bootmem_low_node_25726 __alloc_bootmem_low_node 2-3 25726 &sel_write_context_25726
96643 +mcs_unwrap_fir_25733 mcs_unwrap_fir 3 25733 NULL
96644 +ext2_find_near_25734 ext2_find_near 0 25734 NULL
96645 +__set_clear_dirty_25744 __set_clear_dirty 2 25744 NULL
96646 +cxgbi_device_portmap_create_25747 cxgbi_device_portmap_create 3 25747 NULL
96647 +event_rx_pool_read_25792 event_rx_pool_read 3 25792 NULL
96648 +sg_read_25799 sg_read 3 25799 NULL
96649 +system_enable_read_25815 system_enable_read 3 25815 NULL
96650 +realloc_buffer_25816 realloc_buffer 2 25816 NULL
96651 +mthca_map_user_db_25823 mthca_map_user_db 5 25823 NULL
96652 +pwr_missing_bcns_read_25824 pwr_missing_bcns_read 3 25824 NULL
96653 +parport_read_25855 parport_read 0 25855 NULL
96654 +xfs_dir2_sf_hdr_size_25858 xfs_dir2_sf_hdr_size 0 25858 NULL
96655 +uf_ap_process_data_pdu_25860 uf_ap_process_data_pdu 7 25860 NULL
96656 +ath6kl_regread_read_25884 ath6kl_regread_read 3 25884 NULL
96657 +run_delalloc_nocow_25896 run_delalloc_nocow 3 25896 NULL
96658 +sisusbcon_scroll_area_25899 sisusbcon_scroll_area 4-3 25899 NULL
96659 +lpfc_change_queue_depth_25905 lpfc_change_queue_depth 2 25905 NULL
96660 +do_jffs2_setxattr_25910 do_jffs2_setxattr 5 25910 NULL
96661 +rcname_read_25919 rcname_read 3 25919 NULL
96662 +snd_es1938_capture_copy_25930 snd_es1938_capture_copy 5 25930 NULL
96663 +key_flags_read_25931 key_flags_read 3 25931 NULL
96664 +copy_play_buf_25932 copy_play_buf 3 25932 NULL
96665 +flush_25957 flush 2 25957 NULL
96666 +video_register_device_25971 video_register_device 3 25971 NULL
96667 +udp_setsockopt_25985 udp_setsockopt 5 25985 NULL
96668 +ebt_compat_entry_padsize_26001 ebt_compat_entry_padsize 0 26001 NULL
96669 +lpfc_sli_probe_sriov_nr_virtfn_26004 lpfc_sli_probe_sriov_nr_virtfn 2 26004 NULL
96670 +irq_create_strict_mappings_26025 irq_create_strict_mappings 2-4 26025 NULL
96671 +xfs_xattr_acl_set_26028 xfs_xattr_acl_set 4 26028 NULL
96672 +skb_mac_header_26034 skb_mac_header 0 26034 NULL
96673 +mptscsih_change_queue_depth_26036 mptscsih_change_queue_depth 2 26036 NULL
96674 +selinux_inode_post_setxattr_26037 selinux_inode_post_setxattr 4 26037 NULL
96675 +tun_do_read_26047 tun_do_read 5 26047 NULL
96676 +__alloc_memory_core_early_26053 __alloc_memory_core_early 2-3 26053 NULL
96677 +keyctl_update_key_26061 keyctl_update_key 3 26061 NULL
96678 +rx_rx_wa_density_dropped_frame_read_26095 rx_rx_wa_density_dropped_frame_read 3 26095 NULL
96679 +skb_cow_26138 skb_cow 2 26138 NULL
96680 +usb_dump_device_strings_26146 usb_dump_device_strings 0 26146 NULL
96681 +copy_oldmem_page_26164 copy_oldmem_page 3-1 26164 NULL
96682 +gfs2_xattr_acl_get_26166 gfs2_xattr_acl_get 0 26166 NULL nohasharray
96683 +ath6kl_roam_table_read_26166 ath6kl_roam_table_read 3 26166 &gfs2_xattr_acl_get_26166
96684 +mid_get_vbt_data_r1_26170 mid_get_vbt_data_r1 2 26170 NULL
96685 +disk_devt_26180 disk_devt 0 26180 NULL
96686 +get_registers_26187 get_registers 3 26187 NULL
96687 +cgroup_setxattr_26188 cgroup_setxattr 4 26188 NULL
96688 +ieee80211_if_fmt_dot11MeshTTL_26198 ieee80211_if_fmt_dot11MeshTTL 3 26198 NULL
96689 +xfs_idata_realloc_26199 xfs_idata_realloc 2 26199 NULL
96690 +mce_write_26201 mce_write 3 26201 NULL
96691 +_scsih_change_queue_depth_26230 _scsih_change_queue_depth 2 26230 NULL
96692 +bio_split_26235 bio_split 2 26235 NULL
96693 +crypto_ctxsize_26278 crypto_ctxsize 0 26278 NULL
96694 +wacom_set_device_mode_26280 wacom_set_device_mode 3 26280 NULL
96695 +ext2_find_goal_26306 ext2_find_goal 0 26306 NULL
96696 +snd_pcm_plug_client_channels_buf_26309 snd_pcm_plug_client_channels_buf 0-3 26309 NULL nohasharray
96697 +pax_get_random_long_26309 pax_get_random_long 0 26309 &snd_pcm_plug_client_channels_buf_26309
96698 +pwr_wake_on_host_read_26321 pwr_wake_on_host_read 3 26321 NULL
96699 +ocfs2_duplicate_clusters_by_page_26357 ocfs2_duplicate_clusters_by_page 5 26357 NULL
96700 +cifs_readdata_alloc_26360 cifs_readdata_alloc 1 26360 NULL
96701 +dup_to_netobj_26363 dup_to_netobj 3 26363 NULL
96702 +invalidate_inode_pages2_range_26403 invalidate_inode_pages2_range 0 26403 NULL
96703 +dma_declare_contiguous_26455 dma_declare_contiguous 2 26455 NULL
96704 +ib_alloc_device_26483 ib_alloc_device 1 26483 NULL
96705 +ulong_write_file_26485 ulong_write_file 3 26485 NULL
96706 +dvb_ca_en50221_io_ioctl_26490 dvb_ca_en50221_io_ioctl 2 26490 NULL
96707 +read_vmcore_26501 read_vmcore 3 26501 NULL
96708 +vfio_pci_set_msi_trigger_26507 vfio_pci_set_msi_trigger 3-4 26507 NULL
96709 +iwl_dbgfs_rf_reset_read_26512 iwl_dbgfs_rf_reset_read 3 26512 NULL
96710 +__vhost_add_used_n_26554 __vhost_add_used_n 3 26554 NULL
96711 +ip6_addr_string_26568 ip6_addr_string 0 26568 NULL
96712 +kvm_iommu_put_pages_26571 kvm_iommu_put_pages 2 26571 NULL
96713 +rts51x_read_mem_26577 rts51x_read_mem 4 26577 NULL nohasharray
96714 +batadv_receive_server_sync_packet_26577 batadv_receive_server_sync_packet 3 26577 &rts51x_read_mem_26577
96715 +cirrusfb_get_memsize_26597 cirrusfb_get_memsize 0 26597 NULL
96716 +__unmap_single_26604 __unmap_single 2-3 26604 NULL
96717 +iommu_alloc_26621 iommu_alloc 4 26621 NULL
96718 +pack_value_26625 pack_value 1 26625 NULL
96719 +pwr_fix_tsf_ps_read_26627 pwr_fix_tsf_ps_read 3 26627 NULL
96720 +irq_alloc_generic_chip_26650 irq_alloc_generic_chip 2 26650 NULL nohasharray
96721 +inb_p_26650 inb_p 0 26650 &irq_alloc_generic_chip_26650
96722 +cipso_v4_map_cat_rbm_hton_26680 cipso_v4_map_cat_rbm_hton 0 26680 NULL
96723 +__alloc_pred_stack_26687 __alloc_pred_stack 2 26687 NULL
96724 +rtllib_authentication_req_26713 rtllib_authentication_req 3 26713 NULL
96725 +aty_ld_le32_26720 aty_ld_le32 0 26720 NULL
96726 +nouveau_namedb_create__26732 nouveau_namedb_create_ 7 26732 NULL
96727 +pipeline_tcp_rx_stat_fifo_int_read_26745 pipeline_tcp_rx_stat_fifo_int_read 3 26745 NULL
96728 +srp_ring_alloc_26760 srp_ring_alloc 2 26760 NULL
96729 +snd_hda_get_raw_connections_26762 snd_hda_get_raw_connections 0 26762 NULL
96730 +qlcnic_alloc_sds_rings_26795 qlcnic_alloc_sds_rings 2 26795 NULL
96731 +cipso_v4_genopt_26812 cipso_v4_genopt 0 26812 NULL
96732 +iwl_trans_read_mem32_26825 iwl_trans_read_mem32 0 26825 NULL
96733 +smk_write_load_26829 smk_write_load 3 26829 NULL
96734 +sizeof_pwm_leds_priv_26830 sizeof_pwm_leds_priv 0-1 26830 NULL
96735 +slgt_compat_ioctl_26834 slgt_compat_ioctl 3 26834 NULL
96736 +__nodes_onto_26838 __nodes_onto 4 26838 NULL
96737 +scnprint_id_26842 scnprint_id 3 26842 NULL
96738 +ecryptfs_miscdev_write_26847 ecryptfs_miscdev_write 3 26847 NULL
96739 +netxen_nic_hw_read_wx_128M_26858 netxen_nic_hw_read_wx_128M 2 26858 NULL
96740 +svc_print_xprts_26881 svc_print_xprts 0 26881 NULL
96741 +ext2_compat_ioctl_26883 ext2_compat_ioctl 3 26883 NULL
96742 +slhc_uncompress_26905 slhc_uncompress 0-3 26905 NULL
96743 +x25_asy_change_mtu_26928 x25_asy_change_mtu 2 26928 NULL
96744 +compat_mtw_from_user_26932 compat_mtw_from_user 0 26932 NULL
96745 +scsi_tgt_copy_sense_26933 scsi_tgt_copy_sense 3 26933 NULL
96746 +pwr_ps_enter_read_26935 pwr_ps_enter_read 3 26935 NULL nohasharray
96747 +sctp_setsockopt_adaptation_layer_26935 sctp_setsockopt_adaptation_layer 3 26935 &pwr_ps_enter_read_26935
96748 +carl9170_handle_mpdu_26940 carl9170_handle_mpdu 3 26940 NULL nohasharray
96749 +create_bm_block_list_26940 create_bm_block_list 0 26940 &carl9170_handle_mpdu_26940
96750 +hecubafb_write_26942 hecubafb_write 3 26942 NULL
96751 +extract_entropy_user_26952 extract_entropy_user 3 26952 NULL nohasharray
96752 +do_trimming_26952 do_trimming 3 26952 &extract_entropy_user_26952
96753 +pcf857x_irq_domain_map_26998 pcf857x_irq_domain_map 2 26998 NULL
96754 +swiotlb_bounce_27046 swiotlb_bounce 2-1 27046 NULL
96755 +ufs_alloc_fragments_27059 ufs_alloc_fragments 3-0-2 27059 NULL
96756 +__videobuf_alloc_vb_27062 __videobuf_alloc_vb 1 27062 NULL
96757 +snd_pcm_lib_period_bytes_27071 snd_pcm_lib_period_bytes 0 27071 NULL
96758 +paravirt_read_msr_27077 paravirt_read_msr 0 27077 NULL
96759 +alloc_fdmem_27083 alloc_fdmem 1 27083 NULL
96760 +find_first_bit_27088 find_first_bit 0-2 27088 NULL
96761 +btmrvl_hscmd_write_27089 btmrvl_hscmd_write 3 27089 NULL
96762 +nes_reg_user_mr_27106 nes_reg_user_mr 2-3 27106 NULL
96763 +__devcgroup_inode_permission_27108 __devcgroup_inode_permission 0 27108 NULL
96764 +get_kernel_page_27133 get_kernel_page 0 27133 NULL
96765 +drbd_get_capacity_27141 drbd_get_capacity 0 27141 NULL
96766 +pms_capture_27142 pms_capture 4 27142 NULL
96767 +btmrvl_hscfgcmd_write_27143 btmrvl_hscfgcmd_write 3 27143 NULL
96768 +snd_compr_calc_avail_27165 snd_compr_calc_avail 0 27165 NULL
96769 +i2400m_net_rx_27170 i2400m_net_rx 5 27170 NULL
96770 +ieee80211_if_read_rc_rateidx_mask_5ghz_27183 ieee80211_if_read_rc_rateidx_mask_5ghz 3 27183 NULL
96771 +mmc_blk_compat_ioctl_27194 mmc_blk_compat_ioctl 4 27194 NULL
96772 +dbAllocAG_27228 dbAllocAG 0 27228 NULL
96773 +rxrpc_request_key_27235 rxrpc_request_key 3 27235 NULL
96774 +cfpkt_add_trail_27260 cfpkt_add_trail 3 27260 NULL
96775 +__dma_map_cont_27289 __dma_map_cont 5 27289 NULL
96776 +hpi_read_reg_27302 hpi_read_reg 0 27302 NULL
96777 +copy_from_buf_27308 copy_from_buf 4-2 27308 NULL
96778 +ath6kl_wmi_test_cmd_27312 ath6kl_wmi_test_cmd 3 27312 NULL
96779 +ocfs2_blocks_to_clusters_27327 ocfs2_blocks_to_clusters 0-2 27327 NULL
96780 +snd_pcm_oss_write2_27332 snd_pcm_oss_write2 3-0 27332 NULL
96781 +afs_cell_create_27346 afs_cell_create 2 27346 NULL
96782 +pcbit_stat_27364 pcbit_stat 2 27364 NULL
96783 +init_memory_mapping_27395 init_memory_mapping 0 27395 NULL
96784 +phys_pte_init_27411 phys_pte_init 0-3-2 27411 NULL
96785 +ib_dma_map_sg_27413 ib_dma_map_sg 0 27413 NULL
96786 +acpi_os_get_root_pointer_27416 acpi_os_get_root_pointer 0 27416 NULL nohasharray
96787 +ieee80211_if_read_smps_27416 ieee80211_if_read_smps 3 27416 &acpi_os_get_root_pointer_27416
96788 +pack_sg_list_27425 pack_sg_list 0-2 27425 NULL
96789 +v4l2_ctrl_new_std_menu_items_27487 v4l2_ctrl_new_std_menu_items 4 27487 NULL
96790 +set_tpl_pfs_27490 set_tpl_pfs 3 27490 NULL
96791 +hcd_buffer_alloc_27495 hcd_buffer_alloc 2 27495 NULL
96792 +qib_create_cq_27497 qib_create_cq 2 27497 NULL
96793 +ip_set_get_h32_27498 ip_set_get_h32 0 27498 NULL
96794 +btrfs_get_64_27499 btrfs_get_64 0 27499 NULL
96795 +__usbnet_write_cmd_27500 __usbnet_write_cmd 7 27500 NULL
96796 +garmin_read_process_27509 garmin_read_process 3 27509 NULL
96797 +ib_copy_to_udata_27525 ib_copy_to_udata 3 27525 NULL
96798 +snd_sonicvibes_getdmaa_27552 snd_sonicvibes_getdmaa 0 27552 NULL
96799 +libipw_alloc_txb_27579 libipw_alloc_txb 1-2-3 27579 NULL
96800 +read_flush_procfs_27642 read_flush_procfs 3 27642 NULL nohasharray
96801 +nl80211_send_connect_result_27642 nl80211_send_connect_result 5-7 27642 &read_flush_procfs_27642 nohasharray
96802 +ocfs2_xattr_ibody_get_27642 ocfs2_xattr_ibody_get 0 27642 &nl80211_send_connect_result_27642
96803 +add_new_gdb_27643 add_new_gdb 3 27643 NULL
96804 +qnx6_readpages_27657 qnx6_readpages 4 27657 NULL
96805 +cdrom_read_cdda_old_27664 cdrom_read_cdda_old 4 27664 NULL
96806 +set_bypass_pwoff_pfs_27669 set_bypass_pwoff_pfs 3 27669 NULL
96807 +qword_get_27670 qword_get 0 27670 NULL
96808 +ocfs2_extend_dir_27695 ocfs2_extend_dir 4 27695 NULL
96809 +fs_path_add_from_extent_buffer_27702 fs_path_add_from_extent_buffer 4 27702 NULL
96810 +evm_write_key_27715 evm_write_key 3 27715 NULL
96811 +ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol_27722 ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol 3 27722 NULL
96812 +reg_w_buf_27724 reg_w_buf 3 27724 NULL
96813 +xfs_dir2_block_sfsize_27727 xfs_dir2_block_sfsize 0 27727 NULL
96814 +a4t_cs_init_27734 a4t_cs_init 3 27734 NULL
96815 +kcalloc_27770 kcalloc 1-2 27770 NULL
96816 +twl4030_set_gpio_dataout_27792 twl4030_set_gpio_dataout 1 27792 NULL
96817 +DivaSTraceGetMemotyRequirement_27797 DivaSTraceGetMemotyRequirement 0-1 27797 NULL
96818 +ttm_object_file_init_27804 ttm_object_file_init 2 27804 NULL
96819 +mpihelp_mul_27805 mpihelp_mul 5-3 27805 NULL
96820 +fwtty_buffer_rx_27821 fwtty_buffer_rx 3 27821 NULL
96821 +init_header_complete_27833 init_header_complete 0 27833 NULL nohasharray
96822 +sys_listxattr_27833 sys_listxattr 3 27833 &init_header_complete_27833
96823 +read_profile_27859 read_profile 3 27859 NULL
96824 +sky2_pci_read16_27863 sky2_pci_read16 0 27863 NULL
96825 +ieee80211_if_read_dot11MeshHWMProotInterval_27873 ieee80211_if_read_dot11MeshHWMProotInterval 3 27873 NULL
96826 +unix_seqpacket_sendmsg_27893 unix_seqpacket_sendmsg 4 27893 NULL
96827 +gluebi_write_27905 gluebi_write 3 27905 NULL
96828 +bm_find_next_27929 bm_find_next 2 27929 NULL
96829 +tracing_clock_write_27961 tracing_clock_write 3 27961 NULL
96830 +tipc_media_addr_printf_27971 tipc_media_addr_printf 2 27971 NULL
96831 +mic_rx_pkts_read_27972 mic_rx_pkts_read 3 27972 NULL
96832 +f2fs_bio_alloc_27983 f2fs_bio_alloc 2 27983 NULL
96833 +edt_ft5x06_debugfs_raw_data_read_28002 edt_ft5x06_debugfs_raw_data_read 3 28002 NULL
96834 +snd_rawmidi_write_28008 snd_rawmidi_write 3 28008 NULL
96835 +serial8250_port_size_28019 serial8250_port_size 0 28019 NULL
96836 +sctp_setsockopt_maxburst_28041 sctp_setsockopt_maxburst 3 28041 NULL
96837 +rts51x_xd_rw_28046 rts51x_xd_rw 3-4 28046 NULL
96838 +cx231xx_init_vbi_isoc_28053 cx231xx_init_vbi_isoc 3-2 28053 NULL
96839 +pool_status_28055 pool_status 5 28055 NULL
96840 +lpfc_idiag_mbxacc_read_28061 lpfc_idiag_mbxacc_read 3 28061 NULL
96841 +tx_frag_bad_mblk_num_read_28064 tx_frag_bad_mblk_num_read 3 28064 NULL
96842 +ext4_read_block_bitmap_nowait_28078 ext4_read_block_bitmap_nowait 2 28078 NULL
96843 +GetRecvByte_28082 GetRecvByte 0 28082 NULL
96844 +platform_get_irq_28088 platform_get_irq 0 28088 NULL
96845 +gdth_init_isa_28091 gdth_init_isa 1 28091 NULL
96846 +mmc_test_alloc_mem_28102 mmc_test_alloc_mem 3-2 28102 NULL
96847 +rx_defrag_need_defrag_read_28117 rx_defrag_need_defrag_read 3 28117 NULL
96848 +vgacon_adjust_height_28124 vgacon_adjust_height 2 28124 NULL
96849 +video_read_28148 video_read 3 28148 NULL
96850 +snd_midi_channel_alloc_set_28153 snd_midi_channel_alloc_set 1 28153 NULL
96851 +stats_dot11FCSErrorCount_read_28154 stats_dot11FCSErrorCount_read 3 28154 NULL
96852 +vread_28173 vread 0 28173 NULL
96853 +macvtap_get_user_28185 macvtap_get_user 4 28185 NULL
96854 +d_path_28198 d_path 0 28198 NULL
96855 +nouveau_mxm_create__28200 nouveau_mxm_create_ 4 28200 NULL
96856 +__qp_memcpy_from_queue_28220 __qp_memcpy_from_queue 3-4 28220 NULL
96857 +line6_alloc_sysex_buffer_28225 line6_alloc_sysex_buffer 4 28225 NULL nohasharray
96858 +set_dis_disc_pfs_28225 set_dis_disc_pfs 3 28225 &line6_alloc_sysex_buffer_28225
96859 +amd_nb_num_28228 amd_nb_num 0 28228 NULL
96860 +ext4_validate_block_bitmap_28243 ext4_validate_block_bitmap 3 28243 NULL
96861 +usemap_size_28281 usemap_size 0 28281 NULL
96862 +dma_map_sg_attrs_28289 dma_map_sg_attrs 0 28289 NULL
96863 +acpi_register_gsi_xen_28305 acpi_register_gsi_xen 2 28305 NULL nohasharray
96864 +nouveau_compat_ioctl_28305 nouveau_compat_ioctl 2 28305 &acpi_register_gsi_xen_28305
96865 +__mlock_vma_pages_range_28315 __mlock_vma_pages_range 2-3 28315 NULL
96866 +snd_pcm_oss_read_28317 snd_pcm_oss_read 3 28317 NULL
96867 +bm_entry_write_28338 bm_entry_write 3 28338 NULL
96868 +snapshot_write_28351 snapshot_write 3 28351 NULL
96869 +sys_writev_28384 sys_writev 3 28384 NULL
96870 +dlmfs_file_read_28385 dlmfs_file_read 3 28385 NULL
96871 +tx_frag_cache_miss_read_28394 tx_frag_cache_miss_read 3 28394 NULL
96872 +set_bypass_pfs_28395 set_bypass_pfs 3 28395 NULL
96873 +subdev_ioctl_28417 subdev_ioctl 2 28417 NULL
96874 +__split_large_page_28429 __split_large_page 2 28429 NULL
96875 +mpage_readpages_28436 mpage_readpages 3 28436 NULL
96876 +set_memory_uc_28439 set_memory_uc 1 28439 NULL
96877 +snd_emu10k1_efx_read_28452 snd_emu10k1_efx_read 2 28452 NULL
96878 +key_mic_failures_read_28457 key_mic_failures_read 3 28457 NULL
96879 +alloc_irq_cpu_rmap_28459 alloc_irq_cpu_rmap 1 28459 NULL
96880 +vmw_du_crtc_cursor_set_28479 vmw_du_crtc_cursor_set 4-5 28479 NULL
96881 +ocfs2_backup_super_blkno_28484 ocfs2_backup_super_blkno 0-2 28484 NULL
96882 +max_response_pages_28492 max_response_pages 0 28492 NULL
96883 +clear_discard_28494 clear_discard 2 28494 NULL
96884 +ps_poll_upsd_utilization_read_28519 ps_poll_upsd_utilization_read 3 28519 NULL
96885 +__next_node_28521 __next_node 1 28521 NULL
96886 +i2400m_tx_stats_read_28527 i2400m_tx_stats_read 3 28527 NULL
96887 +sel_read_policycap_28544 sel_read_policycap 3 28544 NULL
96888 +run_delalloc_range_28545 run_delalloc_range 3 28545 NULL nohasharray
96889 +mptctl_getiocinfo_28545 mptctl_getiocinfo 2 28545 &run_delalloc_range_28545
96890 +b43legacy_debugfs_write_28556 b43legacy_debugfs_write 3 28556 NULL
96891 +asymmetric_verify_28567 asymmetric_verify 3 28567 NULL
96892 +phys_pud_init_28574 phys_pud_init 0-3-2 28574 NULL
96893 +cfg80211_send_rx_auth_28580 cfg80211_send_rx_auth 3 28580 NULL
96894 +oxygen_read32_28582 oxygen_read32 0 28582 NULL
96895 +ocfs2_read_dir_block_28587 ocfs2_read_dir_block 2 28587 NULL
96896 +extract_entropy_28604 extract_entropy 3-5 28604 NULL
96897 +kfifo_unused_28612 kfifo_unused 0 28612 NULL
96898 +mp_override_legacy_irq_28618 mp_override_legacy_irq 4 28618 NULL
96899 +snd_nm256_capture_copy_28622 snd_nm256_capture_copy 5-3 28622 NULL
96900 +_set_range_28627 _set_range 3 28627 NULL
96901 +v4l2_compat_ioctl32_28630 v4l2_compat_ioctl32 3 28630 NULL
96902 +setup_usemap_28636 setup_usemap 3-4 28636 NULL
96903 +blk_queue_resize_tags_28670 blk_queue_resize_tags 2 28670 NULL
96904 +__dev_alloc_skb_28681 __dev_alloc_skb 1 28681 NULL
96905 +nl80211_send_new_peer_candidate_28692 nl80211_send_new_peer_candidate 5 28692 NULL nohasharray
96906 +kvm_mmu_get_page_28692 kvm_mmu_get_page 2 28692 &nl80211_send_new_peer_candidate_28692
96907 +drm_plane_init_28731 drm_plane_init 6 28731 NULL
96908 +spi_execute_28736 spi_execute 5 28736 NULL
96909 +snd_pcm_aio_write_28738 snd_pcm_aio_write 3 28738 NULL nohasharray
96910 +phantom_compat_ioctl_28738 phantom_compat_ioctl 3 28738 &snd_pcm_aio_write_28738
96911 +read_file_btcoex_28743 read_file_btcoex 3 28743 NULL
96912 +ath6kl_get_num_reg_28780 ath6kl_get_num_reg 0 28780 NULL
96913 +dvb_net_sec_callback_28786 dvb_net_sec_callback 2 28786 NULL
96914 +sel_write_member_28800 sel_write_member 3 28800 NULL
96915 +cgroup_file_read_28804 cgroup_file_read 3 28804 NULL
96916 +btrfs_ref_to_path_28809 btrfs_ref_to_path 0 28809 NULL
96917 +memory_bm_create_28814 memory_bm_create 0 28814 NULL
96918 +iwl_dbgfs_rxon_filter_flags_read_28832 iwl_dbgfs_rxon_filter_flags_read 3 28832 NULL
96919 +vp_request_msix_vectors_28849 vp_request_msix_vectors 2 28849 NULL
96920 +ipv6_renew_options_28867 ipv6_renew_options 5 28867 NULL
96921 +packet_sendmsg_spkt_28885 packet_sendmsg_spkt 4 28885 NULL
96922 +to_cblock_28899 to_cblock 0-1 28899 NULL
96923 +da9055_group_write_28904 da9055_group_write 2-3 28904 NULL
96924 +ps_upsd_timeouts_read_28924 ps_upsd_timeouts_read 3 28924 NULL
96925 +ocfs2_frozen_trigger_28929 ocfs2_frozen_trigger 4 28929 NULL
96926 +push_rx_28939 push_rx 3 28939 NULL
96927 +btrfs_trim_block_group_28963 btrfs_trim_block_group 3 28963 NULL
96928 +alloc_sched_domains_28972 alloc_sched_domains 1 28972 NULL
96929 +ext4_mb_add_groupinfo_28988 ext4_mb_add_groupinfo 2 28988 NULL
96930 +bin_uuid_28999 bin_uuid 3 28999 NULL
96931 +xz_dec_init_29029 xz_dec_init 2 29029 NULL
96932 +sys_fcntl64_29031 sys_fcntl64 3 29031 NULL
96933 +ieee80211_if_read_ht_opmode_29044 ieee80211_if_read_ht_opmode 3 29044 NULL
96934 +rxrpc_sendmsg_29049 rxrpc_sendmsg 4 29049 NULL
96935 +iso_packets_buffer_init_29061 iso_packets_buffer_init 3-4 29061 NULL
96936 +lpfc_idiag_extacc_drivr_get_29067 lpfc_idiag_extacc_drivr_get 0-3 29067 NULL
96937 +memblock_alloc_base_nid_29072 memblock_alloc_base_nid 1-2 29072 NULL
96938 +sctp_getsockopt_assoc_stats_29074 sctp_getsockopt_assoc_stats 2 29074 NULL
96939 +mark_extents_written_29082 mark_extents_written 2 29082 NULL
96940 +isdn_ppp_write_29109 isdn_ppp_write 4 29109 NULL
96941 +snprintf_29125 snprintf 0 29125 NULL
96942 +iov_shorten_29130 iov_shorten 0 29130 NULL
96943 +proc_scsi_write_29142 proc_scsi_write 3 29142 NULL
96944 +reshape_ring_29147 reshape_ring 2 29147 NULL
96945 +alloc_irqs_from_29152 alloc_irqs_from 1-2 29152 NULL
96946 +drm_property_create_enum_29201 drm_property_create_enum 5 29201 NULL
96947 +wusb_prf_256_29203 wusb_prf_256 7 29203 NULL nohasharray
96948 +alloc_group_attrs_29203 alloc_group_attrs 3 29203 &wusb_prf_256_29203
96949 +__mm_populate_29204 __mm_populate 1 29204 NULL
96950 +comedi_alloc_subdevices_29207 comedi_alloc_subdevices 2 29207 NULL
96951 +do_shrinker_shrink_29208 do_shrinker_shrink 0 29208 NULL
96952 +iwl_dbgfs_temperature_read_29224 iwl_dbgfs_temperature_read 3 29224 NULL
96953 +devm_ioremap_29235 devm_ioremap 2-3 29235 NULL
96954 +irq_domain_add_linear_29236 irq_domain_add_linear 2 29236 NULL
96955 +recover_peb_29238 recover_peb 6-7 29238 NULL
96956 +security_context_to_sid_core_29248 security_context_to_sid_core 2 29248 NULL
96957 +block_div_29268 block_div 0-1-2 29268 NULL
96958 +prism2_set_genericelement_29277 prism2_set_genericelement 3 29277 NULL
96959 +bitmap_ord_to_pos_29279 bitmap_ord_to_pos 3 29279 NULL
96960 +sn9c102_read_29305 sn9c102_read 3 29305 NULL
96961 +lo_compat_ioctl_29336 lo_compat_ioctl 4 29336 NULL
96962 +tun_put_user_29337 tun_put_user 5 29337 NULL
96963 +__alloc_ei_netdev_29338 __alloc_ei_netdev 1 29338 NULL
96964 +alloc_and_copy_ftrace_hash_29368 alloc_and_copy_ftrace_hash 1 29368 NULL
96965 +mwifiex_cfg80211_mgmt_tx_29387 mwifiex_cfg80211_mgmt_tx 7 29387 NULL
96966 +pca953x_irq_setup_29407 pca953x_irq_setup 3 29407 NULL
96967 +mempool_create_29437 mempool_create 1 29437 NULL
96968 +crypto_ahash_alignmask_29445 crypto_ahash_alignmask 0 29445 NULL
96969 +apei_exec_ctx_get_output_29457 apei_exec_ctx_get_output 0 29457 NULL
96970 +validate_scan_freqs_29462 validate_scan_freqs 0 29462 NULL
96971 +do_register_entry_29478 do_register_entry 4 29478 NULL
96972 +simple_strtoul_29480 simple_strtoul 0 29480 NULL
96973 +btmrvl_pscmd_write_29504 btmrvl_pscmd_write 3 29504 NULL
96974 +btrfs_file_extent_disk_bytenr_29505 btrfs_file_extent_disk_bytenr 0 29505 NULL
96975 +atk_debugfs_ggrp_read_29522 atk_debugfs_ggrp_read 3 29522 NULL
96976 +_regmap_raw_write_29541 _regmap_raw_write 4-2 29541 NULL
96977 +set_brk_29551 set_brk 1 29551 NULL nohasharray
96978 +ftrace_write_29551 ftrace_write 3 29551 &set_brk_29551
96979 +idetape_queue_rw_tail_29562 idetape_queue_rw_tail 3 29562 NULL
96980 +leaf_dealloc_29566 leaf_dealloc 3 29566 NULL nohasharray
96981 +alloc_empty_pages_29566 alloc_empty_pages 2 29566 &leaf_dealloc_29566
96982 +lbs_lowsnr_read_29571 lbs_lowsnr_read 3 29571 NULL
96983 +pvr2_hdw_report_unlocked_29589 pvr2_hdw_report_unlocked 4 29589 NULL
96984 +slots_per_page_29601 slots_per_page 0 29601 NULL
96985 +qla4_82xx_pci_set_window_29605 qla4_82xx_pci_set_window 0-2 29605 NULL
96986 +alloc_low_pages_29623 alloc_low_pages 1 29623 NULL
96987 +nla_get_u16_29624 nla_get_u16 0 29624 NULL
96988 +tx_frag_cache_hit_read_29639 tx_frag_cache_hit_read 3 29639 NULL
96989 +lowmem_page_address_29649 lowmem_page_address 0 29649 NULL
96990 +sctp_make_abort_user_29654 sctp_make_abort_user 3 29654 NULL
96991 +br_send_bpdu_29669 br_send_bpdu 3 29669 NULL
96992 +sisusb_write_mem_bulk_29678 sisusb_write_mem_bulk 4 29678 NULL
96993 +sd_alloc_ctl_entry_29708 sd_alloc_ctl_entry 1 29708 NULL nohasharray
96994 +posix_acl_from_xattr_29708 posix_acl_from_xattr 3 29708 &sd_alloc_ctl_entry_29708
96995 +probes_write_29711 probes_write 3 29711 NULL
96996 +emi62_writememory_29731 emi62_writememory 4 29731 NULL
96997 +read_cis_cache_29735 read_cis_cache 4 29735 NULL
96998 +ip_vs_conn_fill_param_sync_29771 ip_vs_conn_fill_param_sync 6 29771 NULL
96999 +dbAlloc_29794 dbAlloc 0 29794 NULL
97000 +ext4_trim_all_free_29806 ext4_trim_all_free 4-3-2 29806 NULL
97001 +tcp_sendpage_29829 tcp_sendpage 4 29829 NULL
97002 +scan_bitmap_block_29840 scan_bitmap_block 4 29840 NULL
97003 +__probe_kernel_write_29842 __probe_kernel_write 3 29842 NULL
97004 +kvm_read_hva_atomic_29848 kvm_read_hva_atomic 3 29848 NULL
97005 +ipv6_setsockopt_29871 ipv6_setsockopt 5 29871 NULL
97006 +scsi_end_request_29876 scsi_end_request 3 29876 NULL
97007 +crypto_aead_alignmask_29885 crypto_aead_alignmask 0 29885 NULL
97008 +nfc_targets_found_29886 nfc_targets_found 3 29886 NULL
97009 +ext4_xattr_set_acl_29930 ext4_xattr_set_acl 4 29930 NULL
97010 +__btrfs_getxattr_29947 __btrfs_getxattr 0 29947 NULL
97011 +irias_add_octseq_attrib_29983 irias_add_octseq_attrib 4 29983 NULL nohasharray
97012 +diva_os_get_context_size_29983 diva_os_get_context_size 0 29983 &irias_add_octseq_attrib_29983
97013 +arch_setup_dmar_msi_29992 arch_setup_dmar_msi 1 29992 NULL
97014 +vmci_host_setup_notify_30002 vmci_host_setup_notify 2 30002 NULL
97015 +utf32_to_utf8_30028 utf32_to_utf8 0 30028 NULL
97016 +alloc_netdev_mqs_30030 alloc_netdev_mqs 1 30030 NULL
97017 +scsi_vpd_inquiry_30040 scsi_vpd_inquiry 4 30040 NULL
97018 +drp_wmove_30043 drp_wmove 4 30043 NULL
97019 +cxgbi_ddp_reserve_30091 cxgbi_ddp_reserve 4 30091 NULL
97020 +snd_midi_channel_init_set_30092 snd_midi_channel_init_set 1 30092 NULL
97021 +tg3_run_loopback_30093 tg3_run_loopback 2 30093 NULL
97022 +rx_filter_data_filter_read_30098 rx_filter_data_filter_read 3 30098 NULL nohasharray
97023 +dma_to_phys_30098 dma_to_phys 0-2 30098 &rx_filter_data_filter_read_30098
97024 +skb_pagelen_30113 skb_pagelen 0 30113 NULL
97025 +spi_async_locked_30117 spi_async_locked 0 30117 NULL
97026 +calgary_unmap_page_30130 calgary_unmap_page 2-3 30130 NULL
97027 +_osd_req_sizeof_alist_header_30134 _osd_req_sizeof_alist_header 0 30134 NULL
97028 +u_memcpya_30139 u_memcpya 2-3 30139 NULL
97029 +cx25821_video_ioctl_30188 cx25821_video_ioctl 2 30188 NULL
97030 +mempool_create_page_pool_30189 mempool_create_page_pool 1 30189 NULL
97031 +drm_property_create_bitmask_30195 drm_property_create_bitmask 5 30195 NULL
97032 +usblp_ioctl_30203 usblp_ioctl 2 30203 NULL
97033 +nfs_idmap_request_key_30208 nfs_idmap_request_key 3 30208 NULL
97034 +read_4k_modal_eeprom_30212 read_4k_modal_eeprom 3 30212 NULL
97035 +snd_ac97_pcm_assign_30218 snd_ac97_pcm_assign 2 30218 NULL
97036 +f2fs_compat_ioctl_30261 f2fs_compat_ioctl 3 30261 NULL
97037 +isr_pci_pm_read_30271 isr_pci_pm_read 3 30271 NULL
97038 +compat_readv_30273 compat_readv 3 30273 NULL
97039 +lapic_register_intr_30279 lapic_register_intr 1 30279 NULL
97040 +skcipher_sendmsg_30290 skcipher_sendmsg 4 30290 NULL
97041 +pipeline_sec_frag_swi_read_30294 pipeline_sec_frag_swi_read 3 30294 NULL
97042 +tcp_sendmsg_30296 tcp_sendmsg 4 30296 NULL
97043 +ext4_acl_from_disk_30320 ext4_acl_from_disk 2 30320 NULL
97044 +generic_ptrace_pokedata_30338 generic_ptrace_pokedata 2 30338 NULL
97045 +resource_from_user_30341 resource_from_user 3 30341 NULL
97046 +__vmalloc_node_flags_30352 __vmalloc_node_flags 1 30352 NULL
97047 +sys_get_mempolicy_30379 sys_get_mempolicy 3-4 30379 NULL
97048 +mangle_sdp_packet_30381 mangle_sdp_packet 10 30381 NULL
97049 +c4iw_init_resource_30393 c4iw_init_resource 2-3 30393 NULL
97050 +get_kernel_pages_30397 get_kernel_pages 0 30397 NULL
97051 +_drbd_bm_find_next_zero_30415 _drbd_bm_find_next_zero 2 30415 NULL
97052 +vb2_fop_write_30420 vb2_fop_write 3 30420 NULL
97053 +tx_tx_template_prepared_read_30424 tx_tx_template_prepared_read 3 30424 NULL
97054 +mq_create_30425 mq_create 1 30425 NULL
97055 +enable_write_30456 enable_write 3 30456 NULL
97056 +tx_tx_template_programmed_read_30461 tx_tx_template_programmed_read 3 30461 NULL
97057 +urandom_read_30462 urandom_read 3 30462 NULL
97058 +zoran_ioctl_30465 zoran_ioctl 2 30465 NULL
97059 +ocrdma_reg_user_mr_30474 ocrdma_reg_user_mr 2-3 30474 NULL
97060 +write_head_30481 write_head 4 30481 NULL
97061 +adu_write_30487 adu_write 3 30487 NULL
97062 +debug_debug2_read_30526 debug_debug2_read 3 30526 NULL
97063 +batadv_dat_snoop_incoming_arp_request_30548 batadv_dat_snoop_incoming_arp_request 3 30548 NULL
97064 +disk_expand_part_tbl_30561 disk_expand_part_tbl 2 30561 NULL
97065 +set_le_30581 set_le 4 30581 NULL
97066 +from_cblock_30582 from_cblock 0-1 30582 NULL
97067 +blk_init_tags_30592 blk_init_tags 1 30592 NULL
97068 +i2c_hid_get_report_length_30598 i2c_hid_get_report_length 0 30598 NULL
97069 +sgl_map_user_pages_30610 sgl_map_user_pages 2-3-4 30610 NULL
97070 +macvtap_sendmsg_30629 macvtap_sendmsg 4 30629 NULL
97071 +ieee80211_if_read_dot11MeshAwakeWindowDuration_30631 ieee80211_if_read_dot11MeshAwakeWindowDuration 3 30631 NULL
97072 +compat_raw_setsockopt_30634 compat_raw_setsockopt 5 30634 NULL
97073 +agp_remap_30665 agp_remap 2 30665 NULL
97074 +jffs2_flash_read_30667 jffs2_flash_read 0 30667 NULL
97075 +il_free_pages_30692 il_free_pages 2 30692 NULL
97076 +dccp_setsockopt_ccid_30701 dccp_setsockopt_ccid 4 30701 NULL
97077 +lbs_debugfs_read_30721 lbs_debugfs_read 3 30721 NULL
97078 +snd_nm256_playback_silence_30727 snd_nm256_playback_silence 4-3 30727 NULL
97079 +snapshot_status_30744 snapshot_status 5 30744 NULL
97080 +tcf_csum_ipv4_udp_30777 tcf_csum_ipv4_udp 4 30777 NULL
97081 +smk_read_doi_30813 smk_read_doi 3 30813 NULL
97082 +get_kobj_path_length_30831 get_kobj_path_length 0 30831 NULL
97083 +sctp_setsockopt_auth_chunk_30843 sctp_setsockopt_auth_chunk 3 30843 NULL
97084 +cfg80211_rx_mgmt_30844 cfg80211_rx_mgmt 5 30844 NULL
97085 +hda_hwdep_ioctl_compat_30847 hda_hwdep_ioctl_compat 4 30847 NULL
97086 +ieee80211_if_fmt_dropped_frames_no_route_30884 ieee80211_if_fmt_dropped_frames_no_route 3 30884 NULL
97087 +iommu_map_mmio_space_30919 iommu_map_mmio_space 1 30919 NULL
97088 +sctp_setsockopt_rtoinfo_30941 sctp_setsockopt_rtoinfo 3 30941 NULL
97089 +tty_insert_flip_string_flags_30969 tty_insert_flip_string_flags 4 30969 NULL
97090 +huge_page_mask_30981 huge_page_mask 0 30981 NULL
97091 +i2400mu_rx_size_grow_30989 i2400mu_rx_size_grow 0 30989 NULL
97092 +lbs_host_sleep_read_31013 lbs_host_sleep_read 3 31013 NULL
97093 +phys_pmd_init_31024 phys_pmd_init 0-3-2 31024 NULL
97094 +compat_sys_mq_timedsend_31060 compat_sys_mq_timedsend 3 31060 NULL
97095 +lbs_failcount_read_31063 lbs_failcount_read 3 31063 NULL
97096 +find_next_bit_le_31064 find_next_bit_le 0-2-3 31064 NULL
97097 +sys_mincore_31079 sys_mincore 1 31079 NULL
97098 +ttm_bo_ioremap_31082 ttm_bo_ioremap 2-3 31082 NULL
97099 +sctp_setsockopt_context_31091 sctp_setsockopt_context 3 31091 NULL
97100 +compat_sys_get_mempolicy_31109 compat_sys_get_mempolicy 3-4 31109 NULL
97101 +depth_read_31112 depth_read 3 31112 NULL
97102 +ssb_read16_31139 ssb_read16 0 31139 NULL
97103 +kimage_normal_alloc_31140 kimage_normal_alloc 3 31140 NULL
97104 +size_inside_page_31141 size_inside_page 0 31141 NULL
97105 +w9966_v4l_read_31148 w9966_v4l_read 3 31148 NULL
97106 +ch_do_scsi_31171 ch_do_scsi 4 31171 NULL
97107 +acpi_ex_system_memory_space_handler_31192 acpi_ex_system_memory_space_handler 2 31192 NULL
97108 +r592_read_fifo_pio_31198 r592_read_fifo_pio 3 31198 NULL
97109 +mtdchar_readoob_31200 mtdchar_readoob 4 31200 NULL
97110 +__btrfs_free_reserved_extent_31207 __btrfs_free_reserved_extent 2 31207 NULL
97111 +kvm_mmu_page_fault_31213 kvm_mmu_page_fault 2 31213 NULL
97112 +cpumask_weight_31215 cpumask_weight 0 31215 NULL
97113 +__read_reg_31216 __read_reg 0 31216 NULL
97114 +atm_get_addr_31221 atm_get_addr 3 31221 NULL
97115 +cyy_readb_31240 cyy_readb 0 31240 NULL
97116 +_create_sg_bios_31244 _create_sg_bios 4 31244 NULL
97117 +ieee80211_if_read_last_beacon_31257 ieee80211_if_read_last_beacon 3 31257 NULL
97118 +sctp_tsnmap_find_gap_ack_31272 sctp_tsnmap_find_gap_ack 3-2 31272 NULL
97119 +uvc_simplify_fraction_31303 uvc_simplify_fraction 3 31303 NULL
97120 +sisusbcon_scroll_31315 sisusbcon_scroll 5-2-3 31315 NULL
97121 +command_file_write_31318 command_file_write 3 31318 NULL
97122 +em28xx_init_usb_xfer_31337 em28xx_init_usb_xfer 4-6 31337 NULL
97123 +xprt_rdma_allocate_31372 xprt_rdma_allocate 2 31372 NULL
97124 +vb2_vmalloc_get_userptr_31374 vb2_vmalloc_get_userptr 3-2 31374 NULL
97125 +trace_parser_get_init_31379 trace_parser_get_init 2 31379 NULL
97126 +inb_31388 inb 0 31388 NULL
97127 +key_ifindex_read_31411 key_ifindex_read 3 31411 NULL
97128 +mcs7830_set_reg_31413 mcs7830_set_reg 3 31413 NULL
97129 +TSS_checkhmac1_31429 TSS_checkhmac1 5 31429 NULL
97130 +snd_aw2_saa7146_get_hw_ptr_capture_31431 snd_aw2_saa7146_get_hw_ptr_capture 0 31431 NULL
97131 +acpi_sci_ioapic_setup_31445 acpi_sci_ioapic_setup 4 31445 NULL
97132 +opera1_xilinx_rw_31453 opera1_xilinx_rw 5 31453 NULL
97133 +input_get_new_minor_31464 input_get_new_minor 1 31464 NULL
97134 +do_fcntl_31468 do_fcntl 3 31468 NULL
97135 +xfs_btree_get_numrecs_31477 xfs_btree_get_numrecs 0 31477 NULL
97136 +alg_setkey_31485 alg_setkey 3 31485 NULL
97137 +rds_message_map_pages_31487 rds_message_map_pages 2 31487 NULL
97138 +qsfp_2_read_31491 qsfp_2_read 3 31491 NULL
97139 +__alloc_bootmem_31498 __alloc_bootmem 1-2 31498 NULL
97140 +rmode_tss_base_31510 rmode_tss_base 0 31510 NULL
97141 +hidraw_write_31536 hidraw_write 3 31536 NULL
97142 +mtd_div_by_eb_31543 mtd_div_by_eb 0-1 31543 NULL
97143 +usbvision_read_31555 usbvision_read 3 31555 NULL
97144 +normalize_31566 normalize 0-1-2 31566 NULL
97145 +tx_frag_tkip_called_read_31575 tx_frag_tkip_called_read 3 31575 NULL
97146 +get_max_inline_xattr_value_size_31578 get_max_inline_xattr_value_size 0 31578 NULL
97147 +osst_write_31581 osst_write 3 31581 NULL
97148 +snd_compr_get_avail_31584 snd_compr_get_avail 0 31584 NULL
97149 +iwl_dbgfs_ucode_tx_stats_read_31611 iwl_dbgfs_ucode_tx_stats_read 3 31611 NULL
97150 +mtd_get_user_prot_info_31616 mtd_get_user_prot_info 0 31616 NULL
97151 +arvo_sysfs_read_31617 arvo_sysfs_read 6 31617 NULL
97152 +videobuf_read_one_31637 videobuf_read_one 3 31637 NULL
97153 +pod_alloc_sysex_buffer_31651 pod_alloc_sysex_buffer 3 31651 NULL
97154 +xfer_secondary_pool_31661 xfer_secondary_pool 2 31661 NULL
97155 +emulator_set_cr_31665 emulator_set_cr 3 31665 NULL
97156 +__lgread_31668 __lgread 4 31668 NULL
97157 +symbol_string_31670 symbol_string 0 31670 NULL
97158 +_usb_writeN_sync_31682 _usb_writeN_sync 4 31682 NULL
97159 +forced_ps_read_31685 forced_ps_read 3 31685 NULL
97160 +reiserfs_in_journal_31689 reiserfs_in_journal 3 31689 NULL
97161 +audit_log_n_string_31705 audit_log_n_string 3 31705 NULL
97162 +ath6kl_wmi_send_probe_response_cmd_31728 ath6kl_wmi_send_probe_response_cmd 6 31728 NULL nohasharray
97163 +gfn_to_hva_read_31728 gfn_to_hva_read 2 31728 &ath6kl_wmi_send_probe_response_cmd_31728
97164 +utf16s_to_utf8s_31735 utf16s_to_utf8s 0 31735 NULL
97165 +shmem_pwrite_slow_31741 shmem_pwrite_slow 3 31741 NULL
97166 +NCR_700_change_queue_depth_31742 NCR_700_change_queue_depth 2 31742 NULL nohasharray
97167 +input_abs_get_max_31742 input_abs_get_max 0 31742 &NCR_700_change_queue_depth_31742
97168 +bcm_char_read_31750 bcm_char_read 3 31750 NULL
97169 +snd_seq_device_new_31753 snd_seq_device_new 4 31753 NULL
97170 +set_memory_wb_31761 set_memory_wb 1 31761 NULL
97171 +usblp_cache_device_id_string_31790 usblp_cache_device_id_string 0 31790 NULL
97172 +get_count_order_31800 get_count_order 0 31800 NULL
97173 +ecryptfs_send_message_locked_31801 ecryptfs_send_message_locked 2 31801 NULL
97174 +isr_rx_procs_read_31804 isr_rx_procs_read 3 31804 NULL
97175 +strnlen_user_31815 strnlen_user 0-2 31815 NULL
97176 +sta_last_signal_read_31818 sta_last_signal_read 3 31818 NULL
97177 +drm_mode_crtc_set_gamma_size_31881 drm_mode_crtc_set_gamma_size 2 31881 NULL
97178 +ddb_output_write_31902 ddb_output_write 3 31902 NULL
97179 +xattr_permission_31907 xattr_permission 0 31907 NULL
97180 +new_dir_31919 new_dir 3 31919 NULL
97181 +kmem_alloc_31920 kmem_alloc 1 31920 NULL
97182 +guestwidth_to_adjustwidth_31937 guestwidth_to_adjustwidth 0-1 31937 NULL
97183 +iov_iter_copy_from_user_31942 iov_iter_copy_from_user 4 31942 NULL
97184 +vb2_write_31948 vb2_write 3 31948 NULL
97185 +pvr2_ctrl_get_valname_31951 pvr2_ctrl_get_valname 4 31951 NULL
97186 +copy_from_user_toio_31966 copy_from_user_toio 3 31966 NULL
97187 +mtd_add_partition_31971 mtd_add_partition 3 31971 NULL
97188 +find_next_zero_bit_31990 find_next_zero_bit 0-2-3 31990 NULL
97189 +default_setup_hpet_msi_31991 default_setup_hpet_msi 1 31991 NULL
97190 +tps6586x_irq_map_32002 tps6586x_irq_map 2 32002 NULL
97191 +calc_hmac_32010 calc_hmac 3 32010 NULL
97192 +vmcs_read64_32012 vmcs_read64 0 32012 NULL
97193 +aead_len_32021 aead_len 0 32021 NULL
97194 +ocfs2_remove_extent_32032 ocfs2_remove_extent 4-3 32032 NULL
97195 +posix_acl_set_32037 posix_acl_set 4 32037 NULL
97196 +vmw_cursor_update_dmabuf_32045 vmw_cursor_update_dmabuf 3-4 32045 NULL
97197 +sys_sched_setaffinity_32046 sys_sched_setaffinity 2 32046 NULL
97198 +proc_scsi_devinfo_write_32064 proc_scsi_devinfo_write 3 32064 NULL
97199 +cfg80211_send_unprot_deauth_32080 cfg80211_send_unprot_deauth 3 32080 NULL
97200 +bio_alloc_32095 bio_alloc 2 32095 NULL
97201 +alloc_pwms_32100 alloc_pwms 1-2 32100 NULL
97202 +ath6kl_fwlog_read_32101 ath6kl_fwlog_read 3 32101 NULL
97203 +disk_status_32120 disk_status 4 32120 NULL
97204 +venus_link_32165 venus_link 5 32165 NULL
97205 +do_writepages_32173 do_writepages 0 32173 NULL nohasharray
97206 +ntfs_rl_realloc_nofail_32173 ntfs_rl_realloc_nofail 3 32173 &do_writepages_32173
97207 +load_header_32183 load_header 0 32183 NULL
97208 +ubi_wl_scrub_peb_32196 ubi_wl_scrub_peb 0 32196 NULL
97209 +wusb_ccm_mac_32199 wusb_ccm_mac 7 32199 NULL
97210 +riva_get_cmap_len_32218 riva_get_cmap_len 0 32218 NULL
97211 +lbs_lowrssi_read_32242 lbs_lowrssi_read 3 32242 NULL
97212 +ocfs2_xattr_find_entry_32260 ocfs2_xattr_find_entry 0 32260 NULL
97213 +fb_compat_ioctl_32265 fb_compat_ioctl 3 32265 NULL
97214 +vmalloc_user_32308 vmalloc_user 1 32308 NULL
97215 +hex_string_32310 hex_string 0 32310 NULL
97216 +nouveau_bar_create__32332 nouveau_bar_create_ 4 32332 NULL
97217 +nl80211_send_mlme_event_32337 nl80211_send_mlme_event 4 32337 NULL
97218 +t4_alloc_mem_32342 t4_alloc_mem 1 32342 NULL
97219 +dispatch_ioctl_32357 dispatch_ioctl 2 32357 NULL
97220 +sel_read_initcon_32362 sel_read_initcon 3 32362 NULL
97221 +_drbd_bm_find_next_32372 _drbd_bm_find_next 2 32372 NULL
97222 +usbtmc_read_32377 usbtmc_read 3 32377 NULL
97223 +qla4_82xx_pci_mem_write_2M_32398 qla4_82xx_pci_mem_write_2M 2 32398 NULL
97224 +xfs_iext_add_indirect_multi_32400 xfs_iext_add_indirect_multi 3 32400 NULL
97225 +vmci_qp_alloc_32405 vmci_qp_alloc 3-5 32405 NULL
97226 +log_text_32428 log_text 0 32428 NULL
97227 +regmap_irq_map_32429 regmap_irq_map 2 32429 NULL
97228 +hid_input_report_32458 hid_input_report 4 32458 NULL
97229 +cache_status_32462 cache_status 5 32462 NULL
97230 +ieee80211_fill_mesh_addresses_32465 ieee80211_fill_mesh_addresses 0 32465 NULL
97231 +ide_driver_proc_write_32493 ide_driver_proc_write 3 32493 NULL
97232 +ctrl_std_val_to_sym_32516 ctrl_std_val_to_sym 5 32516 NULL
97233 +disconnect_32521 disconnect 4 32521 NULL
97234 +qsfp_read_32522 qsfp_read 0-4-2 32522 NULL
97235 +ilo_read_32531 ilo_read 3 32531 NULL
97236 +ieee80211_if_read_estab_plinks_32533 ieee80211_if_read_estab_plinks 3 32533 NULL
97237 +gnttab_set_unmap_op_32534 gnttab_set_unmap_op 2 32534 NULL
97238 +ieee80211_send_auth_32543 ieee80211_send_auth 6 32543 NULL
97239 +format_devstat_counter_32550 format_devstat_counter 3 32550 NULL
97240 +__first_node_32558 __first_node 0 32558 NULL
97241 +aes_encrypt_fail_read_32562 aes_encrypt_fail_read 3 32562 NULL
97242 +pnp_mem_len_32584 pnp_mem_len 0 32584 NULL
97243 +mem_swapout_entry_32586 mem_swapout_entry 3 32586 NULL
97244 +pipeline_tcp_tx_stat_fifo_int_read_32589 pipeline_tcp_tx_stat_fifo_int_read 3 32589 NULL
97245 +read_file_beacon_32595 read_file_beacon 3 32595 NULL
97246 +ieee80211_if_read_dropped_frames_congestion_32603 ieee80211_if_read_dropped_frames_congestion 3 32603 NULL
97247 +sys_set_mempolicy_32608 sys_set_mempolicy 3 32608 NULL
97248 +cfg80211_roamed_32632 cfg80211_roamed 5-7 32632 NULL
97249 +ieee80211_hdrlen_32637 ieee80211_hdrlen 0 32637 NULL
97250 +ite_decode_bytes_32642 ite_decode_bytes 3 32642 NULL
97251 +kvmalloc_32646 kvmalloc 1 32646 NULL
97252 +ib_sg_dma_len_32649 ib_sg_dma_len 0 32649 NULL
97253 +generic_readlink_32654 generic_readlink 3 32654 NULL
97254 +move_addr_to_kernel_32673 move_addr_to_kernel 2 32673 NULL
97255 +jfs_readpages_32702 jfs_readpages 4 32702 NULL
97256 +snd_hwdep_ioctl_compat_32736 snd_hwdep_ioctl_compat 3 32736 NULL
97257 +get_arg_page_32746 get_arg_page 2 32746 NULL
97258 +megasas_change_queue_depth_32747 megasas_change_queue_depth 2 32747 NULL
97259 +stats_read_ul_32751 stats_read_ul 3 32751 NULL
97260 +tty_compat_ioctl_32761 tty_compat_ioctl 3 32761 NULL
97261 +sctp_tsnmap_grow_32784 sctp_tsnmap_grow 2 32784 NULL
97262 +firmwareUpload_32794 firmwareUpload 3 32794 NULL
97263 +rproc_name_read_32805 rproc_name_read 3 32805 NULL
97264 +vga_rseq_32848 vga_rseq 0 32848 NULL
97265 +new_tape_buffer_32866 new_tape_buffer 2 32866 NULL
97266 +io_apic_setup_irq_pin_32868 io_apic_setup_irq_pin 1 32868 NULL
97267 +ath6kl_usb_submit_ctrl_in_32880 ath6kl_usb_submit_ctrl_in 6 32880 NULL nohasharray
97268 +cifs_writedata_alloc_32880 cifs_writedata_alloc 1 32880 &ath6kl_usb_submit_ctrl_in_32880
97269 +ath6kl_usb_post_recv_transfers_32892 ath6kl_usb_post_recv_transfers 2 32892 NULL
97270 +il_dbgfs_tx_stats_read_32913 il_dbgfs_tx_stats_read 3 32913 NULL
97271 +zlib_inflate_workspacesize_32927 zlib_inflate_workspacesize 0 32927 NULL
97272 +rmap_recycle_32938 rmap_recycle 3 32938 NULL
97273 +irq_reserve_irqs_32946 irq_reserve_irqs 1-2 32946 NULL
97274 +ext4_valid_block_bitmap_32958 ext4_valid_block_bitmap 3 32958 NULL
97275 +arch_ptrace_32981 arch_ptrace 3 32981 NULL
97276 +compat_filldir_32999 compat_filldir 3 32999 NULL
97277 +ext3_alloc_blocks_33007 ext3_alloc_blocks 3 33007 NULL
97278 +pipeline_dec_packet_in_fifo_full_read_33052 pipeline_dec_packet_in_fifo_full_read 3 33052 NULL
97279 +ebt_compat_match_offset_33053 ebt_compat_match_offset 0-2 33053 NULL
97280 +bitmap_resize_33054 bitmap_resize 2 33054 NULL
97281 +stats_dot11RTSSuccessCount_read_33065 stats_dot11RTSSuccessCount_read 3 33065 NULL
97282 +sel_read_checkreqprot_33068 sel_read_checkreqprot 3 33068 NULL
97283 +alloc_tio_33077 alloc_tio 3 33077 NULL
97284 +acl_permission_check_33083 acl_permission_check 0 33083 NULL
97285 +ieee80211_fragment_33112 ieee80211_fragment 4 33112 NULL
97286 +write_node_33121 write_node 4 33121 NULL
97287 +calc_patch_size_33124 calc_patch_size 0 33124 NULL
97288 +fb_sys_write_33130 fb_sys_write 3 33130 NULL
97289 +__len_within_target_33132 __len_within_target 0 33132 NULL
97290 +debug_debug6_read_33168 debug_debug6_read 3 33168 NULL
97291 +dataflash_read_fact_otp_33204 dataflash_read_fact_otp 2-3 33204 NULL
97292 +pp_read_33210 pp_read 3 33210 NULL
97293 +xfs_file_aio_write_33234 xfs_file_aio_write 4 33234 NULL
97294 +build_completion_wait_33242 build_completion_wait 2 33242 NULL
97295 +snd_pcm_plug_client_size_33267 snd_pcm_plug_client_size 0-2 33267 NULL
97296 +sched_find_first_bit_33270 sched_find_first_bit 0 33270 NULL
97297 +cachefiles_cook_key_33274 cachefiles_cook_key 2 33274 NULL
97298 +mei_compat_ioctl_33275 mei_compat_ioctl 3 33275 NULL
97299 +mcs7830_get_reg_33308 mcs7830_get_reg 3 33308 NULL
97300 +ath6kl_usb_ctrl_msg_exchange_33327 ath6kl_usb_ctrl_msg_exchange 4 33327 NULL
97301 +gsm_mux_rx_netchar_33336 gsm_mux_rx_netchar 3 33336 NULL
97302 +joydev_ioctl_33343 joydev_ioctl 2 33343 NULL
97303 +create_xattr_datum_33356 create_xattr_datum 5 33356 NULL nohasharray
97304 +irq_pkt_threshold_read_33356 irq_pkt_threshold_read 3 33356 &create_xattr_datum_33356
97305 +read_file_regidx_33370 read_file_regidx 3 33370 NULL
97306 +ocfs2_quota_read_33382 ocfs2_quota_read 5 33382 NULL
97307 +ieee80211_if_read_dropped_frames_no_route_33383 ieee80211_if_read_dropped_frames_no_route 3 33383 NULL
97308 +scsi_varlen_cdb_length_33385 scsi_varlen_cdb_length 0 33385 NULL
97309 +ocfs2_allocate_unwritten_extents_33394 ocfs2_allocate_unwritten_extents 2-3 33394 NULL
97310 +ext4_meta_bg_first_block_no_33408 ext4_meta_bg_first_block_no 2 33408 NULL nohasharray
97311 +snd_pcm_capture_ioctl1_33408 snd_pcm_capture_ioctl1 0 33408 &ext4_meta_bg_first_block_no_33408
97312 +ufs_getfrag_block_33409 ufs_getfrag_block 2 33409 NULL
97313 +ubh_scanc_33436 ubh_scanc 0-4-3 33436 NULL
97314 +ovs_vport_alloc_33475 ovs_vport_alloc 1 33475 NULL
97315 +create_entry_33479 create_entry 2 33479 NULL
97316 +ip_setsockopt_33487 ip_setsockopt 5 33487 NULL nohasharray
97317 +elf_map_33487 elf_map 0-2 33487 &ip_setsockopt_33487
97318 +netxen_nic_hw_write_wx_128M_33488 netxen_nic_hw_write_wx_128M 2 33488 NULL
97319 +ol_dqblk_chunk_off_33489 ol_dqblk_chunk_off 2 33489 NULL
97320 +res_counter_read_33499 res_counter_read 4 33499 NULL
97321 +fb_read_33506 fb_read 3 33506 NULL
97322 +musb_test_mode_write_33518 musb_test_mode_write 3 33518 NULL
97323 +ahash_setkey_unaligned_33521 ahash_setkey_unaligned 3 33521 NULL
97324 +nes_alloc_fast_reg_page_list_33523 nes_alloc_fast_reg_page_list 2 33523 NULL
97325 +aggr_size_rx_size_read_33526 aggr_size_rx_size_read 3 33526 NULL
97326 +acpi_gsi_to_irq_33533 acpi_gsi_to_irq 1 33533 NULL
97327 +tomoyo_read_self_33539 tomoyo_read_self 3 33539 NULL
97328 +dup_array_33551 dup_array 3 33551 NULL
97329 +solo_enc_read_33553 solo_enc_read 3 33553 NULL
97330 +count_subheaders_33591 count_subheaders 0 33591 NULL
97331 +scsi_execute_33596 scsi_execute 5 33596 NULL
97332 +comedi_buf_write_n_allocated_33604 comedi_buf_write_n_allocated 0 33604 NULL
97333 +xt_compat_target_offset_33608 xt_compat_target_offset 0 33608 NULL nohasharray
97334 +ip6_find_1stfragopt_33608 ip6_find_1stfragopt 0 33608 &xt_compat_target_offset_33608
97335 +usb_gstrings_attach_33615 usb_gstrings_attach 3 33615 NULL nohasharray
97336 +il_dbgfs_qos_read_33615 il_dbgfs_qos_read 3 33615 &usb_gstrings_attach_33615
97337 +irq_blk_threshold_read_33666 irq_blk_threshold_read 3 33666 NULL
97338 +inw_p_33668 inw_p 0 33668 NULL
97339 +arp_hdr_len_33671 arp_hdr_len 0 33671 NULL
97340 +i2c_hid_alloc_buffers_33673 i2c_hid_alloc_buffers 2 33673 NULL
97341 +ath6kl_wmi_startscan_cmd_33674 ath6kl_wmi_startscan_cmd 8 33674 NULL
97342 +nv50_disp_dmac_create__33696 nv50_disp_dmac_create_ 6 33696 NULL
97343 +compat_insnlist_33706 compat_insnlist 2 33706 NULL
97344 +sys_keyctl_33708 sys_keyctl 4 33708 NULL nohasharray
97345 +netlink_sendmsg_33708 netlink_sendmsg 4 33708 &sys_keyctl_33708
97346 +tipc_link_stats_33716 tipc_link_stats 3 33716 NULL
97347 +pvr2_stream_buffer_count_33719 pvr2_stream_buffer_count 2 33719 NULL
97348 +ocfs2_extent_map_get_blocks_33720 ocfs2_extent_map_get_blocks 2 33720 NULL
97349 +__mutex_lock_interruptible_slowpath_33735 __mutex_lock_interruptible_slowpath 0 33735 NULL
97350 +Read_hfc_33755 Read_hfc 0 33755 NULL
97351 +vifs_state_read_33762 vifs_state_read 3 33762 NULL
97352 +hashtab_create_33769 hashtab_create 3 33769 NULL
97353 +midibuf_message_length_33770 midibuf_message_length 0 33770 NULL
97354 +if_sdio_read_rx_len_33800 if_sdio_read_rx_len 0 33800 NULL
97355 +find_next_offset_33804 find_next_offset 3 33804 NULL
97356 +sky2_rx_pad_33819 sky2_rx_pad 0 33819 NULL
97357 +sep_create_msgarea_context_33829 sep_create_msgarea_context 4 33829 NULL
97358 +scrub_setup_recheck_block_33831 scrub_setup_recheck_block 5-4 33831 NULL
97359 +udplite_manip_pkt_33832 udplite_manip_pkt 4 33832 NULL
97360 +usb_dump_endpoint_descriptor_33849 usb_dump_endpoint_descriptor 0 33849 NULL
97361 +calgary_alloc_coherent_33851 calgary_alloc_coherent 2 33851 NULL
97362 +oz_cdev_write_33852 oz_cdev_write 3 33852 NULL
97363 +cap_mmap_addr_33853 cap_mmap_addr 0 33853 NULL
97364 +get_user_pages_33908 get_user_pages 0-3-4 33908 NULL
97365 +queue_logical_block_size_33918 queue_logical_block_size 0 33918 NULL
97366 +sel_read_avc_cache_threshold_33942 sel_read_avc_cache_threshold 3 33942 NULL
97367 +lpfc_idiag_ctlacc_read_33943 lpfc_idiag_ctlacc_read 3 33943 NULL
97368 +read_file_tgt_rx_stats_33944 read_file_tgt_rx_stats 3 33944 NULL
97369 +vga_switcheroo_debugfs_write_33984 vga_switcheroo_debugfs_write 3 33984 NULL
97370 +__ntfs_malloc_34022 __ntfs_malloc 1 34022 NULL
97371 +ppp_write_34034 ppp_write 3 34034 NULL
97372 +tty_insert_flip_string_34042 tty_insert_flip_string 3 34042 NULL
97373 +__domain_flush_pages_34045 __domain_flush_pages 2-3 34045 NULL
97374 +acpi_dev_get_irqresource_34064 acpi_dev_get_irqresource 2 34064 NULL
97375 +memcg_update_all_caches_34068 memcg_update_all_caches 1 34068 NULL
97376 +read_file_ant_diversity_34071 read_file_ant_diversity 3 34071 NULL
97377 +compat_hdio_ioctl_34088 compat_hdio_ioctl 4 34088 NULL
97378 +pipeline_pipeline_fifo_full_read_34095 pipeline_pipeline_fifo_full_read 3 34095 NULL
97379 +is_discarded_oblock_34120 is_discarded_oblock 2 34120 NULL
97380 +islpci_mgt_transmit_34133 islpci_mgt_transmit 5 34133 NULL
97381 +ttm_dma_page_pool_free_34135 ttm_dma_page_pool_free 2 34135 NULL
97382 +cdc_mbim_process_dgram_34136 cdc_mbim_process_dgram 3 34136 NULL
97383 +ixgbe_dbg_netdev_ops_write_34141 ixgbe_dbg_netdev_ops_write 3 34141 NULL
97384 +shmem_pread_fast_34147 shmem_pread_fast 3 34147 NULL
97385 +skb_to_sgvec_34171 skb_to_sgvec 0 34171 NULL
97386 +ext4_da_write_begin_34215 ext4_da_write_begin 3-4 34215 NULL
97387 +bl_pipe_downcall_34264 bl_pipe_downcall 3 34264 NULL
97388 +pcf857x_to_irq_34273 pcf857x_to_irq 2 34273 NULL
97389 +zone_spanned_pages_in_node_34299 zone_spanned_pages_in_node 0 34299 NULL
97390 +iov_iter_single_seg_count_34326 iov_iter_single_seg_count 0 34326 NULL nohasharray
97391 +pcpu_need_to_extend_34326 pcpu_need_to_extend 0 34326 &iov_iter_single_seg_count_34326
97392 +__insert_34349 __insert 2-3 34349 NULL
97393 +crypto_ablkcipher_ivsize_34363 crypto_ablkcipher_ivsize 0 34363 NULL
97394 +rngapi_reset_34366 rngapi_reset 3 34366 NULL nohasharray
97395 +p54_alloc_skb_34366 p54_alloc_skb 3 34366 &rngapi_reset_34366
97396 +reiserfs_resize_34377 reiserfs_resize 2 34377 NULL
97397 +ea_read_34378 ea_read 0 34378 NULL
97398 +av7110_vbi_write_34384 av7110_vbi_write 3 34384 NULL
97399 +usbvision_v4l2_read_34386 usbvision_v4l2_read 3 34386 NULL
97400 +read_rbu_image_type_34387 read_rbu_image_type 6 34387 NULL
97401 +iwl_calib_set_34400 iwl_calib_set 3 34400 NULL nohasharray
97402 +ivtv_read_pos_34400 ivtv_read_pos 3 34400 &iwl_calib_set_34400
97403 +nl80211_send_disassoc_34424 nl80211_send_disassoc 4 34424 NULL
97404 +usbtest_alloc_urb_34446 usbtest_alloc_urb 3-5 34446 NULL
97405 +mwifiex_regrdwr_read_34472 mwifiex_regrdwr_read 3 34472 NULL
97406 +skcipher_sndbuf_34476 skcipher_sndbuf 0 34476 NULL
97407 +i2o_parm_field_get_34477 i2o_parm_field_get 5 34477 NULL
97408 +security_inode_permission_34488 security_inode_permission 0 34488 NULL
97409 +tracing_stats_read_34537 tracing_stats_read 3 34537 NULL
97410 +hugetlbfs_read_actor_34547 hugetlbfs_read_actor 0-2-5-4 34547 NULL
97411 +dbBackSplit_34561 dbBackSplit 0 34561 NULL
97412 +alloc_ieee80211_rsl_34564 alloc_ieee80211_rsl 1 34564 NULL
97413 +velocity_rx_copy_34583 velocity_rx_copy 2 34583 NULL
97414 +init_send_hfcd_34586 init_send_hfcd 1 34586 NULL
97415 +inet6_ifla6_size_34591 inet6_ifla6_size 0 34591 NULL
97416 +ceph_msgpool_init_34599 ceph_msgpool_init 4 34599 NULL
97417 +brcmf_cfg80211_mgmt_tx_34608 brcmf_cfg80211_mgmt_tx 7 34608 NULL
97418 +__jffs2_ref_totlen_34609 __jffs2_ref_totlen 0 34609 NULL
97419 +__cfg80211_disconnected_34622 __cfg80211_disconnected 3 34622 NULL
97420 +cnic_alloc_dma_34641 cnic_alloc_dma 3 34641 NULL
97421 +tomoyo_dump_page_34649 tomoyo_dump_page 2 34649 NULL
97422 +nf_nat_mangle_udp_packet_34661 nf_nat_mangle_udp_packet 8-6 34661 NULL
97423 +isr_fiqs_read_34687 isr_fiqs_read 3 34687 NULL
97424 +port_print_34704 port_print 3 34704 NULL
97425 +alloc_irq_and_cfg_at_34706 alloc_irq_and_cfg_at 1 34706 NULL
97426 +ieee80211_if_read_num_sta_ps_34722 ieee80211_if_read_num_sta_ps 3 34722 NULL
97427 +platform_list_read_file_34734 platform_list_read_file 3 34734 NULL
97428 +reg_w_ixbuf_34736 reg_w_ixbuf 4 34736 NULL
97429 +qib_cdev_init_34778 qib_cdev_init 1 34778 NULL
97430 +__copy_in_user_34790 __copy_in_user 3 34790 NULL
97431 +drbd_get_max_capacity_34804 drbd_get_max_capacity 0 34804 NULL
97432 +b43_debugfs_write_34838 b43_debugfs_write 3 34838 NULL
97433 +nl_portid_hash_zalloc_34843 nl_portid_hash_zalloc 1 34843 NULL
97434 +acpi_system_write_wakeup_device_34853 acpi_system_write_wakeup_device 3 34853 NULL
97435 +usb_serial_generic_prepare_write_buffer_34857 usb_serial_generic_prepare_write_buffer 3 34857 NULL
97436 +ieee80211_if_read_txpower_34871 ieee80211_if_read_txpower 3 34871 NULL
97437 +msg_print_text_34889 msg_print_text 0 34889 NULL
97438 +ieee80211_if_write_34894 ieee80211_if_write 3 34894 NULL
97439 +compat_put_uint_34905 compat_put_uint 1 34905 NULL
97440 +__inode_permission_34925 __inode_permission 0 34925 NULL nohasharray
97441 +btrfs_super_chunk_root_34925 btrfs_super_chunk_root 0 34925 &__inode_permission_34925
97442 +skb_gro_header_slow_34958 skb_gro_header_slow 2 34958 NULL
97443 +Realloc_34961 Realloc 2 34961 NULL
97444 +mq_lookup_34990 mq_lookup 2 34990 NULL
97445 +rx_rx_hdr_overflow_read_35002 rx_rx_hdr_overflow_read 3 35002 NULL
97446 +l2cap_skbuff_fromiovec_35003 l2cap_skbuff_fromiovec 4-3 35003 NULL
97447 +dm_cache_insert_mapping_35005 dm_cache_insert_mapping 2-3 35005 NULL
97448 +sisusb_copy_memory_35016 sisusb_copy_memory 4 35016 NULL
97449 +alloc_p2m_page_35025 alloc_p2m_page 0 35025 NULL
97450 +coda_psdev_read_35029 coda_psdev_read 3 35029 NULL
97451 +btmrvl_gpiogap_write_35053 btmrvl_gpiogap_write 3 35053 NULL
97452 +pwr_connection_out_of_sync_read_35061 pwr_connection_out_of_sync_read 3 35061 NULL
97453 +store_ifalias_35088 store_ifalias 4 35088 NULL
97454 +__kfifo_uint_must_check_helper_35097 __kfifo_uint_must_check_helper 0-1 35097 NULL
97455 +capi_write_35104 capi_write 3 35104 NULL nohasharray
97456 +tx_tx_done_template_read_35104 tx_tx_done_template_read 3 35104 &capi_write_35104
97457 +ide_settings_proc_write_35110 ide_settings_proc_write 3 35110 NULL
97458 +pointer_35138 pointer 0 35138 NULL
97459 +gntdev_alloc_map_35145 gntdev_alloc_map 2 35145 NULL
97460 +iscsi_conn_setup_35159 iscsi_conn_setup 2 35159 NULL
97461 +ieee80211_if_read_bssid_35161 ieee80211_if_read_bssid 3 35161 NULL
97462 +mlx4_ib_get_cq_umem_35184 mlx4_ib_get_cq_umem 5-6 35184 NULL
97463 +iwl_nvm_read_chunk_35198 iwl_nvm_read_chunk 0 35198 NULL
97464 +uprobe_get_swbp_addr_35201 uprobe_get_swbp_addr 0 35201 NULL
97465 +unix_stream_recvmsg_35210 unix_stream_recvmsg 4 35210 NULL
97466 +_osd_req_alist_elem_size_35216 _osd_req_alist_elem_size 0-2 35216 NULL
97467 +striped_read_35218 striped_read 0-2-8-3 35218 NULL nohasharray
97468 +security_key_getsecurity_35218 security_key_getsecurity 0 35218 &striped_read_35218
97469 +rx_rx_cmplt_task_read_35226 rx_rx_cmplt_task_read 3 35226 NULL nohasharray
97470 +video_register_device_no_warn_35226 video_register_device_no_warn 3 35226 &rx_rx_cmplt_task_read_35226
97471 +gfn_to_page_many_atomic_35234 gfn_to_page_many_atomic 2 35234 NULL
97472 +set_fd_set_35249 set_fd_set 1 35249 NULL
97473 +ioapic_setup_resources_35255 ioapic_setup_resources 1 35255 NULL
97474 +dma_show_regs_35266 dma_show_regs 3 35266 NULL
97475 +irda_recvmsg_stream_35280 irda_recvmsg_stream 4 35280 NULL
97476 +i2o_block_end_request_35282 i2o_block_end_request 3 35282 NULL
97477 +isr_rx_rdys_read_35283 isr_rx_rdys_read 3 35283 NULL
97478 +brcmf_sdio_forensic_read_35311 brcmf_sdio_forensic_read 3 35311 NULL nohasharray
97479 +__btrfs_buffered_write_35311 __btrfs_buffered_write 3 35311 &brcmf_sdio_forensic_read_35311
97480 +tracing_read_pipe_35312 tracing_read_pipe 3 35312 NULL
97481 +sys_setsockopt_35320 sys_setsockopt 5 35320 NULL
97482 +irq_domain_disassociate_many_35325 irq_domain_disassociate_many 2-3 35325 NULL
97483 +fallback_on_nodma_alloc_35332 fallback_on_nodma_alloc 2 35332 NULL
97484 +pskb_network_may_pull_35336 pskb_network_may_pull 2 35336 NULL
97485 +ieee80211_if_fmt_ap_power_level_35347 ieee80211_if_fmt_ap_power_level 3 35347 NULL
97486 +nouveau_devinit_create__35348 nouveau_devinit_create_ 4 35348 NULL
97487 +hpi_alloc_control_cache_35351 hpi_alloc_control_cache 1 35351 NULL
97488 +compat_filldir64_35354 compat_filldir64 3 35354 NULL
97489 +rawv6_send_hdrinc_35425 rawv6_send_hdrinc 3 35425 NULL
97490 +__set_test_and_free_35436 __set_test_and_free 2 35436 NULL
97491 +buffer_to_user_35439 buffer_to_user 3 35439 NULL
97492 +i915_wedged_read_35474 i915_wedged_read 3 35474 NULL
97493 +ecryptfs_get_zeroed_pages_35483 ecryptfs_get_zeroed_pages 0 35483 NULL
97494 +do_atm_ioctl_35519 do_atm_ioctl 3 35519 NULL
97495 +async_setkey_35521 async_setkey 3 35521 NULL
97496 +__filemap_fdatawrite_range_35528 __filemap_fdatawrite_range 0 35528 NULL
97497 +iwl_dbgfs_bt_traffic_read_35534 iwl_dbgfs_bt_traffic_read 3 35534 NULL
97498 +rxpipe_tx_xfr_host_int_trig_rx_data_read_35538 rxpipe_tx_xfr_host_int_trig_rx_data_read 3 35538 NULL
97499 +ibnl_put_attr_35541 ibnl_put_attr 3 35541 NULL
97500 +ieee80211_if_write_smps_35550 ieee80211_if_write_smps 3 35550 NULL
97501 +ext2_acl_from_disk_35580 ext2_acl_from_disk 2 35580 NULL
97502 +spk_msg_set_35586 spk_msg_set 3 35586 NULL
97503 +ReadZReg_35604 ReadZReg 0 35604 NULL
97504 +kernel_readv_35617 kernel_readv 3 35617 NULL
97505 +ixgbe_pci_sriov_configure_35624 ixgbe_pci_sriov_configure 2 35624 NULL
97506 +reiserfs_readpages_35629 reiserfs_readpages 4 35629 NULL
97507 +spi_register_board_info_35651 spi_register_board_info 2 35651 NULL
97508 +store_debug_level_35652 store_debug_level 3 35652 NULL
97509 +rdmaltWithLock_35669 rdmaltWithLock 0 35669 NULL
97510 +compat_sys_kexec_load_35674 compat_sys_kexec_load 2 35674 NULL
97511 +dm_table_create_35687 dm_table_create 3 35687 NULL
97512 +rds_page_copy_user_35691 rds_page_copy_user 4 35691 NULL
97513 +pci_enable_sriov_35745 pci_enable_sriov 2 35745 NULL
97514 +iwl_dbgfs_disable_ht40_read_35761 iwl_dbgfs_disable_ht40_read 3 35761 NULL
97515 +udf_alloc_i_data_35786 udf_alloc_i_data 2 35786 NULL
97516 +pvr2_hdw_cpufw_get_35824 pvr2_hdw_cpufw_get 0-4-2 35824 NULL
97517 +tx_tx_cmplt_read_35854 tx_tx_cmplt_read 3 35854 NULL
97518 +mthca_buf_alloc_35861 mthca_buf_alloc 2 35861 NULL
97519 +fls64_35862 fls64 0 35862 NULL
97520 +kvm_dirty_bitmap_bytes_35886 kvm_dirty_bitmap_bytes 0 35886 NULL
97521 +ieee80211_if_fmt_dot11MeshRetryTimeout_35890 ieee80211_if_fmt_dot11MeshRetryTimeout 3 35890 NULL
97522 +uwb_rc_cmd_done_35892 uwb_rc_cmd_done 4 35892 NULL
97523 +kernel_setsockopt_35913 kernel_setsockopt 5 35913 NULL
97524 +rbio_nr_pages_35916 rbio_nr_pages 0-1-2 35916 NULL
97525 +vol_cdev_compat_ioctl_35923 vol_cdev_compat_ioctl 3 35923 NULL
97526 +sctp_tsnmap_mark_35929 sctp_tsnmap_mark 2 35929 NULL
97527 +rx_defrag_init_called_read_35935 rx_defrag_init_called_read 3 35935 NULL
97528 +put_cmsg_compat_35937 put_cmsg_compat 4 35937 NULL
97529 +ext_rts51x_sd_execute_write_data_35971 ext_rts51x_sd_execute_write_data 9 35971 NULL
97530 +ceph_buffer_new_35974 ceph_buffer_new 1 35974 NULL
97531 +acl_alloc_35979 acl_alloc 1 35979 NULL
97532 +generic_file_aio_read_35987 generic_file_aio_read 0 35987 NULL
97533 +koneplus_sysfs_write_35993 koneplus_sysfs_write 6 35993 NULL
97534 +il3945_ucode_tx_stats_read_36016 il3945_ucode_tx_stats_read 3 36016 NULL
97535 +ubi_eba_write_leb_36029 ubi_eba_write_leb 5-6 36029 NULL
97536 +account_shadowed_36048 account_shadowed 2 36048 NULL
97537 +gpio_power_read_36059 gpio_power_read 3 36059 NULL
97538 +write_emulate_36065 write_emulate 2-4 36065 NULL
97539 +radeon_vm_num_pdes_36070 radeon_vm_num_pdes 0 36070 NULL
97540 +ieee80211_if_fmt_peer_36071 ieee80211_if_fmt_peer 3 36071 NULL
97541 +ext3_new_blocks_36073 ext3_new_blocks 3 36073 NULL
97542 +ieee80211_if_write_tsf_36077 ieee80211_if_write_tsf 3 36077 NULL
97543 +snd_pcm_plug_read_transfer_36080 snd_pcm_plug_read_transfer 0-3 36080 NULL
97544 +vga_arb_write_36112 vga_arb_write 3 36112 NULL
97545 +simple_xattr_alloc_36118 simple_xattr_alloc 2 36118 NULL
97546 +compat_ptrace_request_36131 compat_ptrace_request 3-4 36131 NULL
97547 +vmalloc_exec_36132 vmalloc_exec 1 36132 NULL
97548 +max8925_irq_domain_map_36133 max8925_irq_domain_map 2 36133 NULL
97549 +ext3_readpages_36144 ext3_readpages 4 36144 NULL
97550 +alloc_vm_area_36149 alloc_vm_area 1 36149 NULL
97551 +twl_set_36154 twl_set 2 36154 NULL
97552 +b1_alloc_card_36155 b1_alloc_card 1 36155 NULL
97553 +btrfs_file_extent_inline_len_36158 btrfs_file_extent_inline_len 0 36158 NULL
97554 +snd_korg1212_copy_from_36169 snd_korg1212_copy_from 6 36169 NULL
97555 +ubifs_read_nnode_36221 ubifs_read_nnode 0 36221 NULL
97556 +is_dirty_36223 is_dirty 2 36223 NULL
97557 +dma_alloc_attrs_36225 dma_alloc_attrs 0 36225 NULL
97558 +nfqnl_mangle_36226 nfqnl_mangle 4-2 36226 NULL
97559 +atomic_stats_read_36228 atomic_stats_read 3 36228 NULL
97560 +viafb_iga1_odev_proc_write_36241 viafb_iga1_odev_proc_write 3 36241 NULL
97561 +rproc_recovery_read_36245 rproc_recovery_read 3 36245 NULL
97562 +scrub_stripe_36248 scrub_stripe 5-4 36248 NULL
97563 +compat_sys_mbind_36256 compat_sys_mbind 5 36256 NULL
97564 +usb_buffer_alloc_36276 usb_buffer_alloc 2 36276 NULL
97565 +codec_reg_read_file_36280 codec_reg_read_file 3 36280 NULL
97566 +crypto_shash_digestsize_36284 crypto_shash_digestsize 0 36284 NULL
97567 +nouveau_cli_create_36293 nouveau_cli_create 3 36293 NULL
97568 +lpfc_debugfs_dif_err_read_36303 lpfc_debugfs_dif_err_read 3 36303 NULL
97569 +ad7879_spi_xfer_36311 ad7879_spi_xfer 3 36311 NULL
97570 +fuse_get_user_addr_36312 fuse_get_user_addr 0 36312 NULL
97571 +fat_compat_ioctl_filldir_36328 fat_compat_ioctl_filldir 3 36328 NULL
97572 +lc_create_36332 lc_create 4 36332 NULL
97573 +jbd2_journal_init_revoke_table_36336 jbd2_journal_init_revoke_table 1 36336 NULL
97574 +v9fs_file_readn_36353 v9fs_file_readn 4 36353 NULL nohasharray
97575 +xz_dec_lzma2_create_36353 xz_dec_lzma2_create 2 36353 &v9fs_file_readn_36353
97576 +to_sector_36361 to_sector 0-1 36361 NULL
97577 +tunables_read_36385 tunables_read 3 36385 NULL
97578 +afs_alloc_flat_call_36399 afs_alloc_flat_call 2-3 36399 NULL
97579 +sctp_tsnmap_init_36446 sctp_tsnmap_init 2 36446 NULL
97580 +alloc_etherdev_mqs_36450 alloc_etherdev_mqs 1 36450 NULL
97581 +b43_nphy_load_samples_36481 b43_nphy_load_samples 3 36481 NULL
97582 +tx_tx_checksum_result_read_36490 tx_tx_checksum_result_read 3 36490 NULL
97583 +__hwahc_op_set_ptk_36510 __hwahc_op_set_ptk 5 36510 NULL
97584 +mcam_v4l_read_36513 mcam_v4l_read 3 36513 NULL
97585 +get_param_l_36518 get_param_l 0 36518 NULL
97586 +ieee80211_if_read_fwded_frames_36520 ieee80211_if_read_fwded_frames 3 36520 NULL
97587 +lguest_setup_irq_36531 lguest_setup_irq 1 36531 NULL
97588 +crypto_aead_authsize_36537 crypto_aead_authsize 0 36537 NULL
97589 +cpu_type_read_36540 cpu_type_read 3 36540 NULL
97590 +get_entry_len_36549 get_entry_len 0 36549 NULL
97591 +__kfifo_to_user_36555 __kfifo_to_user 3 36555 NULL nohasharray
97592 +macvtap_do_read_36555 macvtap_do_read 4 36555 &__kfifo_to_user_36555
97593 +btrfs_get_token_64_36572 btrfs_get_token_64 0 36572 NULL
97594 +ssb_bus_scan_36578 ssb_bus_scan 2 36578 NULL
97595 +__erst_read_36579 __erst_read 0 36579 NULL
97596 +put_cmsg_36589 put_cmsg 4 36589 NULL
97597 +pcnet32_realloc_rx_ring_36598 pcnet32_realloc_rx_ring 3 36598 NULL
97598 +fat_ioctl_filldir_36621 fat_ioctl_filldir 3 36621 NULL
97599 +vxge_config_vpaths_36636 vxge_config_vpaths 0 36636 NULL
97600 +format_decode_36638 format_decode 0 36638 NULL
97601 +ced_ioctl_36647 ced_ioctl 2 36647 NULL
97602 +lpfc_idiag_extacc_alloc_get_36648 lpfc_idiag_extacc_alloc_get 0-3 36648 NULL
97603 +osd_req_list_collection_objects_36664 osd_req_list_collection_objects 5 36664 NULL
97604 +iscsi_host_alloc_36671 iscsi_host_alloc 2 36671 NULL
97605 +ptr_to_compat_36680 ptr_to_compat 0 36680 NULL
97606 +ext4_mb_discard_group_preallocations_36685 ext4_mb_discard_group_preallocations 2 36685 NULL
97607 +extract_icmp6_fields_36732 extract_icmp6_fields 2 36732 NULL
97608 +snd_rawmidi_kernel_read1_36740 snd_rawmidi_kernel_read1 4 36740 NULL
97609 +cxgbi_device_register_36746 cxgbi_device_register 1-2 36746 NULL
97610 +ps_poll_upsd_timeouts_read_36755 ps_poll_upsd_timeouts_read 3 36755 NULL
97611 +ip4ip6_err_36772 ip4ip6_err 5 36772 NULL
97612 +ptp_filter_init_36780 ptp_filter_init 2 36780 NULL
97613 +proc_fault_inject_read_36802 proc_fault_inject_read 3 36802 NULL
97614 +hiddev_ioctl_36816 hiddev_ioctl 2 36816 NULL
97615 +int_hardware_entry_36833 int_hardware_entry 3 36833 NULL
97616 +fc_change_queue_depth_36841 fc_change_queue_depth 2 36841 NULL
97617 +keyctl_describe_key_36853 keyctl_describe_key 3 36853 NULL
97618 +cm_write_36858 cm_write 3 36858 NULL
97619 +tx_tx_data_programmed_read_36871 tx_tx_data_programmed_read 3 36871 NULL
97620 +svc_setsockopt_36876 svc_setsockopt 5 36876 NULL
97621 +raid56_parity_write_36877 raid56_parity_write 5 36877 NULL
97622 +__btrfs_map_block_36883 __btrfs_map_block 3 36883 NULL
97623 +ib_ucm_alloc_data_36885 ib_ucm_alloc_data 3 36885 NULL
97624 +selinux_inode_notifysecctx_36896 selinux_inode_notifysecctx 3 36896 NULL
97625 +OS_kmalloc_36909 OS_kmalloc 1 36909 NULL
97626 +build_key_36931 build_key 1 36931 NULL
97627 +crypto_blkcipher_ivsize_36944 crypto_blkcipher_ivsize 0 36944 NULL
97628 +write_leb_36957 write_leb 5 36957 NULL
97629 +ntfs_external_attr_find_36963 ntfs_external_attr_find 0 36963 NULL
97630 +sparse_early_mem_maps_alloc_node_36971 sparse_early_mem_maps_alloc_node 4 36971 NULL
97631 +drbd_new_dev_size_36998 drbd_new_dev_size 0-3 36998 NULL
97632 +auok190xfb_write_37001 auok190xfb_write 3 37001 NULL
97633 +setxattr_37006 setxattr 4 37006 NULL
97634 +qp_broker_create_37053 qp_broker_create 6-5 37053 NULL nohasharray
97635 +ieee80211_if_read_drop_unencrypted_37053 ieee80211_if_read_drop_unencrypted 3 37053 &qp_broker_create_37053
97636 +parse_command_37079 parse_command 2 37079 NULL
97637 +pipeline_cs_rx_packet_in_read_37089 pipeline_cs_rx_packet_in_read 3 37089 NULL
97638 +tun_get_user_37094 tun_get_user 5 37094 NULL
97639 +has_wrprotected_page_37123 has_wrprotected_page 2-3 37123 NULL
97640 +snd_hda_get_conn_list_37132 snd_hda_get_conn_list 0 37132 NULL
97641 +msg_word_37164 msg_word 0 37164 NULL
97642 +can_set_xattr_37182 can_set_xattr 4 37182 NULL
97643 +crypto_shash_descsize_37212 crypto_shash_descsize 0 37212 NULL
97644 +regmap_access_read_file_37223 regmap_access_read_file 3 37223 NULL
97645 +__do_replace_37227 __do_replace 5 37227 NULL
97646 +rx_filter_dup_filter_read_37238 rx_filter_dup_filter_read 3 37238 NULL
97647 +prot_queue_del_37258 prot_queue_del 0 37258 NULL
97648 +ath6kl_wmi_set_ie_cmd_37260 ath6kl_wmi_set_ie_cmd 6 37260 NULL
97649 +exofs_max_io_pages_37263 exofs_max_io_pages 0-2 37263 NULL
97650 +nested_svm_map_37268 nested_svm_map 2 37268 NULL
97651 +c101_run_37279 c101_run 2 37279 NULL
97652 +srp_target_alloc_37288 srp_target_alloc 3 37288 NULL
97653 +ieee80211_if_read_power_mode_37305 ieee80211_if_read_power_mode 3 37305 NULL
97654 +jffs2_write_dirent_37311 jffs2_write_dirent 5 37311 NULL
97655 +send_msg_37323 send_msg 4 37323 NULL
97656 +brcmf_sdbrcm_membytes_37324 brcmf_sdbrcm_membytes 3-5 37324 NULL
97657 +l2cap_create_connless_pdu_37327 l2cap_create_connless_pdu 3 37327 NULL
97658 +scsi_mode_select_37330 scsi_mode_select 6 37330 NULL
97659 +rxrpc_server_sendmsg_37331 rxrpc_server_sendmsg 4 37331 NULL
97660 +security_inode_getsecurity_37354 security_inode_getsecurity 0 37354 NULL
97661 +iommu_num_pages_37391 iommu_num_pages 0-1-3-2 37391 NULL
97662 +sys_getxattr_37418 sys_getxattr 4 37418 NULL
97663 +hci_sock_sendmsg_37420 hci_sock_sendmsg 4 37420 NULL
97664 +acpi_os_allocate_zeroed_37422 acpi_os_allocate_zeroed 1 37422 NULL nohasharray
97665 +find_next_bit_37422 find_next_bit 0-2-3 37422 &acpi_os_allocate_zeroed_37422
97666 +tty_insert_flip_string_fixed_flag_37428 tty_insert_flip_string_fixed_flag 4 37428 NULL
97667 +iwl_print_last_event_logs_37433 iwl_print_last_event_logs 0-7-9 37433 NULL
97668 +tcp_established_options_37450 tcp_established_options 0 37450 NULL
97669 +brcmf_sdio_dump_console_37455 brcmf_sdio_dump_console 4 37455 NULL
97670 +__remove_37457 __remove 2 37457 NULL
97671 +ufs_data_ptr_to_cpu_37475 ufs_data_ptr_to_cpu 0 37475 NULL
97672 +get_est_timing_37484 get_est_timing 0 37484 NULL
97673 +kmem_realloc_37489 kmem_realloc 2 37489 NULL
97674 +kvm_vcpu_compat_ioctl_37500 kvm_vcpu_compat_ioctl 3 37500 NULL
97675 +vmalloc_32_user_37519 vmalloc_32_user 1 37519 NULL
97676 +fault_inject_read_37534 fault_inject_read 3 37534 NULL
97677 +hdr_size_37536 hdr_size 0 37536 NULL
97678 +a2p_37544 a2p 0-1 37544 NULL
97679 +sep_create_dcb_dmatables_context_37551 sep_create_dcb_dmatables_context 6 37551 NULL nohasharray
97680 +nf_nat_mangle_tcp_packet_37551 nf_nat_mangle_tcp_packet 6-8 37551 &sep_create_dcb_dmatables_context_37551
97681 +xhci_alloc_streams_37586 xhci_alloc_streams 5 37586 NULL
97682 +mlx4_get_mgm_entry_size_37607 mlx4_get_mgm_entry_size 0 37607 NULL
97683 +kvm_read_guest_page_mmu_37611 kvm_read_guest_page_mmu 6-3 37611 NULL
97684 +policy_residency_37629 policy_residency 0 37629 NULL
97685 +check_pt_base_37635 check_pt_base 3 37635 NULL
97686 +alloc_fd_37637 alloc_fd 1 37637 NULL
97687 +bio_copy_user_iov_37660 bio_copy_user_iov 4 37660 NULL
97688 +rfcomm_sock_sendmsg_37661 rfcomm_sock_sendmsg 4 37661 NULL nohasharray
97689 +vmw_framebuffer_dmabuf_dirty_37661 vmw_framebuffer_dmabuf_dirty 6 37661 &rfcomm_sock_sendmsg_37661
97690 +lnw_gpio_to_irq_37665 lnw_gpio_to_irq 2 37665 NULL
97691 +ieee80211_if_read_rc_rateidx_mcs_mask_2ghz_37675 ieee80211_if_read_rc_rateidx_mcs_mask_2ghz 3 37675 NULL
97692 +regmap_map_read_file_37685 regmap_map_read_file 3 37685 NULL
97693 +nametbl_header_37698 nametbl_header 2 37698 NULL
97694 +__le32_to_cpup_37702 __le32_to_cpup 0 37702 NULL
97695 +dm_thin_remove_block_37724 dm_thin_remove_block 2 37724 NULL
97696 +find_active_uprobe_37733 find_active_uprobe 1 37733 NULL
97697 +read_enabled_file_bool_37744 read_enabled_file_bool 3 37744 NULL
97698 +ocfs2_duplicate_clusters_by_jbd_37749 ocfs2_duplicate_clusters_by_jbd 6-4-5 37749 NULL
97699 +ocfs2_control_cfu_37750 ocfs2_control_cfu 2 37750 NULL
97700 +ipath_cdev_init_37752 ipath_cdev_init 1 37752 NULL
97701 +dccp_setsockopt_cscov_37766 dccp_setsockopt_cscov 2 37766 NULL
97702 +dma_pte_addr_37784 dma_pte_addr 0 37784 NULL
97703 +il4965_rs_sta_dbgfs_rate_scale_data_read_37792 il4965_rs_sta_dbgfs_rate_scale_data_read 3 37792 NULL
97704 +smk_read_logging_37804 smk_read_logging 3 37804 NULL
97705 +deny_write_access_37813 deny_write_access 0 37813 NULL
97706 +rx_decrypt_key_not_found_read_37820 rx_decrypt_key_not_found_read 3 37820 NULL
97707 +bitmap_find_next_zero_area_37827 bitmap_find_next_zero_area 2-3-5-4 37827 NULL
97708 +o2hb_debug_read_37851 o2hb_debug_read 3 37851 NULL
97709 +xfs_dir2_block_to_sf_37868 xfs_dir2_block_to_sf 3 37868 NULL
97710 +sys_setxattr_37880 sys_setxattr 4 37880 NULL
97711 +dvb_net_sec_37884 dvb_net_sec 3 37884 NULL
97712 +max77686_irq_domain_map_37897 max77686_irq_domain_map 2 37897 NULL
97713 +compat_sys_rt_sigpending_37899 compat_sys_rt_sigpending 2 37899 NULL
97714 +tipc_link_send_sections_fast_37920 tipc_link_send_sections_fast 4 37920 NULL
97715 +pkt_alloc_packet_data_37928 pkt_alloc_packet_data 1 37928 NULL
97716 +read_rbu_packet_size_37939 read_rbu_packet_size 6 37939 NULL
97717 +fifo_alloc_37961 fifo_alloc 1 37961 NULL
97718 +ext3_free_blocks_sb_37967 ext3_free_blocks_sb 3-4 37967 NULL
97719 +rds_rdma_extra_size_37990 rds_rdma_extra_size 0 37990 NULL
97720 +persistent_ram_old_size_37997 persistent_ram_old_size 0 37997 NULL
97721 +vfs_readv_38011 vfs_readv 3 38011 NULL
97722 +aggr_recv_addba_req_evt_38037 aggr_recv_addba_req_evt 4 38037 NULL
97723 +klsi_105_prepare_write_buffer_38044 klsi_105_prepare_write_buffer 3 38044 NULL nohasharray
97724 +il_dbgfs_chain_noise_read_38044 il_dbgfs_chain_noise_read 3 38044 &klsi_105_prepare_write_buffer_38044
97725 +_xfs_buf_alloc_38058 _xfs_buf_alloc 3 38058 NULL nohasharray
97726 +is_discarded_38058 is_discarded 2 38058 &_xfs_buf_alloc_38058
97727 +nsm_create_handle_38060 nsm_create_handle 4 38060 NULL
97728 +alloc_ltalkdev_38071 alloc_ltalkdev 1 38071 NULL
97729 +xfs_buf_readahead_map_38081 xfs_buf_readahead_map 3 38081 NULL
97730 +uwb_mac_addr_print_38085 uwb_mac_addr_print 2 38085 NULL
97731 +request_key_auth_new_38092 request_key_auth_new 3 38092 NULL
97732 +proc_self_readlink_38094 proc_self_readlink 3 38094 NULL
97733 +ep0_read_38095 ep0_read 3 38095 NULL
97734 +sk_wmem_schedule_38096 sk_wmem_schedule 2 38096 NULL
97735 +rbd_obj_read_sync_38098 rbd_obj_read_sync 3-4 38098 NULL
97736 +snd_pcm_oss_write_38108 snd_pcm_oss_write 3 38108 NULL
97737 +vmw_kms_present_38130 vmw_kms_present 9 38130 NULL
97738 +__ntfs_copy_from_user_iovec_inatomic_38153 __ntfs_copy_from_user_iovec_inatomic 3-4 38153 NULL
97739 +kvm_clear_guest_38164 kvm_clear_guest 3-2 38164 NULL
97740 +cdev_add_38176 cdev_add 2-3 38176 NULL
97741 +brcmf_sdcard_recv_buf_38179 brcmf_sdcard_recv_buf 6 38179 NULL
97742 +rt2x00debug_write_rf_38195 rt2x00debug_write_rf 3 38195 NULL
97743 +get_ucode_user_38202 get_ucode_user 3 38202 NULL
97744 +ext3_new_block_38208 ext3_new_block 3 38208 NULL
97745 +stmpe_gpio_irq_map_38222 stmpe_gpio_irq_map 3 38222 NULL
97746 +osd_req_list_partition_collections_38223 osd_req_list_partition_collections 5 38223 NULL
97747 +palmas_gpio_to_irq_38235 palmas_gpio_to_irq 2 38235 NULL
97748 +vhost_net_compat_ioctl_38237 vhost_net_compat_ioctl 3 38237 NULL
97749 +_ipw_read_reg32_38245 _ipw_read_reg32 0 38245 NULL
97750 +from_dblock_38256 from_dblock 0-1 38256 NULL
97751 +vmci_qp_broker_set_page_store_38260 vmci_qp_broker_set_page_store 2-3 38260 NULL
97752 +ieee80211_if_read_auto_open_plinks_38268 ieee80211_if_read_auto_open_plinks 3 38268 NULL nohasharray
97753 +mthca_alloc_icm_table_38268 mthca_alloc_icm_table 4-3 38268 &ieee80211_if_read_auto_open_plinks_38268
97754 +xfs_bmbt_to_bmdr_38275 xfs_bmbt_to_bmdr 3 38275 NULL nohasharray
97755 +xfs_bmdr_to_bmbt_38275 xfs_bmdr_to_bmbt 5 38275 &xfs_bmbt_to_bmdr_38275
97756 +ftdi_process_packet_38281 ftdi_process_packet 4 38281 NULL nohasharray
97757 +swiotlb_sync_single_for_cpu_38281 swiotlb_sync_single_for_cpu 2 38281 &ftdi_process_packet_38281
97758 +gpa_to_gfn_38291 gpa_to_gfn 0-1 38291 NULL
97759 +zd_mac_rx_38296 zd_mac_rx 3 38296 NULL
97760 +isr_rx_headers_read_38325 isr_rx_headers_read 3 38325 NULL
97761 +ida_simple_get_38326 ida_simple_get 2 38326 NULL
97762 +__snd_gf1_look8_38333 __snd_gf1_look8 0 38333 NULL
97763 +pyra_sysfs_write_38370 pyra_sysfs_write 6 38370 NULL
97764 +dn_sendmsg_38390 dn_sendmsg 4 38390 NULL
97765 +get_valid_node_allowed_38412 get_valid_node_allowed 1-0 38412 NULL
97766 +ocfs2_which_cluster_group_38413 ocfs2_which_cluster_group 2 38413 NULL
97767 +ht_destroy_irq_38418 ht_destroy_irq 1 38418 NULL
97768 +ieee80211_if_read_dtim_count_38419 ieee80211_if_read_dtim_count 3 38419 NULL
97769 +asix_write_cmd_async_38420 asix_write_cmd_async 5 38420 NULL
97770 +pcnet32_realloc_tx_ring_38428 pcnet32_realloc_tx_ring 3 38428 NULL
97771 +pmcraid_copy_sglist_38431 pmcraid_copy_sglist 3 38431 NULL
97772 +kvm_write_guest_38454 kvm_write_guest 4-2 38454 NULL
97773 +i915_min_freq_read_38470 i915_min_freq_read 3 38470 NULL
97774 +kvm_arch_setup_async_pf_38481 kvm_arch_setup_async_pf 3 38481 NULL
97775 +blk_end_bidi_request_38482 blk_end_bidi_request 3-4 38482 NULL
97776 +dev_names_read_38509 dev_names_read 3 38509 NULL
97777 +iscsi_create_iface_38510 iscsi_create_iface 5 38510 NULL
97778 +event_rx_mismatch_read_38518 event_rx_mismatch_read 3 38518 NULL
97779 +set_queue_count_38519 set_queue_count 0 38519 NULL
97780 +mlx4_ib_db_map_user_38529 mlx4_ib_db_map_user 2 38529 NULL
97781 +ubifs_idx_node_sz_38546 ubifs_idx_node_sz 0-2 38546 NULL
97782 +btrfs_discard_extent_38547 btrfs_discard_extent 2 38547 NULL
97783 +irda_sendmsg_dgram_38563 irda_sendmsg_dgram 4 38563 NULL
97784 +il4965_rs_sta_dbgfs_scale_table_read_38564 il4965_rs_sta_dbgfs_scale_table_read 3 38564 NULL
97785 +_ipw_read32_38565 _ipw_read32 0 38565 NULL
97786 +snd_nm256_playback_copy_38567 snd_nm256_playback_copy 5-3 38567 NULL
97787 +copy_ctl_value_to_user_38587 copy_ctl_value_to_user 4 38587 NULL
97788 +cosa_net_setup_rx_38594 cosa_net_setup_rx 2 38594 NULL
97789 +compat_sys_ptrace_38595 compat_sys_ptrace 3-4 38595 NULL
97790 +icn_writecmd_38629 icn_writecmd 2 38629 NULL
97791 +ext2_readpages_38640 ext2_readpages 4 38640 NULL
97792 +cma_create_area_38642 cma_create_area 2 38642 NULL
97793 +audit_init_entry_38644 audit_init_entry 1 38644 NULL
97794 +qp_broker_alloc_38646 qp_broker_alloc 5-6 38646 NULL
97795 +mmc_send_cxd_data_38655 mmc_send_cxd_data 5 38655 NULL
97796 +nouveau_instmem_create__38664 nouveau_instmem_create_ 4 38664 NULL
97797 +cfg80211_send_disassoc_38678 cfg80211_send_disassoc 3 38678 NULL
97798 +iscsit_dump_data_payload_38683 iscsit_dump_data_payload 2 38683 NULL
97799 +ext4_wait_block_bitmap_38695 ext4_wait_block_bitmap 2 38695 NULL
97800 +rbio_add_io_page_38700 rbio_add_io_page 6 38700 NULL
97801 +find_next_usable_block_38716 find_next_usable_block 1-3 38716 NULL
97802 +alloc_trace_probe_38720 alloc_trace_probe 6 38720 NULL
97803 +phys_to_virt_38757 phys_to_virt 0-1 38757 NULL
97804 +udf_readpages_38761 udf_readpages 4 38761 NULL
97805 +iwl_dbgfs_thermal_throttling_read_38779 iwl_dbgfs_thermal_throttling_read 3 38779 NULL
97806 +snd_gus_dram_write_38784 snd_gus_dram_write 4 38784 NULL
97807 +err_decode_38804 err_decode 2 38804 NULL
97808 +ipv6_renew_option_38813 ipv6_renew_option 3 38813 NULL
97809 +sys_select_38827 sys_select 1 38827 NULL
97810 +b43_txhdr_size_38832 b43_txhdr_size 0 38832 NULL
97811 +direct_entry_38836 direct_entry 3 38836 NULL
97812 +compat_udp_setsockopt_38840 compat_udp_setsockopt 5 38840 NULL
97813 +interfaces_38859 interfaces 2 38859 NULL
97814 +pci_msix_table_size_38867 pci_msix_table_size 0 38867 NULL
97815 +sizeof_gpio_leds_priv_38882 sizeof_gpio_leds_priv 0-1 38882 NULL
97816 +dbgfs_state_38894 dbgfs_state 3 38894 NULL
97817 +f2fs_xattr_set_acl_38895 f2fs_xattr_set_acl 4 38895 NULL
97818 +process_bulk_data_command_38906 process_bulk_data_command 4 38906 NULL
97819 +ext3_trim_all_free_38929 ext3_trim_all_free 3-4-2 38929 NULL
97820 +sbp_count_se_tpg_luns_38943 sbp_count_se_tpg_luns 0 38943 NULL
97821 +__ath6kl_wmi_send_mgmt_cmd_38971 __ath6kl_wmi_send_mgmt_cmd 7 38971 NULL
97822 +usb_maxpacket_38977 usb_maxpacket 0 38977 NULL
97823 +OSDSetBlock_38986 OSDSetBlock 4-2 38986 NULL
97824 +udf_new_block_38999 udf_new_block 4 38999 NULL
97825 +get_nodes_39012 get_nodes 3 39012 NULL
97826 +twl6030_interrupt_unmask_39013 twl6030_interrupt_unmask 2 39013 NULL
97827 +acpi_install_gpe_block_39031 acpi_install_gpe_block 4 39031 NULL
97828 +_zd_iowrite32v_async_locked_39034 _zd_iowrite32v_async_locked 3 39034 NULL
97829 +line6_midibuf_read_39067 line6_midibuf_read 0-3 39067 NULL
97830 +ext4_init_block_bitmap_39071 ext4_init_block_bitmap 3 39071 NULL
97831 +tomoyo_truncate_39105 tomoyo_truncate 0 39105 NULL
97832 +__kfifo_to_user_r_39123 __kfifo_to_user_r 3 39123 NULL
97833 +ea_foreach_39133 ea_foreach 0 39133 NULL
97834 +generic_permission_39150 generic_permission 0 39150 NULL
97835 +alloc_ring_39151 alloc_ring 2-4 39151 NULL
97836 +proc_coredump_filter_read_39153 proc_coredump_filter_read 3 39153 NULL
97837 +create_bounce_buffer_39155 create_bounce_buffer 3 39155 NULL
97838 +ext3_xattr_check_names_39174 ext3_xattr_check_names 0 39174 NULL
97839 +init_list_set_39188 init_list_set 2-3 39188 NULL
97840 +ubi_more_update_data_39189 ubi_more_update_data 4 39189 NULL
97841 +qcam_read_bytes_39205 qcam_read_bytes 0 39205 NULL
97842 +qla4_82xx_pci_mem_read_direct_39208 qla4_82xx_pci_mem_read_direct 2 39208 NULL
97843 +vfio_group_fops_compat_ioctl_39219 vfio_group_fops_compat_ioctl 3 39219 NULL
97844 +ivtv_v4l2_write_39226 ivtv_v4l2_write 3 39226 NULL
97845 +batadv_tt_response_fill_table_39236 batadv_tt_response_fill_table 1 39236 NULL
97846 +posix_acl_to_xattr_39237 posix_acl_to_xattr 0 39237 NULL
97847 +drm_order_39244 drm_order 0 39244 NULL
97848 +r128_compat_ioctl_39250 r128_compat_ioctl 2 39250 NULL nohasharray
97849 +pwr_cont_miss_bcns_spread_read_39250 pwr_cont_miss_bcns_spread_read 3 39250 &r128_compat_ioctl_39250
97850 +__skb_cow_39254 __skb_cow 2 39254 NULL
97851 +ath6kl_wmi_set_appie_cmd_39266 ath6kl_wmi_set_appie_cmd 5 39266 NULL
97852 +rx_filter_protection_filter_read_39282 rx_filter_protection_filter_read 3 39282 NULL
97853 +__vmalloc_node_39308 __vmalloc_node 1 39308 NULL
97854 +__cfg80211_connect_result_39326 __cfg80211_connect_result 4-6 39326 NULL
97855 +wimax_msg_alloc_39343 wimax_msg_alloc 4 39343 NULL
97856 +__cfg80211_send_deauth_39344 __cfg80211_send_deauth 3 39344 NULL
97857 +__copy_from_user_nocache_39351 __copy_from_user_nocache 3 39351 NULL
97858 +ide_complete_rq_39354 ide_complete_rq 3 39354 NULL
97859 +do_write_log_from_user_39362 do_write_log_from_user 3 39362 NULL
97860 +vortex_wtdma_getlinearpos_39371 vortex_wtdma_getlinearpos 0 39371 NULL
97861 +regmap_name_read_file_39379 regmap_name_read_file 3 39379 NULL
97862 +fnic_trace_debugfs_read_39380 fnic_trace_debugfs_read 3 39380 NULL
97863 +ps_poll_ps_poll_utilization_read_39383 ps_poll_ps_poll_utilization_read 3 39383 NULL
97864 +__send_to_port_39386 __send_to_port 3 39386 NULL
97865 +user_power_read_39414 user_power_read 3 39414 NULL
97866 +alloc_agpphysmem_i8xx_39427 alloc_agpphysmem_i8xx 1 39427 NULL
97867 +sys_semop_39457 sys_semop 3 39457 NULL
97868 +setkey_unaligned_39474 setkey_unaligned 3 39474 NULL
97869 +do_get_mempolicy_39485 do_get_mempolicy 3 39485 NULL
97870 +ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries_39499 ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries 3 39499 NULL
97871 +atomic64_read_unchecked_39505 atomic64_read_unchecked 0 39505 NULL
97872 +int_proc_write_39542 int_proc_write 3 39542 NULL
97873 +pp_write_39554 pp_write 3 39554 NULL
97874 +ol_dqblk_block_39558 ol_dqblk_block 0-3-2 39558 NULL
97875 +datablob_format_39571 datablob_format 2 39571 NULL nohasharray
97876 +ieee80211_if_read_fwded_mcast_39571 ieee80211_if_read_fwded_mcast 3 39571 &datablob_format_39571
97877 +handle_response_icmp_39574 handle_response_icmp 7 39574 NULL
97878 +mtdchar_compat_ioctl_39602 mtdchar_compat_ioctl 3 39602 NULL
97879 +n_tty_compat_ioctl_helper_39605 n_tty_compat_ioctl_helper 4 39605 NULL
97880 +ext_depth_39607 ext_depth 0 39607 NULL
97881 +nfs_idmap_get_key_39616 nfs_idmap_get_key 2 39616 NULL
97882 +sdio_readb_39618 sdio_readb 0 39618 NULL
97883 +set_dev_class_39645 set_dev_class 4 39645 NULL nohasharray
97884 +dm_exception_table_init_39645 dm_exception_table_init 2 39645 &set_dev_class_39645
97885 +snd_rme32_capture_copy_39653 snd_rme32_capture_copy 5 39653 NULL
97886 +tcp_try_rmem_schedule_39657 tcp_try_rmem_schedule 3 39657 NULL nohasharray
97887 +prism2_info_hostscanresults_39657 prism2_info_hostscanresults 3 39657 &tcp_try_rmem_schedule_39657
97888 +kvm_read_guest_cached_39666 kvm_read_guest_cached 4 39666 NULL
97889 +v4l_stk_read_39672 v4l_stk_read 3 39672 NULL
97890 +hsc_msg_len_get_39673 hsc_msg_len_get 0 39673 NULL
97891 +do_surface_dirty_sou_39678 do_surface_dirty_sou 7 39678 NULL
97892 +ftrace_pid_write_39710 ftrace_pid_write 3 39710 NULL
97893 +tcf_csum_ipv4_tcp_39713 tcf_csum_ipv4_tcp 4 39713 NULL
97894 +remap_to_origin_clear_discard_39767 remap_to_origin_clear_discard 3 39767 NULL
97895 +ocfs2_pages_per_cluster_39790 ocfs2_pages_per_cluster 0 39790 NULL
97896 +crypto_ablkcipher_blocksize_39811 crypto_ablkcipher_blocksize 0 39811 NULL
97897 +security_inode_listsecurity_39812 security_inode_listsecurity 0 39812 NULL
97898 +snd_pcm_oss_writev3_39818 snd_pcm_oss_writev3 3 39818 NULL
97899 +sys_migrate_pages_39825 sys_migrate_pages 2 39825 NULL
97900 +get_priv_size_39828 get_priv_size 0-1 39828 NULL
97901 +pkt_add_39897 pkt_add 3 39897 NULL
97902 +read_file_modal_eeprom_39909 read_file_modal_eeprom 3 39909 NULL
97903 +gen_pool_add_virt_39913 gen_pool_add_virt 4 39913 NULL
97904 +dw210x_op_rw_39915 dw210x_op_rw 6 39915 NULL
97905 +aes_encrypt_interrupt_read_39919 aes_encrypt_interrupt_read 3 39919 NULL
97906 +exofs_read_kern_39921 exofs_read_kern 6 39921 NULL nohasharray
97907 +oom_score_adj_read_39921 oom_score_adj_read 3 39921 &exofs_read_kern_39921
97908 +__spi_async_39932 __spi_async 0 39932 NULL
97909 +__get_order_39935 __get_order 0 39935 NULL
97910 +error_error_frame_read_39947 error_error_frame_read 3 39947 NULL nohasharray
97911 +fwnet_pd_new_39947 fwnet_pd_new 4 39947 &error_error_frame_read_39947
97912 +tty_prepare_flip_string_39955 tty_prepare_flip_string 3 39955 NULL
97913 +dma_push_rx_39973 dma_push_rx 2 39973 NULL
97914 +broadsheetfb_write_39976 broadsheetfb_write 3 39976 NULL
97915 +mthca_array_init_39987 mthca_array_init 2 39987 NULL
97916 +xen_hvm_config_40018 xen_hvm_config 2 40018 NULL
97917 +nf_nat_icmpv6_reply_translation_40023 nf_nat_icmpv6_reply_translation 5 40023 NULL nohasharray
97918 +ivtvfb_write_40023 ivtvfb_write 3 40023 &nf_nat_icmpv6_reply_translation_40023
97919 +ea_foreach_i_40028 ea_foreach_i 0 40028 NULL
97920 +datablob_hmac_append_40038 datablob_hmac_append 3 40038 NULL
97921 +regmap_add_irq_chip_40042 regmap_add_irq_chip 4 40042 NULL
97922 +add_tty_40055 add_tty 1 40055 NULL nohasharray
97923 +l2cap_create_iframe_pdu_40055 l2cap_create_iframe_pdu 3 40055 &add_tty_40055
97924 +atomic_xchg_40070 atomic_xchg 0 40070 NULL
97925 +gen_pool_first_fit_40110 gen_pool_first_fit 2-3-4 40110 NULL
97926 +sctp_setsockopt_delayed_ack_40129 sctp_setsockopt_delayed_ack 3 40129 NULL
97927 +rx_rx_frame_checksum_read_40140 rx_rx_frame_checksum_read 3 40140 NULL
97928 +iwch_alloc_fastreg_pbl_40153 iwch_alloc_fastreg_pbl 2 40153 NULL
97929 +pt_write_40159 pt_write 3 40159 NULL
97930 +scsi_sg_count_40182 scsi_sg_count 0 40182 NULL
97931 +ipr_alloc_ucode_buffer_40199 ipr_alloc_ucode_buffer 1 40199 NULL nohasharray
97932 +devnode_find_40199 devnode_find 3-2 40199 &ipr_alloc_ucode_buffer_40199
97933 +allocate_probes_40204 allocate_probes 1 40204 NULL
97934 +compat_put_long_40214 compat_put_long 1 40214 NULL
97935 +au0828_v4l2_read_40220 au0828_v4l2_read 3 40220 NULL
97936 +osst_read_40237 osst_read 3 40237 NULL
97937 +lpage_info_slot_40243 lpage_info_slot 1-3 40243 NULL
97938 +ocfs2_zero_extend_get_range_40248 ocfs2_zero_extend_get_range 4 40248 NULL
97939 +of_get_child_count_40254 of_get_child_count 0 40254 NULL
97940 +rs_sta_dbgfs_scale_table_read_40262 rs_sta_dbgfs_scale_table_read 3 40262 NULL
97941 +usbnet_read_cmd_40275 usbnet_read_cmd 7 40275 NULL
97942 +rx_xfr_hint_trig_read_40283 rx_xfr_hint_trig_read 3 40283 NULL
97943 +crash_free_reserved_phys_range_40292 crash_free_reserved_phys_range 1 40292 NULL
97944 +ubi_io_write_data_40305 ubi_io_write_data 4-5 40305 NULL
97945 +batadv_tt_changes_fill_buff_40323 batadv_tt_changes_fill_buff 4 40323 NULL
97946 +ib_get_mad_data_offset_40336 ib_get_mad_data_offset 0 40336 NULL
97947 +mmio_read_40348 mmio_read 4 40348 NULL
97948 +usb_dump_interface_40353 usb_dump_interface 0 40353 NULL
97949 +ocfs2_release_clusters_40355 ocfs2_release_clusters 4 40355 NULL
97950 +event_rx_mem_empty_read_40363 event_rx_mem_empty_read 3 40363 NULL
97951 +ocfs2_check_range_for_refcount_40365 ocfs2_check_range_for_refcount 2-3 40365 NULL
97952 +fwnet_incoming_packet_40380 fwnet_incoming_packet 3 40380 NULL
97953 +brcmf_sdbrcm_get_image_40397 brcmf_sdbrcm_get_image 0-2 40397 NULL
97954 +atmel_rmem16_40450 atmel_rmem16 0 40450 NULL
97955 +tomoyo_update_policy_40458 tomoyo_update_policy 2 40458 NULL
97956 +zd_usb_scnprint_id_40459 zd_usb_scnprint_id 0-3 40459 NULL
97957 +batadv_hash_new_40491 batadv_hash_new 1 40491 NULL
97958 +devcgroup_inode_permission_40492 devcgroup_inode_permission 0 40492 NULL
97959 +tty_write_room_40495 tty_write_room 0 40495 NULL
97960 +persistent_ram_new_40501 persistent_ram_new 1-2 40501 NULL
97961 +sg_phys_40507 sg_phys 0 40507 NULL
97962 +TSS_checkhmac2_40520 TSS_checkhmac2 5-7 40520 NULL
97963 +ixgbe_dbg_reg_ops_read_40540 ixgbe_dbg_reg_ops_read 3 40540 NULL
97964 +ima_write_policy_40548 ima_write_policy 3 40548 NULL
97965 +esp_alloc_tmp_40558 esp_alloc_tmp 3-2 40558 NULL
97966 +ufs_inode_getfrag_40560 ufs_inode_getfrag 2-4 40560 NULL
97967 +skge_rx_get_40598 skge_rx_get 3 40598 NULL
97968 +get_priv_descr_and_size_40612 get_priv_descr_and_size 0 40612 NULL
97969 +bl_mark_sectors_init_40613 bl_mark_sectors_init 2-3 40613 NULL
97970 +cpuset_sprintf_cpulist_40627 cpuset_sprintf_cpulist 0 40627 NULL
97971 +twl4030_kpwrite_u8_40665 twl4030_kpwrite_u8 3 40665 NULL
97972 +__cfg80211_roamed_40668 __cfg80211_roamed 4-6 40668 NULL
97973 +pipeline_rx_complete_stat_fifo_int_read_40671 pipeline_rx_complete_stat_fifo_int_read 3 40671 NULL
97974 +fops_read_40672 fops_read 3 40672 NULL
97975 +alloc_rbio_40676 alloc_rbio 4 40676 NULL
97976 +videobuf_dma_init_user_locked_40678 videobuf_dma_init_user_locked 3 40678 NULL
97977 +nfc_hci_set_param_40697 nfc_hci_set_param 5 40697 NULL
97978 +__seq_open_private_40715 __seq_open_private 3 40715 NULL
97979 +fuse_readpages_40737 fuse_readpages 4 40737 NULL
97980 +xfs_iext_remove_direct_40744 xfs_iext_remove_direct 3 40744 NULL nohasharray
97981 +find_next_zero_bit_le_40744 find_next_zero_bit_le 0-2-3 40744 &xfs_iext_remove_direct_40744
97982 +security_inode_listxattr_40752 security_inode_listxattr 0 40752 NULL
97983 +fat_generic_compat_ioctl_40755 fat_generic_compat_ioctl 3 40755 NULL
97984 +card_send_command_40757 card_send_command 3 40757 NULL
97985 +ad1889_readl_40765 ad1889_readl 0 40765 NULL
97986 +pg_write_40766 pg_write 3 40766 NULL
97987 +show_list_40775 show_list 3 40775 NULL
97988 +kfifo_out_copy_r_40784 kfifo_out_copy_r 0-3 40784 NULL
97989 +bitmap_weight_40791 bitmap_weight 0-2 40791 NULL
97990 +pyra_sysfs_read_40795 pyra_sysfs_read 6 40795 NULL
97991 +netdev_alloc_skb_ip_align_40811 netdev_alloc_skb_ip_align 2 40811 NULL
97992 +nl80211_send_roamed_40825 nl80211_send_roamed 5-7 40825 NULL
97993 +__mlx4_qp_reserve_range_40847 __mlx4_qp_reserve_range 2-3 40847 NULL
97994 +ocfs2_zero_partial_clusters_40856 ocfs2_zero_partial_clusters 2-3 40856 NULL
97995 +v9fs_file_read_40858 v9fs_file_read 3 40858 NULL
97996 +read_file_queue_40895 read_file_queue 3 40895 NULL
97997 +waiters_read_40902 waiters_read 3 40902 NULL
97998 +isdn_add_channels_40905 isdn_add_channels 3 40905 NULL
97999 +gfs2_ea_find_40913 gfs2_ea_find 0 40913 NULL
98000 +vol_cdev_write_40915 vol_cdev_write 3 40915 NULL
98001 +snd_vx_create_40948 snd_vx_create 4 40948 NULL
98002 +skb_end_offset_40949 skb_end_offset 0 40949 NULL
98003 +wm8994_free_irq_40951 wm8994_free_irq 2 40951 NULL
98004 +rds_sendmsg_40976 rds_sendmsg 4 40976 NULL
98005 +il_dbgfs_fh_reg_read_40993 il_dbgfs_fh_reg_read 3 40993 NULL
98006 +mac80211_format_buffer_41010 mac80211_format_buffer 2 41010 NULL
98007 +mtd_block_isbad_41015 mtd_block_isbad 0 41015 NULL
98008 +_req_append_segment_41031 _req_append_segment 2 41031 NULL
98009 +mISDN_sock_sendmsg_41035 mISDN_sock_sendmsg 4 41035 NULL
98010 +ocfs2_xattr_index_block_find_41040 ocfs2_xattr_index_block_find 0 41040 NULL
98011 +vfs_listxattr_41062 vfs_listxattr 0 41062 NULL
98012 +cfg80211_inform_bss_frame_41078 cfg80211_inform_bss_frame 4 41078 NULL
98013 +roccat_read_41093 roccat_read 3 41093 NULL nohasharray
98014 +nvme_map_user_pages_41093 nvme_map_user_pages 3-4 41093 &roccat_read_41093
98015 +dma_attach_41094 dma_attach 5-6 41094 NULL
98016 +provide_user_output_41105 provide_user_output 3 41105 NULL
98017 +f_audio_buffer_alloc_41110 f_audio_buffer_alloc 1 41110 NULL
98018 +v4l2_ctrl_new_int_menu_41151 v4l2_ctrl_new_int_menu 4 41151 NULL
98019 +tx_frag_mpdu_alloc_failed_read_41167 tx_frag_mpdu_alloc_failed_read 3 41167 NULL
98020 +dvb_ca_write_41171 dvb_ca_write 3 41171 NULL
98021 +ol_quota_chunk_block_41177 ol_quota_chunk_block 0-2 41177 NULL
98022 +netif_get_num_default_rss_queues_41187 netif_get_num_default_rss_queues 0 41187 NULL
98023 +compat_sys_process_vm_writev_41194 compat_sys_process_vm_writev 3-5 41194 NULL
98024 +dfs_file_write_41196 dfs_file_write 3 41196 NULL
98025 +xfs_readdir_41200 xfs_readdir 3 41200 NULL
98026 +ocfs2_read_quota_block_41207 ocfs2_read_quota_block 2 41207 NULL
98027 +nfs_page_array_len_41219 nfs_page_array_len 0-2-1 41219 NULL
98028 +hiddev_compat_ioctl_41255 hiddev_compat_ioctl 2-3 41255 NULL
98029 +erst_read_41260 erst_read 0 41260 NULL
98030 +__fprog_create_41263 __fprog_create 2 41263 NULL
98031 +alloc_context_41283 alloc_context 1 41283 NULL
98032 +arch_gnttab_map_shared_41306 arch_gnttab_map_shared 3 41306 NULL
98033 +twl_change_queue_depth_41342 twl_change_queue_depth 2 41342 NULL
98034 +cnic_init_id_tbl_41354 cnic_init_id_tbl 2 41354 NULL
98035 +jbd2_alloc_41359 jbd2_alloc 1 41359 NULL
98036 +kmp_init_41373 kmp_init 2 41373 NULL
98037 +isr_commands_read_41398 isr_commands_read 3 41398 NULL
98038 +is_writethrough_io_41406 is_writethrough_io 3 41406 NULL
98039 +sys_flistxattr_41407 sys_flistxattr 3 41407 NULL
98040 +rx_defrag_decrypt_failed_read_41411 rx_defrag_decrypt_failed_read 3 41411 NULL
98041 +xfs_iext_add_41422 xfs_iext_add 3 41422 NULL
98042 +vsock_dev_compat_ioctl_41427 vsock_dev_compat_ioctl 3 41427 NULL
98043 +isdn_ppp_fill_rq_41428 isdn_ppp_fill_rq 2 41428 NULL
98044 +lbs_rdrf_read_41431 lbs_rdrf_read 3 41431 NULL
98045 +iio_device_alloc_41440 iio_device_alloc 1 41440 NULL
98046 +ntfs_file_buffered_write_41442 ntfs_file_buffered_write 4-6 41442 NULL
98047 +pcpu_build_alloc_info_41443 pcpu_build_alloc_info 1-2-3 41443 NULL
98048 +layout_leb_in_gaps_41470 layout_leb_in_gaps 0 41470 NULL
98049 +rt2x00debug_write_rfcsr_41473 rt2x00debug_write_rfcsr 3 41473 NULL
98050 +wep_interrupt_read_41492 wep_interrupt_read 3 41492 NULL
98051 +hpfs_translate_name_41497 hpfs_translate_name 3 41497 NULL
98052 +xfrm_hash_new_size_41505 xfrm_hash_new_size 0-1 41505 NULL
98053 +ldisc_receive_41516 ldisc_receive 4 41516 NULL
98054 +tx_tx_frame_checksum_read_41553 tx_tx_frame_checksum_read 3 41553 NULL
98055 +ath6kl_endpoint_stats_read_41554 ath6kl_endpoint_stats_read 3 41554 NULL
98056 +nr_status_frames_41559 nr_status_frames 0-1 41559 NULL
98057 +batadv_receive_client_update_packet_41578 batadv_receive_client_update_packet 3 41578 NULL
98058 +rng_dev_read_41581 rng_dev_read 3 41581 NULL
98059 +read_file_rx_chainmask_41605 read_file_rx_chainmask 3 41605 NULL
98060 +vga_io_r_41609 vga_io_r 0 41609 NULL
98061 +tcp_hdrlen_41610 tcp_hdrlen 0 41610 NULL
98062 +usb_endpoint_maxp_41613 usb_endpoint_maxp 0 41613 NULL
98063 +a2mp_send_41615 a2mp_send 4 41615 NULL
98064 +mempool_create_kmalloc_pool_41650 mempool_create_kmalloc_pool 1 41650 NULL
98065 +rx_rx_pre_complt_read_41653 rx_rx_pre_complt_read 3 41653 NULL
98066 +get_std_timing_41654 get_std_timing 0 41654 NULL
98067 +squashfs_cache_init_41656 squashfs_cache_init 2 41656 NULL
98068 +ieee80211_if_fmt_bssid_41677 ieee80211_if_fmt_bssid 3 41677 NULL
98069 +params_period_bytes_41683 params_period_bytes 0 41683 NULL
98070 +aac_src_ioremap_41688 aac_src_ioremap 2 41688 NULL
98071 +bdx_tx_db_init_41719 bdx_tx_db_init 2 41719 NULL
98072 +sys_pwritev_41722 sys_pwritev 3 41722 NULL
98073 +get_bios_ebda_41730 get_bios_ebda 0 41730 NULL
98074 +fillonedir_41746 fillonedir 3 41746 NULL
98075 +ocfs2_dx_dir_rebalance_41793 ocfs2_dx_dir_rebalance 7 41793 NULL
98076 +hsi_alloc_controller_41802 hsi_alloc_controller 1 41802 NULL
98077 +da9052_enable_irq_41814 da9052_enable_irq 2 41814 NULL
98078 +sco_send_frame_41815 sco_send_frame 3 41815 NULL
98079 +lp_gpio_to_irq_41822 lp_gpio_to_irq 2 41822 NULL
98080 +ixgbe_dbg_netdev_ops_read_41839 ixgbe_dbg_netdev_ops_read 3 41839 NULL
98081 +do_ip_setsockopt_41852 do_ip_setsockopt 5 41852 NULL
98082 +keyctl_instantiate_key_41855 keyctl_instantiate_key 3 41855 NULL
98083 +ieee80211_rx_radiotap_space_41870 ieee80211_rx_radiotap_space 0 41870 NULL
98084 +get_fdb_entries_41916 get_fdb_entries 3 41916 NULL
98085 +find_ge_pid_41918 find_ge_pid 1 41918 NULL
98086 +build_inv_iotlb_pages_41922 build_inv_iotlb_pages 4-5 41922 NULL
98087 +nfsd_getxattr_41934 nfsd_getxattr 0 41934 NULL
98088 +ext4_da_write_inline_data_begin_41935 ext4_da_write_inline_data_begin 3-4 41935 NULL
98089 +ocfs2_xattr_bucket_get_name_value_41949 ocfs2_xattr_bucket_get_name_value 0 41949 NULL
98090 +portnames_read_41958 portnames_read 3 41958 NULL
98091 +ubi_self_check_all_ff_41959 ubi_self_check_all_ff 4 41959 NULL
98092 +dst_mtu_41969 dst_mtu 0 41969 NULL
98093 +cx24116_writeregN_41975 cx24116_writeregN 4 41975 NULL
98094 +ubi_io_is_bad_41983 ubi_io_is_bad 0 41983 NULL
98095 +lguest_map_42008 lguest_map 1-2 42008 NULL
98096 +pool_allocate_42012 pool_allocate 3 42012 NULL
98097 +spidev_sync_read_42014 spidev_sync_read 0 42014 NULL
98098 +acpi_ut_create_buffer_object_42030 acpi_ut_create_buffer_object 1 42030 NULL
98099 +__hwahc_op_set_gtk_42038 __hwahc_op_set_gtk 4 42038 NULL
98100 +irda_sendmsg_ultra_42047 irda_sendmsg_ultra 4 42047 NULL
98101 +dma_generic_alloc_coherent_42048 dma_generic_alloc_coherent 2 42048 NULL nohasharray
98102 +jffs2_do_link_42048 jffs2_do_link 6 42048 &dma_generic_alloc_coherent_42048
98103 +ps_poll_upsd_max_ap_turn_read_42050 ps_poll_upsd_max_ap_turn_read 3 42050 NULL
98104 +InterfaceTransmitPacket_42058 InterfaceTransmitPacket 3 42058 NULL
98105 +alloc_bitset_42085 alloc_bitset 1 42085 NULL
98106 +scsi_execute_req_42088 scsi_execute_req 5 42088 NULL
98107 +sk_chk_filter_42095 sk_chk_filter 2 42095 NULL
98108 +submit_inquiry_42108 submit_inquiry 3 42108 NULL
98109 +sysfs_read_file_42113 sysfs_read_file 3 42113 NULL nohasharray
98110 +dw_dma_cyclic_prep_42113 dw_dma_cyclic_prep 3-4 42113 &sysfs_read_file_42113
98111 +Read_hfc16_stable_42131 Read_hfc16_stable 0 42131 NULL
98112 +mmc_align_data_size_42161 mmc_align_data_size 0-2 42161 NULL
98113 +read_file_base_eeprom_42168 read_file_base_eeprom 3 42168 NULL
98114 +iwl_mvm_send_cmd_42173 iwl_mvm_send_cmd 0 42173 NULL
98115 +oprofilefs_str_to_user_42182 oprofilefs_str_to_user 3 42182 NULL
98116 +get_znodes_to_commit_42201 get_znodes_to_commit 0 42201 NULL
98117 +btmrvl_hsmode_write_42252 btmrvl_hsmode_write 3 42252 NULL
98118 +rx_defrag_need_decrypt_read_42253 rx_defrag_need_decrypt_read 3 42253 NULL
98119 +netxen_nic_map_indirect_address_128M_42257 netxen_nic_map_indirect_address_128M 2 42257 NULL
98120 +savu_sysfs_write_42273 savu_sysfs_write 6 42273 NULL
98121 +snd_pcm_hw_param_value_max_42280 snd_pcm_hw_param_value_max 0 42280 NULL
98122 +sel_read_perm_42302 sel_read_perm 3 42302 NULL
98123 +sctp_setsockopt_del_key_42304 sctp_setsockopt_del_key 3 42304 NULL nohasharray
98124 +ulong_read_file_42304 ulong_read_file 3 42304 &sctp_setsockopt_del_key_42304
98125 +gfn_to_hva_42305 gfn_to_hva 0-2 42305 NULL
98126 +xfs_vm_readpages_42308 xfs_vm_readpages 4 42308 NULL
98127 +free_cblock_42318 free_cblock 2 42318 NULL
98128 +hysdn_conf_read_42324 hysdn_conf_read 3 42324 NULL
98129 +tcp_sync_mss_42330 tcp_sync_mss 0-2 42330 NULL
98130 +snd_pcm_plug_alloc_42339 snd_pcm_plug_alloc 2 42339 NULL
98131 +ide_raw_taskfile_42355 ide_raw_taskfile 4 42355 NULL
98132 +il_dbgfs_disable_ht40_read_42386 il_dbgfs_disable_ht40_read 3 42386 NULL
98133 +msnd_fifo_read_42406 msnd_fifo_read 0-3 42406 NULL
98134 +krng_get_random_42420 krng_get_random 3 42420 NULL
98135 +gsm_data_alloc_42437 gsm_data_alloc 3 42437 NULL
98136 +key_conf_keyidx_read_42443 key_conf_keyidx_read 3 42443 NULL
98137 +snd_pcm_action_group_42452 snd_pcm_action_group 0 42452 NULL
98138 +tcm_loop_change_queue_depth_42454 tcm_loop_change_queue_depth 2 42454 NULL
98139 +tc3589x_gpio_irq_get_virq_42457 tc3589x_gpio_irq_get_virq 2 42457 NULL
98140 +ext3_valid_block_bitmap_42459 ext3_valid_block_bitmap 3 42459 NULL
98141 +__simple_xattr_set_42474 __simple_xattr_set 4 42474 NULL
98142 +follow_hugetlb_page_42486 follow_hugetlb_page 0-7 42486 NULL
98143 +omfs_readpages_42490 omfs_readpages 4 42490 NULL
98144 +brcmf_sdbrcm_bus_txctl_42492 brcmf_sdbrcm_bus_txctl 3 42492 NULL
98145 +kvm_write_wall_clock_42520 kvm_write_wall_clock 2 42520 NULL
98146 +smk_write_netlbladdr_42525 smk_write_netlbladdr 3 42525 NULL
98147 +snd_emux_create_port_42533 snd_emux_create_port 3 42533 NULL
98148 +dbAllocNear_42546 dbAllocNear 0 42546 NULL
98149 +i915_ring_stop_read_42549 i915_ring_stop_read 3 42549 NULL nohasharray
98150 +ath6kl_wmi_proc_events_vif_42549 ath6kl_wmi_proc_events_vif 5 42549 &i915_ring_stop_read_42549
98151 +iwl_print_event_log_42566 iwl_print_event_log 0-5-7 42566 NULL
98152 +xfrm_new_hash_mask_42579 xfrm_new_hash_mask 0-1 42579 NULL
98153 +oom_score_adj_write_42594 oom_score_adj_write 3 42594 NULL
98154 +map_state_42602 map_state 1 42602 NULL nohasharray
98155 +__pskb_pull_42602 __pskb_pull 2 42602 &map_state_42602
98156 +nd_get_link_42603 nd_get_link 0 42603 NULL
98157 +sys_move_pages_42626 sys_move_pages 2 42626 NULL
98158 +ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout_42635 ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout 3 42635 NULL
98159 +scsi_activate_tcq_42640 scsi_activate_tcq 2 42640 NULL
98160 +br_mdb_rehash_42643 br_mdb_rehash 2 42643 NULL
98161 +l2tp_xmit_skb_42672 l2tp_xmit_skb 3 42672 NULL
98162 +request_key_and_link_42693 request_key_and_link 4 42693 NULL
98163 +vb2_read_42703 vb2_read 3 42703 NULL
98164 +sierra_net_send_cmd_42708 sierra_net_send_cmd 3 42708 NULL
98165 +__ocfs2_decrease_refcount_42717 __ocfs2_decrease_refcount 4 42717 NULL
98166 +dvb_demux_ioctl_42733 dvb_demux_ioctl 2 42733 NULL
98167 +set_aoe_iflist_42737 set_aoe_iflist 2 42737 NULL
98168 +ax25_setsockopt_42740 ax25_setsockopt 5 42740 NULL
98169 +xen_bind_pirq_gsi_to_irq_42750 xen_bind_pirq_gsi_to_irq 1 42750 NULL
98170 +snd_midi_event_decode_42780 snd_midi_event_decode 0 42780 NULL
98171 +cryptd_hash_setkey_42781 cryptd_hash_setkey 3 42781 NULL
98172 +koneplus_sysfs_read_42792 koneplus_sysfs_read 6 42792 NULL
98173 +ntfs_attr_extend_allocation_42796 ntfs_attr_extend_allocation 0-2 42796 NULL
98174 +fw_device_op_compat_ioctl_42804 fw_device_op_compat_ioctl 2-3 42804 NULL
98175 +drm_ioctl_42813 drm_ioctl 2 42813 NULL
98176 +iwl_dbgfs_ucode_bt_stats_read_42820 iwl_dbgfs_ucode_bt_stats_read 3 42820 NULL
98177 +set_arg_42824 set_arg 3 42824 NULL
98178 +ocfs2_desc_bitmap_to_cluster_off_42831 ocfs2_desc_bitmap_to_cluster_off 2 42831 NULL
98179 +prandom_u32_42853 prandom_u32 0 42853 NULL
98180 +of_property_count_strings_42863 of_property_count_strings 0 42863 NULL
98181 +ocfs2_clusters_for_bytes_42872 ocfs2_clusters_for_bytes 0-2 42872 NULL
98182 +pskb_expand_head_42881 pskb_expand_head 2-3 42881 NULL
98183 +vt_compat_ioctl_42887 vt_compat_ioctl 3 42887 NULL
98184 +tipc_port_recv_sections_42890 tipc_port_recv_sections 4 42890 NULL
98185 +xpc_kmalloc_cacheline_aligned_42895 xpc_kmalloc_cacheline_aligned 1 42895 NULL
98186 +SendTxCommandPacket_42901 SendTxCommandPacket 3 42901 NULL
98187 +hd_end_request_42904 hd_end_request 2 42904 NULL
98188 +sta_last_rx_rate_read_42909 sta_last_rx_rate_read 3 42909 NULL
98189 +sctp_getsockopt_maxburst_42941 sctp_getsockopt_maxburst 2 42941 NULL
98190 +get_unmapped_area_42944 get_unmapped_area 0 42944 NULL
98191 +sys_sethostname_42962 sys_sethostname 2 42962 NULL
98192 +read_file_node_stat_42964 read_file_node_stat 3 42964 NULL
98193 +compat_udpv6_setsockopt_42981 compat_udpv6_setsockopt 5 42981 NULL
98194 +snd_timer_user_ioctl_compat_42985 snd_timer_user_ioctl_compat 3 42985 NULL
98195 +nfs_idmap_get_desc_42990 nfs_idmap_get_desc 4-2 42990 NULL
98196 +mlx4_qp_reserve_range_43000 mlx4_qp_reserve_range 2-3 43000 NULL
98197 +isr_rx_mem_overflow_read_43025 isr_rx_mem_overflow_read 3 43025 NULL
98198 +wep_default_key_count_read_43035 wep_default_key_count_read 3 43035 NULL
98199 +nouveau_gpuobj_create__43072 nouveau_gpuobj_create_ 9 43072 NULL
98200 +nfs_map_group_to_gid_43082 nfs_map_group_to_gid 3 43082 NULL
98201 +cpuset_sprintf_memlist_43088 cpuset_sprintf_memlist 0 43088 NULL
98202 +ieee80211_if_fmt_drop_unencrypted_43107 ieee80211_if_fmt_drop_unencrypted 3 43107 NULL
98203 +read_file_dfs_43145 read_file_dfs 3 43145 NULL
98204 +uuid_string_43154 uuid_string 0 43154 NULL
98205 +usb_string_sub_43164 usb_string_sub 0 43164 NULL
98206 +il_dbgfs_power_save_status_read_43165 il_dbgfs_power_save_status_read 3 43165 NULL
98207 +ath6kl_set_assoc_req_ies_43185 ath6kl_set_assoc_req_ies 3 43185 NULL
98208 +process_measurement_43190 process_measurement 0 43190 NULL
98209 +ext4_xattr_ibody_get_43200 ext4_xattr_ibody_get 0 43200 NULL
98210 +uio_write_43202 uio_write 3 43202 NULL
98211 +iso_callback_43208 iso_callback 3 43208 NULL
98212 +f2fs_acl_from_disk_43210 f2fs_acl_from_disk 2 43210 NULL
98213 +atomic_long_add_return_43217 atomic_long_add_return 1 43217 NULL
98214 +comedi_compat_ioctl_43218 comedi_compat_ioctl 3 43218 NULL
98215 +vmemmap_alloc_block_43245 vmemmap_alloc_block 1 43245 NULL
98216 +fixup_leb_43256 fixup_leb 3 43256 NULL
98217 +ide_end_rq_43269 ide_end_rq 4 43269 NULL
98218 +evtchn_write_43278 evtchn_write 3 43278 NULL
98219 +filemap_write_and_wait_range_43279 filemap_write_and_wait_range 0 43279 NULL
98220 +mpage_alloc_43299 mpage_alloc 3 43299 NULL
98221 +get_nr_irqs_gsi_43315 get_nr_irqs_gsi 0 43315 NULL
98222 +mmu_set_spte_43327 mmu_set_spte 6-7 43327 NULL
98223 +__ext4_get_inode_loc_43332 __ext4_get_inode_loc 0 43332 NULL
98224 +kvm_host_page_size_43348 kvm_host_page_size 2 43348 NULL
98225 +gart_free_coherent_43362 gart_free_coherent 4-2 43362 NULL
98226 +__alloc_bootmem_low_43423 __alloc_bootmem_low 1-2 43423 NULL nohasharray
98227 +gdm_wimax_netif_rx_43423 gdm_wimax_netif_rx 3 43423 &__alloc_bootmem_low_43423
98228 +usb_alloc_urb_43436 usb_alloc_urb 1 43436 NULL
98229 +ucs2_strsize_43438 ucs2_strsize 0 43438 NULL
98230 +ath6kl_wmi_roam_tbl_event_rx_43440 ath6kl_wmi_roam_tbl_event_rx 3 43440 NULL
98231 +usemap_size_43443 usemap_size 0-2-1 43443 NULL nohasharray
98232 +usb_string_43443 usb_string 0 43443 &usemap_size_43443
98233 +alloc_new_reservation_43480 alloc_new_reservation 4 43480 NULL
98234 +tx_tx_data_prepared_read_43497 tx_tx_data_prepared_read 3 43497 NULL
98235 +ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime_43505 ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime 3 43505 NULL
98236 +do_readlink_43518 do_readlink 2 43518 NULL
98237 +dvb_ca_en50221_io_write_43533 dvb_ca_en50221_io_write 3 43533 NULL
98238 +cachefiles_daemon_write_43535 cachefiles_daemon_write 3 43535 NULL
98239 +tx_frag_failed_read_43540 tx_frag_failed_read 3 43540 NULL nohasharray
98240 +ufs_alloccg_block_43540 ufs_alloccg_block 3-0 43540 &tx_frag_failed_read_43540
98241 +ath_rx_init_43564 ath_rx_init 2 43564 NULL
98242 +_fc_frame_alloc_43568 _fc_frame_alloc 1 43568 NULL
98243 +rpc_malloc_43573 rpc_malloc 2 43573 NULL
98244 +lpfc_idiag_drbacc_read_reg_43606 lpfc_idiag_drbacc_read_reg 0-3 43606 NULL
98245 +proc_read_43614 proc_read 3 43614 NULL
98246 +bio_integrity_tag_43658 bio_integrity_tag 3 43658 NULL
98247 +ext4_acl_count_43659 ext4_acl_count 0-1 43659 NULL
98248 +dmam_declare_coherent_memory_43679 dmam_declare_coherent_memory 4-2 43679 NULL
98249 +calgary_map_page_43686 calgary_map_page 3-4 43686 NULL
98250 +max77693_bulk_write_43698 max77693_bulk_write 2-3 43698 NULL
98251 +snd_rme32_playback_copy_43732 snd_rme32_playback_copy 5 43732 NULL
98252 +ocfs2_replace_clusters_43733 ocfs2_replace_clusters 5 43733 NULL
98253 +osdv1_attr_list_elem_size_43747 osdv1_attr_list_elem_size 0-1 43747 NULL
98254 +__bm_find_next_43748 __bm_find_next 2 43748 NULL
98255 +gigaset_initcs_43753 gigaset_initcs 2 43753 NULL
98256 +sctp_setsockopt_active_key_43755 sctp_setsockopt_active_key 3 43755 NULL
98257 +ocfs2_xattr_get_value_outside_43787 ocfs2_xattr_get_value_outside 0 43787 NULL nohasharray
98258 +byte_pos_43787 byte_pos 0-2 43787 &ocfs2_xattr_get_value_outside_43787
98259 +btrfs_copy_from_user_43806 btrfs_copy_from_user 3-1 43806 NULL
98260 +ext4_read_block_bitmap_43814 ext4_read_block_bitmap 2 43814 NULL
98261 +ieee80211_if_fmt_element_ttl_43825 ieee80211_if_fmt_element_ttl 3 43825 NULL
98262 +ieee80211_alloc_hw_43829 ieee80211_alloc_hw 1 43829 NULL
98263 +p54_download_eeprom_43842 p54_download_eeprom 4 43842 NULL
98264 +read_flush_43851 read_flush 3 43851 NULL
98265 +ocfs2_block_group_find_clear_bits_43874 ocfs2_block_group_find_clear_bits 4 43874 NULL
98266 +pm860x_bulk_write_43875 pm860x_bulk_write 2-3 43875 NULL
98267 +prism2_sta_send_mgmt_43916 prism2_sta_send_mgmt 5 43916 NULL
98268 +SendString_43928 SendString 3 43928 NULL
98269 +xen_register_gsi_43946 xen_register_gsi 1-2 43946 NULL
98270 +stats_dot11RTSFailureCount_read_43948 stats_dot11RTSFailureCount_read 3 43948 NULL
98271 +__get_required_blob_size_43980 __get_required_blob_size 0-2-3 43980 NULL
98272 +nla_reserve_43984 nla_reserve 3 43984 NULL
98273 +__clkdev_alloc_43990 __clkdev_alloc 1 43990 NULL
98274 +scsi_command_size_43992 scsi_command_size 0 43992 NULL nohasharray
98275 +bcm_recvmsg_43992 bcm_recvmsg 4 43992 &scsi_command_size_43992
98276 +emit_flags_44006 emit_flags 4-3 44006 NULL
98277 +write_flush_procfs_44011 write_flush_procfs 3 44011 NULL
98278 +swiotlb_unmap_page_44063 swiotlb_unmap_page 2 44063 NULL
98279 +load_discard_44083 load_discard 3 44083 NULL
98280 +xlog_recover_add_to_cont_trans_44102 xlog_recover_add_to_cont_trans 4 44102 NULL
98281 +tracing_set_trace_read_44122 tracing_set_trace_read 3 44122 NULL
98282 +vmw_gmr_bind_44130 vmw_gmr_bind 3 44130 NULL
98283 +scsi_get_resid_44147 scsi_get_resid 0 44147 NULL
98284 +ubifs_find_dirty_idx_leb_44169 ubifs_find_dirty_idx_leb 0 44169 NULL
98285 +ocfs2_xattr_bucket_find_44174 ocfs2_xattr_bucket_find 0 44174 NULL
98286 +handle_eviocgbit_44193 handle_eviocgbit 3 44193 NULL
98287 +IO_APIC_get_PCI_irq_vector_44198 IO_APIC_get_PCI_irq_vector 0 44198 NULL
98288 +__set_free_44211 __set_free 2 44211 NULL
98289 +claim_ptd_buffers_44213 claim_ptd_buffers 3 44213 NULL
98290 +srp_alloc_iu_44227 srp_alloc_iu 2 44227 NULL
98291 +ioapic_register_intr_44238 ioapic_register_intr 1 44238 NULL
98292 +scsi_track_queue_full_44239 scsi_track_queue_full 2 44239 NULL
98293 +tc3589x_gpio_irq_map_44245 tc3589x_gpio_irq_map 2 44245 NULL
98294 +enlarge_skb_44248 enlarge_skb 2 44248 NULL
98295 +ufs_clusteracct_44293 ufs_clusteracct 3 44293 NULL
98296 +ocfs2_zero_range_for_truncate_44294 ocfs2_zero_range_for_truncate 3 44294 NULL
98297 +ath6kl_keepalive_read_44303 ath6kl_keepalive_read 3 44303 NULL
98298 +bitmap_scnprintf_44318 bitmap_scnprintf 2 44318 NULL
98299 +dispatch_proc_write_44320 dispatch_proc_write 3 44320 NULL
98300 +ubi_eba_write_leb_st_44343 ubi_eba_write_leb_st 5 44343 NULL
98301 +nfs_fscache_get_super_cookie_44355 nfs_fscache_get_super_cookie 3 44355 NULL nohasharray
98302 +blk_queue_init_tags_44355 blk_queue_init_tags 2 44355 &nfs_fscache_get_super_cookie_44355
98303 +__is_discarded_44359 __is_discarded 2 44359 NULL
98304 +rts_threshold_read_44384 rts_threshold_read 3 44384 NULL
98305 +aoedev_flush_44398 aoedev_flush 2 44398 NULL
98306 +drm_buffer_alloc_44405 drm_buffer_alloc 2 44405 NULL
98307 +osst_do_scsi_44410 osst_do_scsi 4 44410 NULL
98308 +check_user_page_hwpoison_44412 check_user_page_hwpoison 1 44412 NULL
98309 +ieee80211_if_read_rc_rateidx_mcs_mask_5ghz_44423 ieee80211_if_read_rc_rateidx_mcs_mask_5ghz 3 44423 NULL
98310 +prandom_u32_state_44445 prandom_u32_state 0 44445 NULL
98311 +___alloc_bootmem_node_nopanic_44461 ___alloc_bootmem_node_nopanic 2-3 44461 NULL
98312 +btrfs_chunk_item_size_44478 btrfs_chunk_item_size 0-1 44478 NULL
98313 +sdio_align_size_44489 sdio_align_size 0-2 44489 NULL
98314 +ieee80211_if_read_dropped_frames_ttl_44500 ieee80211_if_read_dropped_frames_ttl 3 44500 NULL
98315 +security_getprocattr_44505 security_getprocattr 0 44505 NULL nohasharray
98316 +iwl_dbgfs_sram_read_44505 iwl_dbgfs_sram_read 3 44505 &security_getprocattr_44505
98317 +spidev_write_44510 spidev_write 3 44510 NULL
98318 +sys_msgsnd_44537 sys_msgsnd 3 44537 NULL nohasharray
98319 +comm_write_44537 comm_write 3 44537 &sys_msgsnd_44537
98320 +dgrp_config_proc_write_44571 dgrp_config_proc_write 3 44571 NULL
98321 +snd_pcm_alloc_vmalloc_buffer_44595 snd_pcm_alloc_vmalloc_buffer 2 44595 NULL
98322 +slip_compat_ioctl_44599 slip_compat_ioctl 4 44599 NULL
98323 +brcmf_sdbrcm_glom_len_44618 brcmf_sdbrcm_glom_len 0 44618 NULL
98324 +cfpkt_add_body_44630 cfpkt_add_body 3 44630 NULL
98325 +ext2_new_block_44645 ext2_new_block 2 44645 NULL
98326 +alloc_ctrl_packet_44667 alloc_ctrl_packet 1 44667 NULL
98327 +mpi_resize_44674 mpi_resize 2 44674 NULL
98328 +ts_read_44687 ts_read 3 44687 NULL
98329 +qib_get_user_pages_44689 qib_get_user_pages 1-2 44689 NULL
98330 +_zd_iowrite32v_locked_44725 _zd_iowrite32v_locked 3 44725 NULL
98331 +clusterip_proc_write_44729 clusterip_proc_write 3 44729 NULL
98332 +fib_count_nexthops_44730 fib_count_nexthops 0 44730 NULL
98333 +key_tx_rx_count_read_44742 key_tx_rx_count_read 3 44742 NULL
98334 +WIL_GET_BITS_44747 WIL_GET_BITS 0-1-2-3 44747 NULL
98335 +set_brk_44749 set_brk 1 44749 NULL
98336 +tnode_new_44757 tnode_new 3 44757 NULL nohasharray
98337 +pty_write_44757 pty_write 3 44757 &tnode_new_44757
98338 +__videobuf_copy_stream_44769 __videobuf_copy_stream 4 44769 NULL
98339 +handsfree_ramp_44777 handsfree_ramp 2 44777 NULL
98340 +sctp_setsockopt_44788 sctp_setsockopt 5 44788 NULL
98341 +rx_dropped_read_44799 rx_dropped_read 3 44799 NULL
98342 +qla4xxx_alloc_work_44813 qla4xxx_alloc_work 2 44813 NULL
98343 +rmap_write_protect_44833 rmap_write_protect 2 44833 NULL
98344 +sisusb_write_44834 sisusb_write 3 44834 NULL
98345 +nl80211_send_unprot_disassoc_44846 nl80211_send_unprot_disassoc 4 44846 NULL
98346 +kvm_read_hva_44847 kvm_read_hva 3 44847 NULL
98347 +skb_availroom_44883 skb_availroom 0 44883 NULL
98348 +nf_bridge_encap_header_len_44890 nf_bridge_encap_header_len 0 44890 NULL
98349 +do_tty_write_44896 do_tty_write 5 44896 NULL
98350 +tx_queue_status_read_44978 tx_queue_status_read 3 44978 NULL
98351 +nf_nat_seq_adjust_44989 nf_nat_seq_adjust 4 44989 NULL
98352 +bytepos_delta_45017 bytepos_delta 0 45017 NULL
98353 +read_block_bitmap_45021 read_block_bitmap 2 45021 NULL nohasharray
98354 +ptrace_writedata_45021 ptrace_writedata 4-3 45021 &read_block_bitmap_45021
98355 +vhci_get_user_45039 vhci_get_user 3 45039 NULL
98356 +sel_write_user_45060 sel_write_user 3 45060 NULL
98357 +snd_mixart_BA0_read_45069 snd_mixart_BA0_read 5 45069 NULL nohasharray
98358 +do_video_ioctl_45069 do_video_ioctl 3 45069 &snd_mixart_BA0_read_45069
98359 +kvm_mmu_page_get_gfn_45110 kvm_mmu_page_get_gfn 0-2 45110 NULL
98360 +pwr_missing_bcns_cnt_read_45113 pwr_missing_bcns_cnt_read 3 45113 NULL
98361 +usbdev_read_45114 usbdev_read 3 45114 NULL
98362 +send_to_tty_45141 send_to_tty 3 45141 NULL
98363 +stmpe_irq_map_45146 stmpe_irq_map 2 45146 NULL
98364 +crypto_aead_blocksize_45148 crypto_aead_blocksize 0 45148 NULL
98365 +gen_bitmask_string_45149 gen_bitmask_string 6 45149 NULL
98366 +ocfs2_remove_inode_range_45156 ocfs2_remove_inode_range 3-4 45156 NULL nohasharray
98367 +device_write_45156 device_write 3 45156 &ocfs2_remove_inode_range_45156
98368 +ocfs2_dq_frozen_trigger_45159 ocfs2_dq_frozen_trigger 4 45159 NULL
98369 +tomoyo_write_self_45161 tomoyo_write_self 3 45161 NULL
98370 +sta_agg_status_write_45164 sta_agg_status_write 3 45164 NULL
98371 +snd_sb_csp_load_user_45190 snd_sb_csp_load_user 3 45190 NULL
98372 +num_clusters_in_group_45194 num_clusters_in_group 2 45194 NULL
98373 +add_child_45201 add_child 4 45201 NULL
98374 +iso_alloc_urb_45206 iso_alloc_urb 4-5 45206 NULL
98375 +spi_alloc_master_45223 spi_alloc_master 2 45223 NULL
98376 +__dirty_45228 __dirty 2 45228 NULL
98377 +ieee80211_if_read_peer_45233 ieee80211_if_read_peer 3 45233 NULL
98378 +input_mt_init_slots_45279 input_mt_init_slots 2 45279 NULL
98379 +vcc_compat_ioctl_45291 vcc_compat_ioctl 3 45291 NULL
98380 +snd_pcm_oss_sync1_45298 snd_pcm_oss_sync1 2 45298 NULL
98381 +pte_val_45313 pte_val 0 45313 NULL
98382 +copy_vm86_regs_from_user_45340 copy_vm86_regs_from_user 3 45340 NULL
98383 +lane2_associate_req_45398 lane2_associate_req 4 45398 NULL
98384 +keymap_store_45406 keymap_store 4 45406 NULL
98385 +paging64_gva_to_gpa_45421 paging64_gva_to_gpa 2 45421 NULL nohasharray
98386 +ieee80211_if_fmt_dot11MeshHWMProotInterval_45421 ieee80211_if_fmt_dot11MeshHWMProotInterval 3 45421 &paging64_gva_to_gpa_45421
98387 +tty_buffer_alloc_45437 tty_buffer_alloc 2 45437 NULL
98388 +intel_render_ring_init_dri_45446 intel_render_ring_init_dri 2-3 45446 NULL
98389 +__node_remap_45458 __node_remap 4 45458 NULL
98390 +rds_ib_set_wr_signal_state_45463 rds_ib_set_wr_signal_state 0 45463 NULL
98391 +udp_manip_pkt_45467 udp_manip_pkt 4 45467 NULL
98392 +tracing_read_dyn_info_45468 tracing_read_dyn_info 3 45468 NULL
98393 +arizona_init_fll_45503 arizona_init_fll 5 45503 NULL
98394 +rds_message_copy_from_user_45510 rds_message_copy_from_user 3 45510 NULL
98395 +sys_lgetxattr_45531 sys_lgetxattr 4 45531 NULL
98396 +cgroup_read_u64_45532 cgroup_read_u64 5 45532 NULL
98397 +copy_macs_45534 copy_macs 4 45534 NULL
98398 +nla_attr_size_45545 nla_attr_size 0-1 45545 NULL
98399 +v9fs_direct_read_45546 v9fs_direct_read 3 45546 NULL
98400 +cx18_copy_mdl_to_user_45549 cx18_copy_mdl_to_user 4 45549 NULL
98401 +atomic_long_sub_return_45551 atomic_long_sub_return 1 45551 NULL
98402 +ext3_group_first_block_no_45555 ext3_group_first_block_no 0-2 45555 NULL
98403 +stats_dot11ACKFailureCount_read_45558 stats_dot11ACKFailureCount_read 3 45558 NULL
98404 +_regmap_bus_raw_write_45559 _regmap_bus_raw_write 2 45559 NULL
98405 +posix_acl_xattr_size_45561 posix_acl_xattr_size 0-1 45561 NULL
98406 +venus_rmdir_45564 venus_rmdir 4 45564 NULL
98407 +ipath_create_cq_45586 ipath_create_cq 2 45586 NULL
98408 +rdma_set_ib_paths_45592 rdma_set_ib_paths 3 45592 NULL
98409 +hidraw_get_report_45609 hidraw_get_report 3 45609 NULL
98410 +audit_log_n_hex_45617 audit_log_n_hex 3 45617 NULL
98411 +ebitmap_next_positive_45651 ebitmap_next_positive 3 45651 NULL
98412 +dma_map_cont_45668 dma_map_cont 5 45668 NULL
98413 +compat_mpctl_ioctl_45671 compat_mpctl_ioctl 2 45671 NULL
98414 +dgram_sendmsg_45679 dgram_sendmsg 4 45679 NULL
98415 +smk_write_ambient_45691 smk_write_ambient 3 45691 NULL
98416 +dm_compat_ctl_ioctl_45692 dm_compat_ctl_ioctl 3 45692 NULL
98417 +unix_dgram_sendmsg_45699 unix_dgram_sendmsg 4 45699 NULL nohasharray
98418 +bscnl_emit_45699 bscnl_emit 2-5-0 45699 &unix_dgram_sendmsg_45699
98419 +dvb_ca_en50221_init_45718 dvb_ca_en50221_init 4 45718 NULL
98420 +snd_cs46xx_io_read_45734 snd_cs46xx_io_read 5 45734 NULL
98421 +rw_copy_check_uvector_45748 rw_copy_check_uvector 3 45748 NULL nohasharray
98422 +v4l2_ctrl_new_std_45748 v4l2_ctrl_new_std 5 45748 &rw_copy_check_uvector_45748
98423 +lkdtm_debugfs_read_45752 lkdtm_debugfs_read 3 45752 NULL
98424 +nilfs_compat_ioctl_45769 nilfs_compat_ioctl 3 45769 NULL
98425 +alloc_ts_config_45775 alloc_ts_config 1 45775 NULL
98426 +raw_setsockopt_45800 raw_setsockopt 5 45800 NULL
98427 +lbs_rdbbp_read_45805 lbs_rdbbp_read 3 45805 NULL
98428 +pcpu_alloc_alloc_info_45813 pcpu_alloc_alloc_info 1-2 45813 NULL
98429 +fm_v4l2_init_video_device_45821 fm_v4l2_init_video_device 2 45821 NULL
98430 +memcg_update_cache_size_45828 memcg_update_cache_size 2 45828 NULL
98431 +x509_process_extension_45854 x509_process_extension 5 45854 NULL
98432 +isdn_write_45863 isdn_write 3 45863 NULL
98433 +unpack_orig_pfns_45867 unpack_orig_pfns 0 45867 NULL
98434 +get_rdac_req_45882 get_rdac_req 3 45882 NULL
98435 +ocfs2_xattr_block_find_45891 ocfs2_xattr_block_find 0 45891 NULL
98436 +wm_adsp_region_to_reg_45915 wm_adsp_region_to_reg 0-2 45915 NULL
98437 +dbgfs_frame_45917 dbgfs_frame 3 45917 NULL
98438 +nf_nat_ftp_fmt_cmd_45926 nf_nat_ftp_fmt_cmd 0 45926 NULL
98439 +smp_scan_config_45934 smp_scan_config 1 45934 NULL
98440 +alloc_mr_45935 alloc_mr 1 45935 NULL
98441 +split_large_page_45941 split_large_page 2 45941 NULL
98442 +rb_simple_read_45972 rb_simple_read 3 45972 NULL
98443 +ezusb_writememory_45976 ezusb_writememory 4 45976 NULL
98444 +ioat2_dca_count_dca_slots_45984 ioat2_dca_count_dca_slots 0 45984 NULL
98445 +sierra_setup_urb_46029 sierra_setup_urb 5 46029 NULL
98446 +get_free_entries_46030 get_free_entries 1 46030 NULL
98447 +__access_remote_vm_46031 __access_remote_vm 0-5-3 46031 NULL
98448 +snd_emu10k1x_ptr_read_46049 snd_emu10k1x_ptr_read 0 46049 NULL
98449 +acpi_register_gsi_xen_hvm_46052 acpi_register_gsi_xen_hvm 2 46052 NULL
98450 +line6_midibuf_bytes_used_46059 line6_midibuf_bytes_used 0 46059 NULL
98451 +__ocfs2_move_extent_46060 __ocfs2_move_extent 5-6 46060 NULL nohasharray
98452 +dma_tx_errors_read_46060 dma_tx_errors_read 3 46060 &__ocfs2_move_extent_46060
98453 +slhc_toss_46066 slhc_toss 0 46066 NULL
98454 +sel_commit_bools_write_46077 sel_commit_bools_write 3 46077 NULL
98455 +vfio_config_do_rw_46091 vfio_config_do_rw 3 46091 NULL
98456 +ata_host_alloc_46094 ata_host_alloc 2 46094 NULL
98457 +arizona_set_irq_wake_46101 arizona_set_irq_wake 2 46101 NULL
98458 +pkt_ctl_compat_ioctl_46110 pkt_ctl_compat_ioctl 3 46110 NULL
98459 +memcg_update_array_size_46111 memcg_update_array_size 1 46111 NULL nohasharray
98460 +il3945_ucode_general_stats_read_46111 il3945_ucode_general_stats_read 3 46111 &memcg_update_array_size_46111
98461 +mlx4_ib_alloc_fast_reg_page_list_46119 mlx4_ib_alloc_fast_reg_page_list 2 46119 NULL
98462 +paging32_walk_addr_nested_46121 paging32_walk_addr_nested 3 46121 NULL
98463 +__netlink_change_ngroups_46156 __netlink_change_ngroups 2 46156 NULL
98464 +twl_direction_out_46182 twl_direction_out 2 46182 NULL
98465 +vxge_os_dma_malloc_46184 vxge_os_dma_malloc 2 46184 NULL
98466 +add_conn_list_46197 add_conn_list 3 46197 NULL
98467 +i2400m_op_msg_from_user_46213 i2400m_op_msg_from_user 4 46213 NULL
98468 +tm6000_i2c_recv_regs_46215 tm6000_i2c_recv_regs 5 46215 NULL
98469 +dsp_write_46218 dsp_write 2 46218 NULL
98470 +mpi_read_raw_data_46248 mpi_read_raw_data 2 46248 NULL
98471 +nf_nat_ftp_46265 nf_nat_ftp 6 46265 NULL
98472 +ReadReg_46277 ReadReg 0 46277 NULL
98473 +batadv_iv_ogm_queue_add_46319 batadv_iv_ogm_queue_add 3 46319 NULL
98474 +__hwahc_dev_set_key_46328 __hwahc_dev_set_key 5 46328 NULL
98475 +iwl_dbgfs_chain_noise_read_46355 iwl_dbgfs_chain_noise_read 3 46355 NULL
98476 +smk_write_direct_46363 smk_write_direct 3 46363 NULL
98477 +__iommu_calculate_agaw_46366 __iommu_calculate_agaw 2 46366 NULL
98478 +ubi_dump_flash_46381 ubi_dump_flash 4 46381 NULL
98479 +fuse_file_aio_write_46399 fuse_file_aio_write 4 46399 NULL
98480 +crypto_ablkcipher_reqsize_46411 crypto_ablkcipher_reqsize 0 46411 NULL
98481 +cp210x_set_config_46447 cp210x_set_config 4 46447 NULL
98482 +filldir64_46469 filldir64 3 46469 NULL
98483 +fill_in_write_vector_46498 fill_in_write_vector 0 46498 NULL
98484 +pin_code_reply_46510 pin_code_reply 4 46510 NULL
98485 +mthca_alloc_cq_buf_46512 mthca_alloc_cq_buf 3 46512 NULL
98486 +kmsg_read_46514 kmsg_read 3 46514 NULL
98487 +bdx_rxdb_create_46525 bdx_rxdb_create 1 46525 NULL
98488 +nl80211_send_rx_assoc_46538 nl80211_send_rx_assoc 4 46538 NULL
98489 +pm860x_irq_domain_map_46553 pm860x_irq_domain_map 2 46553 NULL
98490 +mv_get_hc_count_46554 mv_get_hc_count 0 46554 NULL
98491 +link_send_sections_long_46556 link_send_sections_long 4 46556 NULL
98492 +irq_domain_associate_46564 irq_domain_associate 2 46564 NULL
98493 +dn_current_mss_46574 dn_current_mss 0 46574 NULL
98494 +serverworks_create_gatt_pages_46582 serverworks_create_gatt_pages 1 46582 NULL
98495 +snd_compr_write_data_46592 snd_compr_write_data 3 46592 NULL
98496 +il3945_stats_flag_46606 il3945_stats_flag 0-3 46606 NULL
98497 +vscnprintf_46617 vscnprintf 0-2 46617 NULL
98498 +__kfifo_out_r_46623 __kfifo_out_r 0-3 46623 NULL
98499 +request_key_async_with_auxdata_46624 request_key_async_with_auxdata 4 46624 NULL
98500 +vfs_getxattr_alloc_46649 vfs_getxattr_alloc 0 46649 NULL
98501 +av7110_ipack_init_46655 av7110_ipack_init 2 46655 NULL
98502 +alloc_data_packet_46698 alloc_data_packet 1 46698 NULL
98503 +__ilog2_u32_46706 __ilog2_u32 0 46706 NULL
98504 +erst_dbg_write_46715 erst_dbg_write 3 46715 NULL
98505 +wl1271_rx_filter_alloc_field_46721 wl1271_rx_filter_alloc_field 5 46721 NULL
98506 +prepare_copy_46725 prepare_copy 2 46725 NULL
98507 +irq_domain_add_simple_46734 irq_domain_add_simple 2-3 46734 NULL
98508 +set_memory_wc_46747 set_memory_wc 1 46747 NULL
98509 +ext4_count_free_46754 ext4_count_free 2 46754 NULL nohasharray
98510 +pte_pfn_46754 pte_pfn 0 46754 &ext4_count_free_46754
98511 +hest_ghes_dev_register_46766 hest_ghes_dev_register 1 46766 NULL
98512 +int_hw_irq_en_46776 int_hw_irq_en 3 46776 NULL
98513 +regcache_lzo_sync_46777 regcache_lzo_sync 2 46777 NULL
98514 +_sys_packet_req_46793 _sys_packet_req 4 46793 NULL
98515 +_xfs_buf_get_pages_46811 _xfs_buf_get_pages 2 46811 NULL
98516 +xfs_iroot_realloc_46826 xfs_iroot_realloc 2 46826 NULL
98517 +shmem_pwrite_fast_46842 shmem_pwrite_fast 3 46842 NULL
98518 +spi_async_46857 spi_async 0 46857 NULL
98519 +vsnprintf_46863 vsnprintf 0 46863 NULL
98520 +nvme_alloc_queue_46865 nvme_alloc_queue 3 46865 NULL
98521 +sip_sprintf_addr_46872 sip_sprintf_addr 0 46872 NULL
98522 +rvmalloc_46873 rvmalloc 1 46873 NULL
98523 +qp_memcpy_from_queue_iov_46874 qp_memcpy_from_queue_iov 4-5 46874 NULL
98524 +hpi_read_word_nolock_46881 hpi_read_word_nolock 0 46881 NULL
98525 +stmpe_gpio_irq_unmap_46884 stmpe_gpio_irq_unmap 2 46884 NULL
98526 +ixgbe_dbg_reg_ops_write_46895 ixgbe_dbg_reg_ops_write 3 46895 NULL
98527 +sk_mem_pages_46896 sk_mem_pages 0-1 46896 NULL
98528 +ol_dqblk_off_46904 ol_dqblk_off 3-2 46904 NULL
98529 +ieee80211_if_fmt_power_mode_46906 ieee80211_if_fmt_power_mode 3 46906 NULL
98530 +wlcore_alloc_hw_46917 wlcore_alloc_hw 1 46917 NULL
98531 +fb_write_46924 fb_write 3 46924 NULL
98532 +btmrvl_curpsmode_read_46939 btmrvl_curpsmode_read 3 46939 NULL
98533 +kvm_register_read_46948 kvm_register_read 0 46948 NULL
98534 +__sctp_setsockopt_connectx_46949 __sctp_setsockopt_connectx 3 46949 NULL
98535 +qla4xxx_post_aen_work_46953 qla4xxx_post_aen_work 3 46953 NULL
98536 +crypto_tfm_alg_alignmask_46971 crypto_tfm_alg_alignmask 0 46971 NULL
98537 +mgmt_pending_add_46976 mgmt_pending_add 5 46976 NULL
98538 +gfs2_xattr_system_set_46996 gfs2_xattr_system_set 4 46996 NULL nohasharray
98539 +sel_write_bool_46996 sel_write_bool 3 46996 &gfs2_xattr_system_set_46996
98540 +ttm_bo_io_47000 ttm_bo_io 5 47000 NULL
98541 +blk_rq_map_kern_47004 blk_rq_map_kern 4 47004 NULL
98542 +__map_single_47020 __map_single 3-4-7 47020 NULL
98543 +cx231xx_init_bulk_47024 cx231xx_init_bulk 3-2 47024 NULL
98544 +swiotlb_sync_single_47031 swiotlb_sync_single 2 47031 NULL
98545 +set_dis_bypass_pfs_47038 set_dis_bypass_pfs 3 47038 NULL
98546 +fs_path_len_47060 fs_path_len 0 47060 NULL
98547 +ufs_new_fragments_47070 ufs_new_fragments 3-5-4 47070 NULL
98548 +pipeline_dec_packet_in_read_47076 pipeline_dec_packet_in_read 3 47076 NULL
98549 +scsi_deactivate_tcq_47086 scsi_deactivate_tcq 2 47086 NULL
98550 +mousedev_read_47123 mousedev_read 3 47123 NULL
98551 +ses_recv_diag_47143 ses_recv_diag 4 47143 NULL nohasharray
98552 +acpi_ut_initialize_buffer_47143 acpi_ut_initialize_buffer 2 47143 &ses_recv_diag_47143
98553 +persistent_ram_iomap_47156 persistent_ram_iomap 1-2 47156 NULL
98554 +mxms_headerlen_47161 mxms_headerlen 0 47161 NULL
98555 +rs_sta_dbgfs_rate_scale_data_read_47165 rs_sta_dbgfs_rate_scale_data_read 3 47165 NULL
98556 +rts51x_ms_rw_47171 rts51x_ms_rw 3-4 47171 NULL
98557 +svc_pool_map_alloc_arrays_47181 svc_pool_map_alloc_arrays 2 47181 NULL
98558 +can_set_system_xattr_47182 can_set_system_xattr 4 47182 NULL
98559 +ioremap_cache_47189 ioremap_cache 1-2 47189 NULL
98560 +gnttab_set_map_op_47206 gnttab_set_map_op 2 47206 NULL
98561 +l2headersize_47238 l2headersize 0 47238 NULL
98562 +options_write_47243 options_write 3 47243 NULL
98563 +portcntrs_1_read_47253 portcntrs_1_read 3 47253 NULL
98564 +da9052_disable_irq_nosync_47260 da9052_disable_irq_nosync 2 47260 NULL
98565 +ablkcipher_next_slow_47274 ablkcipher_next_slow 4-3 47274 NULL
98566 +tty_audit_log_47280 tty_audit_log 8 47280 NULL
98567 +gfs2_readpages_47285 gfs2_readpages 4 47285 NULL
98568 +vsnprintf_47291 vsnprintf 0 47291 NULL
98569 +tx_internal_desc_overflow_read_47300 tx_internal_desc_overflow_read 3 47300 NULL
98570 +ieee80211_if_read_dot11MeshHoldingTimeout_47356 ieee80211_if_read_dot11MeshHoldingTimeout 3 47356 NULL
98571 +avc_get_hash_stats_47359 avc_get_hash_stats 0 47359 NULL
98572 +find_first_zero_bit_le_47369 find_first_zero_bit_le 2 47369 NULL
98573 +__bio_map_kern_47379 __bio_map_kern 3 47379 NULL
98574 +nv_rd32_47390 nv_rd32 0 47390 NULL nohasharray
98575 +trace_options_core_read_47390 trace_options_core_read 3 47390 &nv_rd32_47390
98576 +nametbl_list_47391 nametbl_list 2 47391 NULL
98577 +dgrp_net_write_47392 dgrp_net_write 3 47392 NULL
98578 +pfkey_sendmsg_47394 pfkey_sendmsg 4 47394 NULL
98579 +gfn_to_pfn_prot_47398 gfn_to_pfn_prot 2 47398 NULL
98580 +ocfs2_resv_end_47408 ocfs2_resv_end 0 47408 NULL
98581 +crypto_ablkcipher_alignmask_47410 crypto_ablkcipher_alignmask 0 47410 NULL
98582 +vzalloc_47421 vzalloc 1 47421 NULL
98583 +posix_acl_from_disk_47445 posix_acl_from_disk 2 47445 NULL
98584 +__load_mapping_47460 __load_mapping 2 47460 NULL
98585 +wb_force_mapping_47485 wb_force_mapping 2 47485 NULL nohasharray
98586 +newpart_47485 newpart 6 47485 &wb_force_mapping_47485
98587 +core_sys_select_47494 core_sys_select 1 47494 NULL
98588 +unlink_simple_47506 unlink_simple 3 47506 NULL
98589 +ufs_inode_getblock_47512 ufs_inode_getblock 4 47512 NULL
98590 +vscnprintf_47533 vscnprintf 0-2 47533 NULL nohasharray
98591 +process_vm_rw_47533 process_vm_rw 3-5 47533 &vscnprintf_47533
98592 +oz_events_read_47535 oz_events_read 3 47535 NULL
98593 +ieee80211_if_fmt_min_discovery_timeout_47539 ieee80211_if_fmt_min_discovery_timeout 3 47539 NULL
98594 +read_ldt_47570 read_ldt 2 47570 NULL
98595 +pci_iomap_47575 pci_iomap 3 47575 NULL
98596 +rpipe_get_idx_47579 rpipe_get_idx 2 47579 NULL
98597 +ext4_kvzalloc_47605 ext4_kvzalloc 1 47605 NULL
98598 +sctp_ssnmap_new_47608 sctp_ssnmap_new 1-2 47608 NULL
98599 +uea_request_47613 uea_request 4 47613 NULL
98600 +cache_read_pipefs_47615 cache_read_pipefs 3 47615 NULL
98601 +twl4030_clear_set_47624 twl4030_clear_set 4 47624 NULL
98602 +irq_set_chip_47638 irq_set_chip 1 47638 NULL
98603 +__build_packet_message_47643 __build_packet_message 3-9 47643 NULL
98604 +save_microcode_47717 save_microcode 3 47717 NULL
98605 +bits_to_user_47733 bits_to_user 2-3 47733 NULL
98606 +carl9170_debugfs_read_47738 carl9170_debugfs_read 3 47738 NULL
98607 +ir_prepare_write_buffer_47747 ir_prepare_write_buffer 3 47747 NULL
98608 +mvumi_alloc_mem_resource_47750 mvumi_alloc_mem_resource 3 47750 NULL
98609 +ext3_find_near_47752 ext3_find_near 0 47752 NULL
98610 +alloc_sched_domains_47756 alloc_sched_domains 1 47756 NULL
98611 +i915_wedged_write_47771 i915_wedged_write 3 47771 NULL
98612 +uwb_ie_dump_hex_47774 uwb_ie_dump_hex 4 47774 NULL
98613 +error_error_numll_frame_cts_start_read_47781 error_error_numll_frame_cts_start_read 3 47781 NULL
98614 +posix_acl_fix_xattr_from_user_47793 posix_acl_fix_xattr_from_user 2 47793 NULL
98615 +stmmac_set_bfsize_47834 stmmac_set_bfsize 0 47834 NULL
98616 +ubifs_unpack_nnode_47866 ubifs_unpack_nnode 0 47866 NULL
98617 +vhci_read_47878 vhci_read 3 47878 NULL
98618 +keyctl_instantiate_key_common_47889 keyctl_instantiate_key_common 4 47889 NULL
98619 +load_mapping_47904 load_mapping 3 47904 NULL
98620 +osd_req_read_sg_47905 osd_req_read_sg 5 47905 NULL
98621 +comedi_write_47926 comedi_write 3 47926 NULL
98622 +lp8788_irq_map_47964 lp8788_irq_map 2 47964 NULL
98623 +iwl_dbgfs_ucode_tracing_read_47983 iwl_dbgfs_ucode_tracing_read 3 47983 NULL nohasharray
98624 +mempool_resize_47983 mempool_resize 2 47983 &iwl_dbgfs_ucode_tracing_read_47983
98625 +dbg_port_buf_47990 dbg_port_buf 2 47990 NULL
98626 +ib_umad_write_47993 ib_umad_write 3 47993 NULL
98627 +ffs_epfile_write_48014 ffs_epfile_write 3 48014 NULL
98628 +bio_integrity_set_tag_48035 bio_integrity_set_tag 3 48035 NULL
98629 +pppoe_sendmsg_48039 pppoe_sendmsg 4 48039 NULL
98630 +wpan_phy_alloc_48056 wpan_phy_alloc 1 48056 NULL
98631 +posix_acl_alloc_48063 posix_acl_alloc 1 48063 NULL
98632 +palmas_bulk_write_48068 palmas_bulk_write 2-3-5 48068 NULL
98633 +mmc_alloc_host_48097 mmc_alloc_host 1 48097 NULL
98634 +skb_copy_datagram_const_iovec_48102 skb_copy_datagram_const_iovec 4-2-5 48102 NULL
98635 +radio_isa_common_probe_48107 radio_isa_common_probe 3 48107 NULL
98636 +vmw_framebuffer_surface_dirty_48132 vmw_framebuffer_surface_dirty 6 48132 NULL
98637 +set_discoverable_48141 set_discoverable 4 48141 NULL
98638 +dn_fib_count_nhs_48145 dn_fib_count_nhs 0 48145 NULL
98639 +bitmap_onto_48152 bitmap_onto 4 48152 NULL
98640 +isr_dma1_done_read_48159 isr_dma1_done_read 3 48159 NULL
98641 +c4iw_id_table_alloc_48163 c4iw_id_table_alloc 3 48163 NULL
98642 +ocfs2_find_next_zero_bit_unaligned_48170 ocfs2_find_next_zero_bit_unaligned 2-3 48170 NULL
98643 +alloc_cc770dev_48186 alloc_cc770dev 1 48186 NULL
98644 +init_ipath_48187 init_ipath 1 48187 NULL
98645 +snd_seq_dump_var_event_48209 snd_seq_dump_var_event 0 48209 NULL
98646 +is_block_in_journal_48223 is_block_in_journal 3 48223 NULL
98647 +uv_blade_nr_possible_cpus_48226 uv_blade_nr_possible_cpus 0 48226 NULL
98648 +nilfs_readpages_48229 nilfs_readpages 4 48229 NULL
98649 +read_file_recv_48232 read_file_recv 3 48232 NULL
98650 +unaccount_shadowed_48233 unaccount_shadowed 2 48233 NULL
98651 +nfsctl_transaction_read_48250 nfsctl_transaction_read 3 48250 NULL
98652 +cache_write_pipefs_48270 cache_write_pipefs 3 48270 NULL
98653 +send_set_info_48288 send_set_info 7 48288 NULL
98654 +set_disc_pwup_pfs_48300 set_disc_pwup_pfs 3 48300 NULL
98655 +lpfc_idiag_extacc_read_48301 lpfc_idiag_extacc_read 3 48301 NULL
98656 +timblogiw_read_48305 timblogiw_read 3 48305 NULL
98657 +hash_setkey_48310 hash_setkey 3 48310 NULL
98658 +__alloc_fd_48356 __alloc_fd 2 48356 NULL
98659 +skb_add_data_48363 skb_add_data 3 48363 NULL
98660 +tx_frag_init_called_read_48377 tx_frag_init_called_read 3 48377 NULL
98661 +ixgbe_pci_sriov_enable_48410 ixgbe_pci_sriov_enable 2 48410 NULL
98662 +lbs_debugfs_write_48413 lbs_debugfs_write 3 48413 NULL
98663 +pwr_tx_without_ps_read_48423 pwr_tx_without_ps_read 3 48423 NULL
98664 +nfs4_alloc_pages_48426 nfs4_alloc_pages 1 48426 NULL
98665 +tun_recvmsg_48463 tun_recvmsg 4 48463 NULL
98666 +r8712_usbctrl_vendorreq_48489 r8712_usbctrl_vendorreq 6 48489 NULL
98667 +send_control_msg_48498 send_control_msg 6 48498 NULL
98668 +mlx4_en_create_tx_ring_48501 mlx4_en_create_tx_ring 4 48501 NULL
98669 +count_masked_bytes_48507 count_masked_bytes 0-1 48507 NULL
98670 +diva_os_copy_to_user_48508 diva_os_copy_to_user 4 48508 NULL
98671 +brcmf_sdio_trap_info_48510 brcmf_sdio_trap_info 4 48510 NULL
98672 +phantom_get_free_48514 phantom_get_free 0 48514 NULL
98673 +wiimote_hid_send_48528 wiimote_hid_send 3 48528 NULL
98674 +ext3_splice_branch_48531 ext3_splice_branch 6 48531 NULL
98675 +named_distribute_48544 named_distribute 4 48544 NULL
98676 +raid10_size_48571 raid10_size 0-2-3 48571 NULL
98677 +ufs_dtogd_48616 ufs_dtogd 0-2 48616 NULL
98678 +do_ip_vs_set_ctl_48641 do_ip_vs_set_ctl 4 48641 NULL
98679 +mtd_read_48655 mtd_read 0 48655 NULL
98680 +aes_encrypt_packets_read_48666 aes_encrypt_packets_read 3 48666 NULL
98681 +sm501_create_subdev_48668 sm501_create_subdev 3-4 48668 NULL nohasharray
98682 +sys_setgroups_48668 sys_setgroups 1 48668 &sm501_create_subdev_48668
98683 +altera_drscan_48698 altera_drscan 2 48698 NULL
98684 +kvm_set_irq_routing_48704 kvm_set_irq_routing 3 48704 NULL
98685 +ath6kl_usb_bmi_read_48745 ath6kl_usb_bmi_read 3 48745 NULL
98686 +ath6kl_regwrite_read_48747 ath6kl_regwrite_read 3 48747 NULL
98687 +l2cap_segment_sdu_48772 l2cap_segment_sdu 4 48772 NULL
98688 +lua_sysfs_write_48797 lua_sysfs_write 6 48797 NULL
98689 +il3945_sta_dbgfs_stats_table_read_48802 il3945_sta_dbgfs_stats_table_read 3 48802 NULL
98690 +twa_change_queue_depth_48808 twa_change_queue_depth 2 48808 NULL
98691 +atomic_counters_read_48827 atomic_counters_read 3 48827 NULL
98692 +efi_memory_uc_48828 efi_memory_uc 1 48828 NULL
98693 +azx_get_position_48841 azx_get_position 0 48841 NULL
98694 +vc_do_resize_48842 vc_do_resize 3-4 48842 NULL
98695 +viafb_dvp1_proc_write_48864 viafb_dvp1_proc_write 3 48864 NULL
98696 +__ffs_ep0_read_events_48868 __ffs_ep0_read_events 3 48868 NULL
98697 +sys_setgroups16_48882 sys_setgroups16 1 48882 NULL
98698 +ext2_alloc_branch_48889 ext2_alloc_branch 4 48889 NULL
98699 +crypto_cipher_ctxsize_48890 crypto_cipher_ctxsize 0 48890 NULL
98700 +xdi_copy_to_user_48900 xdi_copy_to_user 4 48900 NULL
98701 +msg_hdr_sz_48908 msg_hdr_sz 0 48908 NULL
98702 +gdth_isa_probe_one_48925 gdth_isa_probe_one 1 48925 NULL
98703 +sep_crypto_dma_48937 sep_crypto_dma 0 48937 NULL
98704 +event_heart_beat_read_48961 event_heart_beat_read 3 48961 NULL
98705 +nand_ecc_test_run_48966 nand_ecc_test_run 1 48966 NULL
98706 +vmci_handle_arr_create_48971 vmci_handle_arr_create 1 48971 NULL
98707 +batadv_orig_hash_del_if_48972 batadv_orig_hash_del_if 2 48972 NULL
98708 +_alloc_set_attr_list_48991 _alloc_set_attr_list 4 48991 NULL
98709 +rds_rm_size_48996 rds_rm_size 0-2 48996 NULL
98710 +sel_write_enforce_48998 sel_write_enforce 3 48998 NULL
98711 +transient_status_49027 transient_status 4 49027 NULL
98712 +ipath_reg_user_mr_49038 ipath_reg_user_mr 2-3 49038 NULL
98713 +setup_msi_irq_49052 setup_msi_irq 3-4 49052 NULL
98714 +ubi_read_49061 ubi_read 0 49061 NULL
98715 +scsi_register_49094 scsi_register 2 49094 NULL
98716 +paging64_walk_addr_nested_49100 paging64_walk_addr_nested 3 49100 NULL
98717 +compat_do_readv_writev_49102 compat_do_readv_writev 4 49102 NULL
98718 +xfrm_replay_state_esn_len_49119 xfrm_replay_state_esn_len 0 49119 NULL
98719 +pt_read_49136 pt_read 3 49136 NULL
98720 +tipc_multicast_49144 tipc_multicast 5 49144 NULL
98721 +atyfb_setup_generic_49151 atyfb_setup_generic 3 49151 NULL
98722 +ipwireless_tty_received_49154 ipwireless_tty_received 3 49154 NULL
98723 +f2fs_acl_count_49155 f2fs_acl_count 0-1 49155 NULL
98724 +ipw_queue_tx_init_49161 ipw_queue_tx_init 3 49161 NULL
98725 +ext4_free_clusters_after_init_49174 ext4_free_clusters_after_init 2 49174 NULL
98726 +dvb_dvr_ioctl_49182 dvb_dvr_ioctl 2 49182 NULL
98727 +iwl_dbgfs_ucode_general_stats_read_49199 iwl_dbgfs_ucode_general_stats_read 3 49199 NULL
98728 +il4965_rs_sta_dbgfs_stats_table_read_49206 il4965_rs_sta_dbgfs_stats_table_read 3 49206 NULL
98729 +do_jffs2_getxattr_49210 do_jffs2_getxattr 0 49210 NULL
98730 +nouveau_therm_create__49228 nouveau_therm_create_ 4 49228 NULL
98731 +nouveau_i2c_port_create__49237 nouveau_i2c_port_create_ 6 49237 NULL
98732 +hugetlb_cgroup_read_49259 hugetlb_cgroup_read 5 49259 NULL
98733 +ieee80211_if_read_rssi_threshold_49260 ieee80211_if_read_rssi_threshold 3 49260 NULL
98734 +osd_req_add_get_attr_list_49278 osd_req_add_get_attr_list 3 49278 NULL
98735 +rx_filter_beacon_filter_read_49279 rx_filter_beacon_filter_read 3 49279 NULL
98736 +uio_read_49300 uio_read 3 49300 NULL
98737 +ocfs2_resmap_find_free_bits_49301 ocfs2_resmap_find_free_bits 3 49301 NULL
98738 +fwtty_port_handler_49327 fwtty_port_handler 9 49327 NULL
98739 +srpt_alloc_ioctx_ring_49330 srpt_alloc_ioctx_ring 2-3-4 49330 NULL
98740 +cfpkt_setlen_49343 cfpkt_setlen 2 49343 NULL
98741 +joydev_ioctl_common_49359 joydev_ioctl_common 2 49359 NULL
98742 +ocfs2_remove_btree_range_49370 ocfs2_remove_btree_range 4-5-3 49370 NULL
98743 +px_raw_event_49371 px_raw_event 4 49371 NULL
98744 +iscsi_alloc_session_49390 iscsi_alloc_session 3 49390 NULL
98745 +applesmc_create_nodes_49392 applesmc_create_nodes 2 49392 NULL
98746 +rx_streaming_always_read_49401 rx_streaming_always_read 3 49401 NULL
98747 +tnode_alloc_49407 tnode_alloc 1 49407 NULL
98748 +samples_to_bytes_49426 samples_to_bytes 0-2 49426 NULL
98749 +md_domain_init_49432 md_domain_init 2 49432 NULL
98750 +compat_do_msg_fill_49440 compat_do_msg_fill 3 49440 NULL
98751 +agp_3_5_isochronous_node_enable_49465 agp_3_5_isochronous_node_enable 3 49465 NULL
98752 +xfs_iformat_local_49472 xfs_iformat_local 4 49472 NULL
98753 +savu_sysfs_read_49473 savu_sysfs_read 6 49473 NULL
98754 +isr_decrypt_done_read_49490 isr_decrypt_done_read 3 49490 NULL
98755 +emulator_write_phys_49520 emulator_write_phys 2-4 49520 NULL
98756 +acpi_os_ioremap_49523 acpi_os_ioremap 1-2 49523 NULL
98757 +smk_write_access_49561 smk_write_access 3 49561 NULL
98758 +ntfs_malloc_nofs_49572 ntfs_malloc_nofs 1 49572 NULL
98759 +alloc_chunk_49575 alloc_chunk 1 49575 NULL
98760 +sctp_setsockopt_default_send_param_49578 sctp_setsockopt_default_send_param 3 49578 NULL
98761 +isr_wakeups_read_49607 isr_wakeups_read 3 49607 NULL
98762 +btrfs_mksubvol_49616 btrfs_mksubvol 3 49616 NULL
98763 +heap_init_49617 heap_init 2 49617 NULL
98764 +smk_write_doi_49621 smk_write_doi 3 49621 NULL
98765 +btrfsic_cmp_log_and_dev_bytenr_49628 btrfsic_cmp_log_and_dev_bytenr 2 49628 NULL
98766 +aa_simple_write_to_buffer_49683 aa_simple_write_to_buffer 3-4 49683 NULL
98767 +sys_gethostname_49698 sys_gethostname 2 49698 NULL
98768 +cx2341x_ctrl_new_menu_49700 cx2341x_ctrl_new_menu 3 49700 NULL
98769 +dm_thin_insert_block_49720 dm_thin_insert_block 2-3 49720 NULL
98770 +sep_create_dcb_dmatables_context_kernel_49728 sep_create_dcb_dmatables_context_kernel 6 49728 NULL
98771 +sys_fsetxattr_49736 sys_fsetxattr 4 49736 NULL
98772 +check_frame_49741 check_frame 0 49741 NULL
98773 +zd_usb_iowrite16v_49744 zd_usb_iowrite16v 3 49744 NULL
98774 +btrfs_chunk_num_stripes_49751 btrfs_chunk_num_stripes 0 49751 NULL
98775 +fuse_wr_pages_49753 fuse_wr_pages 0-1-2 49753 NULL
98776 +key_conf_keylen_read_49758 key_conf_keylen_read 3 49758 NULL
98777 +fuse_conn_waiting_read_49762 fuse_conn_waiting_read 3 49762 NULL
98778 +isku_sysfs_write_49767 isku_sysfs_write 6 49767 NULL
98779 +ceph_osdc_readpages_49789 ceph_osdc_readpages 10-4 49789 NULL
98780 +nfs4_acl_new_49806 nfs4_acl_new 1 49806 NULL
98781 +arch_gnttab_map_status_49812 arch_gnttab_map_status 3 49812 NULL
98782 +ntfs_copy_from_user_iovec_49829 ntfs_copy_from_user_iovec 3-6-0 49829 NULL
98783 +add_uuid_49831 add_uuid 4 49831 NULL
98784 +ath6kl_fwlog_block_read_49836 ath6kl_fwlog_block_read 3 49836 NULL
98785 +twl4030_write_49846 twl4030_write 2 49846 NULL
98786 +scsi_dispatch_cmd_entry_49848 scsi_dispatch_cmd_entry 3 49848 NULL
98787 +timeradd_entry_49850 timeradd_entry 3 49850 NULL
98788 +sctp_setsockopt_bindx_49870 sctp_setsockopt_bindx 3 49870 NULL
98789 +ceph_get_caps_49890 ceph_get_caps 0 49890 NULL
98790 +__cow_file_range_49901 __cow_file_range 5 49901 NULL
98791 +__copy_from_user_inatomic_nocache_49921 __copy_from_user_inatomic_nocache 3 49921 NULL
98792 +batadv_tt_realloc_packet_buff_49960 batadv_tt_realloc_packet_buff 4 49960 NULL
98793 +b43legacy_pio_read_49978 b43legacy_pio_read 0 49978 NULL
98794 +ieee80211_if_fmt_dtim_count_49987 ieee80211_if_fmt_dtim_count 3 49987 NULL
98795 +l2cap_chan_send_49995 l2cap_chan_send 3 49995 NULL
98796 +__module_alloc_50004 __module_alloc 1 50004 NULL
98797 +dn_mss_from_pmtu_50011 dn_mss_from_pmtu 0-2 50011 NULL
98798 +ptrace_readdata_50020 ptrace_readdata 2-4 50020 NULL
98799 +isdn_read_50021 isdn_read 3 50021 NULL
98800 +qp_alloc_queue_50028 qp_alloc_queue 1 50028 NULL
98801 +alloc_ebda_hpc_50046 alloc_ebda_hpc 1-2 50046 NULL
98802 +vmw_surface_destroy_size_50072 vmw_surface_destroy_size 0 50072 NULL
98803 +arch_setup_ht_irq_50073 arch_setup_ht_irq 1 50073 NULL
98804 +dev_set_alias_50084 dev_set_alias 3 50084 NULL
98805 +pcpu_get_vm_areas_50085 pcpu_get_vm_areas 3 50085 NULL
98806 +sock_setsockopt_50088 sock_setsockopt 5 50088 NULL
98807 +altera_swap_dr_50090 altera_swap_dr 2 50090 NULL
98808 +read_file_slot_50111 read_file_slot 3 50111 NULL
98809 +copy_items_50140 copy_items 6 50140 NULL
98810 +tx_frag_need_fragmentation_read_50153 tx_frag_need_fragmentation_read 3 50153 NULL
98811 +set_cmd_header_50155 set_cmd_header 0 50155 NULL
98812 +reiserfs_bmap_count_50160 reiserfs_bmap_count 0 50160 NULL
98813 +aac_nark_ioremap_50163 aac_nark_ioremap 2 50163 NULL nohasharray
98814 +kmalloc_node_50163 kmalloc_node 1 50163 &aac_nark_ioremap_50163
98815 +rx_filter_ibss_filter_read_50167 rx_filter_ibss_filter_read 3 50167 NULL
98816 +odev_update_50169 odev_update 2 50169 NULL
98817 +ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172 ieee80211_if_fmt_dot11MeshHWMPRannInterval 3 50172 NULL nohasharray
98818 +ubi_resize_volume_50172 ubi_resize_volume 2 50172 &ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172
98819 +ib_send_cm_drep_50186 ib_send_cm_drep 3 50186 NULL
98820 +cfg80211_roamed_bss_50198 cfg80211_roamed_bss 4-6 50198 NULL
98821 +rx_rx_timeout_wa_read_50204 rx_rx_timeout_wa_read 3 50204 NULL
98822 +ieee80211_skb_resize_50211 ieee80211_skb_resize 3 50211 NULL
98823 +mon_bin_compat_ioctl_50234 mon_bin_compat_ioctl 3 50234 NULL
98824 +sg_kmalloc_50240 sg_kmalloc 1 50240 NULL
98825 +afs_extract_data_50261 afs_extract_data 5 50261 NULL
98826 +rxrpc_setsockopt_50286 rxrpc_setsockopt 5 50286 NULL
98827 +soc_codec_reg_show_50302 soc_codec_reg_show 0 50302 NULL
98828 +soc_camera_read_50319 soc_camera_read 3 50319 NULL
98829 +do_launder_page_50329 do_launder_page 0 50329 NULL
98830 +nouveau_engine_create__50331 nouveau_engine_create_ 7 50331 NULL
98831 +lpfc_idiag_pcicfg_read_50334 lpfc_idiag_pcicfg_read 3 50334 NULL
98832 +ocfs2_block_to_cluster_group_50337 ocfs2_block_to_cluster_group 2 50337 NULL nohasharray
98833 +snd_pcm_lib_writev_50337 snd_pcm_lib_writev 0-3 50337 &ocfs2_block_to_cluster_group_50337
98834 +roccat_common2_send_with_status_50343 roccat_common2_send_with_status 4 50343 NULL
98835 +tpm_read_50344 tpm_read 3 50344 NULL
98836 +kvm_arch_create_memslot_50354 kvm_arch_create_memslot 2 50354 NULL
98837 +isdn_ppp_read_50356 isdn_ppp_read 4 50356 NULL
98838 +unpack_u16_chunk_50357 unpack_u16_chunk 0 50357 NULL
98839 +xfrm_send_migrate_50365 xfrm_send_migrate 5 50365 NULL
98840 +roccat_common2_receive_50369 roccat_common2_receive 4 50369 NULL
98841 +sl_alloc_bufs_50380 sl_alloc_bufs 2 50380 NULL
98842 +l2tp_ip_sendmsg_50411 l2tp_ip_sendmsg 4 50411 NULL
98843 +iscsi_create_conn_50425 iscsi_create_conn 2 50425 NULL
98844 +validate_acl_mac_addrs_50429 validate_acl_mac_addrs 0 50429 NULL
98845 +btrfs_error_discard_extent_50444 btrfs_error_discard_extent 2 50444 NULL
98846 +pgctrl_write_50453 pgctrl_write 3 50453 NULL
98847 +force_mapping_50464 force_mapping 2 50464 NULL
98848 +cdrom_read_cdda_50478 cdrom_read_cdda 4 50478 NULL
98849 +mei_io_cb_alloc_req_buf_50493 mei_io_cb_alloc_req_buf 2 50493 NULL
98850 +pwr_rcvd_awake_beacons_read_50505 pwr_rcvd_awake_beacons_read 3 50505 NULL
98851 +fwnet_receive_packet_50537 fwnet_receive_packet 9 50537 NULL
98852 +ath6kl_set_ap_probe_resp_ies_50539 ath6kl_set_ap_probe_resp_ies 3 50539 NULL
98853 +hme_read_desc32_50574 hme_read_desc32 0 50574 NULL
98854 +fat_readpages_50582 fat_readpages 4 50582 NULL
98855 +iwl_dbgfs_missed_beacon_read_50584 iwl_dbgfs_missed_beacon_read 3 50584 NULL
98856 +build_inv_iommu_pages_50589 build_inv_iommu_pages 2-3 50589 NULL
98857 +rx_rx_checksum_result_read_50617 rx_rx_checksum_result_read 3 50617 NULL
98858 +__ffs_50625 __ffs 0 50625 NULL
98859 +simple_transaction_get_50633 simple_transaction_get 3 50633 NULL
98860 +ath6kl_tm_rx_event_50664 ath6kl_tm_rx_event 3 50664 NULL nohasharray
98861 +sys_readv_50664 sys_readv 3 50664 &ath6kl_tm_rx_event_50664
98862 +bnad_debugfs_read_50665 bnad_debugfs_read 3 50665 NULL
98863 +ext2_try_to_allocate_with_rsv_50669 ext2_try_to_allocate_with_rsv 4-2 50669 NULL
98864 +btmrvl_psstate_read_50683 btmrvl_psstate_read 3 50683 NULL
98865 +swiotlb_free_coherent_50690 swiotlb_free_coherent 4 50690 NULL
98866 +paging32_gva_to_gpa_50696 paging32_gva_to_gpa 2 50696 NULL
98867 +xfs_growfs_get_hdr_buf_50697 xfs_growfs_get_hdr_buf 3 50697 NULL
98868 +blk_check_plugged_50736 blk_check_plugged 3 50736 NULL
98869 +__ext3_get_inode_loc_50744 __ext3_get_inode_loc 0 50744 NULL
98870 +skb_padto_50759 skb_padto 2 50759 NULL
98871 +ocfs2_xattr_block_get_50773 ocfs2_xattr_block_get 0 50773 NULL
98872 +tm6000_read_write_usb_50774 tm6000_read_write_usb 7 50774 NULL
98873 +bio_alloc_map_data_50782 bio_alloc_map_data 1-2 50782 NULL
98874 +tpm_write_50798 tpm_write 3 50798 NULL
98875 +write_flush_50803 write_flush 3 50803 NULL
98876 +dvb_play_50814 dvb_play 3 50814 NULL
98877 +dpcm_show_state_50827 dpcm_show_state 0 50827 NULL
98878 +acpi_ev_install_gpe_block_50829 acpi_ev_install_gpe_block 2 50829 NULL
98879 +SetArea_50835 SetArea 4 50835 NULL nohasharray
98880 +create_mem_extents_50835 create_mem_extents 0 50835 &SetArea_50835
98881 +videobuf_dma_init_user_50839 videobuf_dma_init_user 3 50839 NULL
98882 +self_check_write_50856 self_check_write 5 50856 NULL
98883 +carl9170_debugfs_write_50857 carl9170_debugfs_write 3 50857 NULL
98884 +netlbl_secattr_catmap_walk_rng_50894 netlbl_secattr_catmap_walk_rng 0-2 50894 NULL
98885 +osd_req_write_sg_50908 osd_req_write_sg 5 50908 NULL
98886 +xfs_iext_remove_50909 xfs_iext_remove 3 50909 NULL
98887 +blk_rq_cur_sectors_50910 blk_rq_cur_sectors 0 50910 NULL
98888 +hash_recvmsg_50924 hash_recvmsg 4 50924 NULL
98889 +chd_dec_fetch_cdata_50926 chd_dec_fetch_cdata 3 50926 NULL
98890 +ocfs2_add_refcount_flag_50952 ocfs2_add_refcount_flag 6 50952 NULL
98891 +iwl_statistics_flag_50981 iwl_statistics_flag 0-3 50981 NULL
98892 +timeout_write_50991 timeout_write 3 50991 NULL
98893 +wm831x_irq_map_50995 wm831x_irq_map 2 50995 NULL
98894 +proc_write_51003 proc_write 3 51003 NULL
98895 +snd_pcm_default_page_ops_51021 snd_pcm_default_page_ops 2 51021 NULL
98896 +lbs_dev_info_51023 lbs_dev_info 3 51023 NULL
98897 +ntfs_attr_find_51028 ntfs_attr_find 0 51028 NULL nohasharray
98898 +fuse_conn_congestion_threshold_read_51028 fuse_conn_congestion_threshold_read 3 51028 &ntfs_attr_find_51028
98899 +BcmGetSectionValEndOffset_51039 BcmGetSectionValEndOffset 0 51039 NULL
98900 +dump_midi_51040 dump_midi 3 51040 NULL
98901 +srpt_alloc_ioctx_51042 srpt_alloc_ioctx 2-3 51042 NULL
98902 +do_arpt_set_ctl_51053 do_arpt_set_ctl 4 51053 NULL
98903 +wusb_prf_64_51065 wusb_prf_64 7 51065 NULL
98904 +jbd2_journal_init_revoke_51088 jbd2_journal_init_revoke 2 51088 NULL
98905 +__ocfs2_find_path_51096 __ocfs2_find_path 0 51096 NULL
98906 +ti_recv_51110 ti_recv 3 51110 NULL
98907 +dgrp_net_read_51113 dgrp_net_read 3 51113 NULL
98908 +nfs_map_name_to_uid_51132 nfs_map_name_to_uid 3 51132 NULL
98909 +alloc_rtllib_51136 alloc_rtllib 1 51136 NULL
98910 +simple_xattr_set_51140 simple_xattr_set 4 51140 NULL
98911 +set_dirty_51144 set_dirty 3 51144 NULL
98912 +xfs_trans_get_efd_51148 xfs_trans_get_efd 3 51148 NULL
98913 +compat_sys_pwritev64_51151 compat_sys_pwritev64 3 51151 NULL
98914 +blk_bio_map_sg_51213 blk_bio_map_sg 0 51213 NULL
98915 +nf_ct_ext_create_51232 nf_ct_ext_create 3 51232 NULL
98916 +snd_pcm_write_51235 snd_pcm_write 3 51235 NULL
98917 +tipc_send_51238 tipc_send 4 51238 NULL
98918 +drm_property_create_51239 drm_property_create 4 51239 NULL
98919 +st_read_51251 st_read 3 51251 NULL
98920 +compat_dccp_setsockopt_51263 compat_dccp_setsockopt 5 51263 NULL
98921 +dvb_audio_write_51275 dvb_audio_write 3 51275 NULL
98922 +ipwireless_network_packet_received_51277 ipwireless_network_packet_received 4 51277 NULL
98923 +zone_reclaimable_pages_51283 zone_reclaimable_pages 0 51283 NULL
98924 +pvr2_std_id_to_str_51288 pvr2_std_id_to_str 2 51288 NULL
98925 +bnad_debugfs_read_regrd_51308 bnad_debugfs_read_regrd 3 51308 NULL
98926 +get_cell_51316 get_cell 2 51316 NULL
98927 +alloc_hippi_dev_51320 alloc_hippi_dev 1 51320 NULL
98928 +ext2_xattr_get_51327 ext2_xattr_get 0 51327 NULL
98929 +alloc_smp_req_51337 alloc_smp_req 1 51337 NULL nohasharray
98930 +compat_arch_ptrace_51337 compat_arch_ptrace 3-4 51337 &alloc_smp_req_51337
98931 +ipw_get_event_log_len_51341 ipw_get_event_log_len 0 51341 NULL
98932 +ieee80211_if_fmt_estab_plinks_51370 ieee80211_if_fmt_estab_plinks 3 51370 NULL
98933 +radeon_kms_compat_ioctl_51371 radeon_kms_compat_ioctl 2 51371 NULL
98934 +ieee80211_wx_set_gen_ie_51399 ieee80211_wx_set_gen_ie 3 51399 NULL
98935 +ceph_sync_read_51410 ceph_sync_read 3 51410 NULL
98936 +x86_swiotlb_free_coherent_51421 x86_swiotlb_free_coherent 4 51421 NULL
98937 +blk_register_region_51424 blk_register_region 1-2 51424 NULL
98938 +mwifiex_rdeeprom_read_51429 mwifiex_rdeeprom_read 3 51429 NULL
98939 +ieee80211_if_read_dot11MeshHWMPRootMode_51441 ieee80211_if_read_dot11MeshHWMPRootMode 3 51441 NULL
98940 +print_devstats_dot11ACKFailureCount_51443 print_devstats_dot11ACKFailureCount 3 51443 NULL
98941 +____alloc_ei_netdev_51475 ____alloc_ei_netdev 1 51475 NULL
98942 +xfs_buf_get_uncached_51477 xfs_buf_get_uncached 2 51477 NULL
98943 +vaddr_51480 vaddr 0 51480 NULL
98944 +__cpa_process_fault_51502 __cpa_process_fault 2 51502 NULL
98945 +ieee80211_if_write_uapsd_queues_51526 ieee80211_if_write_uapsd_queues 3 51526 NULL
98946 +load_pdptrs_51541 load_pdptrs 3 51541 NULL
98947 +__alloc_eip_netdev_51549 __alloc_eip_netdev 1 51549 NULL
98948 +icmp_manip_pkt_51560 icmp_manip_pkt 4 51560 NULL
98949 +ixgb_get_eeprom_len_51586 ixgb_get_eeprom_len 0 51586 NULL
98950 +aac_convert_sgraw2_51598 aac_convert_sgraw2 4 51598 NULL
98951 +raw_ioctl_51607 raw_ioctl 3 51607 NULL
98952 +table_size_to_number_of_entries_51613 table_size_to_number_of_entries 0-1 51613 NULL
98953 +gnttab_end_foreign_access_51617 gnttab_end_foreign_access 3 51617 NULL
98954 +dns_resolve_server_name_to_ip_51632 dns_resolve_server_name_to_ip 0 51632 NULL
98955 +sctp_auth_create_key_51641 sctp_auth_create_key 1 51641 NULL
98956 +iscsi_create_session_51647 iscsi_create_session 3 51647 NULL
98957 +get_new_cssid_51665 get_new_cssid 2 51665 NULL
98958 +ps_upsd_utilization_read_51669 ps_upsd_utilization_read 3 51669 NULL
98959 +sctp_setsockopt_associnfo_51684 sctp_setsockopt_associnfo 3 51684 NULL
98960 +sfi_sysfs_install_table_51688 sfi_sysfs_install_table 1 51688 NULL
98961 +host_mapping_level_51696 host_mapping_level 2 51696 NULL
98962 +sel_write_access_51704 sel_write_access 3 51704 NULL
98963 +tty_cdev_add_51714 tty_cdev_add 2-4 51714 NULL
98964 +v9fs_alloc_rdir_buf_51716 v9fs_alloc_rdir_buf 2 51716 NULL
98965 +drm_compat_ioctl_51717 drm_compat_ioctl 2 51717 NULL
98966 +sg_read_oxfer_51724 sg_read_oxfer 3 51724 NULL
98967 +hid_parse_report_51737 hid_parse_report 3 51737 NULL
98968 +get_user_pages_fast_51751 get_user_pages_fast 0-1-2 51751 NULL
98969 +ifx_spi_insert_flip_string_51752 ifx_spi_insert_flip_string 3 51752 NULL
98970 +if_write_51756 if_write 3 51756 NULL
98971 +ioremap_prot_51764 ioremap_prot 1-2 51764 NULL
98972 +iio_buffer_add_channel_sysfs_51766 iio_buffer_add_channel_sysfs 0 51766 NULL
98973 +qib_alloc_devdata_51819 qib_alloc_devdata 2 51819 NULL
98974 +buffer_from_user_51826 buffer_from_user 3 51826 NULL
98975 +ioread32_51847 ioread32 0 51847 NULL nohasharray
98976 +read_file_tgt_tx_stats_51847 read_file_tgt_tx_stats 3 51847 &ioread32_51847
98977 +do_readv_writev_51849 do_readv_writev 4 51849 NULL
98978 +pointer_size_read_51863 pointer_size_read 3 51863 NULL
98979 +mlx4_alloc_db_from_pgdir_51865 mlx4_alloc_db_from_pgdir 3 51865 NULL
98980 +get_indirect_ea_51869 get_indirect_ea 4 51869 NULL
98981 +user_read_51881 user_read 3 51881 NULL
98982 +memblock_alloc_51884 memblock_alloc 1-2 51884 NULL
98983 +dbAdjCtl_51888 dbAdjCtl 0 51888 NULL
98984 +virt_to_phys_51896 virt_to_phys 0 51896 NULL
98985 +wmi_set_ie_51919 wmi_set_ie 3 51919 NULL
98986 +dbg_status_buf_51930 dbg_status_buf 2 51930 NULL
98987 +__tcp_mtu_to_mss_51938 __tcp_mtu_to_mss 0-2 51938 NULL
98988 +xfrm_alg_len_51940 xfrm_alg_len 0 51940 NULL
98989 +irq_dispose_mapping_51941 irq_dispose_mapping 1 51941 NULL
98990 +scsi_get_vpd_page_51951 scsi_get_vpd_page 4 51951 NULL
98991 +arizona_free_irq_51969 arizona_free_irq 2 51969 NULL nohasharray
98992 +snd_mask_min_51969 snd_mask_min 0 51969 &arizona_free_irq_51969
98993 +ath6kl_sdio_alloc_prep_scat_req_51986 ath6kl_sdio_alloc_prep_scat_req 2 51986 NULL
98994 +skb_copy_datagram_from_iovec_52014 skb_copy_datagram_from_iovec 4-2-5 52014 NULL
98995 +rdmalt_52022 rdmalt 0 52022 NULL
98996 +vxge_rx_alloc_52024 vxge_rx_alloc 3 52024 NULL
98997 +override_release_52032 override_release 2 52032 NULL
98998 +end_port_52042 end_port 0 52042 NULL
98999 +dma_rx_errors_read_52045 dma_rx_errors_read 3 52045 NULL
99000 +msnd_fifo_write_52052 msnd_fifo_write 0-3 52052 NULL
99001 +dvb_ringbuffer_avail_52057 dvb_ringbuffer_avail 0 52057 NULL
99002 +__fuse_request_alloc_52060 __fuse_request_alloc 1 52060 NULL
99003 +isofs_readpages_52067 isofs_readpages 4 52067 NULL
99004 +nsm_get_handle_52089 nsm_get_handle 4 52089 NULL
99005 +o2net_debug_read_52105 o2net_debug_read 3 52105 NULL
99006 +retry_count_read_52129 retry_count_read 3 52129 NULL
99007 +zram_meta_alloc_52140 zram_meta_alloc 1 52140 NULL
99008 +hysdn_conf_write_52145 hysdn_conf_write 3 52145 NULL nohasharray
99009 +ext2_alloc_blocks_52145 ext2_alloc_blocks 2 52145 &hysdn_conf_write_52145
99010 +htable_size_52148 htable_size 0-1 52148 NULL
99011 +__le16_to_cpup_52155 __le16_to_cpup 0 52155 NULL nohasharray
99012 +smk_write_load2_52155 smk_write_load2 3 52155 &__le16_to_cpup_52155
99013 +alix_present_52165 alix_present 1 52165 NULL
99014 +ieee80211_if_read_dot11MeshRetryTimeout_52168 ieee80211_if_read_dot11MeshRetryTimeout 3 52168 NULL
99015 +mga_compat_ioctl_52170 mga_compat_ioctl 2 52170 NULL
99016 +print_prefix_52176 print_prefix 0 52176 NULL
99017 +proc_pid_readlink_52186 proc_pid_readlink 3 52186 NULL
99018 +vmci_qp_broker_alloc_52216 vmci_qp_broker_alloc 5-6 52216 NULL
99019 +do_dmabuf_dirty_ldu_52241 do_dmabuf_dirty_ldu 6 52241 NULL
99020 +fuse_request_alloc_52243 fuse_request_alloc 1 52243 NULL
99021 +pm80x_request_irq_52250 pm80x_request_irq 2 52250 NULL
99022 +mdiobus_alloc_size_52259 mdiobus_alloc_size 1 52259 NULL
99023 +shrink_slab_52261 shrink_slab 2-3 52261 NULL
99024 +hva_to_pfn_slow_52262 hva_to_pfn_slow 1 52262 NULL
99025 +sisusbcon_do_font_op_52271 sisusbcon_do_font_op 9 52271 NULL
99026 +ath6kl_wmi_get_new_buf_52304 ath6kl_wmi_get_new_buf 1 52304 NULL
99027 +read_file_reset_52310 read_file_reset 3 52310 NULL
99028 +request_asymmetric_key_52317 request_asymmetric_key 2-4 52317 NULL
99029 +hwflags_read_52318 hwflags_read 3 52318 NULL
99030 +ntfs_rl_split_52328 ntfs_rl_split 2-4 52328 NULL
99031 +test_unaligned_bulk_52333 test_unaligned_bulk 3 52333 NULL
99032 +bytes_to_frames_52362 bytes_to_frames 0-2 52362 NULL
99033 +copy_entries_to_user_52367 copy_entries_to_user 1 52367 NULL
99034 +mq_emit_config_values_52378 mq_emit_config_values 3 52378 NULL
99035 +isdn_writebuf_stub_52383 isdn_writebuf_stub 4 52383 NULL
99036 +jfs_setxattr_52389 jfs_setxattr 4 52389 NULL
99037 +aer_inject_write_52399 aer_inject_write 3 52399 NULL
99038 +aac_rx_ioremap_52410 aac_rx_ioremap 2 52410 NULL
99039 +cgroup_file_write_52417 cgroup_file_write 3 52417 NULL
99040 +line6_midibuf_init_52425 line6_midibuf_init 2 52425 NULL
99041 +delay_status_52431 delay_status 5 52431 NULL
99042 +ieee80211_if_fmt_num_sta_ps_52438 ieee80211_if_fmt_num_sta_ps 3 52438 NULL
99043 +nl80211_send_mgmt_tx_status_52445 nl80211_send_mgmt_tx_status 5 52445 NULL
99044 +ieee80211_alloc_txb_52477 ieee80211_alloc_txb 1-2 52477 NULL
99045 +ocfs2_extend_no_holes_52483 ocfs2_extend_no_holes 3-4 52483 NULL
99046 +fd_do_rw_52495 fd_do_rw 3 52495 NULL nohasharray
99047 +skb_cow_head_52495 skb_cow_head 2 52495 &fd_do_rw_52495
99048 +qib_user_sdma_pin_pages_52498 qib_user_sdma_pin_pages 3-5 52498 NULL
99049 +int_tasklet_entry_52500 int_tasklet_entry 3 52500 NULL
99050 +pm_qos_power_write_52513 pm_qos_power_write 3 52513 NULL
99051 +dup_variable_bug_52525 dup_variable_bug 3 52525 NULL
99052 +from_oblock_52546 from_oblock 0-1 52546 NULL
99053 +dccpprobe_read_52549 dccpprobe_read 3 52549 NULL
99054 +ocfs2_make_right_split_rec_52562 ocfs2_make_right_split_rec 3 52562 NULL
99055 +emit_code_52583 emit_code 0-3 52583 NULL
99056 +tps80031_writes_52638 tps80031_writes 3-4 52638 NULL
99057 +brcmf_sdio_assert_info_52653 brcmf_sdio_assert_info 4 52653 NULL
99058 +nvd0_disp_pioc_create__52693 nvd0_disp_pioc_create_ 5 52693 NULL
99059 +nouveau_client_create__52715 nouveau_client_create_ 5 52715 NULL
99060 +cx25840_ir_rx_read_52724 cx25840_ir_rx_read 3 52724 NULL
99061 +blkcipher_next_slow_52733 blkcipher_next_slow 3-4 52733 NULL
99062 +relay_alloc_page_array_52735 relay_alloc_page_array 1 52735 NULL
99063 +carl9170_debugfs_vif_dump_read_52755 carl9170_debugfs_vif_dump_read 3 52755 NULL
99064 +copy_ctr_args_52761 copy_ctr_args 2 52761 NULL
99065 +pwr_rcvd_beacons_read_52836 pwr_rcvd_beacons_read 3 52836 NULL
99066 +ext2_xattr_set_acl_52857 ext2_xattr_set_acl 4 52857 NULL
99067 +mon_bin_get_event_52863 mon_bin_get_event 4 52863 NULL
99068 +twlreg_write_52880 twlreg_write 3 52880 NULL
99069 +pvr2_ctrl_value_to_sym_internal_52881 pvr2_ctrl_value_to_sym_internal 5 52881 NULL
99070 +cache_read_procfs_52882 cache_read_procfs 3 52882 NULL
99071 +kvm_kvzalloc_52894 kvm_kvzalloc 1 52894 NULL
99072 +arizona_request_irq_52908 arizona_request_irq 2 52908 NULL
99073 +__kfifo_out_peek_r_52919 __kfifo_out_peek_r 3 52919 NULL
99074 +iblock_get_bio_52936 iblock_get_bio 3 52936 NULL nohasharray
99075 +__iio_device_attr_init_52936 __iio_device_attr_init 0 52936 &iblock_get_bio_52936
99076 +__nodes_remap_52951 __nodes_remap 5 52951 NULL
99077 +send_packet_52960 send_packet 4 52960 NULL
99078 +ieee80211_if_fmt_fwded_mcast_52961 ieee80211_if_fmt_fwded_mcast 3 52961 NULL
99079 +hx8357_spi_write_then_read_52964 hx8357_spi_write_then_read 3 52964 NULL nohasharray
99080 +compat_sock_ioctl_52964 compat_sock_ioctl 3 52964 &hx8357_spi_write_then_read_52964
99081 +tx_tx_exch_read_52986 tx_tx_exch_read 3 52986 NULL
99082 +num_node_state_52989 num_node_state 0 52989 NULL
99083 +batadv_check_management_packet_52993 batadv_check_management_packet 3 52993 NULL
99084 +efivarfs_file_write_53000 efivarfs_file_write 3 53000 NULL
99085 +btrfs_free_and_pin_reserved_extent_53016 btrfs_free_and_pin_reserved_extent 2 53016 NULL
99086 +tx_tx_exch_pending_read_53018 tx_tx_exch_pending_read 3 53018 NULL
99087 +ext4_meta_bg_first_group_53031 ext4_meta_bg_first_group 0-2 53031 NULL
99088 +bio_cur_bytes_53037 bio_cur_bytes 0 53037 NULL
99089 +regcache_lzo_block_count_53056 regcache_lzo_block_count 0 53056 NULL
99090 +cfi_read_query_53066 cfi_read_query 0 53066 NULL
99091 +mwifiex_debug_read_53074 mwifiex_debug_read 3 53074 NULL
99092 +qib_resize_cq_53090 qib_resize_cq 2 53090 NULL
99093 +verity_status_53120 verity_status 5 53120 NULL
99094 +brcmf_usb_dl_cmd_53130 brcmf_usb_dl_cmd 4 53130 NULL
99095 +ps_poll_ps_poll_max_ap_turn_read_53140 ps_poll_ps_poll_max_ap_turn_read 3 53140 NULL
99096 +ieee80211_bss_info_update_53170 ieee80211_bss_info_update 4 53170 NULL
99097 +clear_capture_buf_53192 clear_capture_buf 2 53192 NULL
99098 +mtdoops_erase_block_53206 mtdoops_erase_block 2 53206 NULL
99099 +fixup_user_fault_53210 fixup_user_fault 3 53210 NULL
99100 +tx_tx_start_data_read_53219 tx_tx_start_data_read 3 53219 NULL
99101 +rbd_obj_method_sync_53252 rbd_obj_method_sync 8 53252 NULL
99102 +xfs_trans_read_buf_map_53258 xfs_trans_read_buf_map 5 53258 NULL
99103 +wil_write_file_ssid_53266 wil_write_file_ssid 3 53266 NULL
99104 +btrfs_file_extent_num_bytes_53269 btrfs_file_extent_num_bytes 0 53269 NULL
99105 +batadv_interface_rx_53325 batadv_interface_rx 4 53325 NULL
99106 +gsm_control_reply_53333 gsm_control_reply 4 53333 NULL
99107 +vm_mmap_53339 vm_mmap 0 53339 NULL
99108 +sock_setbindtodevice_53369 sock_setbindtodevice 3 53369 NULL
99109 +get_random_bytes_arch_53370 get_random_bytes_arch 2 53370 NULL
99110 +iwl_pcie_txq_alloc_53413 iwl_pcie_txq_alloc 3 53413 NULL
99111 +isr_cmd_cmplt_read_53439 isr_cmd_cmplt_read 3 53439 NULL
99112 +mwifiex_info_read_53447 mwifiex_info_read 3 53447 NULL
99113 +apei_exec_run_optional_53452 apei_exec_run_optional 0 53452 NULL
99114 +acpi_tb_parse_root_table_53455 acpi_tb_parse_root_table 1 53455 NULL
99115 +n2_run_53459 n2_run 3 53459 NULL
99116 +paging64_prefetch_gpte_53468 paging64_prefetch_gpte 4 53468 NULL
99117 +rds_tcp_data_recv_53476 rds_tcp_data_recv 3 53476 NULL
99118 +iowarrior_read_53483 iowarrior_read 3 53483 NULL
99119 +osd_req_write_kern_53486 osd_req_write_kern 5 53486 NULL
99120 +do_verify_xattr_datum_53499 do_verify_xattr_datum 0 53499 NULL
99121 +snd_pcm_format_physical_width_53505 snd_pcm_format_physical_width 0 53505 NULL
99122 +dbAllocNext_53506 dbAllocNext 0 53506 NULL
99123 +ocfs2_xattr_set_acl_53508 ocfs2_xattr_set_acl 4 53508 NULL
99124 +check_acl_53512 check_acl 0 53512 NULL
99125 +alloc_pages_exact_nid_53515 alloc_pages_exact_nid 2 53515 NULL
99126 +set_registers_53582 set_registers 3 53582 NULL
99127 +cifs_utf16_bytes_53593 cifs_utf16_bytes 0 53593 NULL
99128 +gfn_to_pfn_async_53597 gfn_to_pfn_async 2 53597 NULL
99129 +___alloc_bootmem_nopanic_53626 ___alloc_bootmem_nopanic 1-2 53626 NULL
99130 +xd_write_multiple_pages_53633 xd_write_multiple_pages 6-5 53633 NULL
99131 +ccid_getsockopt_builtin_ccids_53634 ccid_getsockopt_builtin_ccids 2 53634 NULL
99132 +nr_sendmsg_53656 nr_sendmsg 4 53656 NULL
99133 +_preload_range_53676 _preload_range 2-3 53676 NULL
99134 +fuse_fill_write_pages_53682 fuse_fill_write_pages 4 53682 NULL
99135 +v4l2_event_subscribe_53687 v4l2_event_subscribe 3 53687 NULL
99136 +bdev_logical_block_size_53690 bdev_logical_block_size 0 53690 NULL nohasharray
99137 +igb_alloc_q_vector_53690 igb_alloc_q_vector 4-6 53690 &bdev_logical_block_size_53690
99138 +find_overflow_devnum_53711 find_overflow_devnum 0 53711 NULL
99139 +bio_integrity_split_53714 bio_integrity_split 3 53714 NULL
99140 +__ocfs2_resv_find_window_53721 __ocfs2_resv_find_window 3 53721 NULL
99141 +wdm_write_53735 wdm_write 3 53735 NULL
99142 +ext3_try_to_allocate_with_rsv_53737 ext3_try_to_allocate_with_rsv 5-3 53737 NULL
99143 +da9052_disable_irq_53745 da9052_disable_irq 2 53745 NULL
99144 +lpfc_idiag_queacc_read_qe_53755 lpfc_idiag_queacc_read_qe 0-2 53755 NULL nohasharray
99145 +amdtp_out_stream_get_max_payload_53755 amdtp_out_stream_get_max_payload 0 53755 &lpfc_idiag_queacc_read_qe_53755
99146 +ext2_acl_count_53773 ext2_acl_count 0-1 53773 NULL
99147 +__kfifo_dma_in_prepare_r_53792 __kfifo_dma_in_prepare_r 4-5 53792 NULL
99148 +qp_alloc_host_work_53798 qp_alloc_host_work 3-5 53798 NULL
99149 +__tty_alloc_driver_53799 __tty_alloc_driver 1 53799 NULL
99150 +regmap_raw_write_53803 regmap_raw_write 2-4 53803 NULL
99151 +lpfc_idiag_ctlacc_read_reg_53809 lpfc_idiag_ctlacc_read_reg 0-3 53809 NULL
99152 +nls_nullsize_53815 nls_nullsize 0 53815 NULL
99153 +pms_read_53873 pms_read 3 53873 NULL
99154 +ieee80211_if_fmt_dropped_frames_congestion_53883 ieee80211_if_fmt_dropped_frames_congestion 3 53883 NULL
99155 +ocfs2_rm_xattr_cluster_53900 ocfs2_rm_xattr_cluster 5-4-3 53900 NULL
99156 +proc_file_read_53905 proc_file_read 3 53905 NULL
99157 +early_reserve_e820_53915 early_reserve_e820 1-2 53915 NULL
99158 +ocfs2_make_clusters_writable_53938 ocfs2_make_clusters_writable 4 53938 NULL
99159 +mthca_setup_cmd_doorbells_53954 mthca_setup_cmd_doorbells 2 53954 NULL
99160 +mlx4_num_eq_uar_53965 mlx4_num_eq_uar 0 53965 NULL
99161 +idetape_chrdev_write_53976 idetape_chrdev_write 3 53976 NULL
99162 +mthca_reg_user_mr_53980 mthca_reg_user_mr 2-3 53980 NULL
99163 +__ocfs2_xattr_set_value_outside_53981 __ocfs2_xattr_set_value_outside 5 53981 NULL
99164 +ieee80211_if_fmt_dot11MeshHWMPperrMinInterval_53998 ieee80211_if_fmt_dot11MeshHWMPperrMinInterval 3 53998 NULL
99165 +snd_pcm_lib_write_transfer_54018 snd_pcm_lib_write_transfer 4-2-5 54018 NULL
99166 +cmpk_message_handle_tx_54024 cmpk_message_handle_tx 4 54024 NULL
99167 +ipxrtr_route_packet_54036 ipxrtr_route_packet 4 54036 NULL
99168 +pipeline_dec_packet_out_read_54052 pipeline_dec_packet_out_read 3 54052 NULL
99169 +nl80211_send_disconnected_54056 nl80211_send_disconnected 5 54056 NULL
99170 +rproc_state_read_54057 rproc_state_read 3 54057 NULL
99171 +_malloc_54077 _malloc 1 54077 NULL
99172 +bitmap_bitremap_54096 bitmap_bitremap 4 54096 NULL
99173 +altera_set_ir_pre_54103 altera_set_ir_pre 2 54103 NULL
99174 +create_xattr_54106 create_xattr 5 54106 NULL
99175 +strn_len_54122 strn_len 0 54122 NULL
99176 +isku_receive_54130 isku_receive 4 54130 NULL
99177 +isr_host_acknowledges_read_54136 isr_host_acknowledges_read 3 54136 NULL
99178 +i2400m_zrealloc_2x_54166 i2400m_zrealloc_2x 3 54166 NULL nohasharray
99179 +memcpy_toiovec_54166 memcpy_toiovec 3 54166 &i2400m_zrealloc_2x_54166
99180 +nouveau_falcon_create__54169 nouveau_falcon_create_ 8 54169 NULL
99181 +acpi_os_read_memory_54186 acpi_os_read_memory 1-3 54186 NULL
99182 +__register_chrdev_54223 __register_chrdev 2-3 54223 NULL
99183 +_format_mac_addr_54229 _format_mac_addr 2-0 54229 NULL
99184 +pi_read_regr_54231 pi_read_regr 0 54231 NULL
99185 +reada_add_block_54247 reada_add_block 2 54247 NULL
99186 +xfs_dir2_sf_addname_hard_54254 xfs_dir2_sf_addname_hard 3 54254 NULL
99187 +ceph_msgpool_get_54258 ceph_msgpool_get 2 54258 NULL
99188 +wusb_prf_54261 wusb_prf 7 54261 NULL nohasharray
99189 +audio_write_54261 audio_write 4 54261 &wusb_prf_54261
99190 +mwifiex_getlog_read_54269 mwifiex_getlog_read 3 54269 NULL
99191 +ubi_calc_data_len_54279 ubi_calc_data_len 0-3 54279 NULL
99192 +altera_set_dr_post_54291 altera_set_dr_post 2 54291 NULL
99193 +dlm_alloc_pagevec_54296 dlm_alloc_pagevec 1 54296 NULL
99194 +get_iovec_page_array_54298 get_iovec_page_array 6 54298 NULL
99195 +sprintf_54306 sprintf 0 54306 NULL
99196 +irq_domain_associate_many_54307 irq_domain_associate_many 2 54307 NULL
99197 +br_fdb_fillbuf_54339 br_fdb_fillbuf 0 54339 NULL
99198 +__alloc_dev_table_54343 __alloc_dev_table 2 54343 NULL
99199 +__get_free_pages_54352 __get_free_pages 0 54352 NULL nohasharray
99200 +_osd_realloc_seg_54352 _osd_realloc_seg 3 54352 &__get_free_pages_54352
99201 +tcf_hash_create_54360 tcf_hash_create 4 54360 NULL
99202 +read_file_credit_dist_stats_54367 read_file_credit_dist_stats 3 54367 NULL
99203 +vfs_readlink_54368 vfs_readlink 3 54368 NULL
99204 +do_dccp_setsockopt_54377 do_dccp_setsockopt 5 54377 NULL nohasharray
99205 +intel_sdvo_write_cmd_54377 intel_sdvo_write_cmd 4 54377 &do_dccp_setsockopt_54377
99206 +ah_alloc_tmp_54378 ah_alloc_tmp 3-2 54378 NULL
99207 +gart_unmap_page_54379 gart_unmap_page 2-3 54379 NULL
99208 +snd_pcm_oss_read2_54387 snd_pcm_oss_read2 0-3 54387 NULL
99209 +i386_mmap_check_54388 i386_mmap_check 0 54388 NULL
99210 +__do_krealloc_54389 __do_krealloc 2 54389 NULL
99211 +iwl_dbgfs_power_save_status_read_54392 iwl_dbgfs_power_save_status_read 3 54392 NULL
99212 +copy_gadget_strings_54417 copy_gadget_strings 2-3 54417 NULL
99213 +swiotlb_tbl_sync_single_54486 swiotlb_tbl_sync_single 2 54486 NULL
99214 +simple_strtoull_54493 simple_strtoull 0 54493 NULL
99215 +swiotlb_tbl_map_single_54495 swiotlb_tbl_map_single 3-0 54495 NULL
99216 +btrfs_ordered_sum_size_54509 btrfs_ordered_sum_size 0-2 54509 NULL
99217 +cgroup_write_X64_54514 cgroup_write_X64 5 54514 NULL nohasharray
99218 +xen_bus_to_phys_54514 xen_bus_to_phys 0 54514 &cgroup_write_X64_54514
99219 +rfc4106_set_key_54519 rfc4106_set_key 3 54519 NULL
99220 +vmci_transport_dgram_enqueue_54525 vmci_transport_dgram_enqueue 4 54525 NULL
99221 +viacam_read_54526 viacam_read 3 54526 NULL
99222 +unix_dgram_connect_54535 unix_dgram_connect 3 54535 NULL
99223 +setsockopt_54539 setsockopt 5 54539 NULL
99224 +mwifiex_usb_submit_rx_urb_54558 mwifiex_usb_submit_rx_urb 2 54558 NULL
99225 +nfsd_vfs_write_54577 nfsd_vfs_write 6 54577 NULL
99226 +fw_iso_buffer_init_54582 fw_iso_buffer_init 3 54582 NULL
99227 +nvme_npages_54601 nvme_npages 0-1 54601 NULL
99228 +fwSendNullPacket_54618 fwSendNullPacket 2 54618 NULL
99229 +irq_timeout_read_54653 irq_timeout_read 3 54653 NULL
99230 +dns_resolver_read_54658 dns_resolver_read 3 54658 NULL
99231 +twl6030_interrupt_mask_54659 twl6030_interrupt_mask 2 54659 NULL
99232 +kvm_read_cr3_54662 kvm_read_cr3 0 54662 NULL
99233 +bio_kmalloc_54672 bio_kmalloc 2 54672 NULL
99234 +vring_new_virtqueue_54673 vring_new_virtqueue 2 54673 NULL
99235 +evm_read_key_54674 evm_read_key 3 54674 NULL
99236 +resource_string_54699 resource_string 0 54699 NULL
99237 +platform_get_irq_byname_54700 platform_get_irq_byname 0 54700 NULL
99238 +rfkill_fop_read_54711 rfkill_fop_read 3 54711 NULL
99239 +_add_sg_continuation_descriptor_54721 _add_sg_continuation_descriptor 3 54721 NULL
99240 +ocfs2_control_write_54737 ocfs2_control_write 3 54737 NULL
99241 +kzalloc_54740 kzalloc 1 54740 NULL
99242 +wep_iv_read_54744 wep_iv_read 3 54744 NULL
99243 +iio_event_chrdev_read_54757 iio_event_chrdev_read 3 54757 NULL
99244 +batadv_iv_ogm_aggregate_new_54761 batadv_iv_ogm_aggregate_new 2 54761 NULL
99245 +adis16480_show_firmware_date_54762 adis16480_show_firmware_date 3 54762 NULL
99246 +flexcop_device_kmalloc_54793 flexcop_device_kmalloc 1 54793 NULL
99247 +domain_init_54797 domain_init 2 54797 NULL
99248 +ext3_find_goal_54801 ext3_find_goal 0 54801 NULL
99249 +get_dev_size_54807 get_dev_size 0 54807 NULL
99250 +nfsd_write_54809 nfsd_write 6 54809 NULL
99251 +aes_decrypt_fail_read_54815 aes_decrypt_fail_read 3 54815 NULL nohasharray
99252 +crypto_tfm_ctx_alignment_54815 crypto_tfm_ctx_alignment 0 54815 &aes_decrypt_fail_read_54815
99253 +generic_perform_write_54832 generic_perform_write 3 54832 NULL
99254 +write_rio_54837 write_rio 3 54837 NULL
99255 +nouveau_engctx_create__54839 nouveau_engctx_create_ 8 54839 NULL nohasharray
99256 +ext3_acl_from_disk_54839 ext3_acl_from_disk 2 54839 &nouveau_engctx_create__54839
99257 +ufx_ops_write_54848 ufx_ops_write 3 54848 NULL
99258 +printer_read_54851 printer_read 3 54851 NULL
99259 +qib_reg_user_mr_54858 qib_reg_user_mr 2-3 54858 NULL
99260 +alloc_ep_req_54860 alloc_ep_req 2 54860 NULL
99261 +broadsheet_spiflash_rewrite_sector_54864 broadsheet_spiflash_rewrite_sector 2 54864 NULL
99262 +prism_build_supp_rates_54865 prism_build_supp_rates 0 54865 NULL
99263 +tcf_csum_ipv6_tcp_54877 tcf_csum_ipv6_tcp 4 54877 NULL
99264 +iscsi_pool_init_54913 iscsi_pool_init 2-4 54913 NULL
99265 +btrfs_stack_chunk_num_stripes_54923 btrfs_stack_chunk_num_stripes 0 54923 NULL
99266 +mxms_structlen_54939 mxms_structlen 0 54939 NULL
99267 +add_port_54941 add_port 2 54941 NULL
99268 +virtblk_add_buf_wait_54943 virtblk_add_buf_wait 3-4 54943 NULL
99269 +wl12xx_cmd_build_probe_req_54946 wl12xx_cmd_build_probe_req 6-8 54946 NULL
99270 +ath9k_dump_btcoex_54949 ath9k_dump_btcoex 0 54949 NULL
99271 +c4_add_card_54968 c4_add_card 3 54968 NULL
99272 +iwl_pcie_dump_fh_54975 iwl_pcie_dump_fh 0 54975 NULL
99273 +__proc_file_read_54978 __proc_file_read 3 54978 NULL
99274 +ext3_xattr_get_54989 ext3_xattr_get 0 54989 NULL
99275 +Bus_to_Virtual_54991 Bus_to_Virtual 1 54991 NULL
99276 +cx231xx_v4l2_read_55014 cx231xx_v4l2_read 3 55014 NULL
99277 +paging32_get_level1_sp_gpa_55022 paging32_get_level1_sp_gpa 0 55022 NULL
99278 +error_error_null_Frame_tx_start_read_55024 error_error_null_Frame_tx_start_read 3 55024 NULL
99279 +__netdev_alloc_skb_ip_align_55067 __netdev_alloc_skb_ip_align 2 55067 NULL
99280 +apei_exec_run_55075 apei_exec_run 0 55075 NULL
99281 +bitmap_storage_alloc_55077 bitmap_storage_alloc 2 55077 NULL
99282 +hx8357_spi_write_array_55095 hx8357_spi_write_array 3 55095 NULL
99283 +rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read_55106 rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read 3 55106 NULL
99284 +corrupt_data_55120 corrupt_data 0 55120 NULL
99285 +crypto_ahash_setkey_55134 crypto_ahash_setkey 3 55134 NULL
99286 +ocfs2_prepare_refcount_change_for_del_55137 ocfs2_prepare_refcount_change_for_del 3 55137 NULL nohasharray
99287 +filldir_55137 filldir 3 55137 &ocfs2_prepare_refcount_change_for_del_55137
99288 +ocfs2_truncate_file_55148 ocfs2_truncate_file 3 55148 NULL
99289 +ieee80211_if_read_uapsd_queues_55150 ieee80211_if_read_uapsd_queues 3 55150 NULL
99290 +mtd_get_fact_prot_info_55186 mtd_get_fact_prot_info 0 55186 NULL
99291 +sel_write_relabel_55195 sel_write_relabel 3 55195 NULL
99292 +sched_feat_write_55202 sched_feat_write 3 55202 NULL
99293 +ht40allow_map_read_55209 ht40allow_map_read 3 55209 NULL
99294 +__kfifo_dma_out_prepare_r_55211 __kfifo_dma_out_prepare_r 4-5 55211 NULL
99295 +do_raw_setsockopt_55215 do_raw_setsockopt 5 55215 NULL
99296 +dump_command_55220 dump_command 1 55220 NULL
99297 +dbAllocDmap_55227 dbAllocDmap 0 55227 NULL
99298 +tipc_port_reject_sections_55229 tipc_port_reject_sections 5 55229 NULL
99299 +register_unifi_sdio_55239 register_unifi_sdio 2 55239 NULL
99300 +memcpy_fromiovec_55247 memcpy_fromiovec 3 55247 NULL
99301 +ptrace_request_55288 ptrace_request 3 55288 NULL
99302 +rx_streaming_interval_read_55291 rx_streaming_interval_read 3 55291 NULL
99303 +gsm_control_modem_55303 gsm_control_modem 3 55303 NULL
99304 +qp_alloc_guest_work_55305 qp_alloc_guest_work 3-5 55305 NULL nohasharray
99305 +__get_vm_area_node_55305 __get_vm_area_node 1 55305 &qp_alloc_guest_work_55305
99306 +do_shmat_55336 do_shmat 5 55336 NULL
99307 +vme_user_read_55338 vme_user_read 3 55338 NULL
99308 +sctp_datamsg_from_user_55342 sctp_datamsg_from_user 4 55342 NULL nohasharray
99309 +__wa_xfer_setup_sizes_55342 __wa_xfer_setup_sizes 0 55342 &sctp_datamsg_from_user_55342
99310 +__memblock_alloc_base_55359 __memblock_alloc_base 1-2 55359 NULL
99311 +acpi_system_read_event_55362 acpi_system_read_event 3 55362 NULL
99312 +nf_nat_ipv4_manip_pkt_55387 nf_nat_ipv4_manip_pkt 2 55387 NULL
99313 +iwl_dbgfs_plcp_delta_read_55407 iwl_dbgfs_plcp_delta_read 3 55407 NULL
99314 +alloc_skb_55439 alloc_skb 1 55439 NULL
99315 +__vxge_hw_channel_allocate_55462 __vxge_hw_channel_allocate 3 55462 NULL
99316 +isdnhdlc_decode_55466 isdnhdlc_decode 0 55466 NULL
99317 +cx23888_ir_rx_read_55473 cx23888_ir_rx_read 3 55473 NULL
99318 +batadv_unicast_push_and_fill_skb_55474 batadv_unicast_push_and_fill_skb 2 55474 NULL
99319 +snd_pcm_lib_write_55483 snd_pcm_lib_write 0-3 55483 NULL
99320 +i2o_pool_alloc_55485 i2o_pool_alloc 4 55485 NULL
99321 +ocfs2_rec_clusters_55501 ocfs2_rec_clusters 0 55501 NULL
99322 +ext4_flex_bg_size_55502 ext4_flex_bg_size 0 55502 NULL
99323 +cfpkt_pad_trail_55511 cfpkt_pad_trail 2 55511 NULL nohasharray
99324 +tx_tx_done_int_template_read_55511 tx_tx_done_int_template_read 3 55511 &cfpkt_pad_trail_55511
99325 +ea_get_55522 ea_get 0 55522 NULL
99326 +buffer_size_55534 buffer_size 0 55534 NULL
99327 +set_msr_interception_55538 set_msr_interception 2 55538 NULL
99328 +tty_port_register_device_55543 tty_port_register_device 3 55543 NULL
99329 +add_partition_55588 add_partition 2 55588 NULL
99330 +free_pages_55603 free_pages 1 55603 NULL
99331 +macvtap_put_user_55609 macvtap_put_user 4 55609 NULL
99332 +selinux_setprocattr_55611 selinux_setprocattr 4 55611 NULL
99333 +edge_tty_recv_55622 edge_tty_recv 3 55622 NULL
99334 +reiserfs_xattr_get_55628 reiserfs_xattr_get 0 55628 NULL nohasharray
99335 +pktgen_if_write_55628 pktgen_if_write 3 55628 &reiserfs_xattr_get_55628
99336 +dvb_dmxdev_set_buffer_size_55643 dvb_dmxdev_set_buffer_size 2 55643 NULL
99337 +mlx4_buddy_alloc_55647 mlx4_buddy_alloc 2 55647 NULL
99338 +xfs_bmbt_maxrecs_55649 xfs_bmbt_maxrecs 0-2 55649 NULL
99339 +ib_umad_compat_ioctl_55650 ib_umad_compat_ioctl 3 55650 NULL
99340 +cfg80211_send_rx_assoc_55651 cfg80211_send_rx_assoc 4 55651 NULL
99341 +read_oldmem_55658 read_oldmem 3 55658 NULL
99342 +lpfc_idiag_queinfo_read_55662 lpfc_idiag_queinfo_read 3 55662 NULL
99343 +il_dbgfs_tx_queue_read_55668 il_dbgfs_tx_queue_read 3 55668 NULL
99344 +get_info_55681 get_info 3 55681 NULL
99345 +wil_vring_alloc_skb_55703 wil_vring_alloc_skb 4 55703 NULL
99346 +__videobuf_alloc_uncached_55711 __videobuf_alloc_uncached 1 55711 NULL
99347 +pm8001_store_update_fw_55716 pm8001_store_update_fw 4 55716 NULL
99348 +mtdswap_init_55719 mtdswap_init 2 55719 NULL
99349 +__iio_allocate_kfifo_55738 __iio_allocate_kfifo 2 55738 NULL
99350 +set_local_name_55757 set_local_name 4 55757 NULL
99351 +strlen_55778 strlen 0 55778 NULL
99352 +set_spte_55783 set_spte 5-4 55783 NULL
99353 +req_bio_endio_55786 req_bio_endio 3 55786 NULL nohasharray
99354 +conf_read_55786 conf_read 3 55786 &req_bio_endio_55786
99355 +uwb_rc_neh_grok_event_55799 uwb_rc_neh_grok_event 3 55799 NULL
99356 +sb16_copy_from_user_55836 sb16_copy_from_user 10-6-7 55836 NULL
99357 +ip_hdrlen_55849 ip_hdrlen 0 55849 NULL
99358 +hcd_alloc_coherent_55862 hcd_alloc_coherent 5 55862 NULL
99359 +shmem_setxattr_55867 shmem_setxattr 4 55867 NULL
99360 +hsc_write_55875 hsc_write 3 55875 NULL
99361 +pm_qos_power_read_55891 pm_qos_power_read 3 55891 NULL
99362 +snd_pcm_hw_param_value_min_55917 snd_pcm_hw_param_value_min 0 55917 NULL
99363 +paging64_page_fault_55942 paging64_page_fault 2 55942 NULL
99364 +sel_read_policy_55947 sel_read_policy 3 55947 NULL
99365 +ceph_get_direct_page_vector_55956 ceph_get_direct_page_vector 2 55956 NULL
99366 +simple_read_from_buffer_55957 simple_read_from_buffer 2-5 55957 NULL
99367 +tx_tx_imm_resp_read_55964 tx_tx_imm_resp_read 3 55964 NULL
99368 +ssb_bus_pcmciabus_register_56020 ssb_bus_pcmciabus_register 3 56020 NULL
99369 +nvme_alloc_iod_56027 nvme_alloc_iod 1-2 56027 NULL
99370 +dccp_sendmsg_56058 dccp_sendmsg 4 56058 NULL
99371 +__set_discard_56081 __set_discard 2 56081 NULL
99372 +pscsi_get_bio_56103 pscsi_get_bio 1 56103 NULL
99373 +usb_alloc_stream_buffers_56123 usb_alloc_stream_buffers 3 56123 NULL
99374 +kmem_zalloc_large_56128 kmem_zalloc_large 1 56128 NULL
99375 +sel_read_handle_status_56139 sel_read_handle_status 3 56139 NULL
99376 +map_addr_56144 map_addr 7 56144 NULL
99377 +rawv6_setsockopt_56165 rawv6_setsockopt 5 56165 NULL
99378 +create_irq_nr_56180 create_irq_nr 1 56180 NULL
99379 +ath9k_dump_legacy_btcoex_56194 ath9k_dump_legacy_btcoex 0 56194 NULL
99380 +skb_headroom_56200 skb_headroom 0 56200 NULL
99381 +usb_dump_iad_descriptor_56204 usb_dump_iad_descriptor 0 56204 NULL
99382 +ncp_read_bounce_size_56221 ncp_read_bounce_size 0-1 56221 NULL
99383 +ocfs2_find_xe_in_bucket_56224 ocfs2_find_xe_in_bucket 0 56224 NULL
99384 +cp210x_get_config_56229 cp210x_get_config 4 56229 NULL
99385 +do_ipt_set_ctl_56238 do_ipt_set_ctl 4 56238 NULL
99386 +fd_copyin_56247 fd_copyin 3 56247 NULL
99387 +sk_rmem_schedule_56255 sk_rmem_schedule 3 56255 NULL
99388 +il4965_ucode_general_stats_read_56277 il4965_ucode_general_stats_read 3 56277 NULL
99389 +ieee80211_if_fmt_user_power_level_56283 ieee80211_if_fmt_user_power_level 3 56283 NULL
99390 +RESIZE_IF_NEEDED_56286 RESIZE_IF_NEEDED 2 56286 NULL
99391 +dvb_aplay_56296 dvb_aplay 3 56296 NULL
99392 +btmrvl_hscfgcmd_read_56303 btmrvl_hscfgcmd_read 3 56303 NULL
99393 +compat_cdrom_read_audio_56304 compat_cdrom_read_audio 4 56304 NULL
99394 +pipeline_pre_to_defrag_swi_read_56321 pipeline_pre_to_defrag_swi_read 3 56321 NULL
99395 +journal_init_revoke_table_56331 journal_init_revoke_table 1 56331 NULL
99396 +snd_rawmidi_read_56337 snd_rawmidi_read 3 56337 NULL
99397 +sixpack_compat_ioctl_56346 sixpack_compat_ioctl 4 56346 NULL
99398 +vxge_os_dma_malloc_async_56348 vxge_os_dma_malloc_async 3 56348 NULL
99399 +iov_iter_copy_from_user_atomic_56368 iov_iter_copy_from_user_atomic 4 56368 NULL
99400 +dev_read_56369 dev_read 3 56369 NULL
99401 +ocfs2_control_read_56405 ocfs2_control_read 3 56405 NULL
99402 +__get_vm_area_caller_56416 __get_vm_area_caller 1 56416 NULL nohasharray
99403 +acpi_os_write_memory_56416 acpi_os_write_memory 1-3 56416 &__get_vm_area_caller_56416
99404 +store_msg_56417 store_msg 3 56417 NULL
99405 +pppol2tp_sendmsg_56420 pppol2tp_sendmsg 4 56420 NULL
99406 +fl_create_56435 fl_create 5 56435 NULL
99407 +gnttab_map_56439 gnttab_map 2 56439 NULL
99408 +cx231xx_init_isoc_56453 cx231xx_init_isoc 3-2 56453 NULL
99409 +set_connectable_56458 set_connectable 4 56458 NULL
99410 +osd_req_list_partition_objects_56464 osd_req_list_partition_objects 5 56464 NULL
99411 +calc_linear_pos_56472 calc_linear_pos 0-3 56472 NULL
99412 +crypto_shash_alignmask_56486 crypto_shash_alignmask 0 56486 NULL
99413 +ieee80211_rx_mgmt_probe_beacon_56491 ieee80211_rx_mgmt_probe_beacon 3 56491 NULL
99414 +cfg80211_connect_result_56515 cfg80211_connect_result 4-6 56515 NULL
99415 +ip_options_get_56538 ip_options_get 4 56538 NULL
99416 +ocfs2_change_extent_flag_56549 ocfs2_change_extent_flag 5 56549 NULL
99417 +alloc_apertures_56561 alloc_apertures 1 56561 NULL
99418 +rs_sta_dbgfs_stats_table_read_56573 rs_sta_dbgfs_stats_table_read 3 56573 NULL
99419 +portcntrs_2_read_56586 portcntrs_2_read 3 56586 NULL
99420 +event_filter_write_56609 event_filter_write 3 56609 NULL
99421 +gather_array_56641 gather_array 3 56641 NULL
99422 +uvc_debugfs_stats_read_56651 uvc_debugfs_stats_read 3 56651 NULL
99423 +snd_gus_dram_read_56686 snd_gus_dram_read 4 56686 NULL nohasharray
99424 +da9055_gpio_to_irq_56686 da9055_gpio_to_irq 2 56686 &snd_gus_dram_read_56686
99425 +build_map_info_56696 build_map_info 2 56696 NULL
99426 +dvb_ringbuffer_read_user_56702 dvb_ringbuffer_read_user 3 56702 NULL
99427 +sta_flags_read_56710 sta_flags_read 3 56710 NULL
99428 +ipv6_getsockopt_sticky_56711 ipv6_getsockopt_sticky 5 56711 NULL
99429 +__wa_xfer_setup_segs_56725 __wa_xfer_setup_segs 2 56725 NULL
99430 +pcpu_populate_chunk_56741 pcpu_populate_chunk 2-3 56741 NULL
99431 +drm_agp_bind_pages_56748 drm_agp_bind_pages 3 56748 NULL
99432 +btrfsic_map_block_56751 btrfsic_map_block 2 56751 NULL
99433 +alloc_iommu_56778 alloc_iommu 2-3 56778 NULL
99434 +__carl9170_rx_56784 __carl9170_rx 3 56784 NULL
99435 +hash_lookup_56792 hash_lookup 2 56792 NULL
99436 +do_syslog_56807 do_syslog 3 56807 NULL
99437 +mtdchar_write_56831 mtdchar_write 3 56831 NULL nohasharray
99438 +ntfs_rl_realloc_56831 ntfs_rl_realloc 3 56831 &mtdchar_write_56831
99439 +snd_rawmidi_kernel_write1_56847 snd_rawmidi_kernel_write1 4 56847 NULL
99440 +wb_lookup_56858 wb_lookup 2 56858 NULL
99441 +ext3_xattr_ibody_get_56880 ext3_xattr_ibody_get 0 56880 NULL
99442 +pvr2_debugifc_print_status_56890 pvr2_debugifc_print_status 3 56890 NULL
99443 +debug_debug3_read_56894 debug_debug3_read 3 56894 NULL
99444 +batadv_tt_update_changes_56895 batadv_tt_update_changes 3 56895 NULL
99445 +strcspn_56913 strcspn 0 56913 NULL
99446 +__kfifo_out_56927 __kfifo_out 0-3 56927 NULL
99447 +check_header_56930 check_header 2 56930 NULL
99448 +journal_init_revoke_56933 journal_init_revoke 2 56933 NULL
99449 +diva_get_driver_info_56967 diva_get_driver_info 0 56967 NULL
99450 +nouveau_device_create__56984 nouveau_device_create_ 6 56984 NULL
99451 +vlsi_alloc_ring_57003 vlsi_alloc_ring 3-4 57003 NULL
99452 +btrfs_super_csum_size_57004 btrfs_super_csum_size 0 57004 NULL
99453 +aircable_process_packet_57027 aircable_process_packet 4 57027 NULL
99454 +skb_network_offset_57043 skb_network_offset 0 57043 NULL nohasharray
99455 +ieee80211_if_fmt_state_57043 ieee80211_if_fmt_state 3 57043 &skb_network_offset_57043
99456 +bytes_to_samples_57049 bytes_to_samples 0-2 57049 NULL
99457 +xfs_buf_read_map_57053 xfs_buf_read_map 3 57053 NULL
99458 +autofs_dev_ioctl_compat_57059 autofs_dev_ioctl_compat 3 57059 NULL
99459 +cx2341x_ctrl_new_std_57061 cx2341x_ctrl_new_std 4 57061 NULL
99460 +sca3000_read_data_57064 sca3000_read_data 4 57064 NULL
99461 +pcmcia_replace_cis_57066 pcmcia_replace_cis 3 57066 NULL
99462 +sis190_try_rx_copy_57069 sis190_try_rx_copy 3 57069 NULL
99463 +tracing_set_trace_write_57096 tracing_set_trace_write 3 57096 NULL
99464 +crypto_compress_ctxsize_57109 crypto_compress_ctxsize 0 57109 NULL
99465 +sysfs_write_file_57116 sysfs_write_file 3 57116 NULL
99466 +cipso_v4_gentag_loc_57119 cipso_v4_gentag_loc 0 57119 NULL
99467 +nl80211_send_deauth_57136 nl80211_send_deauth 4 57136 NULL nohasharray
99468 +rds_ib_sub_signaled_57136 rds_ib_sub_signaled 2 57136 &nl80211_send_deauth_57136 nohasharray
99469 +ima_show_htable_value_57136 ima_show_htable_value 2 57136 &rds_ib_sub_signaled_57136
99470 +snd_sonicvibes_getdmac_57140 snd_sonicvibes_getdmac 0 57140 NULL
99471 +udl_prime_create_57159 udl_prime_create 2 57159 NULL
99472 +__ipath_get_user_pages_57166 __ipath_get_user_pages 1-2 57166 NULL
99473 +stk_prepare_sio_buffers_57168 stk_prepare_sio_buffers 2 57168 NULL
99474 +rx_hw_stuck_read_57179 rx_hw_stuck_read 3 57179 NULL
99475 +tt3650_ci_msg_57219 tt3650_ci_msg 4 57219 NULL
99476 +dma_fifo_alloc_57236 dma_fifo_alloc 5-3-2 57236 NULL
99477 +ieee80211_if_fmt_tsf_57249 ieee80211_if_fmt_tsf 3 57249 NULL
99478 +oprofilefs_ulong_from_user_57251 oprofilefs_ulong_from_user 3 57251 NULL
99479 +alloc_flex_gd_57259 alloc_flex_gd 1 57259 NULL
99480 +security_mmap_file_57268 security_mmap_file 0 57268 NULL
99481 +pstore_file_read_57288 pstore_file_read 3 57288 NULL
99482 +snd_pcm_read_57289 snd_pcm_read 3 57289 NULL
99483 +ath6kl_buf_alloc_57304 ath6kl_buf_alloc 1 57304 NULL
99484 +fw_file_size_57307 fw_file_size 0 57307 NULL
99485 +ftdi_elan_write_57309 ftdi_elan_write 3 57309 NULL
99486 +__mxt_write_reg_57326 __mxt_write_reg 3 57326 NULL
99487 +ocfs2_xattr_shrink_size_57328 ocfs2_xattr_shrink_size 3 57328 NULL
99488 +check_mirror_57342 check_mirror 1-2 57342 NULL nohasharray
99489 +usblp_read_57342 usblp_read 3 57342 &check_mirror_57342
99490 +print_devstats_dot11RTSFailureCount_57347 print_devstats_dot11RTSFailureCount 3 57347 NULL
99491 +tipc_bclink_stats_57372 tipc_bclink_stats 2 57372 NULL
99492 +max8997_irq_domain_map_57375 max8997_irq_domain_map 2 57375 NULL
99493 +tty_register_device_attr_57381 tty_register_device_attr 2 57381 NULL
99494 +read_file_blob_57406 read_file_blob 3 57406 NULL
99495 +enclosure_register_57412 enclosure_register 3 57412 NULL
99496 +gre_manip_pkt_57416 gre_manip_pkt 4 57416 NULL
99497 +compat_keyctl_instantiate_key_iov_57431 compat_keyctl_instantiate_key_iov 3 57431 NULL nohasharray
99498 +alloc_ftrace_hash_57431 alloc_ftrace_hash 1 57431 &compat_keyctl_instantiate_key_iov_57431
99499 +copy_to_user_fromio_57432 copy_to_user_fromio 3 57432 NULL
99500 +sys_pselect6_57449 sys_pselect6 1 57449 NULL
99501 +ReadReg_57453 ReadReg 0 57453 NULL
99502 +__roundup_pow_of_two_57461 __roundup_pow_of_two 0 57461 NULL
99503 +crypto_tfm_alg_blocksize_57463 crypto_tfm_alg_blocksize 0 57463 NULL nohasharray
99504 +send_midi_async_57463 send_midi_async 3 57463 &crypto_tfm_alg_blocksize_57463
99505 +sisusb_clear_vram_57466 sisusb_clear_vram 3-2 57466 NULL
99506 +ieee80211_if_read_flags_57470 ieee80211_if_read_flags 3 57470 NULL nohasharray
99507 +sep_lock_user_pages_57470 sep_lock_user_pages 2-3 57470 &ieee80211_if_read_flags_57470
99508 +ocfs2_write_cluster_57483 ocfs2_write_cluster 8-2-9 57483 NULL
99509 +bnad_debugfs_write_regwr_57500 bnad_debugfs_write_regwr 3 57500 NULL
99510 +skb_headlen_57501 skb_headlen 0 57501 NULL
99511 +copy_in_user_57502 copy_in_user 3 57502 NULL
99512 +ks8842_read32_57505 ks8842_read32 0 57505 NULL nohasharray
99513 +ckhdid_printf_57505 ckhdid_printf 2 57505 &ks8842_read32_57505
99514 +init_tag_map_57515 init_tag_map 3 57515 NULL
99515 +wil_read_file_ssid_57517 wil_read_file_ssid 3 57517 NULL nohasharray
99516 +il_dbgfs_force_reset_read_57517 il_dbgfs_force_reset_read 3 57517 &wil_read_file_ssid_57517
99517 +inode_permission_57531 inode_permission 0 57531 NULL
99518 +acpi_dev_get_resources_57534 acpi_dev_get_resources 0 57534 NULL nohasharray
99519 +DoC_Probe_57534 DoC_Probe 1 57534 &acpi_dev_get_resources_57534
99520 +ext4_group_first_block_no_57559 ext4_group_first_block_no 0-2 57559 NULL
99521 +snd_pcm_playback_ioctl1_57569 snd_pcm_playback_ioctl1 0 57569 NULL
99522 +uio_find_mem_index_57584 uio_find_mem_index 0 57584 NULL
99523 +read_file_spectral_fft_period_57593 read_file_spectral_fft_period 3 57593 NULL
99524 +wm831x_gpio_to_irq_57614 wm831x_gpio_to_irq 2 57614 NULL
99525 +sk_stream_alloc_skb_57622 sk_stream_alloc_skb 2 57622 NULL
99526 +tx_tx_retry_template_read_57623 tx_tx_retry_template_read 3 57623 NULL
99527 +osdmap_set_max_osd_57630 osdmap_set_max_osd 2 57630 NULL nohasharray
99528 +sisusbcon_putcs_57630 sisusbcon_putcs 3 57630 &osdmap_set_max_osd_57630
99529 +mem_read_57631 mem_read 3 57631 NULL
99530 +tc3589x_irq_map_57639 tc3589x_irq_map 2 57639 NULL
99531 +sys_mq_timedsend_57661 sys_mq_timedsend 3 57661 NULL
99532 +r3964_write_57662 r3964_write 4 57662 NULL
99533 +proc_ns_readlink_57664 proc_ns_readlink 3 57664 NULL
99534 +__lgwrite_57669 __lgwrite 4 57669 NULL
99535 +ieee80211_MFIE_rate_len_57692 ieee80211_MFIE_rate_len 0 57692 NULL
99536 +f1x_match_to_this_node_57695 f1x_match_to_this_node 3 57695 NULL
99537 +check_prefree_segments_57702 check_prefree_segments 2 57702 NULL
99538 +i2400m_rx_stats_read_57706 i2400m_rx_stats_read 3 57706 NULL
99539 +ieee80211_if_read_dot11MeshHWMPconfirmationInterval_57722 ieee80211_if_read_dot11MeshHWMPconfirmationInterval 3 57722 NULL
99540 +nouveau_gpio_create__57735 nouveau_gpio_create_ 4-5 57735 NULL
99541 +compat_sys_set_mempolicy_57742 compat_sys_set_mempolicy 3 57742 NULL
99542 +ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval_57762 ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval 3 57762 NULL
99543 +ld2_57794 ld2 0 57794 NULL
99544 +ivtv_read_57796 ivtv_read 3 57796 NULL
99545 +generic_ptrace_peekdata_57806 generic_ptrace_peekdata 2 57806 NULL
99546 +ipath_user_sdma_num_pages_57813 ipath_user_sdma_num_pages 0 57813 NULL
99547 +usb_dump_config_57817 usb_dump_config 0 57817 NULL
99548 +bfad_debugfs_read_regrd_57830 bfad_debugfs_read_regrd 3 57830 NULL
99549 +copy_to_user_57835 copy_to_user 3 57835 NULL
99550 +flash_read_57843 flash_read 3 57843 NULL
99551 +xt_alloc_table_info_57903 xt_alloc_table_info 1 57903 NULL
99552 +emi26_writememory_57908 emi26_writememory 4 57908 NULL
99553 +iio_read_first_n_kfifo_57910 iio_read_first_n_kfifo 2 57910 NULL
99554 +memcg_caches_array_size_57918 memcg_caches_array_size 0-1 57918 NULL
99555 +twl_i2c_write_57923 twl_i2c_write 4-3 57923 NULL
99556 +__snd_gf1_look16_57925 __snd_gf1_look16 0 57925 NULL
99557 +sel_read_handle_unknown_57933 sel_read_handle_unknown 3 57933 NULL
99558 +key_algorithm_read_57946 key_algorithm_read 3 57946 NULL
99559 +ip_set_alloc_57953 ip_set_alloc 1 57953 NULL nohasharray
99560 +ioat3_dca_count_dca_slots_57953 ioat3_dca_count_dca_slots 0 57953 &ip_set_alloc_57953
99561 +i915_cache_sharing_write_57961 i915_cache_sharing_write 3 57961 NULL
99562 +hfc_empty_fifo_57972 hfc_empty_fifo 2 57972 NULL
99563 +c2_reg_user_mr_57982 c2_reg_user_mr 2-3 57982 NULL
99564 +rx_reset_counter_read_58001 rx_reset_counter_read 3 58001 NULL
99565 +regcache_rbtree_insert_to_block_58009 regcache_rbtree_insert_to_block 5 58009 NULL
99566 +iwl_dbgfs_ucode_rx_stats_read_58023 iwl_dbgfs_ucode_rx_stats_read 3 58023 NULL
99567 +io_playback_transfer_58030 io_playback_transfer 4 58030 NULL
99568 +mce_async_out_58056 mce_async_out 3 58056 NULL
99569 +ocfs2_find_leaf_58065 ocfs2_find_leaf 0 58065 NULL
99570 +dt3155_alloc_coherent_58073 dt3155_alloc_coherent 2 58073 NULL
99571 +cm4040_write_58079 cm4040_write 3 58079 NULL
99572 +udi_log_event_58105 udi_log_event 3 58105 NULL
99573 +savemem_58129 savemem 3 58129 NULL
99574 +ipv6_flowlabel_opt_58135 ipv6_flowlabel_opt 3 58135 NULL nohasharray
99575 +slhc_init_58135 slhc_init 1-2 58135 &ipv6_flowlabel_opt_58135
99576 +garmin_write_bulk_58191 garmin_write_bulk 3 58191 NULL
99577 +asix_write_cmd_58192 asix_write_cmd 5 58192 NULL
99578 +ieee80211_if_fmt_flags_58205 ieee80211_if_fmt_flags 3 58205 NULL
99579 +hva_to_pfn_58241 hva_to_pfn 1 58241 NULL
99580 +btrfsic_create_link_to_next_block_58246 btrfsic_create_link_to_next_block 4 58246 NULL
99581 +read_file_debug_58256 read_file_debug 3 58256 NULL
99582 +cfg80211_mgmt_tx_status_58266 cfg80211_mgmt_tx_status 4 58266 NULL
99583 +profile_load_58267 profile_load 3 58267 NULL
99584 +acpi_ds_build_internal_package_obj_58271 acpi_ds_build_internal_package_obj 3 58271 NULL
99585 +r100_mm_rreg_58276 r100_mm_rreg 0 58276 NULL
99586 +iscsi_decode_text_input_58292 iscsi_decode_text_input 4 58292 NULL
99587 +ieee80211_if_read_dot11MeshTTL_58307 ieee80211_if_read_dot11MeshTTL 3 58307 NULL
99588 +tx_tx_start_int_templates_read_58324 tx_tx_start_int_templates_read 3 58324 NULL
99589 +pcim_iomap_58334 pcim_iomap 3 58334 NULL
99590 +diva_init_dma_map_58336 diva_init_dma_map 3 58336 NULL
99591 +next_pidmap_58347 next_pidmap 2 58347 NULL
99592 +vmalloc_to_sg_58354 vmalloc_to_sg 2 58354 NULL
99593 +save_hint_58359 save_hint 2 58359 NULL
99594 +brcmf_debugfs_sdio_counter_read_58369 brcmf_debugfs_sdio_counter_read 3 58369 NULL
99595 +il_dbgfs_status_read_58388 il_dbgfs_status_read 3 58388 NULL
99596 +kvm_mmu_write_protect_pt_masked_58406 kvm_mmu_write_protect_pt_masked 3 58406 NULL
99597 +i2400m_pld_size_58415 i2400m_pld_size 0 58415 NULL
99598 +__mlx4_alloc_mtt_range_58418 __mlx4_alloc_mtt_range 2 58418 NULL
99599 +__iio_add_chan_devattr_58451 __iio_add_chan_devattr 0 58451 NULL
99600 +capabilities_read_58457 capabilities_read 3 58457 NULL
99601 +batadv_iv_ogm_aggr_packet_58462 batadv_iv_ogm_aggr_packet 3 58462 NULL
99602 +lpfc_idiag_baracc_read_58466 lpfc_idiag_baracc_read 3 58466 NULL nohasharray
99603 +compat_do_ipt_set_ctl_58466 compat_do_ipt_set_ctl 4 58466 &lpfc_idiag_baracc_read_58466
99604 +snd_gf1_read_addr_58483 snd_gf1_read_addr 0 58483 NULL
99605 +snd_rme96_capture_copy_58484 snd_rme96_capture_copy 5 58484 NULL
99606 +batadv_bla_is_backbone_gw_58488 batadv_bla_is_backbone_gw 3 58488 NULL
99607 +memblock_alloc_try_nid_58493 memblock_alloc_try_nid 1-2 58493 NULL
99608 +rndis_add_response_58544 rndis_add_response 2 58544 NULL
99609 +__clear_discard_58546 __clear_discard 2 58546 NULL
99610 +wep_decrypt_fail_read_58567 wep_decrypt_fail_read 3 58567 NULL
99611 +sip_sprintf_addr_port_58574 sip_sprintf_addr_port 0 58574 NULL
99612 +scnprint_mac_oui_58578 scnprint_mac_oui 3-0 58578 NULL
99613 +ea_read_inline_58589 ea_read_inline 0 58589 NULL
99614 +xip_file_read_58592 xip_file_read 3 58592 NULL
99615 +gdth_search_isa_58595 gdth_search_isa 1 58595 NULL
99616 +ebt_buf_count_58607 ebt_buf_count 0 58607 NULL
99617 +skb_copy_to_page_nocache_58624 skb_copy_to_page_nocache 6 58624 NULL
99618 +module_alloc_update_bounds_rx_58634 module_alloc_update_bounds_rx 1 58634 NULL nohasharray
99619 +efi_ioremap_58634 efi_ioremap 1-2 58634 &module_alloc_update_bounds_rx_58634
99620 +tx_tx_start_fw_gen_read_58648 tx_tx_start_fw_gen_read 3 58648 NULL
99621 +ocfs2_block_to_cluster_start_58653 ocfs2_block_to_cluster_start 2 58653 NULL
99622 +__gfn_to_pfn_58671 __gfn_to_pfn 2 58671 NULL
99623 +iwl_trans_send_cmd_58681 iwl_trans_send_cmd 0 58681 NULL
99624 +find_zero_58685 find_zero 0-1 58685 NULL nohasharray
99625 +mcs7830_set_reg_async_58685 mcs7830_set_reg_async 3 58685 &find_zero_58685
99626 +uwb_bce_print_IEs_58686 uwb_bce_print_IEs 4 58686 NULL
99627 +pci_alloc_consistent_58688 pci_alloc_consistent 0 58688 NULL
99628 +tps6586x_writes_58689 tps6586x_writes 3-2 58689 NULL
99629 +vmalloc_node_58700 vmalloc_node 1 58700 NULL
99630 +acpi_map_58725 acpi_map 1-2 58725 NULL
99631 +da9052_gpio_to_irq_58729 da9052_gpio_to_irq 2 58729 NULL
99632 +csum_exist_in_range_58730 csum_exist_in_range 2 58730 NULL
99633 +frames_to_bytes_58741 frames_to_bytes 0-2 58741 NULL
99634 +ieee80211_if_write_tkip_mic_test_58748 ieee80211_if_write_tkip_mic_test 3 58748 NULL
99635 +agp_allocate_memory_58761 agp_allocate_memory 2 58761 NULL
99636 +oblock_to_dblock_58762 oblock_to_dblock 0-2 58762 NULL
99637 +__do_config_autodelink_58763 __do_config_autodelink 3 58763 NULL
99638 +regmap_calc_reg_len_58795 regmap_calc_reg_len 0 58795 NULL
99639 +raw_send_hdrinc_58803 raw_send_hdrinc 4 58803 NULL
99640 +isku_sysfs_read_58806 isku_sysfs_read 6 58806 NULL
99641 +ep_read_58813 ep_read 3 58813 NULL
99642 +command_write_58841 command_write 3 58841 NULL
99643 +ocfs2_truncate_log_append_58850 ocfs2_truncate_log_append 3 58850 NULL
99644 +ath6kl_wmi_send_action_cmd_58860 ath6kl_wmi_send_action_cmd 7 58860 NULL
99645 +gs_alloc_req_58883 gs_alloc_req 2 58883 NULL
99646 +cs553x_init_one_58886 cs553x_init_one 3 58886 NULL
99647 +raw_ctl_compat_ioctl_58905 raw_ctl_compat_ioctl 3 58905 NULL
99648 +print_devstats_dot11FCSErrorCount_58919 print_devstats_dot11FCSErrorCount 3 58919 NULL
99649 +tun_chr_compat_ioctl_58921 tun_chr_compat_ioctl 3 58921 NULL
99650 +pipeline_cs_rx_packet_out_read_58926 pipeline_cs_rx_packet_out_read 3 58926 NULL
99651 +st5481_isoc_flatten_58952 st5481_isoc_flatten 0 58952 NULL
99652 +ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout_58965 ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout 3 58965 NULL
99653 +idx_to_kaddr_58968 idx_to_kaddr 0 58968 NULL
99654 +crypto_aead_ivsize_58970 crypto_aead_ivsize 0 58970 NULL
99655 +remap_to_cache_dirty_58991 remap_to_cache_dirty 4-3 58991 NULL
99656 +handle_rx_packet_58993 handle_rx_packet 3 58993 NULL
99657 +edac_align_ptr_59003 edac_align_ptr 0 59003 NULL
99658 +ep_write_59008 ep_write 3 59008 NULL
99659 +i915_ring_stop_write_59010 i915_ring_stop_write 3 59010 NULL
99660 +init_pci_cap_msi_perm_59033 init_pci_cap_msi_perm 2 59033 NULL
99661 +selinux_transaction_write_59038 selinux_transaction_write 3 59038 NULL
99662 +crypto_aead_reqsize_59039 crypto_aead_reqsize 0 59039 NULL
99663 +regmap_bulk_write_59049 regmap_bulk_write 4-2 59049 NULL
99664 +vfio_device_fops_compat_ioctl_59111 vfio_device_fops_compat_ioctl 3 59111 NULL
99665 +mmc_sd_num_wr_blocks_59112 mmc_sd_num_wr_blocks 0 59112 NULL
99666 +scsi_io_completion_59122 scsi_io_completion 2 59122 NULL
99667 +nfc_llcp_send_i_frame_59130 nfc_llcp_send_i_frame 3 59130 NULL
99668 +__iio_add_event_config_attrs_59136 __iio_add_event_config_attrs 0 59136 NULL
99669 +print_devstats_dot11RTSSuccessCount_59145 print_devstats_dot11RTSSuccessCount 3 59145 NULL nohasharray
99670 +framebuffer_alloc_59145 framebuffer_alloc 1 59145 &print_devstats_dot11RTSSuccessCount_59145
99671 +radeon_compat_ioctl_59150 radeon_compat_ioctl 2 59150 NULL
99672 +pvr2_hdw_report_clients_59152 pvr2_hdw_report_clients 3 59152 NULL
99673 +setup_window_59178 setup_window 4-2-5-7 59178 NULL
99674 +ocfs2_move_extent_59187 ocfs2_move_extent 3 59187 NULL
99675 +xfs_iext_realloc_indirect_59211 xfs_iext_realloc_indirect 2 59211 NULL
99676 +fast_rx_path_59214 fast_rx_path 3 59214 NULL
99677 +inftl_partscan_59216 inftl_partscan 0 59216 NULL
99678 +skb_transport_header_59223 skb_transport_header 0 59223 NULL
99679 +dt3155_read_59226 dt3155_read 3 59226 NULL
99680 +paging64_gpte_to_gfn_lvl_59229 paging64_gpte_to_gfn_lvl 0-1-2 59229 NULL
99681 +tty_prepare_flip_string_flags_59240 tty_prepare_flip_string_flags 4 59240 NULL
99682 +solo_v4l2_read_59247 solo_v4l2_read 3 59247 NULL
99683 +nla_len_59258 nla_len 0 59258 NULL
99684 +btrfs_insert_dir_item_59304 btrfs_insert_dir_item 4 59304 NULL
99685 +fd_copyout_59323 fd_copyout 3 59323 NULL
99686 +read_9287_modal_eeprom_59327 read_9287_modal_eeprom 3 59327 NULL
99687 +rx_defrag_in_process_called_read_59338 rx_defrag_in_process_called_read 3 59338 NULL
99688 +paging64_get_level1_sp_gpa_59346 paging64_get_level1_sp_gpa 0 59346 NULL nohasharray
99689 +xfs_attrmulti_attr_set_59346 xfs_attrmulti_attr_set 4 59346 &paging64_get_level1_sp_gpa_59346
99690 +xfs_dir2_sf_entsize_59366 xfs_dir2_sf_entsize 0-2 59366 NULL
99691 +pvr2_debugifc_print_info_59380 pvr2_debugifc_print_info 3 59380 NULL
99692 +fc_frame_alloc_fill_59394 fc_frame_alloc_fill 2 59394 NULL
99693 +vxge_hw_ring_rxds_per_block_get_59425 vxge_hw_ring_rxds_per_block_get 0 59425 NULL
99694 +squashfs_read_data_59440 squashfs_read_data 6 59440 NULL
99695 +fs_path_ensure_buf_59445 fs_path_ensure_buf 2 59445 NULL
99696 +descriptor_loc_59446 descriptor_loc 3 59446 NULL
99697 +do_compat_semctl_59449 do_compat_semctl 4 59449 NULL
99698 +virtqueue_add_buf_59470 virtqueue_add_buf 3-4 59470 NULL
99699 +ib_copy_from_udata_59502 ib_copy_from_udata 3 59502 NULL
99700 +nfsd_nrpools_59503 nfsd_nrpools 0 59503 NULL
99701 +rds_pin_pages_59507 rds_pin_pages 0-1-2 59507 NULL
99702 +mpi_get_nbits_59551 mpi_get_nbits 0 59551 NULL
99703 +tunables_write_59563 tunables_write 3 59563 NULL
99704 +memdup_user_59590 memdup_user 2 59590 NULL
99705 +tps6586x_irq_get_virq_59601 tps6586x_irq_get_virq 2 59601 NULL
99706 +mem_fwlog_free_mem_blks_read_59616 mem_fwlog_free_mem_blks_read 3 59616 NULL
99707 +mtrr_write_59622 mtrr_write 3 59622 NULL
99708 +find_first_zero_bit_59636 find_first_zero_bit 0-2 59636 NULL
99709 +ubifs_setxattr_59650 ubifs_setxattr 4 59650 NULL nohasharray
99710 +hidraw_read_59650 hidraw_read 3 59650 &ubifs_setxattr_59650
99711 +v9fs_xattr_set_acl_59651 v9fs_xattr_set_acl 4 59651 NULL
99712 +__devcgroup_check_permission_59665 __devcgroup_check_permission 0 59665 NULL
99713 +alloc_dca_provider_59670 alloc_dca_provider 2 59670 NULL
99714 +can_nocow_odirect_59681 can_nocow_odirect 3 59681 NULL
99715 +sriov_enable_59689 sriov_enable 2 59689 NULL
99716 +mic_calc_failure_read_59700 mic_calc_failure_read 3 59700 NULL
99717 +prism2_info_scanresults_59729 prism2_info_scanresults 3 59729 NULL
99718 +ieee80211_if_read_fwded_unicast_59740 ieee80211_if_read_fwded_unicast 3 59740 NULL
99719 +qib_decode_7220_sdma_errs_59745 qib_decode_7220_sdma_errs 4 59745 NULL
99720 +strnlen_59746 strnlen 0 59746 NULL
99721 +sctp_manip_pkt_59749 sctp_manip_pkt 4 59749 NULL
99722 +ext3_acl_count_59754 ext3_acl_count 0-1 59754 NULL
99723 +long_retry_limit_read_59766 long_retry_limit_read 3 59766 NULL
99724 +venus_remove_59781 venus_remove 4 59781 NULL
99725 +ipw_write_59807 ipw_write 3 59807 NULL
99726 +rtllib_wx_set_gen_ie_59808 rtllib_wx_set_gen_ie 3 59808 NULL
99727 +scsi_init_shared_tag_map_59812 scsi_init_shared_tag_map 2 59812 NULL
99728 +ieee80211_if_read_dot11MeshHWMPmaxPREQretries_59829 ieee80211_if_read_dot11MeshHWMPmaxPREQretries 3 59829 NULL
99729 +gspca_dev_probe2_59833 gspca_dev_probe2 4 59833 NULL
99730 +regmap_raw_write_async_59849 regmap_raw_write_async 2-4 59849 NULL
99731 +pvr2_ioread_set_sync_key_59882 pvr2_ioread_set_sync_key 3 59882 NULL
99732 +shmem_zero_setup_59885 shmem_zero_setup 0 59885 NULL
99733 +ffs_prepare_buffer_59892 ffs_prepare_buffer 2 59892 NULL
99734 +swiotlb_map_page_59909 swiotlb_map_page 3 59909 NULL
99735 +il_dbgfs_rxon_flags_read_59950 il_dbgfs_rxon_flags_read 3 59950 NULL nohasharray
99736 +dapm_widget_power_read_file_59950 dapm_widget_power_read_file 3 59950 &il_dbgfs_rxon_flags_read_59950
99737 +lookup_node_59953 lookup_node 2 59953 NULL
99738 +il_dbgfs_missed_beacon_read_59956 il_dbgfs_missed_beacon_read 3 59956 NULL nohasharray
99739 +compat_ipmi_ioctl_59956 compat_ipmi_ioctl 3 59956 &il_dbgfs_missed_beacon_read_59956
99740 +kvm_set_cr3_59965 kvm_set_cr3 2 59965 NULL
99741 +fb_getput_cmap_59971 fb_getput_cmap 3 59971 NULL
99742 +__arch_hweight16_59975 __arch_hweight16 0 59975 NULL
99743 +osd_req_read_kern_59990 osd_req_read_kern 5 59990 NULL
99744 +ghash_async_setkey_60001 ghash_async_setkey 3 60001 NULL
99745 +ieee80211_if_fmt_dot11MeshAwakeWindowDuration_60006 ieee80211_if_fmt_dot11MeshAwakeWindowDuration 3 60006 NULL
99746 +rawsock_sendmsg_60010 rawsock_sendmsg 4 60010 NULL
99747 +mthca_init_cq_60011 mthca_init_cq 2 60011 NULL
99748 +register_device_60015 register_device 2-3 60015 NULL
99749 +osd_req_list_dev_partitions_60027 osd_req_list_dev_partitions 4 60027 NULL
99750 +xlog_bread_offset_60030 xlog_bread_offset 3 60030 NULL
99751 +sys_sched_getaffinity_60033 sys_sched_getaffinity 2 60033 NULL
99752 +bio_integrity_hw_sectors_60039 bio_integrity_hw_sectors 0-2 60039 NULL
99753 +do_ip6t_set_ctl_60040 do_ip6t_set_ctl 4 60040 NULL
99754 +pin_2_irq_60050 pin_2_irq 0-3 60050 NULL nohasharray
99755 +vcs_size_60050 vcs_size 0 60050 &pin_2_irq_60050
99756 +gru_alloc_gts_60056 gru_alloc_gts 3-2 60056 NULL
99757 +compat_writev_60063 compat_writev 3 60063 NULL
99758 +ieee80211_build_probe_req_60064 ieee80211_build_probe_req 6-8 60064 NULL
99759 +c4iw_num_stags_60073 c4iw_num_stags 0 60073 NULL
99760 +mp_register_gsi_60079 mp_register_gsi 2 60079 NULL
99761 +rxrpc_kernel_send_data_60083 rxrpc_kernel_send_data 3 60083 NULL
99762 +ieee80211_if_fmt_fwded_frames_60103 ieee80211_if_fmt_fwded_frames 3 60103 NULL
99763 +ttm_bo_kmap_60118 ttm_bo_kmap 3-2 60118 NULL
99764 +jmb38x_ms_count_slots_60164 jmb38x_ms_count_slots 0 60164 NULL
99765 +init_state_60165 init_state 2 60165 NULL
99766 +sg_build_sgat_60179 sg_build_sgat 3 60179 NULL nohasharray
99767 +jffs2_alloc_full_dirent_60179 jffs2_alloc_full_dirent 1 60179 &sg_build_sgat_60179
99768 +rx_rx_tkip_replays_read_60193 rx_rx_tkip_replays_read 3 60193 NULL
99769 +svc_compat_ioctl_60194 svc_compat_ioctl 3 60194 NULL
99770 +ib_send_cm_mra_60202 ib_send_cm_mra 4 60202 NULL nohasharray
99771 +qib_reg_phys_mr_60202 qib_reg_phys_mr 3 60202 &ib_send_cm_mra_60202
99772 +set_tap_pfs_60203 set_tap_pfs 3 60203 NULL
99773 +ieee80211_mgmt_tx_60209 ieee80211_mgmt_tx 7 60209 NULL
99774 +btrfs_get_token_16_60220 btrfs_get_token_16 0 60220 NULL
99775 +arizona_map_irq_60230 arizona_map_irq 2 60230 NULL nohasharray
99776 +__phys_addr_nodebug_60230 __phys_addr_nodebug 0-1 60230 &arizona_map_irq_60230
99777 +wm831x_irq_60254 wm831x_irq 2 60254 NULL
99778 +compat_sys_fcntl64_60256 compat_sys_fcntl64 3 60256 NULL
99779 +printer_write_60276 printer_write 3 60276 NULL
99780 +__pskb_pull_tail_60287 __pskb_pull_tail 2 60287 NULL
99781 +do_xip_mapping_read_60297 do_xip_mapping_read 5 60297 NULL
99782 +getDataLength_60301 getDataLength 0 60301 NULL
99783 +ceph_parse_server_name_60318 ceph_parse_server_name 2 60318 NULL
99784 +__kfifo_from_user_r_60345 __kfifo_from_user_r 3-5 60345 NULL
99785 +dccp_setsockopt_60367 dccp_setsockopt 5 60367 NULL
99786 +ubi_eba_atomic_leb_change_60379 ubi_eba_atomic_leb_change 5 60379 NULL
99787 +instruction_pointer_60384 instruction_pointer 0 60384 NULL
99788 +mthca_alloc_resize_buf_60394 mthca_alloc_resize_buf 3 60394 NULL
99789 +ocfs2_zero_extend_60396 ocfs2_zero_extend 3 60396 NULL
99790 +driver_names_read_60399 driver_names_read 3 60399 NULL
99791 +paging32_walk_addr_generic_60415 paging32_walk_addr_generic 4 60415 NULL
99792 +simple_alloc_urb_60420 simple_alloc_urb 3 60420 NULL
99793 +excessive_retries_read_60425 excessive_retries_read 3 60425 NULL
99794 +tstats_write_60432 tstats_write 3 60432 NULL nohasharray
99795 +kmalloc_60432 kmalloc 1 60432 &tstats_write_60432
99796 +tipc_buf_acquire_60437 tipc_buf_acquire 1 60437 NULL
99797 +rx_data_60442 rx_data 4 60442 NULL
99798 +tcf_csum_ipv4_igmp_60446 tcf_csum_ipv4_igmp 3 60446 NULL
99799 +snd_hda_get_num_raw_conns_60462 snd_hda_get_num_raw_conns 0 60462 NULL
99800 +crypto_shash_setkey_60483 crypto_shash_setkey 3 60483 NULL
99801 +ath_tx_init_60515 ath_tx_init 2 60515 NULL
99802 +hysdn_sched_rx_60533 hysdn_sched_rx 3 60533 NULL
99803 +v9fs_fid_readn_60544 v9fs_fid_readn 4 60544 NULL
99804 +nonpaging_map_60551 nonpaging_map 4 60551 NULL
99805 +skb_transport_offset_60619 skb_transport_offset 0 60619 NULL
99806 +wl1273_fm_fops_write_60621 wl1273_fm_fops_write 3 60621 NULL
99807 +acl_alloc_stack_init_60630 acl_alloc_stack_init 1 60630 NULL
99808 +ubifs_recover_leb_60639 ubifs_recover_leb 3 60639 NULL
99809 +fb_get_fscreeninfo_60640 fb_get_fscreeninfo 3 60640 NULL
99810 +if_sdio_host_to_card_60666 if_sdio_host_to_card 4 60666 NULL
99811 +ieee80211_if_read_dot11MeshConfirmTimeout_60670 ieee80211_if_read_dot11MeshConfirmTimeout 3 60670 NULL
99812 +read_vbt_r10_60679 read_vbt_r10 1 60679 NULL
99813 +init_data_container_60709 init_data_container 1 60709 NULL
99814 +snd_ice1712_ds_read_60754 snd_ice1712_ds_read 0 60754 NULL
99815 +raid_status_60755 raid_status 5 60755 NULL
99816 +sel_write_checkreqprot_60774 sel_write_checkreqprot 3 60774 NULL
99817 +opticon_write_60775 opticon_write 4 60775 NULL
99818 +acl_alloc_num_60778 acl_alloc_num 1-2 60778 NULL
99819 +snd_pcm_oss_readv3_60792 snd_pcm_oss_readv3 3 60792 NULL
99820 +pwr_tx_with_ps_read_60851 pwr_tx_with_ps_read 3 60851 NULL
99821 +alloc_buf_60864 alloc_buf 3-2 60864 NULL
99822 +generic_writepages_60871 generic_writepages 0 60871 NULL
99823 +ext4_update_inline_data_60888 ext4_update_inline_data 3 60888 NULL
99824 +iio_debugfs_read_reg_60908 iio_debugfs_read_reg 3 60908 NULL
99825 +mgt_set_varlen_60916 mgt_set_varlen 4 60916 NULL
99826 +scrub_chunk_60926 scrub_chunk 5 60926 NULL
99827 +sys_mlock_60932 sys_mlock 1 60932 NULL
99828 +pti_char_write_60960 pti_char_write 3 60960 NULL
99829 +mwifiex_alloc_sdio_mpa_buffers_60961 mwifiex_alloc_sdio_mpa_buffers 2-3 60961 NULL
99830 +__a2mp_build_60987 __a2mp_build 3 60987 NULL
99831 +hsc_msg_alloc_60990 hsc_msg_alloc 1 60990 NULL
99832 +ath6kl_lrssi_roam_read_61022 ath6kl_lrssi_roam_read 3 61022 NULL
99833 +symtab_init_61050 symtab_init 2 61050 NULL
99834 +fuse_send_write_61053 fuse_send_write 0 61053 NULL
99835 +bitmap_scnlistprintf_61062 bitmap_scnlistprintf 0-4-2 61062 NULL
99836 +ahash_align_buffer_size_61070 ahash_align_buffer_size 0-1-2 61070 NULL
99837 +get_derived_key_61100 get_derived_key 4 61100 NULL
99838 +alloc_chrdev_region_61112 alloc_chrdev_region 0 61112 NULL
99839 +p80211_headerlen_61119 p80211_headerlen 0 61119 NULL nohasharray
99840 +__probe_kernel_read_61119 __probe_kernel_read 3 61119 &p80211_headerlen_61119
99841 +vmemmap_alloc_block_buf_61126 vmemmap_alloc_block_buf 1 61126 NULL
99842 +afs_proc_cells_write_61139 afs_proc_cells_write 3 61139 NULL
99843 +__vmalloc_61168 __vmalloc 1 61168 NULL
99844 +event_oom_late_read_61175 event_oom_late_read 3 61175 NULL nohasharray
99845 +pair_device_61175 pair_device 4 61175 &event_oom_late_read_61175
99846 +sys_lsetxattr_61177 sys_lsetxattr 4 61177 NULL
99847 +arch_hibernation_header_save_61212 arch_hibernation_header_save 0 61212 NULL
99848 +smk_read_ambient_61220 smk_read_ambient 3 61220 NULL
99849 +btrfs_bio_alloc_61270 btrfs_bio_alloc 3 61270 NULL
99850 +vortex_adbdma_getlinearpos_61283 vortex_adbdma_getlinearpos 0 61283 NULL
99851 +sys_add_key_61288 sys_add_key 4 61288 NULL
99852 +ext4_issue_discard_61305 ext4_issue_discard 2 61305 NULL
99853 +xfrm_user_sec_ctx_size_61320 xfrm_user_sec_ctx_size 0 61320 NULL
99854 +st5481_setup_isocpipes_61340 st5481_setup_isocpipes 6-4 61340 NULL
99855 +rx_rx_wa_ba_not_expected_read_61341 rx_rx_wa_ba_not_expected_read 3 61341 NULL
99856 +f1x_map_sysaddr_to_csrow_61344 f1x_map_sysaddr_to_csrow 2 61344 NULL
99857 +debug_debug4_read_61367 debug_debug4_read 3 61367 NULL
99858 +sys_ptrace_61369 sys_ptrace 3 61369 NULL
99859 +change_xattr_61390 change_xattr 5 61390 NULL
99860 +size_entry_mwt_61400 size_entry_mwt 0 61400 NULL
99861 +dma_ops_area_alloc_61440 dma_ops_area_alloc 3-4-5 61440 NULL
99862 +tc3589x_irq_unmap_61447 tc3589x_irq_unmap 2 61447 NULL
99863 +unix_stream_sendmsg_61455 unix_stream_sendmsg 4 61455 NULL
99864 +snd_pcm_lib_writev_transfer_61483 snd_pcm_lib_writev_transfer 4-2-5 61483 NULL
99865 +btrfs_item_size_61485 btrfs_item_size 0 61485 NULL
99866 +erst_errno_61526 erst_errno 0 61526 NULL
99867 +ntfs_attr_lookup_61539 ntfs_attr_lookup 0 61539 NULL
99868 +o2hb_pop_count_61553 o2hb_pop_count 2 61553 NULL
99869 +dvb_net_ioctl_61559 dvb_net_ioctl 2 61559 NULL
99870 +ieee80211_if_read_rc_rateidx_mask_2ghz_61570 ieee80211_if_read_rc_rateidx_mask_2ghz 3 61570 NULL
99871 +seq_open_private_61589 seq_open_private 3 61589 NULL
99872 +__get_vm_area_61599 __get_vm_area 1 61599 NULL
99873 +nfs4_init_uniform_client_string_61601 nfs4_init_uniform_client_string 3 61601 NULL
99874 +ncp_compat_ioctl_61608 ncp_compat_ioctl 3 61608 NULL
99875 +configfs_write_file_61621 configfs_write_file 3 61621 NULL
99876 +ieee80211_if_fmt_hw_queues_61629 ieee80211_if_fmt_hw_queues 3 61629 NULL
99877 +i2o_parm_table_get_61635 i2o_parm_table_get 6 61635 NULL
99878 +snd_pcm_oss_read3_61643 snd_pcm_oss_read3 0-3 61643 NULL
99879 +resize_stripes_61650 resize_stripes 2 61650 NULL
99880 +ttm_page_pool_free_61661 ttm_page_pool_free 2 61661 NULL
99881 +insert_one_name_61668 insert_one_name 7 61668 NULL
99882 +lock_loop_61681 lock_loop 1 61681 NULL
99883 +filter_read_61692 filter_read 3 61692 NULL
99884 +iov_length_61716 iov_length 0 61716 NULL
99885 +fragmentation_threshold_read_61718 fragmentation_threshold_read 3 61718 NULL
99886 +read_file_interrupt_61742 read_file_interrupt 3 61742 NULL nohasharray
99887 +read_file_regval_61742 read_file_regval 3 61742 &read_file_interrupt_61742
99888 +batadv_dat_snoop_incoming_arp_reply_61801 batadv_dat_snoop_incoming_arp_reply 3 61801 NULL
99889 +tps80031_irq_init_61830 tps80031_irq_init 3 61830 NULL
99890 +bfad_debugfs_write_regwr_61841 bfad_debugfs_write_regwr 3 61841 NULL
99891 +fs_path_prepare_for_add_61854 fs_path_prepare_for_add 2 61854 NULL
99892 +evdev_compute_buffer_size_61863 evdev_compute_buffer_size 0 61863 NULL
99893 +get_fw_name_61874 get_fw_name 3 61874 NULL
99894 +free_init_pages_61875 free_init_pages 2 61875 NULL
99895 +twl4030_sih_setup_61878 twl4030_sih_setup 3 61878 NULL
99896 +ieee80211_rtl_auth_challenge_61897 ieee80211_rtl_auth_challenge 3 61897 NULL
99897 +ax25_addr_size_61899 ax25_addr_size 0 61899 NULL nohasharray
99898 +cxgb4_pktgl_to_skb_61899 cxgb4_pktgl_to_skb 2 61899 &ax25_addr_size_61899
99899 +clear_refs_write_61904 clear_refs_write 3 61904 NULL
99900 +rx_filter_arp_filter_read_61914 rx_filter_arp_filter_read 3 61914 NULL
99901 +au0828_init_isoc_61917 au0828_init_isoc 3-2 61917 NULL
99902 +sctp_sendmsg_61919 sctp_sendmsg 4 61919 NULL
99903 +send_bulk_static_data_61932 send_bulk_static_data 3 61932 NULL
99904 +gfn_to_pfn_memslot_atomic_61947 gfn_to_pfn_memslot_atomic 2 61947 NULL
99905 +il4965_ucode_rx_stats_read_61948 il4965_ucode_rx_stats_read 3 61948 NULL
99906 +squashfs_read_id_index_table_61961 squashfs_read_id_index_table 4 61961 NULL
99907 +mlx4_alloc_mtt_range_61966 mlx4_alloc_mtt_range 2 61966 NULL
99908 +ocfs2_quota_write_61972 ocfs2_quota_write 5-4 61972 NULL
99909 +cow_file_range_61979 cow_file_range 3 61979 NULL
99910 +module_alloc_exec_61991 module_alloc_exec 1 61991 NULL
99911 +virtnet_send_command_61993 virtnet_send_command 5-6 61993 NULL
99912 +xt_compat_match_offset_62011 xt_compat_match_offset 0 62011 NULL
99913 +jffs2_do_unlink_62020 jffs2_do_unlink 4 62020 NULL
99914 +pmcraid_build_passthrough_ioadls_62034 pmcraid_build_passthrough_ioadls 2 62034 NULL
99915 +ppp_tx_cp_62044 ppp_tx_cp 5 62044 NULL
99916 +sctp_user_addto_chunk_62047 sctp_user_addto_chunk 2-3 62047 NULL
99917 +do_pselect_62061 do_pselect 1 62061 NULL
99918 +pcpu_alloc_bootmem_62074 pcpu_alloc_bootmem 2-3 62074 NULL
99919 +get_domain_for_dev_62099 get_domain_for_dev 2 62099 NULL
99920 +ipath_user_sdma_pin_pages_62100 ipath_user_sdma_pin_pages 3-5 62100 NULL
99921 +jffs2_security_setxattr_62107 jffs2_security_setxattr 4 62107 NULL
99922 +llc_ui_header_len_62131 llc_ui_header_len 0 62131 NULL
99923 +qib_diag_write_62133 qib_diag_write 3 62133 NULL
99924 +ql_status_62135 ql_status 5 62135 NULL
99925 +video_usercopy_62151 video_usercopy 2 62151 NULL
99926 +prism54_wpa_bss_ie_get_62173 prism54_wpa_bss_ie_get 0 62173 NULL
99927 +alloc_upcall_62186 alloc_upcall 2 62186 NULL
99928 +btrfs_xattr_acl_set_62203 btrfs_xattr_acl_set 4 62203 NULL
99929 +sock_kmalloc_62205 sock_kmalloc 2 62205 NULL
99930 +nfsd_read_file_62241 nfsd_read_file 6 62241 NULL
99931 +allocate_partition_62245 allocate_partition 4 62245 NULL
99932 +__qib_get_user_pages_62287 __qib_get_user_pages 1-2 62287 NULL
99933 +il_dbgfs_sram_read_62296 il_dbgfs_sram_read 3 62296 NULL
99934 +sparse_early_usemaps_alloc_pgdat_section_62304 sparse_early_usemaps_alloc_pgdat_section 2 62304 NULL
99935 +subsystem_filter_read_62310 subsystem_filter_read 3 62310 NULL
99936 +udf_sb_alloc_partition_maps_62313 udf_sb_alloc_partition_maps 2 62313 NULL
99937 +Wb35Reg_BurstWrite_62327 Wb35Reg_BurstWrite 4 62327 NULL
99938 +subseq_list_62332 subseq_list 3-0 62332 NULL
99939 +flash_write_62354 flash_write 3 62354 NULL
99940 +set_wd_exp_mode_pfs_62372 set_wd_exp_mode_pfs 3 62372 NULL
99941 +twl_get_num_slaves_62386 twl_get_num_slaves 0 62386 NULL
99942 +rx_rx_timeout_read_62389 rx_rx_timeout_read 3 62389 NULL
99943 +altera_irscan_62396 altera_irscan 2 62396 NULL
99944 +set_ssp_62411 set_ssp 4 62411 NULL
99945 +unmap_single_62423 unmap_single 2 62423 NULL
99946 +netdev_alloc_skb_62437 netdev_alloc_skb 2 62437 NULL
99947 +e1000_check_copybreak_62448 e1000_check_copybreak 3 62448 NULL
99948 +ip_vs_icmp_xmit_v6_62477 ip_vs_icmp_xmit_v6 4 62477 NULL
99949 +ceph_dns_resolve_name_62488 ceph_dns_resolve_name 2 62488 NULL
99950 +remove_mapping_62491 remove_mapping 2 62491 NULL
99951 +mlx4_en_create_rx_ring_62498 mlx4_en_create_rx_ring 3 62498 NULL
99952 +ext_rts51x_sd_execute_read_data_62501 ext_rts51x_sd_execute_read_data 9 62501 NULL
99953 +pep_sendmsg_62524 pep_sendmsg 4 62524 NULL nohasharray
99954 +i915_next_seqno_read_62524 i915_next_seqno_read 3 62524 &pep_sendmsg_62524
99955 +test_iso_queue_62534 test_iso_queue 5 62534 NULL
99956 +debugfs_read_62535 debugfs_read 3 62535 NULL
99957 +sco_sock_sendmsg_62542 sco_sock_sendmsg 4 62542 NULL
99958 +qib_refresh_qsfp_cache_62547 qib_refresh_qsfp_cache 0 62547 NULL
99959 +xfrm_user_policy_62573 xfrm_user_policy 4 62573 NULL
99960 +get_subdir_62581 get_subdir 3 62581 NULL
99961 +prism2_send_mgmt_62605 prism2_send_mgmt 4 62605 NULL nohasharray
99962 +nfsd_vfs_read_62605 nfsd_vfs_read 6 62605 &prism2_send_mgmt_62605
99963 +iommu_area_alloc_62619 iommu_area_alloc 2-3-4-7 62619 NULL
99964 +ems_pcmcia_add_card_62627 ems_pcmcia_add_card 2 62627 NULL
99965 +compat_rangeinfo_62630 compat_rangeinfo 2 62630 NULL
99966 +lpfc_sli4_queue_alloc_62646 lpfc_sli4_queue_alloc 3 62646 NULL
99967 +memblock_alloc_nid_62652 memblock_alloc_nid 1-2 62652 NULL
99968 +ima_file_mmap_62663 ima_file_mmap 0 62663 NULL
99969 +write_62671 write 3 62671 NULL
99970 +printer_req_alloc_62687 printer_req_alloc 2 62687 NULL
99971 +qla4_83xx_rd_reg_62693 qla4_83xx_rd_reg 0 62693 NULL
99972 +ioremap_wc_62695 ioremap_wc 1-2 62695 NULL
99973 +bioset_integrity_create_62708 bioset_integrity_create 2 62708 NULL
99974 +rdm_62719 rdm 0 62719 NULL
99975 +key_replays_read_62746 key_replays_read 3 62746 NULL
99976 +init_chip_wc_pat_62768 init_chip_wc_pat 2 62768 NULL
99977 +ax25_sendmsg_62770 ax25_sendmsg 4 62770 NULL
99978 +page_key_alloc_62771 page_key_alloc 0 62771 NULL
99979 +tracing_total_entries_read_62817 tracing_total_entries_read 3 62817 NULL
99980 +__rounddown_pow_of_two_62836 __rounddown_pow_of_two 0 62836 NULL
99981 +bio_get_nr_vecs_62838 bio_get_nr_vecs 0 62838 NULL
99982 +xlog_recover_add_to_trans_62839 xlog_recover_add_to_trans 4 62839 NULL
99983 +rx_fcs_err_read_62844 rx_fcs_err_read 3 62844 NULL
99984 +set_swbp_62853 set_swbp 3 62853 NULL
99985 +hpi_read_word_62862 hpi_read_word 0 62862 NULL
99986 +aoechr_write_62883 aoechr_write 3 62883 NULL
99987 +resize_info_buffer_62889 resize_info_buffer 2 62889 NULL
99988 +if_spi_host_to_card_62890 if_spi_host_to_card 4 62890 NULL
99989 +mempool_create_slab_pool_62907 mempool_create_slab_pool 1 62907 NULL
99990 +getdqbuf_62908 getdqbuf 1 62908 NULL
99991 +try_async_pf_62914 try_async_pf 3 62914 NULL
99992 +agp_create_user_memory_62955 agp_create_user_memory 1 62955 NULL
99993 +__vb2_perform_fileio_63033 __vb2_perform_fileio 3 63033 NULL
99994 +pipeline_defrag_to_csum_swi_read_63037 pipeline_defrag_to_csum_swi_read 3 63037 NULL
99995 +scsi_host_alloc_63041 scsi_host_alloc 2 63041 NULL
99996 +unlink1_63059 unlink1 3 63059 NULL
99997 +xen_set_nslabs_63066 xen_set_nslabs 0 63066 NULL
99998 +ocfs2_decrease_refcount_63078 ocfs2_decrease_refcount 3 63078 NULL
99999 +sep_prepare_input_output_dma_table_in_dcb_63087 sep_prepare_input_output_dma_table_in_dcb 4-5-2-3 63087 NULL
100000 +iwl_dbgfs_sensitivity_read_63116 iwl_dbgfs_sensitivity_read 3 63116 NULL
100001 +alloc_cblock_63133 alloc_cblock 2 63133 NULL
100002 +ib_send_cm_rtu_63138 ib_send_cm_rtu 3 63138 NULL
100003 +xen_zap_pfn_range_63149 xen_zap_pfn_range 1 63149 NULL
100004 +smk_write_revoke_subj_63173 smk_write_revoke_subj 3 63173 NULL
100005 +vme_master_read_63221 vme_master_read 0 63221 NULL
100006 +module_alloc_update_bounds_rw_63233 module_alloc_update_bounds_rw 1 63233 NULL
100007 +ptp_read_63251 ptp_read 4 63251 NULL
100008 +raid5_resize_63306 raid5_resize 2 63306 NULL
100009 +proc_info_read_63344 proc_info_read 3 63344 NULL
100010 +ps_upsd_max_sptime_read_63362 ps_upsd_max_sptime_read 3 63362 NULL
100011 +idmouse_read_63374 idmouse_read 3 63374 NULL
100012 +edac_pci_alloc_ctl_info_63388 edac_pci_alloc_ctl_info 1 63388 NULL nohasharray
100013 +usbnet_read_cmd_nopm_63388 usbnet_read_cmd_nopm 7 63388 &edac_pci_alloc_ctl_info_63388
100014 +rxpipe_missed_beacon_host_int_trig_rx_data_read_63405 rxpipe_missed_beacon_host_int_trig_rx_data_read 3 63405 NULL
100015 +nouveau_event_create_63411 nouveau_event_create 1 63411 NULL
100016 +l2cap_sock_sendmsg_63427 l2cap_sock_sendmsg 4 63427 NULL
100017 +sep_prepare_input_output_dma_table_63429 sep_prepare_input_output_dma_table 2-4-3 63429 NULL
100018 +kone_send_63435 kone_send 4 63435 NULL
100019 +gfn_to_hva_many_63437 gfn_to_hva_many 0-2 63437 NULL
100020 +nfsd_symlink_63442 nfsd_symlink 6 63442 NULL
100021 +ipv6_is_mld_63461 ipv6_is_mld 3 63461 NULL
100022 +snd_info_entry_write_63474 snd_info_entry_write 3 63474 NULL
100023 +reada_find_extent_63486 reada_find_extent 2 63486 NULL
100024 +read_kcore_63488 read_kcore 3 63488 NULL
100025 +save_hint_63497 save_hint 2 63497 NULL
100026 +snd_pcm_plug_write_transfer_63503 snd_pcm_plug_write_transfer 0-3 63503 NULL
100027 +ubi_more_leb_change_data_63534 ubi_more_leb_change_data 4 63534 NULL
100028 +if_sdio_read_scratch_63540 if_sdio_read_scratch 0 63540 NULL
100029 +append_to_buffer_63550 append_to_buffer 3 63550 NULL
100030 +dbg_leb_write_63555 dbg_leb_write 4-5 63555 NULL nohasharray
100031 +kvm_write_guest_page_63555 kvm_write_guest_page 5-2 63555 &dbg_leb_write_63555
100032 +ubifs_lpt_scan_nolock_63572 ubifs_lpt_scan_nolock 0 63572 NULL
100033 +iwch_reg_user_mr_63575 iwch_reg_user_mr 2-3 63575 NULL
100034 +ocfs2_calc_trunc_pos_63576 ocfs2_calc_trunc_pos 4 63576 NULL
100035 +rproc_alloc_63577 rproc_alloc 5 63577 NULL
100036 +ext3_clear_blocks_63597 ext3_clear_blocks 4-5 63597 NULL
100037 +module_alloc_63630 module_alloc 1 63630 NULL
100038 +ntfs_malloc_nofs_nofail_63631 ntfs_malloc_nofs_nofail 1 63631 NULL
100039 +symbol_build_supp_rates_63634 symbol_build_supp_rates 0 63634 NULL
100040 +_ubh_find_next_zero_bit__63640 _ubh_find_next_zero_bit_ 4-5-3 63640 NULL
100041 +proc_loginuid_write_63648 proc_loginuid_write 3 63648 NULL
100042 +ValidateDSDParamsChecksum_63654 ValidateDSDParamsChecksum 3 63654 NULL
100043 +hidraw_ioctl_63658 hidraw_ioctl 2 63658 NULL
100044 +vbi_read_63673 vbi_read 3 63673 NULL nohasharray
100045 +xen_register_pirq_63673 xen_register_pirq 1-2 63673 &vbi_read_63673
100046 +alloc_tty_driver_63681 alloc_tty_driver 1 63681 NULL
100047 +mkiss_compat_ioctl_63686 mkiss_compat_ioctl 4 63686 NULL
100048 +arizona_irq_map_63709 arizona_irq_map 2 63709 NULL
100049 +nouveau_object_create__63715 nouveau_object_create_ 5 63715 NULL
100050 +btrfs_insert_delayed_dir_index_63720 btrfs_insert_delayed_dir_index 4 63720 NULL
100051 +selinux_secctx_to_secid_63744 selinux_secctx_to_secid 2 63744 NULL
100052 +snd_pcm_oss_read1_63771 snd_pcm_oss_read1 3 63771 NULL
100053 +snd_opl4_mem_proc_read_63774 snd_opl4_mem_proc_read 5 63774 NULL
100054 +spidev_compat_ioctl_63778 spidev_compat_ioctl 2-3 63778 NULL
100055 +snapshot_compat_ioctl_63792 snapshot_compat_ioctl 3 63792 NULL
100056 +kovaplus_sysfs_write_63795 kovaplus_sysfs_write 6 63795 NULL
100057 +mwifiex_11n_create_rx_reorder_tbl_63806 mwifiex_11n_create_rx_reorder_tbl 4 63806 NULL
100058 +copy_nodes_to_user_63807 copy_nodes_to_user 2 63807 NULL
100059 +sel_write_load_63830 sel_write_load 3 63830 NULL
100060 +proc_pid_attr_write_63845 proc_pid_attr_write 3 63845 NULL
100061 +init_map_ipmac_63896 init_map_ipmac 4-3 63896 NULL
100062 +divas_write_63901 divas_write 3 63901 NULL
100063 +xhci_alloc_stream_info_63902 xhci_alloc_stream_info 3 63902 NULL
100064 +uvc_alloc_urb_buffers_63922 uvc_alloc_urb_buffers 0-3-2 63922 NULL
100065 +snd_compr_write_63923 snd_compr_write 3 63923 NULL
100066 +acpi_ev_get_gpe_xrupt_block_63924 acpi_ev_get_gpe_xrupt_block 1 63924 NULL
100067 +tipc_send2port_63935 tipc_send2port 5 63935 NULL
100068 +afs_send_simple_reply_63940 afs_send_simple_reply 3 63940 NULL
100069 +__team_options_register_63941 __team_options_register 3 63941 NULL
100070 +macvtap_recvmsg_63949 macvtap_recvmsg 4 63949 NULL
100071 +ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz_63968 ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz 3 63968 NULL
100072 +ieee80211_authentication_req_63973 ieee80211_authentication_req 3 63973 NULL
100073 +diva_xdi_write_63975 diva_xdi_write 4 63975 NULL
100074 +read_file_frameerrors_64001 read_file_frameerrors 3 64001 NULL
100075 +kmemdup_64015 kmemdup 2 64015 NULL
100076 +offset_to_vaddr_64025 offset_to_vaddr 0-2 64025 NULL nohasharray
100077 +tcf_csum_skb_nextlayer_64025 tcf_csum_skb_nextlayer 3 64025 &offset_to_vaddr_64025
100078 +dbAllocDmapLev_64030 dbAllocDmapLev 0 64030 NULL
100079 +resize_async_buffer_64031 resize_async_buffer 4 64031 NULL
100080 +sep_lli_table_secure_dma_64042 sep_lli_table_secure_dma 2-3 64042 NULL
100081 +get_u8_64076 get_u8 0 64076 NULL
100082 +sl_realloc_bufs_64086 sl_realloc_bufs 2 64086 NULL
100083 +vmci_handle_arr_get_size_64088 vmci_handle_arr_get_size 0 64088 NULL
100084 +lbs_highrssi_read_64089 lbs_highrssi_read 3 64089 NULL
100085 +do_load_xattr_datum_64118 do_load_xattr_datum 0 64118 NULL
100086 +ol_quota_entries_per_block_64122 ol_quota_entries_per_block 0 64122 NULL
100087 +ext4_prepare_inline_data_64124 ext4_prepare_inline_data 3 64124 NULL
100088 +init_bch_64130 init_bch 1-2 64130 NULL
100089 +uea_idma_write_64139 uea_idma_write 3 64139 NULL
100090 +ablkcipher_copy_iv_64140 ablkcipher_copy_iv 3 64140 NULL
100091 +dlfb_ops_write_64150 dlfb_ops_write 3 64150 NULL
100092 +__comedi_buf_alloc_64155 __comedi_buf_alloc 3 64155 NULL
100093 +cpumask_scnprintf_64170 cpumask_scnprintf 2 64170 NULL
100094 +read_pulse_64227 read_pulse 0-3 64227 NULL
100095 +header_len_64232 header_len 0 64232 NULL
100096 +redrat3_transmit_ir_64244 redrat3_transmit_ir 3 64244 NULL
100097 +io_capture_transfer_64276 io_capture_transfer 4 64276 NULL
100098 +btrfs_file_extent_offset_64278 btrfs_file_extent_offset 0 64278 NULL
100099 +sta_current_tx_rate_read_64286 sta_current_tx_rate_read 3 64286 NULL
100100 +event_id_read_64288 event_id_read 3 64288 NULL nohasharray
100101 +xfs_dir_cilookup_result_64288 xfs_dir_cilookup_result 3 64288 &event_id_read_64288
100102 +ocfs2_block_check_validate_bhs_64302 ocfs2_block_check_validate_bhs 0 64302 NULL
100103 +error_error_bar_retry_read_64305 error_error_bar_retry_read 3 64305 NULL
100104 +ffz_64324 ffz 0 64324 NULL
100105 +sisusbcon_clear_64329 sisusbcon_clear 4-3-5 64329 NULL
100106 +ts_write_64336 ts_write 3 64336 NULL
100107 +usbtmc_write_64340 usbtmc_write 3 64340 NULL
100108 +do_write_orph_node_64343 do_write_orph_node 2 64343 NULL
100109 +ft1000_read_reg_64352 ft1000_read_reg 0 64352 NULL
100110 +bnx2x_vfop_mcast_cmd_64354 bnx2x_vfop_mcast_cmd 5 64354 NULL
100111 +wlc_phy_loadsampletable_nphy_64367 wlc_phy_loadsampletable_nphy 3 64367 NULL
100112 +ilo_write_64378 ilo_write 3 64378 NULL
100113 +btrfs_map_block_64379 btrfs_map_block 3 64379 NULL
100114 +vmcs_readl_64381 vmcs_readl 0 64381 NULL
100115 +nilfs_alloc_seg_bio_64383 nilfs_alloc_seg_bio 3 64383 NULL
100116 +ir_lirc_transmit_ir_64403 ir_lirc_transmit_ir 3 64403 NULL
100117 +pidlist_allocate_64404 pidlist_allocate 1 64404 NULL
100118 +rx_hdr_overflow_read_64407 rx_hdr_overflow_read 3 64407 NULL
100119 +snd_card_create_64418 snd_card_create 4 64418 NULL nohasharray
100120 +keyctl_get_security_64418 keyctl_get_security 3 64418 &snd_card_create_64418
100121 +nl80211_send_mgmt_64419 nl80211_send_mgmt 7 64419 NULL
100122 +oom_adj_write_64428 oom_adj_write 3 64428 NULL
100123 +ext4_trim_extent_64431 ext4_trim_extent 4 64431 NULL nohasharray
100124 +read_file_spectral_short_repeat_64431 read_file_spectral_short_repeat 3 64431 &ext4_trim_extent_64431
100125 +cap_capable_64462 cap_capable 0 64462 NULL
100126 +ip_vs_create_timeout_table_64478 ip_vs_create_timeout_table 2 64478 NULL
100127 +p54_parse_rssical_64493 p54_parse_rssical 3 64493 NULL
100128 +msg_data_sz_64503 msg_data_sz 0 64503 NULL
100129 +remove_uuid_64505 remove_uuid 4 64505 NULL nohasharray
100130 +handle_abnormal_pfn_64505 handle_abnormal_pfn 3 64505 &remove_uuid_64505
100131 +crypto_blkcipher_alignmask_64520 crypto_blkcipher_alignmask 0 64520 NULL
100132 +opera1_usb_i2c_msgxfer_64521 opera1_usb_i2c_msgxfer 4 64521 NULL
100133 +ses_send_diag_64527 ses_send_diag 4 64527 NULL
100134 +prctl_set_mm_64538 prctl_set_mm 3 64538 NULL
100135 +__spi_sync_64561 __spi_sync 0 64561 NULL
100136 +__apei_exec_run_64563 __apei_exec_run 0 64563 NULL
100137 +fanotify_write_64623 fanotify_write 3 64623 NULL
100138 +to_dblock_64655 to_dblock 0-1 64655 NULL
100139 +regmap_read_debugfs_64658 regmap_read_debugfs 5 64658 NULL
100140 +ocfs2_read_xattr_block_64661 ocfs2_read_xattr_block 0 64661 NULL nohasharray
100141 +tlbflush_read_file_64661 tlbflush_read_file 3 64661 &ocfs2_read_xattr_block_64661
100142 +efx_tsoh_get_buffer_64664 efx_tsoh_get_buffer 3 64664 NULL
100143 +rx_rx_out_of_mpdu_nodes_read_64668 rx_rx_out_of_mpdu_nodes_read 3 64668 NULL
100144 +nr_free_zone_pages_64680 nr_free_zone_pages 0 64680 NULL
100145 +sec_bulk_write_64691 sec_bulk_write 2-3 64691 NULL
100146 +__feat_register_sp_64712 __feat_register_sp 6 64712 NULL
100147 +snd_pcm_oss_capture_position_fixup_64713 snd_pcm_oss_capture_position_fixup 0 64713 NULL
100148 +dapm_bias_read_file_64715 dapm_bias_read_file 3 64715 NULL
100149 +atomic_add_return_64720 atomic_add_return 0-1 64720 NULL
100150 +i2400m_msg_to_dev_64722 i2400m_msg_to_dev 3 64722 NULL
100151 +squashfs_read_inode_lookup_table_64739 squashfs_read_inode_lookup_table 4 64739 NULL
100152 +bio_map_kern_64751 bio_map_kern 3 64751 NULL
100153 +rt2x00debug_write_csr_64753 rt2x00debug_write_csr 3 64753 NULL
100154 +isr_low_rssi_read_64789 isr_low_rssi_read 3 64789 NULL
100155 +nfsctl_transaction_write_64800 nfsctl_transaction_write 3 64800 NULL
100156 +megaraid_change_queue_depth_64815 megaraid_change_queue_depth 2 64815 NULL
100157 +ecryptfs_send_miscdev_64816 ecryptfs_send_miscdev 2 64816 NULL
100158 +vaddr_get_pfn_64818 vaddr_get_pfn 1 64818 NULL
100159 +gfn_to_page_64826 gfn_to_page 2 64826 NULL
100160 +do_kimage_alloc_64827 do_kimage_alloc 3 64827 NULL
100161 +altera_set_dr_pre_64862 altera_set_dr_pre 2 64862 NULL
100162 +gfn_to_pfn_64870 gfn_to_pfn 2 64870 NULL
100163 +ffs_epfile_io_64886 ffs_epfile_io 3 64886 NULL
100164 +ieee80211_if_read_ave_beacon_64924 ieee80211_if_read_ave_beacon 3 64924 NULL
100165 +ubifs_wbuf_write_nolock_64946 ubifs_wbuf_write_nolock 3 64946 NULL
100166 +snd_rawmidi_ioctl_compat_64954 snd_rawmidi_ioctl_compat 3 64954 NULL
100167 +ip_options_get_from_user_64958 ip_options_get_from_user 4 64958 NULL
100168 +acpi_os_install_interrupt_handler_64968 acpi_os_install_interrupt_handler 1 64968 NULL
100169 +traceprobe_probes_write_64969 traceprobe_probes_write 3 64969 NULL
100170 +suspend_dtim_interval_read_64971 suspend_dtim_interval_read 3 64971 NULL
100171 +ext2_group_first_block_no_64972 ext2_group_first_block_no 0-2 64972 NULL
100172 +pskb_pull_65005 pskb_pull 2 65005 NULL
100173 +unifi_write_65012 unifi_write 3 65012 NULL
100174 +crypto_ahash_digestsize_65014 crypto_ahash_digestsize 0 65014 NULL
100175 +nfs_readdata_alloc_65015 nfs_readdata_alloc 2 65015 NULL
100176 +insert_dent_65034 insert_dent 7 65034 NULL
100177 +compat_put_ushort_65040 compat_put_ushort 1 65040 NULL
100178 +brcmf_sdcard_rwdata_65041 brcmf_sdcard_rwdata 5 65041 NULL
100179 +tty_audit_log_65043 tty_audit_log 8 65043 NULL
100180 +compat_cmdtest_65064 compat_cmdtest 2 65064 NULL
100181 +count_run_65072 count_run 0-2-4 65072 NULL nohasharray
100182 +bnx2fc_process_l2_frame_compl_65072 bnx2fc_process_l2_frame_compl 3 65072 &count_run_65072
100183 +__alloc_bootmem_node_high_65076 __alloc_bootmem_node_high 2-3 65076 NULL
100184 +ocfs2_truncate_cluster_pages_65086 ocfs2_truncate_cluster_pages 2 65086 NULL
100185 +ath9k_dump_mci_btcoex_65090 ath9k_dump_mci_btcoex 0 65090 NULL
100186 +ssb_bus_register_65183 ssb_bus_register 3 65183 NULL
100187 +rx_rx_done_read_65217 rx_rx_done_read 3 65217 NULL
100188 +print_endpoint_stat_65232 print_endpoint_stat 3-4-0 65232 NULL
100189 +whci_n_caps_65247 whci_n_caps 0 65247 NULL
100190 +kmem_zalloc_greedy_65268 kmem_zalloc_greedy 3-2 65268 NULL
100191 +kmalloc_parameter_65279 kmalloc_parameter 1 65279 NULL
100192 +compat_core_sys_select_65285 compat_core_sys_select 1 65285 NULL
100193 +mpi_set_buffer_65294 mpi_set_buffer 3 65294 NULL
100194 +redirected_tty_write_65297 redirected_tty_write 3 65297 NULL
100195 +get_var_len_65304 get_var_len 0 65304 NULL
100196 +unpack_array_65318 unpack_array 0 65318 NULL
100197 +pci_vpd_find_tag_65325 pci_vpd_find_tag 0-2 65325 NULL
100198 +dccp_setsockopt_service_65336 dccp_setsockopt_service 4 65336 NULL
100199 +dma_rx_requested_read_65354 dma_rx_requested_read 3 65354 NULL
100200 +batadv_tt_save_orig_buffer_65361 batadv_tt_save_orig_buffer 4 65361 NULL
100201 +alloc_cpu_rmap_65363 alloc_cpu_rmap 1 65363 NULL
100202 +__ext4_new_inode_65370 __ext4_new_inode 5 65370 NULL
100203 +strchr_65372 strchr 0 65372 NULL
100204 +__alloc_bootmem_nopanic_65397 __alloc_bootmem_nopanic 1-2 65397 NULL
100205 +trace_seq_to_user_65398 trace_seq_to_user 3 65398 NULL
100206 +mtd_get_device_size_65400 mtd_get_device_size 0 65400 NULL
100207 +iio_device_add_channel_sysfs_65406 iio_device_add_channel_sysfs 0 65406 NULL
100208 +ocfs2_write_begin_nolock_65410 ocfs2_write_begin_nolock 3-4 65410 NULL
100209 +drm_calloc_large_65421 drm_calloc_large 1-2 65421 NULL
100210 +xpc_kzalloc_cacheline_aligned_65433 xpc_kzalloc_cacheline_aligned 1 65433 NULL
100211 +usb_alloc_coherent_65444 usb_alloc_coherent 2 65444 NULL
100212 +ath_rx_edma_init_65483 ath_rx_edma_init 2 65483 NULL
100213 +dpcm_state_read_file_65489 dpcm_state_read_file 3 65489 NULL
100214 +alloc_dr_65495 alloc_dr 2 65495 NULL
100215 diff --git a/tools/gcc/size_overflow_plugin.c b/tools/gcc/size_overflow_plugin.c
100216 new file mode 100644
100217 index 0000000..9db0d0e
100218 --- /dev/null
100219 +++ b/tools/gcc/size_overflow_plugin.c
100220 @@ -0,0 +1,2114 @@
100221 +/*
100222 + * Copyright 2011, 2012, 2013 by Emese Revfy <re.emese@gmail.com>
100223 + * Licensed under the GPL v2, or (at your option) v3
100224 + *
100225 + * Homepage:
100226 + * http://www.grsecurity.net/~ephox/overflow_plugin/
100227 + *
100228 + * Documentation:
100229 + * http://forums.grsecurity.net/viewtopic.php?f=7&t=3043
100230 + *
100231 + * This plugin recomputes expressions of function arguments marked by a size_overflow attribute
100232 + * with double integer precision (DImode/TImode for 32/64 bit integer types).
100233 + * The recomputed argument is checked against TYPE_MAX and an event is logged on overflow and the triggering process is killed.
100234 + *
100235 + * Usage:
100236 + * $ 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
100237 + * $ gcc -fplugin=size_overflow_plugin.so test.c -O2
100238 + */
100239 +
100240 +#include "gcc-plugin.h"
100241 +#include "config.h"
100242 +#include "system.h"
100243 +#include "coretypes.h"
100244 +#include "tree.h"
100245 +#include "tree-pass.h"
100246 +#include "intl.h"
100247 +#include "plugin-version.h"
100248 +#include "tm.h"
100249 +#include "toplev.h"
100250 +#include "function.h"
100251 +#include "tree-flow.h"
100252 +#include "plugin.h"
100253 +#include "gimple.h"
100254 +#include "diagnostic.h"
100255 +#include "cfgloop.h"
100256 +
100257 +#if BUILDING_GCC_VERSION >= 4008
100258 +#define TODO_dump_func 0
100259 +#endif
100260 +
100261 +struct size_overflow_hash {
100262 + const struct size_overflow_hash * const next;
100263 + const char * const name;
100264 + const unsigned int param;
100265 +};
100266 +
100267 +#include "size_overflow_hash.h"
100268 +
100269 +enum mark {
100270 + MARK_NO, MARK_YES, MARK_NOT_INTENTIONAL, MARK_TURN_OFF
100271 +};
100272 +
100273 +enum err_code_conditions {
100274 + CAST_ONLY, FROM_CONST
100275 +};
100276 +
100277 +static unsigned int call_count = 0;
100278 +
100279 +#define __unused __attribute__((__unused__))
100280 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
100281 +#define NAME_LEN(node) IDENTIFIER_LENGTH(DECL_NAME(node))
100282 +#define BEFORE_STMT true
100283 +#define AFTER_STMT false
100284 +#define CREATE_NEW_VAR NULL_TREE
100285 +#define CODES_LIMIT 32
100286 +#define MAX_PARAM 31
100287 +#define MY_STMT GF_PLF_1
100288 +#define NO_CAST_CHECK GF_PLF_2
100289 +#define FROM_ARG true
100290 +#define FROM_RET false
100291 +
100292 +#if BUILDING_GCC_VERSION == 4005
100293 +#define DECL_CHAIN(NODE) (TREE_CHAIN(DECL_MINIMAL_CHECK(NODE)))
100294 +#endif
100295 +
100296 +int plugin_is_GPL_compatible;
100297 +void debug_gimple_stmt(gimple gs);
100298 +
100299 +static tree expand(struct pointer_set_t *visited, tree lhs);
100300 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs);
100301 +static tree report_size_overflow_decl;
100302 +static const_tree const_char_ptr_type_node;
100303 +static unsigned int handle_function(void);
100304 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before);
100305 +static tree get_size_overflow_type(gimple stmt, const_tree node);
100306 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3);
100307 +static void print_missing_msg(tree func, unsigned int argnum);
100308 +
100309 +static struct plugin_info size_overflow_plugin_info = {
100310 + .version = "20130410beta",
100311 + .help = "no-size-overflow\tturn off size overflow checking\n",
100312 +};
100313 +
100314 +static tree handle_size_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
100315 +{
100316 + unsigned int arg_count;
100317 + enum tree_code code = TREE_CODE(*node);
100318 +
100319 + switch (code) {
100320 + case FUNCTION_DECL:
100321 + arg_count = type_num_arguments(TREE_TYPE(*node));
100322 + break;
100323 + case FUNCTION_TYPE:
100324 + case METHOD_TYPE:
100325 + arg_count = type_num_arguments(*node);
100326 + break;
100327 + default:
100328 + *no_add_attrs = true;
100329 + error("%s: %qE attribute only applies to functions", __func__, name);
100330 + return NULL_TREE;
100331 + }
100332 +
100333 + for (; args; args = TREE_CHAIN(args)) {
100334 + tree position = TREE_VALUE(args);
100335 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
100336 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
100337 + *no_add_attrs = true;
100338 + }
100339 + }
100340 + return NULL_TREE;
100341 +}
100342 +
100343 +static const char* get_asm_name(tree node)
100344 +{
100345 + return IDENTIFIER_POINTER(DECL_ASSEMBLER_NAME(node));
100346 +}
100347 +
100348 +static tree handle_intentional_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
100349 +{
100350 + unsigned int arg_count, arg_num;
100351 + enum tree_code code = TREE_CODE(*node);
100352 +
100353 + switch (code) {
100354 + case FUNCTION_DECL:
100355 + arg_count = type_num_arguments(TREE_TYPE(*node));
100356 + break;
100357 + case FUNCTION_TYPE:
100358 + case METHOD_TYPE:
100359 + arg_count = type_num_arguments(*node);
100360 + break;
100361 + case FIELD_DECL:
100362 + arg_num = TREE_INT_CST_LOW(TREE_VALUE(args));
100363 + if (arg_num != 0) {
100364 + *no_add_attrs = true;
100365 + error("%s: %qE attribute parameter can only be 0 in structure fields", __func__, name);
100366 + }
100367 + return NULL_TREE;
100368 + default:
100369 + *no_add_attrs = true;
100370 + error("%qE attribute only applies to functions", name);
100371 + return NULL_TREE;
100372 + }
100373 +
100374 + if (TREE_INT_CST_HIGH(TREE_VALUE(args)) != 0)
100375 + return NULL_TREE;
100376 +
100377 + for (; args; args = TREE_CHAIN(args)) {
100378 + tree position = TREE_VALUE(args);
100379 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
100380 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
100381 + *no_add_attrs = true;
100382 + }
100383 + }
100384 + return NULL_TREE;
100385 +}
100386 +
100387 +static struct attribute_spec size_overflow_attr = {
100388 + .name = "size_overflow",
100389 + .min_length = 1,
100390 + .max_length = -1,
100391 + .decl_required = true,
100392 + .type_required = false,
100393 + .function_type_required = false,
100394 + .handler = handle_size_overflow_attribute,
100395 +#if BUILDING_GCC_VERSION >= 4007
100396 + .affects_type_identity = false
100397 +#endif
100398 +};
100399 +
100400 +static struct attribute_spec intentional_overflow_attr = {
100401 + .name = "intentional_overflow",
100402 + .min_length = 1,
100403 + .max_length = -1,
100404 + .decl_required = true,
100405 + .type_required = false,
100406 + .function_type_required = false,
100407 + .handler = handle_intentional_overflow_attribute,
100408 +#if BUILDING_GCC_VERSION >= 4007
100409 + .affects_type_identity = false
100410 +#endif
100411 +};
100412 +
100413 +static void register_attributes(void __unused *event_data, void __unused *data)
100414 +{
100415 + register_attribute(&size_overflow_attr);
100416 + register_attribute(&intentional_overflow_attr);
100417 +}
100418 +
100419 +// http://www.team5150.com/~andrew/noncryptohashzoo2~/CrapWow.html
100420 +static unsigned int CrapWow(const char *key, unsigned int len, unsigned int seed)
100421 +{
100422 +#define cwfold( a, b, lo, hi ) { p = (unsigned int)(a) * (unsigned long long)(b); lo ^= (unsigned int)p; hi ^= (unsigned int)(p >> 32); }
100423 +#define cwmixa( in ) { cwfold( in, m, k, h ); }
100424 +#define cwmixb( in ) { cwfold( in, n, h, k ); }
100425 +
100426 + unsigned int m = 0x57559429;
100427 + unsigned int n = 0x5052acdb;
100428 + const unsigned int *key4 = (const unsigned int *)key;
100429 + unsigned int h = len;
100430 + unsigned int k = len + seed + n;
100431 + unsigned long long p;
100432 +
100433 + while (len >= 8) {
100434 + cwmixb(key4[0]) cwmixa(key4[1]) key4 += 2;
100435 + len -= 8;
100436 + }
100437 + if (len >= 4) {
100438 + cwmixb(key4[0]) key4 += 1;
100439 + len -= 4;
100440 + }
100441 + if (len)
100442 + cwmixa(key4[0] & ((1 << (len * 8)) - 1 ));
100443 + cwmixb(h ^ (k + n));
100444 + return k ^ h;
100445 +
100446 +#undef cwfold
100447 +#undef cwmixa
100448 +#undef cwmixb
100449 +}
100450 +
100451 +static inline unsigned int get_hash_num(const char *fndecl, const char *tree_codes, unsigned int len, unsigned int seed)
100452 +{
100453 + unsigned int fn = CrapWow(fndecl, strlen(fndecl), seed) & 0xffff;
100454 + unsigned int codes = CrapWow(tree_codes, len, seed) & 0xffff;
100455 + return fn ^ codes;
100456 +}
100457 +
100458 +static inline tree get_original_function_decl(tree fndecl)
100459 +{
100460 + if (DECL_ABSTRACT_ORIGIN(fndecl))
100461 + return DECL_ABSTRACT_ORIGIN(fndecl);
100462 + return fndecl;
100463 +}
100464 +
100465 +static inline gimple get_def_stmt(const_tree node)
100466 +{
100467 + gcc_assert(node != NULL_TREE);
100468 + if (TREE_CODE(node) != SSA_NAME)
100469 + return NULL;
100470 + return SSA_NAME_DEF_STMT(node);
100471 +}
100472 +
100473 +static unsigned char get_tree_code(const_tree type)
100474 +{
100475 + switch (TREE_CODE(type)) {
100476 + case ARRAY_TYPE:
100477 + return 0;
100478 + case BOOLEAN_TYPE:
100479 + return 1;
100480 + case ENUMERAL_TYPE:
100481 + return 2;
100482 + case FUNCTION_TYPE:
100483 + return 3;
100484 + case INTEGER_TYPE:
100485 + return 4;
100486 + case POINTER_TYPE:
100487 + return 5;
100488 + case RECORD_TYPE:
100489 + return 6;
100490 + case UNION_TYPE:
100491 + return 7;
100492 + case VOID_TYPE:
100493 + return 8;
100494 + case REAL_TYPE:
100495 + return 9;
100496 + case VECTOR_TYPE:
100497 + return 10;
100498 + case REFERENCE_TYPE:
100499 + return 11;
100500 + case OFFSET_TYPE:
100501 + return 12;
100502 + case COMPLEX_TYPE:
100503 + return 13;
100504 + default:
100505 + debug_tree((tree)type);
100506 + gcc_unreachable();
100507 + }
100508 +}
100509 +
100510 +static size_t add_type_codes(const_tree type, unsigned char *tree_codes, size_t len)
100511 +{
100512 + gcc_assert(type != NULL_TREE);
100513 +
100514 + while (type && len < CODES_LIMIT) {
100515 + tree_codes[len] = get_tree_code(type);
100516 + len++;
100517 + type = TREE_TYPE(type);
100518 + }
100519 + return len;
100520 +}
100521 +
100522 +static unsigned int get_function_decl(const_tree fndecl, unsigned char *tree_codes)
100523 +{
100524 + const_tree arg, result, arg_field, type = TREE_TYPE(fndecl);
100525 + enum tree_code code = TREE_CODE(type);
100526 + size_t len = 0;
100527 +
100528 + gcc_assert(code == FUNCTION_TYPE || code == METHOD_TYPE);
100529 +
100530 + arg = TYPE_ARG_TYPES(type);
100531 + // skip builtins __builtin_constant_p
100532 + if (!arg && DECL_BUILT_IN(fndecl))
100533 + return 0;
100534 +
100535 + if (TREE_CODE_CLASS(code) == tcc_type)
100536 + result = type;
100537 + else
100538 + result = DECL_RESULT(fndecl);
100539 +
100540 + gcc_assert(result != NULL_TREE);
100541 + len = add_type_codes(TREE_TYPE(result), tree_codes, len);
100542 +
100543 + if (arg == NULL_TREE) {
100544 + gcc_assert(CODE_CONTAINS_STRUCT(TREE_CODE(fndecl), TS_DECL_NON_COMMON));
100545 + arg_field = DECL_ARGUMENT_FLD(fndecl);
100546 + if (arg_field == NULL_TREE)
100547 + return 0;
100548 + arg = TREE_TYPE(arg_field);
100549 + len = add_type_codes(arg, tree_codes, len);
100550 + gcc_assert(len != 0);
100551 + return len;
100552 + }
100553 +
100554 + gcc_assert(arg != NULL_TREE && TREE_CODE(arg) == TREE_LIST);
100555 + while (arg && len < CODES_LIMIT) {
100556 + len = add_type_codes(TREE_VALUE(arg), tree_codes, len);
100557 + arg = TREE_CHAIN(arg);
100558 + }
100559 +
100560 + gcc_assert(len != 0);
100561 + return len;
100562 +}
100563 +
100564 +static const struct size_overflow_hash *get_function_hash(tree fndecl)
100565 +{
100566 + unsigned int hash;
100567 + const struct size_overflow_hash *entry;
100568 + unsigned char tree_codes[CODES_LIMIT];
100569 + size_t len;
100570 + const char *func_name;
100571 +
100572 + fndecl = get_original_function_decl(fndecl);
100573 + len = get_function_decl(fndecl, tree_codes);
100574 + if (len == 0)
100575 + return NULL;
100576 +
100577 + func_name = get_asm_name(fndecl);
100578 + hash = get_hash_num(func_name, (const char*) tree_codes, len, 0);
100579 +
100580 + entry = size_overflow_hash[hash];
100581 + while (entry) {
100582 + if (!strcmp(entry->name, func_name))
100583 + return entry;
100584 + entry = entry->next;
100585 + }
100586 +
100587 + return NULL;
100588 +}
100589 +
100590 +static bool is_bool(const_tree node)
100591 +{
100592 + const_tree type;
100593 +
100594 + if (node == NULL_TREE)
100595 + return false;
100596 +
100597 + type = TREE_TYPE(node);
100598 + if (!INTEGRAL_TYPE_P(type))
100599 + return false;
100600 + if (TREE_CODE(type) == BOOLEAN_TYPE)
100601 + return true;
100602 + if (TYPE_PRECISION(type) == 1)
100603 + return true;
100604 + return false;
100605 +}
100606 +
100607 +static bool skip_types(const_tree var)
100608 +{
100609 + tree type;
100610 +
100611 + if (is_gimple_constant(var))
100612 + return true;
100613 +
100614 + switch (TREE_CODE(var)) {
100615 + case ADDR_EXPR:
100616 +#if BUILDING_GCC_VERSION >= 4006
100617 + case MEM_REF:
100618 +#endif
100619 + case ARRAY_REF:
100620 + case BIT_FIELD_REF:
100621 + case INDIRECT_REF:
100622 + case TARGET_MEM_REF:
100623 + return true;
100624 + case PARM_DECL:
100625 + case VAR_DECL:
100626 + case COMPONENT_REF:
100627 + return false;
100628 + default:
100629 + break;
100630 + }
100631 +
100632 + gcc_assert(TREE_CODE(var) == SSA_NAME);
100633 +
100634 + type = TREE_TYPE(var);
100635 + switch (TREE_CODE(type)) {
100636 + case INTEGER_TYPE:
100637 + case ENUMERAL_TYPE:
100638 + return false;
100639 + case BOOLEAN_TYPE:
100640 + return is_bool(var);
100641 + default:
100642 + break;
100643 + }
100644 +
100645 + gcc_assert(TREE_CODE(type) == POINTER_TYPE);
100646 +
100647 + type = TREE_TYPE(type);
100648 + gcc_assert(type != NULL_TREE);
100649 + switch (TREE_CODE(type)) {
100650 + case RECORD_TYPE:
100651 + case POINTER_TYPE:
100652 + case ARRAY_TYPE:
100653 + return true;
100654 + case VOID_TYPE:
100655 + case INTEGER_TYPE:
100656 + case UNION_TYPE:
100657 + return false;
100658 + default:
100659 + break;
100660 + }
100661 +
100662 + debug_tree((tree)var);
100663 + gcc_unreachable();
100664 +}
100665 +
100666 +static unsigned int find_arg_number(const_tree arg, tree func)
100667 +{
100668 + tree var;
100669 + unsigned int argnum = 1;
100670 +
100671 + if (TREE_CODE(arg) == SSA_NAME)
100672 + arg = SSA_NAME_VAR(arg);
100673 +
100674 + for (var = DECL_ARGUMENTS(func); var; var = TREE_CHAIN(var), argnum++) {
100675 + if (!operand_equal_p(arg, var, 0) && strcmp(NAME(var), NAME(arg)))
100676 + continue;
100677 + if (!skip_types(var))
100678 + return argnum;
100679 + }
100680 +
100681 + return 0;
100682 +}
100683 +
100684 +static tree create_new_var(tree type)
100685 +{
100686 + tree new_var = create_tmp_var(type, "cicus");
100687 +
100688 +#if BUILDING_GCC_VERSION <= 4007
100689 + add_referenced_var(new_var);
100690 + mark_sym_for_renaming(new_var);
100691 +#endif
100692 + return new_var;
100693 +}
100694 +
100695 +static gimple create_binary_assign(enum tree_code code, gimple stmt, tree rhs1, tree rhs2)
100696 +{
100697 + gimple assign;
100698 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
100699 + tree type = TREE_TYPE(rhs1);
100700 + tree lhs = create_new_var(type);
100701 +
100702 + gcc_assert(types_compatible_p(type, TREE_TYPE(rhs2)));
100703 + assign = gimple_build_assign_with_ops(code, lhs, rhs1, rhs2);
100704 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
100705 +
100706 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
100707 + update_stmt(assign);
100708 + gimple_set_plf(assign, MY_STMT, true);
100709 + return assign;
100710 +}
100711 +
100712 +static tree cast_a_tree(tree type, tree var)
100713 +{
100714 + gcc_assert(type != NULL_TREE);
100715 + gcc_assert(var != NULL_TREE);
100716 + gcc_assert(fold_convertible_p(type, var));
100717 +
100718 + return fold_convert(type, var);
100719 +}
100720 +
100721 +static tree get_lhs(const_gimple stmt)
100722 +{
100723 + switch (gimple_code(stmt)) {
100724 + case GIMPLE_ASSIGN:
100725 + return gimple_get_lhs(stmt);
100726 + case GIMPLE_PHI:
100727 + return gimple_phi_result(stmt);
100728 + case GIMPLE_CALL:
100729 + return gimple_call_lhs(stmt);
100730 + default:
100731 + return NULL_TREE;
100732 + }
100733 +}
100734 +
100735 +static bool skip_cast(tree dst_type, const_tree rhs, bool force)
100736 +{
100737 + const_gimple def_stmt = get_def_stmt(rhs);
100738 +
100739 + if (force)
100740 + return false;
100741 +
100742 + if (is_gimple_constant(rhs))
100743 + return false;
100744 +
100745 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
100746 + return false;
100747 +
100748 + if (!types_compatible_p(dst_type, TREE_TYPE(rhs)))
100749 + return false;
100750 +
100751 + // DI type can be on 32 bit (from create_assign) but overflow type stays DI
100752 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
100753 + return false;
100754 +
100755 + return true;
100756 +}
100757 +
100758 +static gimple build_cast_stmt(tree dst_type, tree rhs, tree lhs, gimple_stmt_iterator *gsi, bool before, bool force)
100759 +{
100760 + gimple assign, def_stmt;
100761 +
100762 + gcc_assert(dst_type != NULL_TREE && rhs != NULL_TREE);
100763 + if (gsi_end_p(*gsi) && before == AFTER_STMT)
100764 + gcc_unreachable();
100765 +
100766 + def_stmt = get_def_stmt(rhs);
100767 + if (skip_cast(dst_type, rhs, force) && gimple_plf(def_stmt, MY_STMT))
100768 + return def_stmt;
100769 +
100770 + if (lhs == CREATE_NEW_VAR)
100771 + lhs = create_new_var(dst_type);
100772 +
100773 + assign = gimple_build_assign(lhs, cast_a_tree(dst_type, rhs));
100774 +
100775 + if (!gsi_end_p(*gsi)) {
100776 + location_t loc = gimple_location(gsi_stmt(*gsi));
100777 + gimple_set_location(assign, loc);
100778 + }
100779 +
100780 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
100781 +
100782 + if (before)
100783 + gsi_insert_before(gsi, assign, GSI_NEW_STMT);
100784 + else
100785 + gsi_insert_after(gsi, assign, GSI_NEW_STMT);
100786 + update_stmt(assign);
100787 + gimple_set_plf(assign, MY_STMT, true);
100788 +
100789 + return assign;
100790 +}
100791 +
100792 +static tree cast_to_new_size_overflow_type(gimple stmt, tree rhs, tree size_overflow_type, bool before)
100793 +{
100794 + gimple_stmt_iterator gsi;
100795 + tree lhs;
100796 + const_gimple new_stmt;
100797 +
100798 + if (rhs == NULL_TREE)
100799 + return NULL_TREE;
100800 +
100801 + gsi = gsi_for_stmt(stmt);
100802 + new_stmt = build_cast_stmt(size_overflow_type, rhs, CREATE_NEW_VAR, &gsi, before, false);
100803 +
100804 + lhs = get_lhs(new_stmt);
100805 + gcc_assert(lhs != NULL_TREE);
100806 + return lhs;
100807 +}
100808 +
100809 +static tree cast_to_TI_type(gimple stmt, tree node)
100810 +{
100811 + gimple_stmt_iterator gsi;
100812 + gimple cast_stmt;
100813 + tree type = TREE_TYPE(node);
100814 +
100815 + if (types_compatible_p(type, intTI_type_node))
100816 + return node;
100817 +
100818 + gsi = gsi_for_stmt(stmt);
100819 + cast_stmt = build_cast_stmt(intTI_type_node, node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
100820 + return gimple_get_lhs(cast_stmt);
100821 +}
100822 +
100823 +static void check_function_hash(const_gimple stmt)
100824 +{
100825 + tree func;
100826 + const struct size_overflow_hash *hash;
100827 +
100828 + if (gimple_code(stmt) != GIMPLE_CALL)
100829 + return;
100830 +
100831 + func = gimple_call_fndecl(stmt);
100832 + //fs/xattr.c D.34222_15 = D.34219_14 (dentry_3(D), name_7(D), 0B, 0);
100833 + if (func == NULL_TREE)
100834 + return;
100835 +
100836 + hash = get_function_hash(func);
100837 + if (!hash)
100838 + print_missing_msg(func, 0);
100839 +}
100840 +
100841 +static tree create_assign(struct pointer_set_t *visited, gimple oldstmt, tree rhs1, bool before)
100842 +{
100843 + tree lhs, new_lhs;
100844 + gimple_stmt_iterator gsi;
100845 +
100846 + if (rhs1 == NULL_TREE) {
100847 + debug_gimple_stmt(oldstmt);
100848 + error("%s: rhs1 is NULL_TREE", __func__);
100849 + gcc_unreachable();
100850 + }
100851 +
100852 + switch (gimple_code(oldstmt)) {
100853 + case GIMPLE_ASM:
100854 + lhs = rhs1;
100855 + break;
100856 + case GIMPLE_CALL:
100857 + lhs = gimple_call_lhs(oldstmt);
100858 + break;
100859 + case GIMPLE_ASSIGN:
100860 + lhs = gimple_get_lhs(oldstmt);
100861 + break;
100862 + default:
100863 + debug_gimple_stmt(oldstmt);
100864 + gcc_unreachable();
100865 + }
100866 +
100867 + gsi = gsi_for_stmt(oldstmt);
100868 + pointer_set_insert(visited, oldstmt);
100869 + if (lookup_stmt_eh_lp(oldstmt) != 0) {
100870 + basic_block next_bb, cur_bb;
100871 + const_edge e;
100872 +
100873 + gcc_assert(before == false);
100874 + gcc_assert(stmt_can_throw_internal(oldstmt));
100875 + gcc_assert(gimple_code(oldstmt) == GIMPLE_CALL);
100876 + gcc_assert(!gsi_end_p(gsi));
100877 +
100878 + cur_bb = gimple_bb(oldstmt);
100879 + next_bb = cur_bb->next_bb;
100880 + e = find_edge(cur_bb, next_bb);
100881 + gcc_assert(e != NULL);
100882 + gcc_assert(e->flags & EDGE_FALLTHRU);
100883 +
100884 + gsi = gsi_after_labels(next_bb);
100885 + gcc_assert(!gsi_end_p(gsi));
100886 +
100887 + before = true;
100888 + oldstmt = gsi_stmt(gsi);
100889 + }
100890 +
100891 + new_lhs = cast_to_new_size_overflow_type(oldstmt, rhs1, get_size_overflow_type(oldstmt, lhs), before);
100892 + return new_lhs;
100893 +}
100894 +
100895 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3)
100896 +{
100897 + gimple stmt;
100898 + gimple_stmt_iterator gsi;
100899 + tree size_overflow_type, new_var, lhs = gimple_get_lhs(oldstmt);
100900 +
100901 + if (gimple_plf(oldstmt, MY_STMT))
100902 + return lhs;
100903 +
100904 + if (gimple_num_ops(oldstmt) != 4 && rhs1 == NULL_TREE) {
100905 + rhs1 = gimple_assign_rhs1(oldstmt);
100906 + rhs1 = create_assign(visited, oldstmt, rhs1, BEFORE_STMT);
100907 + }
100908 + if (gimple_num_ops(oldstmt) == 3 && rhs2 == NULL_TREE) {
100909 + rhs2 = gimple_assign_rhs2(oldstmt);
100910 + rhs2 = create_assign(visited, oldstmt, rhs2, BEFORE_STMT);
100911 + }
100912 +
100913 + stmt = gimple_copy(oldstmt);
100914 + gimple_set_location(stmt, gimple_location(oldstmt));
100915 + gimple_set_plf(stmt, MY_STMT, true);
100916 +
100917 + if (gimple_assign_rhs_code(oldstmt) == WIDEN_MULT_EXPR)
100918 + gimple_assign_set_rhs_code(stmt, MULT_EXPR);
100919 +
100920 + size_overflow_type = get_size_overflow_type(oldstmt, node);
100921 +
100922 + new_var = create_new_var(size_overflow_type);
100923 + new_var = make_ssa_name(new_var, stmt);
100924 + gimple_set_lhs(stmt, new_var);
100925 +
100926 + if (rhs1 != NULL_TREE)
100927 + gimple_assign_set_rhs1(stmt, rhs1);
100928 +
100929 + if (rhs2 != NULL_TREE)
100930 + gimple_assign_set_rhs2(stmt, rhs2);
100931 +#if BUILDING_GCC_VERSION >= 4007
100932 + if (rhs3 != NULL_TREE)
100933 + gimple_assign_set_rhs3(stmt, rhs3);
100934 +#endif
100935 + gimple_set_vuse(stmt, gimple_vuse(oldstmt));
100936 + gimple_set_vdef(stmt, gimple_vdef(oldstmt));
100937 +
100938 + gsi = gsi_for_stmt(oldstmt);
100939 + gsi_insert_after(&gsi, stmt, GSI_SAME_STMT);
100940 + update_stmt(stmt);
100941 + pointer_set_insert(visited, oldstmt);
100942 + return gimple_get_lhs(stmt);
100943 +}
100944 +
100945 +static tree cast_parm_decl(tree phi_ssa_name, tree arg, tree size_overflow_type)
100946 +{
100947 + basic_block first_bb;
100948 + gimple assign;
100949 + gimple_stmt_iterator gsi;
100950 +
100951 + first_bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
100952 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
100953 + set_immediate_dominator(CDI_DOMINATORS, first_bb, ENTRY_BLOCK_PTR);
100954 +
100955 + gsi = gsi_start_bb(first_bb);
100956 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
100957 + return gimple_get_lhs(assign);
100958 +}
100959 +
100960 +static tree use_phi_ssa_name(tree phi_ssa_name, tree new_arg)
100961 +{
100962 + gimple_stmt_iterator gsi;
100963 + const_gimple assign;
100964 + gimple def_stmt = get_def_stmt(new_arg);
100965 +
100966 + if (gimple_code(def_stmt) == GIMPLE_PHI) {
100967 + gsi = gsi_after_labels(gimple_bb(def_stmt));
100968 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, BEFORE_STMT, true);
100969 + } else {
100970 + gsi = gsi_for_stmt(def_stmt);
100971 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, AFTER_STMT, true);
100972 + }
100973 +
100974 + return gimple_get_lhs(assign);
100975 +}
100976 +
100977 +static tree cast_visited_phi_arg(tree phi_ssa_name, tree arg, tree size_overflow_type)
100978 +{
100979 + basic_block bb;
100980 + gimple_stmt_iterator gsi;
100981 + const_gimple assign, def_stmt;
100982 +
100983 + def_stmt = get_def_stmt(arg);
100984 + bb = gimple_bb(def_stmt);
100985 + gcc_assert(bb->index != 0);
100986 + gsi = gsi_after_labels(bb);
100987 +
100988 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
100989 + return gimple_get_lhs(assign);
100990 +}
100991 +
100992 +static tree create_new_phi_arg(tree phi_ssa_name, tree new_arg, tree arg, gimple oldstmt)
100993 +{
100994 + tree size_overflow_type;
100995 + const_gimple def_stmt = get_def_stmt(arg);
100996 +
100997 + if (phi_ssa_name != NULL_TREE)
100998 + phi_ssa_name = SSA_NAME_VAR(phi_ssa_name);
100999 +
101000 + size_overflow_type = get_size_overflow_type(oldstmt, arg);
101001 +
101002 + if (new_arg != NULL_TREE) {
101003 + gcc_assert(types_compatible_p(TREE_TYPE(new_arg), size_overflow_type));
101004 + return use_phi_ssa_name(phi_ssa_name, new_arg);
101005 + }
101006 +
101007 + switch(gimple_code(def_stmt)) {
101008 + case GIMPLE_PHI:
101009 + return cast_visited_phi_arg(phi_ssa_name, arg, size_overflow_type);
101010 + case GIMPLE_NOP:
101011 + return cast_parm_decl(phi_ssa_name, arg, size_overflow_type);
101012 + default:
101013 + debug_gimple_stmt((gimple)def_stmt);
101014 + gcc_unreachable();
101015 + }
101016 +}
101017 +
101018 +static gimple overflow_create_phi_node(gimple oldstmt, tree result)
101019 +{
101020 + basic_block bb;
101021 + gimple phi;
101022 + gimple_seq seq;
101023 + gimple_stmt_iterator gsi = gsi_for_stmt(oldstmt);
101024 +
101025 + bb = gsi_bb(gsi);
101026 +
101027 + phi = create_phi_node(result, bb);
101028 + gimple_phi_set_result(phi, make_ssa_name(result, phi));
101029 + seq = phi_nodes(bb);
101030 + gsi = gsi_last(seq);
101031 + gsi_remove(&gsi, false);
101032 +
101033 + gsi = gsi_for_stmt(oldstmt);
101034 + gsi_insert_after(&gsi, phi, GSI_NEW_STMT);
101035 + gimple_set_bb(phi, bb);
101036 + gimple_set_plf(phi, MY_STMT, true);
101037 + return phi;
101038 +}
101039 +
101040 +static tree handle_phi(struct pointer_set_t *visited, tree orig_result)
101041 +{
101042 + gimple new_phi = NULL;
101043 + gimple oldstmt = get_def_stmt(orig_result);
101044 + tree phi_ssa_name = NULL_TREE;
101045 + unsigned int i;
101046 +
101047 + pointer_set_insert(visited, oldstmt);
101048 + for (i = 0; i < gimple_phi_num_args(oldstmt); i++) {
101049 + tree arg, new_arg;
101050 +
101051 + arg = gimple_phi_arg_def(oldstmt, i);
101052 +
101053 + new_arg = expand(visited, arg);
101054 + new_arg = create_new_phi_arg(phi_ssa_name, new_arg, arg, oldstmt);
101055 + if (i == 0) {
101056 + phi_ssa_name = new_arg;
101057 + new_phi = overflow_create_phi_node(oldstmt, SSA_NAME_VAR(phi_ssa_name));
101058 + }
101059 +
101060 + gcc_assert(new_phi != NULL);
101061 + add_phi_arg(new_phi, new_arg, gimple_phi_arg_edge(oldstmt, i), gimple_location(oldstmt));
101062 + }
101063 +
101064 + gcc_assert(new_phi != NULL);
101065 + update_stmt(new_phi);
101066 + return gimple_phi_result(new_phi);
101067 +}
101068 +
101069 +static tree change_assign_rhs(gimple stmt, const_tree orig_rhs, tree new_rhs)
101070 +{
101071 + const_gimple assign;
101072 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
101073 + tree origtype = TREE_TYPE(orig_rhs);
101074 +
101075 + gcc_assert(gimple_code(stmt) == GIMPLE_ASSIGN);
101076 +
101077 + assign = build_cast_stmt(origtype, new_rhs, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
101078 + return gimple_get_lhs(assign);
101079 +}
101080 +
101081 +static bool is_a_cast_and_const_overflow(const_tree no_const_rhs)
101082 +{
101083 + const_tree rhs1, lhs, rhs1_type, lhs_type;
101084 + enum machine_mode lhs_mode, rhs_mode;
101085 + gimple def_stmt = get_def_stmt(no_const_rhs);
101086 +
101087 + if (!gimple_assign_cast_p(def_stmt))
101088 + return false;
101089 +
101090 + rhs1 = gimple_assign_rhs1(def_stmt);
101091 + lhs = gimple_get_lhs(def_stmt);
101092 + rhs1_type = TREE_TYPE(rhs1);
101093 + lhs_type = TREE_TYPE(lhs);
101094 + rhs_mode = TYPE_MODE(rhs1_type);
101095 + lhs_mode = TYPE_MODE(lhs_type);
101096 + if (TYPE_UNSIGNED(lhs_type) == TYPE_UNSIGNED(rhs1_type) || lhs_mode != rhs_mode)
101097 + return false;
101098 +
101099 + return true;
101100 +}
101101 +
101102 +static tree create_cast_assign(struct pointer_set_t *visited, gimple stmt)
101103 +{
101104 + tree rhs1 = gimple_assign_rhs1(stmt);
101105 + tree lhs = gimple_get_lhs(stmt);
101106 + const_tree rhs1_type = TREE_TYPE(rhs1);
101107 + const_tree lhs_type = TREE_TYPE(lhs);
101108 +
101109 + if (TYPE_UNSIGNED(rhs1_type) == TYPE_UNSIGNED(lhs_type))
101110 + return create_assign(visited, stmt, lhs, AFTER_STMT);
101111 +
101112 + return create_assign(visited, stmt, rhs1, AFTER_STMT);
101113 +}
101114 +
101115 +static bool no_uses(tree node)
101116 +{
101117 + imm_use_iterator imm_iter;
101118 + use_operand_p use_p;
101119 +
101120 + FOR_EACH_IMM_USE_FAST(use_p, imm_iter, node) {
101121 + const_gimple use_stmt = USE_STMT(use_p);
101122 + if (use_stmt == NULL)
101123 + return true;
101124 + if (is_gimple_debug(use_stmt))
101125 + continue;
101126 + if (!(gimple_bb(use_stmt)->flags & BB_REACHABLE))
101127 + continue;
101128 + return false;
101129 + }
101130 + return true;
101131 +}
101132 +
101133 +// 3.8.5 mm/page-writeback.c __ilog2_u64(): ret, uint + uintmax; uint -> int; int max
101134 +static bool is_const_plus_unsigned_signed_truncation(const_tree lhs)
101135 +{
101136 + tree rhs1, lhs_type, rhs_type, rhs2, not_const_rhs;
101137 + gimple def_stmt = get_def_stmt(lhs);
101138 +
101139 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
101140 + return false;
101141 +
101142 + rhs1 = gimple_assign_rhs1(def_stmt);
101143 + rhs_type = TREE_TYPE(rhs1);
101144 + lhs_type = TREE_TYPE(lhs);
101145 + if (TYPE_UNSIGNED(lhs_type) || !TYPE_UNSIGNED(rhs_type))
101146 + return false;
101147 + if (TYPE_MODE(lhs_type) != TYPE_MODE(rhs_type))
101148 + return false;
101149 +
101150 + def_stmt = get_def_stmt(rhs1);
101151 + if (!def_stmt || gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_num_ops(def_stmt) != 3)
101152 + return false;
101153 +
101154 + if (gimple_assign_rhs_code(def_stmt) != PLUS_EXPR)
101155 + return false;
101156 +
101157 + rhs1 = gimple_assign_rhs1(def_stmt);
101158 + rhs2 = gimple_assign_rhs2(def_stmt);
101159 + if (!is_gimple_constant(rhs1) && !is_gimple_constant(rhs2))
101160 + return false;
101161 +
101162 + if (is_gimple_constant(rhs2))
101163 + not_const_rhs = rhs1;
101164 + else
101165 + not_const_rhs = rhs2;
101166 +
101167 + return no_uses(not_const_rhs);
101168 +}
101169 +
101170 +static bool skip_lhs_cast_check(const_gimple stmt)
101171 +{
101172 + const_tree rhs = gimple_assign_rhs1(stmt);
101173 + const_gimple def_stmt = get_def_stmt(rhs);
101174 +
101175 + // 3.8.2 kernel/futex_compat.c compat_exit_robust_list(): get_user() 64 ulong -> int (compat_long_t), int max
101176 + if (gimple_code(def_stmt) == GIMPLE_ASM)
101177 + return true;
101178 +
101179 + if (is_const_plus_unsigned_signed_truncation(rhs))
101180 + return true;
101181 +
101182 + return false;
101183 +}
101184 +
101185 +static tree create_cast_overflow_check(struct pointer_set_t *visited, tree new_rhs1, gimple stmt)
101186 +{
101187 + bool cast_lhs, cast_rhs;
101188 + tree lhs = gimple_get_lhs(stmt);
101189 + tree rhs = gimple_assign_rhs1(stmt);
101190 + const_tree lhs_type = TREE_TYPE(lhs);
101191 + const_tree rhs_type = TREE_TYPE(rhs);
101192 + enum machine_mode lhs_mode = TYPE_MODE(lhs_type);
101193 + enum machine_mode rhs_mode = TYPE_MODE(rhs_type);
101194 + unsigned int lhs_size = GET_MODE_BITSIZE(lhs_mode);
101195 + unsigned int rhs_size = GET_MODE_BITSIZE(rhs_mode);
101196 +
101197 + static bool check_lhs[3][4] = {
101198 + // ss su us uu
101199 + { false, true, true, false }, // lhs > rhs
101200 + { false, false, false, false }, // lhs = rhs
101201 + { true, true, true, true }, // lhs < rhs
101202 + };
101203 +
101204 + static bool check_rhs[3][4] = {
101205 + // ss su us uu
101206 + { true, false, true, true }, // lhs > rhs
101207 + { true, false, true, true }, // lhs = rhs
101208 + { true, false, true, true }, // lhs < rhs
101209 + };
101210 +
101211 + // skip lhs check on signed SI -> HI cast or signed SI -> QI cast !!!!
101212 + if (rhs_mode == SImode && !TYPE_UNSIGNED(rhs_type) && (lhs_mode == HImode || lhs_mode == QImode))
101213 + return create_assign(visited, stmt, lhs, AFTER_STMT);
101214 +
101215 + if (lhs_size > rhs_size) {
101216 + cast_lhs = check_lhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
101217 + cast_rhs = check_rhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
101218 + } else if (lhs_size == rhs_size) {
101219 + cast_lhs = check_lhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
101220 + cast_rhs = check_rhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
101221 + } else {
101222 + cast_lhs = check_lhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
101223 + cast_rhs = check_rhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
101224 + }
101225 +
101226 + if (!cast_lhs && !cast_rhs)
101227 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
101228 +
101229 + if (cast_lhs && !skip_lhs_cast_check(stmt))
101230 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, lhs, BEFORE_STMT);
101231 +
101232 + if (cast_rhs)
101233 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, rhs, BEFORE_STMT);
101234 +
101235 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
101236 +}
101237 +
101238 +static tree handle_unary_rhs(struct pointer_set_t *visited, gimple stmt)
101239 +{
101240 + tree rhs1, new_rhs1, lhs = gimple_get_lhs(stmt);
101241 +
101242 + if (gimple_plf(stmt, MY_STMT))
101243 + return lhs;
101244 +
101245 + rhs1 = gimple_assign_rhs1(stmt);
101246 + if (TREE_CODE(TREE_TYPE(rhs1)) == POINTER_TYPE)
101247 + return create_assign(visited, stmt, lhs, AFTER_STMT);
101248 +
101249 + new_rhs1 = expand(visited, rhs1);
101250 +
101251 + if (new_rhs1 == NULL_TREE)
101252 + return create_cast_assign(visited, stmt);
101253 +
101254 + if (gimple_plf(stmt, NO_CAST_CHECK))
101255 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
101256 +
101257 + if (gimple_assign_rhs_code(stmt) == BIT_NOT_EXPR) {
101258 + tree size_overflow_type = get_size_overflow_type(stmt, rhs1);
101259 +
101260 + new_rhs1 = cast_to_new_size_overflow_type(stmt, new_rhs1, size_overflow_type, BEFORE_STMT);
101261 + check_size_overflow(stmt, size_overflow_type, new_rhs1, rhs1, BEFORE_STMT);
101262 + return create_assign(visited, stmt, lhs, AFTER_STMT);
101263 + }
101264 +
101265 + if (!gimple_assign_cast_p(stmt))
101266 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
101267 +
101268 + return create_cast_overflow_check(visited, new_rhs1, stmt);
101269 +}
101270 +
101271 +static tree handle_unary_ops(struct pointer_set_t *visited, gimple stmt)
101272 +{
101273 + tree rhs1, lhs = gimple_get_lhs(stmt);
101274 + gimple def_stmt = get_def_stmt(lhs);
101275 +
101276 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP);
101277 + rhs1 = gimple_assign_rhs1(def_stmt);
101278 +
101279 + if (is_gimple_constant(rhs1))
101280 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
101281 +
101282 + switch (TREE_CODE(rhs1)) {
101283 + case SSA_NAME:
101284 + return handle_unary_rhs(visited, def_stmt);
101285 + case ARRAY_REF:
101286 + case BIT_FIELD_REF:
101287 + case ADDR_EXPR:
101288 + case COMPONENT_REF:
101289 + case INDIRECT_REF:
101290 +#if BUILDING_GCC_VERSION >= 4006
101291 + case MEM_REF:
101292 +#endif
101293 + case TARGET_MEM_REF:
101294 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
101295 + case PARM_DECL:
101296 + case VAR_DECL:
101297 + return create_assign(visited, stmt, lhs, AFTER_STMT);
101298 +
101299 + default:
101300 + debug_gimple_stmt(def_stmt);
101301 + debug_tree(rhs1);
101302 + gcc_unreachable();
101303 + }
101304 +}
101305 +
101306 +static void insert_cond(basic_block cond_bb, tree arg, enum tree_code cond_code, tree type_value)
101307 +{
101308 + gimple cond_stmt;
101309 + gimple_stmt_iterator gsi = gsi_last_bb(cond_bb);
101310 +
101311 + cond_stmt = gimple_build_cond(cond_code, arg, type_value, NULL_TREE, NULL_TREE);
101312 + gsi_insert_after(&gsi, cond_stmt, GSI_CONTINUE_LINKING);
101313 + update_stmt(cond_stmt);
101314 +}
101315 +
101316 +static tree create_string_param(tree string)
101317 +{
101318 + tree i_type, a_type;
101319 + const int length = TREE_STRING_LENGTH(string);
101320 +
101321 + gcc_assert(length > 0);
101322 +
101323 + i_type = build_index_type(build_int_cst(NULL_TREE, length - 1));
101324 + a_type = build_array_type(char_type_node, i_type);
101325 +
101326 + TREE_TYPE(string) = a_type;
101327 + TREE_CONSTANT(string) = 1;
101328 + TREE_READONLY(string) = 1;
101329 +
101330 + return build1(ADDR_EXPR, ptr_type_node, string);
101331 +}
101332 +
101333 +static void insert_cond_result(basic_block bb_true, const_gimple stmt, const_tree arg, bool min)
101334 +{
101335 + gimple func_stmt;
101336 + const_gimple def_stmt;
101337 + const_tree loc_line;
101338 + tree loc_file, ssa_name, current_func;
101339 + expanded_location xloc;
101340 + char *ssa_name_buf;
101341 + int len;
101342 + gimple_stmt_iterator gsi = gsi_start_bb(bb_true);
101343 +
101344 + def_stmt = get_def_stmt(arg);
101345 + xloc = expand_location(gimple_location(def_stmt));
101346 +
101347 + if (!gimple_has_location(def_stmt)) {
101348 + xloc = expand_location(gimple_location(stmt));
101349 + if (!gimple_has_location(stmt))
101350 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
101351 + }
101352 +
101353 + loc_line = build_int_cstu(unsigned_type_node, xloc.line);
101354 +
101355 + loc_file = build_string(strlen(xloc.file) + 1, xloc.file);
101356 + loc_file = create_string_param(loc_file);
101357 +
101358 + current_func = build_string(NAME_LEN(current_function_decl) + 1, NAME(current_function_decl));
101359 + current_func = create_string_param(current_func);
101360 +
101361 + gcc_assert(DECL_NAME(SSA_NAME_VAR(arg)) != NULL);
101362 + call_count++;
101363 + 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);
101364 + gcc_assert(len > 0);
101365 + ssa_name = build_string(len + 1, ssa_name_buf);
101366 + free(ssa_name_buf);
101367 + ssa_name = create_string_param(ssa_name);
101368 +
101369 + // void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
101370 + func_stmt = gimple_build_call(report_size_overflow_decl, 4, loc_file, loc_line, current_func, ssa_name);
101371 +
101372 + gsi_insert_after(&gsi, func_stmt, GSI_CONTINUE_LINKING);
101373 +}
101374 +
101375 +static void __unused print_the_code_insertions(const_gimple stmt)
101376 +{
101377 + location_t loc = gimple_location(stmt);
101378 +
101379 + inform(loc, "Integer size_overflow check applied here.");
101380 +}
101381 +
101382 +static void insert_check_size_overflow(gimple stmt, enum tree_code cond_code, tree arg, tree type_value, bool before, bool min)
101383 +{
101384 + basic_block cond_bb, join_bb, bb_true;
101385 + edge e;
101386 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
101387 +
101388 + cond_bb = gimple_bb(stmt);
101389 + if (before)
101390 + gsi_prev(&gsi);
101391 + if (gsi_end_p(gsi))
101392 + e = split_block_after_labels(cond_bb);
101393 + else
101394 + e = split_block(cond_bb, gsi_stmt(gsi));
101395 + cond_bb = e->src;
101396 + join_bb = e->dest;
101397 + e->flags = EDGE_FALSE_VALUE;
101398 + e->probability = REG_BR_PROB_BASE;
101399 +
101400 + bb_true = create_empty_bb(cond_bb);
101401 + make_edge(cond_bb, bb_true, EDGE_TRUE_VALUE);
101402 + make_edge(cond_bb, join_bb, EDGE_FALSE_VALUE);
101403 + make_edge(bb_true, join_bb, EDGE_FALLTHRU);
101404 +
101405 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
101406 + set_immediate_dominator(CDI_DOMINATORS, bb_true, cond_bb);
101407 + set_immediate_dominator(CDI_DOMINATORS, join_bb, cond_bb);
101408 +
101409 + if (current_loops != NULL) {
101410 + gcc_assert(cond_bb->loop_father == join_bb->loop_father);
101411 + add_bb_to_loop(bb_true, cond_bb->loop_father);
101412 + }
101413 +
101414 + insert_cond(cond_bb, arg, cond_code, type_value);
101415 + insert_cond_result(bb_true, stmt, arg, min);
101416 +
101417 +// print_the_code_insertions(stmt);
101418 +}
101419 +
101420 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before)
101421 +{
101422 + const_tree rhs_type = TREE_TYPE(rhs);
101423 + tree cast_rhs_type, type_max_type, type_min_type, type_max, type_min;
101424 +
101425 + gcc_assert(rhs_type != NULL_TREE);
101426 + if (TREE_CODE(rhs_type) == POINTER_TYPE)
101427 + return;
101428 +
101429 + gcc_assert(TREE_CODE(rhs_type) == INTEGER_TYPE || TREE_CODE(rhs_type) == ENUMERAL_TYPE);
101430 +
101431 + if (is_const_plus_unsigned_signed_truncation(rhs))
101432 + return;
101433 +
101434 + type_max = cast_a_tree(size_overflow_type, TYPE_MAX_VALUE(rhs_type));
101435 + // typemax (-1) < typemin (0)
101436 + if (TREE_OVERFLOW(type_max))
101437 + return;
101438 +
101439 + type_min = cast_a_tree(size_overflow_type, TYPE_MIN_VALUE(rhs_type));
101440 +
101441 + cast_rhs_type = TREE_TYPE(cast_rhs);
101442 + type_max_type = TREE_TYPE(type_max);
101443 + type_min_type = TREE_TYPE(type_min);
101444 + gcc_assert(types_compatible_p(cast_rhs_type, type_max_type));
101445 + gcc_assert(types_compatible_p(type_max_type, type_min_type));
101446 +
101447 + insert_check_size_overflow(stmt, GT_EXPR, cast_rhs, type_max, before, false);
101448 + insert_check_size_overflow(stmt, LT_EXPR, cast_rhs, type_min, before, true);
101449 +}
101450 +
101451 +static bool is_a_constant_overflow(const_gimple stmt, const_tree rhs)
101452 +{
101453 + if (gimple_assign_rhs_code(stmt) == MIN_EXPR)
101454 + return false;
101455 + if (!is_gimple_constant(rhs))
101456 + return false;
101457 + return true;
101458 +}
101459 +
101460 +static tree get_def_stmt_rhs(const_tree var)
101461 +{
101462 + tree rhs1, def_stmt_rhs1;
101463 + gimple rhs1_def_stmt, def_stmt_rhs1_def_stmt, def_stmt;
101464 +
101465 + def_stmt = get_def_stmt(var);
101466 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP && gimple_plf(def_stmt, MY_STMT) && gimple_assign_cast_p(def_stmt));
101467 +
101468 + rhs1 = gimple_assign_rhs1(def_stmt);
101469 + rhs1_def_stmt = get_def_stmt(rhs1);
101470 + if (!gimple_assign_cast_p(rhs1_def_stmt))
101471 + return rhs1;
101472 +
101473 + def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
101474 + def_stmt_rhs1_def_stmt = get_def_stmt(def_stmt_rhs1);
101475 +
101476 + switch (gimple_code(def_stmt_rhs1_def_stmt)) {
101477 + case GIMPLE_CALL:
101478 + case GIMPLE_NOP:
101479 + case GIMPLE_ASM:
101480 + case GIMPLE_PHI:
101481 + return def_stmt_rhs1;
101482 + case GIMPLE_ASSIGN:
101483 + return rhs1;
101484 + default:
101485 + debug_gimple_stmt(def_stmt_rhs1_def_stmt);
101486 + gcc_unreachable();
101487 + }
101488 +}
101489 +
101490 +static tree handle_intentional_overflow(struct pointer_set_t *visited, bool check_overflow, gimple stmt, tree change_rhs, tree new_rhs2)
101491 +{
101492 + tree new_rhs, orig_rhs;
101493 + void (*gimple_assign_set_rhs)(gimple, tree);
101494 + tree rhs1 = gimple_assign_rhs1(stmt);
101495 + tree rhs2 = gimple_assign_rhs2(stmt);
101496 + tree lhs = gimple_get_lhs(stmt);
101497 +
101498 + if (!check_overflow)
101499 + return create_assign(visited, stmt, lhs, AFTER_STMT);
101500 +
101501 + if (change_rhs == NULL_TREE)
101502 + return create_assign(visited, stmt, lhs, AFTER_STMT);
101503 +
101504 + if (new_rhs2 == NULL_TREE) {
101505 + orig_rhs = rhs1;
101506 + gimple_assign_set_rhs = &gimple_assign_set_rhs1;
101507 + } else {
101508 + orig_rhs = rhs2;
101509 + gimple_assign_set_rhs = &gimple_assign_set_rhs2;
101510 + }
101511 +
101512 + check_size_overflow(stmt, TREE_TYPE(change_rhs), change_rhs, orig_rhs, BEFORE_STMT);
101513 +
101514 + new_rhs = change_assign_rhs(stmt, orig_rhs, change_rhs);
101515 + gimple_assign_set_rhs(stmt, new_rhs);
101516 + update_stmt(stmt);
101517 +
101518 + return create_assign(visited, stmt, lhs, AFTER_STMT);
101519 +}
101520 +
101521 +static bool is_subtraction_special(const_gimple stmt)
101522 +{
101523 + gimple rhs1_def_stmt, rhs2_def_stmt;
101524 + const_tree rhs1_def_stmt_rhs1, rhs2_def_stmt_rhs1, rhs1_def_stmt_lhs, rhs2_def_stmt_lhs;
101525 + enum machine_mode rhs1_def_stmt_rhs1_mode, rhs2_def_stmt_rhs1_mode, rhs1_def_stmt_lhs_mode, rhs2_def_stmt_lhs_mode;
101526 + const_tree rhs1 = gimple_assign_rhs1(stmt);
101527 + const_tree rhs2 = gimple_assign_rhs2(stmt);
101528 +
101529 + if (is_gimple_constant(rhs1) || is_gimple_constant(rhs2))
101530 + return false;
101531 +
101532 + gcc_assert(TREE_CODE(rhs1) == SSA_NAME && TREE_CODE(rhs2) == SSA_NAME);
101533 +
101534 + if (gimple_assign_rhs_code(stmt) != MINUS_EXPR)
101535 + return false;
101536 +
101537 + rhs1_def_stmt = get_def_stmt(rhs1);
101538 + rhs2_def_stmt = get_def_stmt(rhs2);
101539 + if (!gimple_assign_cast_p(rhs1_def_stmt) || !gimple_assign_cast_p(rhs2_def_stmt))
101540 + return false;
101541 +
101542 + rhs1_def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
101543 + rhs2_def_stmt_rhs1 = gimple_assign_rhs1(rhs2_def_stmt);
101544 + rhs1_def_stmt_lhs = gimple_get_lhs(rhs1_def_stmt);
101545 + rhs2_def_stmt_lhs = gimple_get_lhs(rhs2_def_stmt);
101546 + rhs1_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_rhs1));
101547 + rhs2_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_rhs1));
101548 + rhs1_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_lhs));
101549 + rhs2_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_lhs));
101550 + if (GET_MODE_BITSIZE(rhs1_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs1_def_stmt_lhs_mode))
101551 + return false;
101552 + if (GET_MODE_BITSIZE(rhs2_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs2_def_stmt_lhs_mode))
101553 + return false;
101554 +
101555 + gimple_set_plf(rhs1_def_stmt, NO_CAST_CHECK, true);
101556 + gimple_set_plf(rhs2_def_stmt, NO_CAST_CHECK, true);
101557 + return true;
101558 +}
101559 +
101560 +static tree handle_integer_truncation(struct pointer_set_t *visited, const_tree lhs)
101561 +{
101562 + tree new_rhs1, new_rhs2;
101563 + tree new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1, new_lhs;
101564 + gimple assign, stmt = get_def_stmt(lhs);
101565 + tree rhs1 = gimple_assign_rhs1(stmt);
101566 + tree rhs2 = gimple_assign_rhs2(stmt);
101567 +
101568 + if (!is_subtraction_special(stmt))
101569 + return NULL_TREE;
101570 +
101571 + new_rhs1 = expand(visited, rhs1);
101572 + new_rhs2 = expand(visited, rhs2);
101573 +
101574 + new_rhs1_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs1);
101575 + new_rhs2_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs2);
101576 +
101577 + if (!types_compatible_p(TREE_TYPE(new_rhs1_def_stmt_rhs1), TREE_TYPE(new_rhs2_def_stmt_rhs1))) {
101578 + new_rhs1_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs1_def_stmt_rhs1);
101579 + new_rhs2_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs2_def_stmt_rhs1);
101580 + }
101581 +
101582 + assign = create_binary_assign(MINUS_EXPR, stmt, new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1);
101583 + new_lhs = gimple_get_lhs(assign);
101584 + check_size_overflow(assign, TREE_TYPE(new_lhs), new_lhs, rhs1, AFTER_STMT);
101585 +
101586 + return dup_assign(visited, stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
101587 +}
101588 +
101589 +static bool is_a_neg_overflow(const_gimple stmt, const_tree rhs)
101590 +{
101591 + const_gimple def_stmt;
101592 +
101593 + if (TREE_CODE(rhs) != SSA_NAME)
101594 + return false;
101595 +
101596 + if (gimple_assign_rhs_code(stmt) != PLUS_EXPR)
101597 + return false;
101598 +
101599 + def_stmt = get_def_stmt(rhs);
101600 + if (gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_assign_rhs_code(def_stmt) != BIT_NOT_EXPR)
101601 + return false;
101602 +
101603 + return true;
101604 +}
101605 +
101606 +static tree handle_binary_ops(struct pointer_set_t *visited, tree lhs)
101607 +{
101608 + tree rhs1, rhs2, new_lhs;
101609 + gimple def_stmt = get_def_stmt(lhs);
101610 + tree new_rhs1 = NULL_TREE;
101611 + tree new_rhs2 = NULL_TREE;
101612 +
101613 + rhs1 = gimple_assign_rhs1(def_stmt);
101614 + rhs2 = gimple_assign_rhs2(def_stmt);
101615 +
101616 + /* no DImode/TImode division in the 32/64 bit kernel */
101617 + switch (gimple_assign_rhs_code(def_stmt)) {
101618 + case RDIV_EXPR:
101619 + case TRUNC_DIV_EXPR:
101620 + case CEIL_DIV_EXPR:
101621 + case FLOOR_DIV_EXPR:
101622 + case ROUND_DIV_EXPR:
101623 + case TRUNC_MOD_EXPR:
101624 + case CEIL_MOD_EXPR:
101625 + case FLOOR_MOD_EXPR:
101626 + case ROUND_MOD_EXPR:
101627 + case EXACT_DIV_EXPR:
101628 + case POINTER_PLUS_EXPR:
101629 + case BIT_AND_EXPR:
101630 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
101631 + default:
101632 + break;
101633 + }
101634 +
101635 + new_lhs = handle_integer_truncation(visited, lhs);
101636 + if (new_lhs != NULL_TREE)
101637 + return new_lhs;
101638 +
101639 + if (TREE_CODE(rhs1) == SSA_NAME)
101640 + new_rhs1 = expand(visited, rhs1);
101641 + if (TREE_CODE(rhs2) == SSA_NAME)
101642 + new_rhs2 = expand(visited, rhs2);
101643 +
101644 + if (is_a_neg_overflow(def_stmt, rhs2))
101645 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs1, NULL_TREE);
101646 + if (is_a_neg_overflow(def_stmt, rhs1))
101647 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs2, new_rhs2);
101648 +
101649 +
101650 + if (is_a_constant_overflow(def_stmt, rhs2))
101651 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs1), def_stmt, new_rhs1, NULL_TREE);
101652 + if (is_a_constant_overflow(def_stmt, rhs1))
101653 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs2), def_stmt, new_rhs2, new_rhs2);
101654 +
101655 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
101656 +}
101657 +
101658 +#if BUILDING_GCC_VERSION >= 4007
101659 +static tree get_new_rhs(struct pointer_set_t *visited, tree size_overflow_type, tree rhs)
101660 +{
101661 + if (is_gimple_constant(rhs))
101662 + return cast_a_tree(size_overflow_type, rhs);
101663 + if (TREE_CODE(rhs) != SSA_NAME)
101664 + return NULL_TREE;
101665 + return expand(visited, rhs);
101666 +}
101667 +
101668 +static tree handle_ternary_ops(struct pointer_set_t *visited, tree lhs)
101669 +{
101670 + tree rhs1, rhs2, rhs3, new_rhs1, new_rhs2, new_rhs3, size_overflow_type;
101671 + gimple def_stmt = get_def_stmt(lhs);
101672 +
101673 + size_overflow_type = get_size_overflow_type(def_stmt, lhs);
101674 +
101675 + rhs1 = gimple_assign_rhs1(def_stmt);
101676 + rhs2 = gimple_assign_rhs2(def_stmt);
101677 + rhs3 = gimple_assign_rhs3(def_stmt);
101678 + new_rhs1 = get_new_rhs(visited, size_overflow_type, rhs1);
101679 + new_rhs2 = get_new_rhs(visited, size_overflow_type, rhs2);
101680 + new_rhs3 = get_new_rhs(visited, size_overflow_type, rhs3);
101681 +
101682 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, new_rhs3);
101683 +}
101684 +#endif
101685 +
101686 +static tree get_size_overflow_type(gimple stmt, const_tree node)
101687 +{
101688 + const_tree type;
101689 + tree new_type;
101690 +
101691 + gcc_assert(node != NULL_TREE);
101692 +
101693 + type = TREE_TYPE(node);
101694 +
101695 + if (gimple_plf(stmt, MY_STMT))
101696 + return TREE_TYPE(node);
101697 +
101698 + switch (TYPE_MODE(type)) {
101699 + case QImode:
101700 + new_type = intHI_type_node;
101701 + break;
101702 + case HImode:
101703 + new_type = intSI_type_node;
101704 + break;
101705 + case SImode:
101706 + new_type = intDI_type_node;
101707 + break;
101708 + case DImode:
101709 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
101710 + new_type = intDI_type_node;
101711 + else
101712 + new_type = intTI_type_node;
101713 + break;
101714 + default:
101715 + debug_tree((tree)node);
101716 + error("%s: unsupported gcc configuration.", __func__);
101717 + gcc_unreachable();
101718 + }
101719 +
101720 + if (TYPE_QUALS(type) != 0)
101721 + return build_qualified_type(new_type, TYPE_QUALS(type));
101722 + return new_type;
101723 +}
101724 +
101725 +static tree expand_visited(gimple def_stmt)
101726 +{
101727 + const_gimple next_stmt;
101728 + gimple_stmt_iterator gsi;
101729 + enum gimple_code code = gimple_code(def_stmt);
101730 +
101731 + if (code == GIMPLE_ASM)
101732 + return NULL_TREE;
101733 +
101734 + gsi = gsi_for_stmt(def_stmt);
101735 + gsi_next(&gsi);
101736 +
101737 + if (gimple_code(def_stmt) == GIMPLE_PHI && gsi_end_p(gsi))
101738 + return NULL_TREE;
101739 + gcc_assert(!gsi_end_p(gsi));
101740 + next_stmt = gsi_stmt(gsi);
101741 +
101742 + if (gimple_code(def_stmt) == GIMPLE_PHI && !gimple_plf((gimple)next_stmt, MY_STMT))
101743 + return NULL_TREE;
101744 + gcc_assert(gimple_plf((gimple)next_stmt, MY_STMT));
101745 +
101746 + return get_lhs(next_stmt);
101747 +}
101748 +
101749 +static tree expand(struct pointer_set_t *visited, tree lhs)
101750 +{
101751 + gimple def_stmt;
101752 +
101753 + if (skip_types(lhs))
101754 + return NULL_TREE;
101755 +
101756 + def_stmt = get_def_stmt(lhs);
101757 +
101758 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
101759 + return NULL_TREE;
101760 +
101761 + if (gimple_plf(def_stmt, MY_STMT))
101762 + return lhs;
101763 +
101764 + if (pointer_set_contains(visited, def_stmt))
101765 + return expand_visited(def_stmt);
101766 +
101767 + switch (gimple_code(def_stmt)) {
101768 + case GIMPLE_PHI:
101769 + return handle_phi(visited, lhs);
101770 + case GIMPLE_CALL:
101771 + case GIMPLE_ASM:
101772 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
101773 + case GIMPLE_ASSIGN:
101774 + switch (gimple_num_ops(def_stmt)) {
101775 + case 2:
101776 + return handle_unary_ops(visited, def_stmt);
101777 + case 3:
101778 + return handle_binary_ops(visited, lhs);
101779 +#if BUILDING_GCC_VERSION >= 4007
101780 + case 4:
101781 + return handle_ternary_ops(visited, lhs);
101782 +#endif
101783 + }
101784 + default:
101785 + debug_gimple_stmt(def_stmt);
101786 + error("%s: unknown gimple code", __func__);
101787 + gcc_unreachable();
101788 + }
101789 +}
101790 +
101791 +static tree get_new_tree(gimple stmt, const_tree orig_node, tree new_node)
101792 +{
101793 + const_gimple assign;
101794 + tree orig_type = TREE_TYPE(orig_node);
101795 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
101796 +
101797 + assign = build_cast_stmt(orig_type, new_node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
101798 + return gimple_get_lhs(assign);
101799 +}
101800 +
101801 +static void change_function_arg(gimple stmt, const_tree orig_arg, unsigned int argnum, tree new_arg)
101802 +{
101803 + gimple_call_set_arg(stmt, argnum, get_new_tree(stmt, orig_arg, new_arg));
101804 + update_stmt(stmt);
101805 +}
101806 +
101807 +static void change_function_return(gimple stmt, const_tree orig_ret, tree new_ret)
101808 +{
101809 + gimple_return_set_retval(stmt, get_new_tree(stmt, orig_ret, new_ret));
101810 + update_stmt(stmt);
101811 +}
101812 +
101813 +static bool get_function_arg(unsigned int* argnum, const_tree fndecl)
101814 +{
101815 + tree arg;
101816 + const_tree origarg;
101817 +
101818 + if (!DECL_ABSTRACT_ORIGIN(fndecl))
101819 + return true;
101820 +
101821 + origarg = DECL_ARGUMENTS(DECL_ABSTRACT_ORIGIN(fndecl));
101822 + while (origarg && *argnum) {
101823 + (*argnum)--;
101824 + origarg = TREE_CHAIN(origarg);
101825 + }
101826 +
101827 + gcc_assert(*argnum == 0);
101828 +
101829 + gcc_assert(origarg != NULL_TREE);
101830 + *argnum = 0;
101831 + for (arg = DECL_ARGUMENTS(fndecl); arg; arg = TREE_CHAIN(arg), (*argnum)++)
101832 + if (operand_equal_p(origarg, arg, 0) || !strcmp(NAME(origarg), NAME(arg)))
101833 + return true;
101834 + return false;
101835 +}
101836 +
101837 +static enum mark walk_phi(struct pointer_set_t *visited, bool *search_err_code, const_tree result)
101838 +{
101839 + gimple phi = get_def_stmt(result);
101840 + unsigned int i, n = gimple_phi_num_args(phi);
101841 +
101842 + if (!phi)
101843 + return MARK_NO;
101844 +
101845 + pointer_set_insert(visited, phi);
101846 + for (i = 0; i < n; i++) {
101847 + enum mark marked;
101848 + const_tree arg = gimple_phi_arg_def(phi, i);
101849 + marked = pre_expand(visited, search_err_code, arg);
101850 + if (marked != MARK_NO)
101851 + return marked;
101852 + }
101853 + return MARK_NO;
101854 +}
101855 +
101856 +static enum mark walk_unary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
101857 +{
101858 + gimple def_stmt = get_def_stmt(lhs);
101859 + const_tree rhs;
101860 +
101861 + if (!def_stmt)
101862 + return MARK_NO;
101863 +
101864 + rhs = gimple_assign_rhs1(def_stmt);
101865 +
101866 + def_stmt = get_def_stmt(rhs);
101867 + if (is_gimple_constant(rhs))
101868 + search_err_code[FROM_CONST] = true;
101869 +
101870 + return pre_expand(visited, search_err_code, rhs);
101871 +}
101872 +
101873 +static enum mark walk_binary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
101874 +{
101875 + gimple def_stmt = get_def_stmt(lhs);
101876 + const_tree rhs1, rhs2;
101877 + enum mark marked;
101878 +
101879 + if (!def_stmt)
101880 + return MARK_NO;
101881 +
101882 + search_err_code[CAST_ONLY] = false;
101883 +
101884 + rhs1 = gimple_assign_rhs1(def_stmt);
101885 + rhs2 = gimple_assign_rhs2(def_stmt);
101886 + marked = pre_expand(visited, search_err_code, rhs1);
101887 + if (marked != MARK_NO)
101888 + return marked;
101889 + return pre_expand(visited, search_err_code, rhs2);
101890 +}
101891 +
101892 +static const_tree search_field_decl(const_tree comp_ref)
101893 +{
101894 + const_tree field = NULL_TREE;
101895 + unsigned int i, len = TREE_OPERAND_LENGTH(comp_ref);
101896 +
101897 + for (i = 0; i < len; i++) {
101898 + field = TREE_OPERAND(comp_ref, i);
101899 + if (TREE_CODE(field) == FIELD_DECL)
101900 + break;
101901 + }
101902 + gcc_assert(TREE_CODE(field) == FIELD_DECL);
101903 + return field;
101904 +}
101905 +
101906 +static enum mark mark_status(const_tree fndecl, unsigned int argnum)
101907 +{
101908 + const_tree attr, p;
101909 +
101910 + // 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);
101911 + if (fndecl == NULL_TREE)
101912 + return MARK_NO;
101913 +
101914 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(fndecl));
101915 + if (!attr || !TREE_VALUE(attr))
101916 + return MARK_NO;
101917 +
101918 + p = TREE_VALUE(attr);
101919 + if (TREE_INT_CST_HIGH(TREE_VALUE(p)) == -1)
101920 + return MARK_TURN_OFF;
101921 + if (!TREE_INT_CST_LOW(TREE_VALUE(p)))
101922 + return MARK_NOT_INTENTIONAL;
101923 + if (argnum == 0) {
101924 + gcc_assert(current_function_decl == fndecl);
101925 + return MARK_NO;
101926 + }
101927 +
101928 + do {
101929 + if (argnum == TREE_INT_CST_LOW(TREE_VALUE(p)))
101930 + return MARK_YES;
101931 + p = TREE_CHAIN(p);
101932 + } while (p);
101933 +
101934 + return MARK_NO;
101935 +}
101936 +
101937 +static void print_missing_msg(tree func, unsigned int argnum)
101938 +{
101939 + unsigned int new_hash;
101940 + size_t len;
101941 + unsigned char tree_codes[CODES_LIMIT];
101942 + location_t loc;
101943 + const char *curfunc;
101944 +
101945 + func = get_original_function_decl(func);
101946 + loc = DECL_SOURCE_LOCATION(func);
101947 + curfunc = get_asm_name(func);
101948 +
101949 + len = get_function_decl(func, tree_codes);
101950 + new_hash = get_hash_num(curfunc, (const char *) tree_codes, len, 0);
101951 + inform(loc, "Function %s is missing from the size_overflow hash table +%s+%u+%u+", curfunc, curfunc, argnum, new_hash);
101952 +}
101953 +
101954 +static unsigned int search_missing_attribute(const_tree arg)
101955 +{
101956 + unsigned int argnum;
101957 + const struct size_overflow_hash *hash;
101958 + const_tree type = TREE_TYPE(arg);
101959 + tree func = get_original_function_decl(current_function_decl);
101960 +
101961 + gcc_assert(TREE_CODE(arg) != COMPONENT_REF);
101962 +
101963 + if (TREE_CODE(type) == POINTER_TYPE)
101964 + return 0;
101965 +
101966 + argnum = find_arg_number(arg, func);
101967 + if (argnum == 0)
101968 + return 0;
101969 +
101970 + if (lookup_attribute("size_overflow", DECL_ATTRIBUTES(func)))
101971 + return argnum;
101972 +
101973 + hash = get_function_hash(func);
101974 + if (!hash || !(hash->param & (1U << argnum))) {
101975 + print_missing_msg(func, argnum);
101976 + return 0;
101977 + }
101978 + return argnum;
101979 +}
101980 +
101981 +static enum mark is_already_marked(const_tree lhs)
101982 +{
101983 + unsigned int argnum;
101984 + const_tree fndecl;
101985 +
101986 + argnum = search_missing_attribute(lhs);
101987 + fndecl = get_original_function_decl(current_function_decl);
101988 + if (argnum && mark_status(fndecl, argnum) == MARK_YES)
101989 + return MARK_YES;
101990 + return MARK_NO;
101991 +}
101992 +
101993 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
101994 +{
101995 + const_gimple def_stmt;
101996 +
101997 + if (skip_types(lhs))
101998 + return MARK_NO;
101999 +
102000 + if (TREE_CODE(lhs) == PARM_DECL)
102001 + return is_already_marked(lhs);
102002 +
102003 + if (TREE_CODE(lhs) == COMPONENT_REF) {
102004 + const_tree field, attr;
102005 +
102006 + field = search_field_decl(lhs);
102007 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(field));
102008 + if (!attr || !TREE_VALUE(attr))
102009 + return MARK_NO;
102010 + return MARK_YES;
102011 + }
102012 +
102013 + def_stmt = get_def_stmt(lhs);
102014 +
102015 + if (!def_stmt)
102016 + return MARK_NO;
102017 +
102018 + if (pointer_set_contains(visited, def_stmt))
102019 + return MARK_NO;
102020 +
102021 + switch (gimple_code(def_stmt)) {
102022 + case GIMPLE_NOP:
102023 + if (TREE_CODE(SSA_NAME_VAR(lhs)) == PARM_DECL)
102024 + return is_already_marked(lhs);
102025 + return MARK_NO;
102026 + case GIMPLE_PHI:
102027 + return walk_phi(visited, search_err_code, lhs);
102028 + case GIMPLE_CALL:
102029 + if (mark_status((gimple_call_fndecl(def_stmt)), 0) == MARK_TURN_OFF)
102030 + return MARK_TURN_OFF;
102031 + check_function_hash(def_stmt);
102032 + return MARK_NO;
102033 + case GIMPLE_ASM:
102034 + search_err_code[CAST_ONLY] = false;
102035 + return MARK_NO;
102036 + case GIMPLE_ASSIGN:
102037 + switch (gimple_num_ops(def_stmt)) {
102038 + case 2:
102039 + return walk_unary_ops(visited, search_err_code, lhs);
102040 + case 3:
102041 + return walk_binary_ops(visited, search_err_code, lhs);
102042 + }
102043 + default:
102044 + debug_gimple_stmt((gimple)def_stmt);
102045 + error("%s: unknown gimple code", __func__);
102046 + gcc_unreachable();
102047 + }
102048 +}
102049 +
102050 +// e.g., 3.8.2, 64, arch/x86/ia32/ia32_signal.c copy_siginfo_from_user32(): compat_ptr() u32 max
102051 +static bool skip_asm(const_tree arg)
102052 +{
102053 + gimple def_stmt = get_def_stmt(arg);
102054 +
102055 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
102056 + return false;
102057 +
102058 + def_stmt = get_def_stmt(gimple_assign_rhs1(def_stmt));
102059 + return def_stmt && gimple_code(def_stmt) == GIMPLE_ASM;
102060 +}
102061 +
102062 +/*
102063 +0</MARK_YES: no dup, search attributes (so, int)
102064 +0/MARK_NOT_INTENTIONAL: no dup, search attribute (int)
102065 +-1/MARK_TURN_OFF: no dup, no search, current_function_decl -> no dup
102066 +*/
102067 +
102068 +static bool search_attributes(tree fndecl, const_tree arg, unsigned int argnum, bool where)
102069 +{
102070 + struct pointer_set_t *visited;
102071 + enum mark is_marked, is_found;
102072 + location_t loc;
102073 + bool search_err_code[2] = {true, false};
102074 +
102075 + is_marked = mark_status(current_function_decl, 0);
102076 + if (is_marked == MARK_TURN_OFF)
102077 + return true;
102078 +
102079 + is_marked = mark_status(fndecl, argnum + 1);
102080 + if (is_marked == MARK_TURN_OFF || is_marked == MARK_NOT_INTENTIONAL)
102081 + return true;
102082 +
102083 + visited = pointer_set_create();
102084 + is_found = pre_expand(visited, search_err_code, arg);
102085 + pointer_set_destroy(visited);
102086 +
102087 + if (where == FROM_RET && search_err_code[CAST_ONLY] && search_err_code[FROM_CONST])
102088 + return true;
102089 +
102090 + if (where == FROM_ARG && skip_asm(arg))
102091 + return true;
102092 +
102093 + if (is_found == MARK_TURN_OFF)
102094 + return true;
102095 +
102096 + if ((is_found == MARK_YES && is_marked == MARK_YES))
102097 + return true;
102098 +
102099 + if (is_found == MARK_YES) {
102100 + loc = DECL_SOURCE_LOCATION(fndecl);
102101 + inform(loc, "The intentional_overflow attribute is missing from +%s+%u+", get_asm_name(fndecl), argnum + 1);
102102 + return true;
102103 + }
102104 + return false;
102105 +}
102106 +
102107 +static void handle_function_arg(gimple stmt, tree fndecl, unsigned int argnum)
102108 +{
102109 + struct pointer_set_t *visited;
102110 + tree arg, new_arg;
102111 + bool match;
102112 +
102113 + if (argnum == 0)
102114 + return;
102115 +
102116 + argnum--;
102117 +
102118 + match = get_function_arg(&argnum, fndecl);
102119 + if (!match)
102120 + return;
102121 + gcc_assert(gimple_call_num_args(stmt) > argnum);
102122 + arg = gimple_call_arg(stmt, argnum);
102123 + if (arg == NULL_TREE)
102124 + return;
102125 +
102126 + if (skip_types(arg))
102127 + return;
102128 +
102129 + if (search_attributes(fndecl, arg, argnum, FROM_ARG))
102130 + return;
102131 +
102132 + visited = pointer_set_create();
102133 + new_arg = expand(visited, arg);
102134 + pointer_set_destroy(visited);
102135 +
102136 + if (new_arg == NULL_TREE)
102137 + return;
102138 +
102139 + change_function_arg(stmt, arg, argnum, new_arg);
102140 + check_size_overflow(stmt, TREE_TYPE(new_arg), new_arg, arg, BEFORE_STMT);
102141 +}
102142 +
102143 +static void handle_function_by_attribute(gimple stmt, const_tree attr, tree fndecl)
102144 +{
102145 + tree p = TREE_VALUE(attr);
102146 + do {
102147 + handle_function_arg(stmt, fndecl, TREE_INT_CST_LOW(TREE_VALUE(p)));
102148 + p = TREE_CHAIN(p);
102149 + } while (p);
102150 +}
102151 +
102152 +static void handle_function_by_hash(gimple stmt, tree fndecl)
102153 +{
102154 + unsigned int num;
102155 + const struct size_overflow_hash *hash;
102156 +
102157 + hash = get_function_hash(fndecl);
102158 + if (!hash)
102159 + return;
102160 +
102161 + for (num = 0; num <= MAX_PARAM; num++)
102162 + if (hash->param & (1U << num))
102163 + handle_function_arg(stmt, fndecl, num);
102164 +}
102165 +
102166 +static bool check_return_value(void)
102167 +{
102168 + const struct size_overflow_hash *hash;
102169 +
102170 + hash = get_function_hash(current_function_decl);
102171 + if (!hash || !(hash->param & 1U << 0))
102172 + return false;
102173 +
102174 + return true;
102175 +}
102176 +
102177 +static void handle_return_value(gimple ret_stmt)
102178 +{
102179 + struct pointer_set_t *visited;
102180 + tree ret, new_ret;
102181 +
102182 + if (gimple_code(ret_stmt) != GIMPLE_RETURN)
102183 + return;
102184 +
102185 + ret = gimple_return_retval(ret_stmt);
102186 +
102187 + if (skip_types(ret))
102188 + return;
102189 +
102190 + if (search_attributes(current_function_decl, ret, 0, FROM_RET))
102191 + return;
102192 +
102193 + visited = pointer_set_create();
102194 + new_ret = expand(visited, ret);
102195 + pointer_set_destroy(visited);
102196 +
102197 + change_function_return(ret_stmt, ret, new_ret);
102198 + check_size_overflow(ret_stmt, TREE_TYPE(new_ret), new_ret, ret, BEFORE_STMT);
102199 +}
102200 +
102201 +static void set_plf_false(void)
102202 +{
102203 + basic_block bb;
102204 +
102205 + FOR_ALL_BB(bb) {
102206 + gimple_stmt_iterator si;
102207 +
102208 + for (si = gsi_start_bb(bb); !gsi_end_p(si); gsi_next(&si))
102209 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
102210 + for (si = gsi_start_phis(bb); !gsi_end_p(si); gsi_next(&si))
102211 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
102212 + }
102213 +}
102214 +
102215 +static unsigned int handle_function(void)
102216 +{
102217 + basic_block next, bb = ENTRY_BLOCK_PTR->next_bb;
102218 + bool check_ret;
102219 +
102220 + set_plf_false();
102221 +
102222 + check_ret = check_return_value();
102223 +
102224 + do {
102225 + gimple_stmt_iterator gsi;
102226 + next = bb->next_bb;
102227 +
102228 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
102229 + tree fndecl, attr;
102230 + gimple stmt = gsi_stmt(gsi);
102231 +
102232 + if (check_ret)
102233 + handle_return_value(stmt);
102234 +
102235 + if (!(is_gimple_call(stmt)))
102236 + continue;
102237 + fndecl = gimple_call_fndecl(stmt);
102238 + if (fndecl == NULL_TREE)
102239 + continue;
102240 + if (gimple_call_num_args(stmt) == 0)
102241 + continue;
102242 + attr = lookup_attribute("size_overflow", DECL_ATTRIBUTES(fndecl));
102243 + if (!attr || !TREE_VALUE(attr))
102244 + handle_function_by_hash(stmt, fndecl);
102245 + else
102246 + handle_function_by_attribute(stmt, attr, fndecl);
102247 + gsi = gsi_for_stmt(stmt);
102248 + next = gimple_bb(stmt)->next_bb;
102249 + }
102250 + bb = next;
102251 + } while (bb);
102252 + return 0;
102253 +}
102254 +
102255 +static struct gimple_opt_pass size_overflow_pass = {
102256 + .pass = {
102257 + .type = GIMPLE_PASS,
102258 + .name = "size_overflow",
102259 +#if BUILDING_GCC_VERSION >= 4008
102260 + .optinfo_flags = OPTGROUP_NONE,
102261 +#endif
102262 + .gate = NULL,
102263 + .execute = handle_function,
102264 + .sub = NULL,
102265 + .next = NULL,
102266 + .static_pass_number = 0,
102267 + .tv_id = TV_NONE,
102268 + .properties_required = PROP_cfg,
102269 + .properties_provided = 0,
102270 + .properties_destroyed = 0,
102271 + .todo_flags_start = 0,
102272 + .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
102273 + }
102274 +};
102275 +
102276 +static void start_unit_callback(void __unused *gcc_data, void __unused *user_data)
102277 +{
102278 + tree fntype;
102279 +
102280 + const_char_ptr_type_node = build_pointer_type(build_type_variant(char_type_node, 1, 0));
102281 +
102282 + // void report_size_overflow(const char *loc_file, unsigned int loc_line, const char *current_func, const char *ssa_var)
102283 + fntype = build_function_type_list(void_type_node,
102284 + const_char_ptr_type_node,
102285 + unsigned_type_node,
102286 + const_char_ptr_type_node,
102287 + const_char_ptr_type_node,
102288 + NULL_TREE);
102289 + report_size_overflow_decl = build_fn_decl("report_size_overflow", fntype);
102290 +
102291 + DECL_ASSEMBLER_NAME(report_size_overflow_decl);
102292 + TREE_PUBLIC(report_size_overflow_decl) = 1;
102293 + DECL_EXTERNAL(report_size_overflow_decl) = 1;
102294 + DECL_ARTIFICIAL(report_size_overflow_decl) = 1;
102295 + TREE_THIS_VOLATILE(report_size_overflow_decl) = 1;
102296 +}
102297 +
102298 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
102299 +{
102300 + int i;
102301 + const char * const plugin_name = plugin_info->base_name;
102302 + const int argc = plugin_info->argc;
102303 + const struct plugin_argument * const argv = plugin_info->argv;
102304 + bool enable = true;
102305 +
102306 + struct register_pass_info size_overflow_pass_info = {
102307 + .pass = &size_overflow_pass.pass,
102308 + .reference_pass_name = "ssa",
102309 + .ref_pass_instance_number = 1,
102310 + .pos_op = PASS_POS_INSERT_AFTER
102311 + };
102312 +
102313 + if (!plugin_default_version_check(version, &gcc_version)) {
102314 + error(G_("incompatible gcc/plugin versions"));
102315 + return 1;
102316 + }
102317 +
102318 + for (i = 0; i < argc; ++i) {
102319 + if (!strcmp(argv[i].key, "no-size-overflow")) {
102320 + enable = false;
102321 + continue;
102322 + }
102323 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
102324 + }
102325 +
102326 + register_callback(plugin_name, PLUGIN_INFO, NULL, &size_overflow_plugin_info);
102327 + if (enable) {
102328 + register_callback("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
102329 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &size_overflow_pass_info);
102330 + }
102331 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
102332 +
102333 + return 0;
102334 +}
102335 diff --git a/tools/gcc/stackleak_plugin.c b/tools/gcc/stackleak_plugin.c
102336 new file mode 100644
102337 index 0000000..ac2901e
102338 --- /dev/null
102339 +++ b/tools/gcc/stackleak_plugin.c
102340 @@ -0,0 +1,327 @@
102341 +/*
102342 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
102343 + * Licensed under the GPL v2
102344 + *
102345 + * Note: the choice of the license means that the compilation process is
102346 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
102347 + * but for the kernel it doesn't matter since it doesn't link against
102348 + * any of the gcc libraries
102349 + *
102350 + * gcc plugin to help implement various PaX features
102351 + *
102352 + * - track lowest stack pointer
102353 + *
102354 + * TODO:
102355 + * - initialize all local variables
102356 + *
102357 + * BUGS:
102358 + * - none known
102359 + */
102360 +#include "gcc-plugin.h"
102361 +#include "config.h"
102362 +#include "system.h"
102363 +#include "coretypes.h"
102364 +#include "tree.h"
102365 +#include "tree-pass.h"
102366 +#include "flags.h"
102367 +#include "intl.h"
102368 +#include "toplev.h"
102369 +#include "plugin.h"
102370 +//#include "expr.h" where are you...
102371 +#include "diagnostic.h"
102372 +#include "plugin-version.h"
102373 +#include "tm.h"
102374 +#include "function.h"
102375 +#include "basic-block.h"
102376 +#include "gimple.h"
102377 +#include "rtl.h"
102378 +#include "emit-rtl.h"
102379 +
102380 +#if BUILDING_GCC_VERSION >= 4008
102381 +#define TODO_dump_func 0
102382 +#endif
102383 +
102384 +extern void print_gimple_stmt(FILE *, gimple, int, int);
102385 +
102386 +int plugin_is_GPL_compatible;
102387 +
102388 +static int track_frame_size = -1;
102389 +static const char track_function[] = "pax_track_stack";
102390 +static const char check_function[] = "pax_check_alloca";
102391 +static bool init_locals;
102392 +
102393 +static struct plugin_info stackleak_plugin_info = {
102394 + .version = "201302112000",
102395 + .help = "track-lowest-sp=nn\ttrack sp in functions whose frame size is at least nn bytes\n"
102396 +// "initialize-locals\t\tforcibly initialize all stack frames\n"
102397 +};
102398 +
102399 +static bool gate_stackleak_track_stack(void);
102400 +static unsigned int execute_stackleak_tree_instrument(void);
102401 +static unsigned int execute_stackleak_final(void);
102402 +
102403 +static struct gimple_opt_pass stackleak_tree_instrument_pass = {
102404 + .pass = {
102405 + .type = GIMPLE_PASS,
102406 + .name = "stackleak_tree_instrument",
102407 +#if BUILDING_GCC_VERSION >= 4008
102408 + .optinfo_flags = OPTGROUP_NONE,
102409 +#endif
102410 + .gate = gate_stackleak_track_stack,
102411 + .execute = execute_stackleak_tree_instrument,
102412 + .sub = NULL,
102413 + .next = NULL,
102414 + .static_pass_number = 0,
102415 + .tv_id = TV_NONE,
102416 + .properties_required = PROP_gimple_leh | PROP_cfg,
102417 + .properties_provided = 0,
102418 + .properties_destroyed = 0,
102419 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
102420 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
102421 + }
102422 +};
102423 +
102424 +static struct rtl_opt_pass stackleak_final_rtl_opt_pass = {
102425 + .pass = {
102426 + .type = RTL_PASS,
102427 + .name = "stackleak_final",
102428 +#if BUILDING_GCC_VERSION >= 4008
102429 + .optinfo_flags = OPTGROUP_NONE,
102430 +#endif
102431 + .gate = gate_stackleak_track_stack,
102432 + .execute = execute_stackleak_final,
102433 + .sub = NULL,
102434 + .next = NULL,
102435 + .static_pass_number = 0,
102436 + .tv_id = TV_NONE,
102437 + .properties_required = 0,
102438 + .properties_provided = 0,
102439 + .properties_destroyed = 0,
102440 + .todo_flags_start = 0,
102441 + .todo_flags_finish = TODO_dump_func
102442 + }
102443 +};
102444 +
102445 +static bool gate_stackleak_track_stack(void)
102446 +{
102447 + return track_frame_size >= 0;
102448 +}
102449 +
102450 +static void stackleak_check_alloca(gimple_stmt_iterator *gsi)
102451 +{
102452 + gimple check_alloca;
102453 + tree fntype, fndecl, alloca_size;
102454 +
102455 + fntype = build_function_type_list(void_type_node, long_unsigned_type_node, NULL_TREE);
102456 + fndecl = build_fn_decl(check_function, fntype);
102457 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
102458 +
102459 + // insert call to void pax_check_alloca(unsigned long size)
102460 + alloca_size = gimple_call_arg(gsi_stmt(*gsi), 0);
102461 + check_alloca = gimple_build_call(fndecl, 1, alloca_size);
102462 + gsi_insert_before(gsi, check_alloca, GSI_SAME_STMT);
102463 +}
102464 +
102465 +static void stackleak_add_instrumentation(gimple_stmt_iterator *gsi)
102466 +{
102467 + gimple track_stack;
102468 + tree fntype, fndecl;
102469 +
102470 + fntype = build_function_type_list(void_type_node, NULL_TREE);
102471 + fndecl = build_fn_decl(track_function, fntype);
102472 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
102473 +
102474 + // insert call to void pax_track_stack(void)
102475 + track_stack = gimple_build_call(fndecl, 0);
102476 + gsi_insert_after(gsi, track_stack, GSI_CONTINUE_LINKING);
102477 +}
102478 +
102479 +#if BUILDING_GCC_VERSION == 4005
102480 +static bool gimple_call_builtin_p(gimple stmt, enum built_in_function code)
102481 +{
102482 + tree fndecl;
102483 +
102484 + if (!is_gimple_call(stmt))
102485 + return false;
102486 + fndecl = gimple_call_fndecl(stmt);
102487 + if (!fndecl)
102488 + return false;
102489 + if (DECL_BUILT_IN_CLASS(fndecl) != BUILT_IN_NORMAL)
102490 + return false;
102491 +// print_node(stderr, "pax", fndecl, 4);
102492 + return DECL_FUNCTION_CODE(fndecl) == code;
102493 +}
102494 +#endif
102495 +
102496 +static bool is_alloca(gimple stmt)
102497 +{
102498 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA))
102499 + return true;
102500 +
102501 +#if BUILDING_GCC_VERSION >= 4007
102502 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA_WITH_ALIGN))
102503 + return true;
102504 +#endif
102505 +
102506 + return false;
102507 +}
102508 +
102509 +static unsigned int execute_stackleak_tree_instrument(void)
102510 +{
102511 + basic_block bb, entry_bb;
102512 + bool prologue_instrumented = false, is_leaf = true;
102513 +
102514 + entry_bb = ENTRY_BLOCK_PTR_FOR_FUNCTION(cfun)->next_bb;
102515 +
102516 + // 1. loop through BBs and GIMPLE statements
102517 + FOR_EACH_BB(bb) {
102518 + gimple_stmt_iterator gsi;
102519 +
102520 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
102521 + gimple stmt;
102522 +
102523 + stmt = gsi_stmt(gsi);
102524 +
102525 + if (is_gimple_call(stmt))
102526 + is_leaf = false;
102527 +
102528 + // gimple match: align 8 built-in BUILT_IN_NORMAL:BUILT_IN_ALLOCA attributes <tree_list 0xb7576450>
102529 + if (!is_alloca(stmt))
102530 + continue;
102531 +
102532 + // 2. insert stack overflow check before each __builtin_alloca call
102533 + stackleak_check_alloca(&gsi);
102534 +
102535 + // 3. insert track call after each __builtin_alloca call
102536 + stackleak_add_instrumentation(&gsi);
102537 + if (bb == entry_bb)
102538 + prologue_instrumented = true;
102539 + }
102540 + }
102541 +
102542 + // special cases for some bad linux code: taking the address of static inline functions will materialize them
102543 + // but we mustn't instrument some of them as the resulting stack alignment required by the function call ABI
102544 + // will break other assumptions regarding the expected (but not otherwise enforced) register clobbering ABI.
102545 + // case in point: native_save_fl on amd64 when optimized for size clobbers rdx if it were instrumented here.
102546 + if (is_leaf && !TREE_PUBLIC(current_function_decl) && DECL_DECLARED_INLINE_P(current_function_decl))
102547 + return 0;
102548 + if (is_leaf && !strncmp(IDENTIFIER_POINTER(DECL_NAME(current_function_decl)), "_paravirt_", 10))
102549 + return 0;
102550 +
102551 + // 4. insert track call at the beginning
102552 + if (!prologue_instrumented) {
102553 + gimple_stmt_iterator gsi;
102554 +
102555 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
102556 + if (dom_info_available_p(CDI_DOMINATORS))
102557 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
102558 + gsi = gsi_start_bb(bb);
102559 + stackleak_add_instrumentation(&gsi);
102560 + }
102561 +
102562 + return 0;
102563 +}
102564 +
102565 +static unsigned int execute_stackleak_final(void)
102566 +{
102567 + rtx insn, next;
102568 +
102569 + if (cfun->calls_alloca)
102570 + return 0;
102571 +
102572 + // keep calls only if function frame is big enough
102573 + if (get_frame_size() >= track_frame_size)
102574 + return 0;
102575 +
102576 + // 1. find pax_track_stack calls
102577 + for (insn = get_insns(); insn; insn = next) {
102578 + // 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))
102579 + rtx body;
102580 +
102581 + next = NEXT_INSN(insn);
102582 + if (!CALL_P(insn))
102583 + continue;
102584 + body = PATTERN(insn);
102585 + if (GET_CODE(body) != CALL)
102586 + continue;
102587 + body = XEXP(body, 0);
102588 + if (GET_CODE(body) != MEM)
102589 + continue;
102590 + body = XEXP(body, 0);
102591 + if (GET_CODE(body) != SYMBOL_REF)
102592 + continue;
102593 + if (strcmp(XSTR(body, 0), track_function))
102594 + continue;
102595 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
102596 + // 2. delete call
102597 + delete_insn_and_edges(insn);
102598 +#if BUILDING_GCC_VERSION >= 4007
102599 + if (GET_CODE(next) == NOTE && NOTE_KIND(next) == NOTE_INSN_CALL_ARG_LOCATION) {
102600 + insn = next;
102601 + next = NEXT_INSN(insn);
102602 + delete_insn_and_edges(insn);
102603 + }
102604 +#endif
102605 + }
102606 +
102607 +// print_simple_rtl(stderr, get_insns());
102608 +// print_rtl(stderr, get_insns());
102609 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
102610 +
102611 + return 0;
102612 +}
102613 +
102614 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
102615 +{
102616 + const char * const plugin_name = plugin_info->base_name;
102617 + const int argc = plugin_info->argc;
102618 + const struct plugin_argument * const argv = plugin_info->argv;
102619 + int i;
102620 + struct register_pass_info stackleak_tree_instrument_pass_info = {
102621 + .pass = &stackleak_tree_instrument_pass.pass,
102622 +// .reference_pass_name = "tree_profile",
102623 + .reference_pass_name = "optimized",
102624 + .ref_pass_instance_number = 1,
102625 + .pos_op = PASS_POS_INSERT_BEFORE
102626 + };
102627 + struct register_pass_info stackleak_final_pass_info = {
102628 + .pass = &stackleak_final_rtl_opt_pass.pass,
102629 + .reference_pass_name = "final",
102630 + .ref_pass_instance_number = 1,
102631 + .pos_op = PASS_POS_INSERT_BEFORE
102632 + };
102633 +
102634 + if (!plugin_default_version_check(version, &gcc_version)) {
102635 + error(G_("incompatible gcc/plugin versions"));
102636 + return 1;
102637 + }
102638 +
102639 + register_callback(plugin_name, PLUGIN_INFO, NULL, &stackleak_plugin_info);
102640 +
102641 + for (i = 0; i < argc; ++i) {
102642 + if (!strcmp(argv[i].key, "track-lowest-sp")) {
102643 + if (!argv[i].value) {
102644 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
102645 + continue;
102646 + }
102647 + track_frame_size = atoi(argv[i].value);
102648 + if (argv[i].value[0] < '0' || argv[i].value[0] > '9' || track_frame_size < 0)
102649 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
102650 + continue;
102651 + }
102652 + if (!strcmp(argv[i].key, "initialize-locals")) {
102653 + if (argv[i].value) {
102654 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
102655 + continue;
102656 + }
102657 + init_locals = true;
102658 + continue;
102659 + }
102660 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
102661 + }
102662 +
102663 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_tree_instrument_pass_info);
102664 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_final_pass_info);
102665 +
102666 + return 0;
102667 +}
102668 diff --git a/tools/gcc/structleak_plugin.c b/tools/gcc/structleak_plugin.c
102669 new file mode 100644
102670 index 0000000..4fae911
102671 --- /dev/null
102672 +++ b/tools/gcc/structleak_plugin.c
102673 @@ -0,0 +1,277 @@
102674 +/*
102675 + * Copyright 2013 by PaX Team <pageexec@freemail.hu>
102676 + * Licensed under the GPL v2
102677 + *
102678 + * Note: the choice of the license means that the compilation process is
102679 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
102680 + * but for the kernel it doesn't matter since it doesn't link against
102681 + * any of the gcc libraries
102682 + *
102683 + * gcc plugin to forcibly initialize certain local variables that could
102684 + * otherwise leak kernel stack to userland if they aren't properly initialized
102685 + * by later code
102686 + *
102687 + * Homepage: http://pax.grsecurity.net/
102688 + *
102689 + * Usage:
102690 + * $ # for 4.5/4.6/C based 4.7
102691 + * $ 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
102692 + * $ # for C++ based 4.7/4.8+
102693 + * $ 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
102694 + * $ gcc -fplugin=./structleak_plugin.so test.c -O2
102695 + *
102696 + * TODO: eliminate redundant initializers
102697 + * increase type coverage
102698 + */
102699 +
102700 +#include "gcc-plugin.h"
102701 +#include "config.h"
102702 +#include "system.h"
102703 +#include "coretypes.h"
102704 +#include "tree.h"
102705 +#include "tree-pass.h"
102706 +#include "intl.h"
102707 +#include "plugin-version.h"
102708 +#include "tm.h"
102709 +#include "toplev.h"
102710 +#include "function.h"
102711 +#include "tree-flow.h"
102712 +#include "plugin.h"
102713 +#include "gimple.h"
102714 +#include "diagnostic.h"
102715 +#include "cfgloop.h"
102716 +#include "langhooks.h"
102717 +
102718 +#if BUILDING_GCC_VERSION >= 4008
102719 +#define TODO_dump_func 0
102720 +#endif
102721 +
102722 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
102723 +
102724 +// unused type flag in all versions 4.5-4.8
102725 +#define TYPE_USERSPACE(TYPE) TYPE_LANG_FLAG_3(TYPE)
102726 +
102727 +int plugin_is_GPL_compatible;
102728 +void debug_gimple_stmt(gimple gs);
102729 +
102730 +static struct plugin_info structleak_plugin_info = {
102731 + .version = "201304082245",
102732 + .help = "disable\tdo not activate plugin\n",
102733 +};
102734 +
102735 +static tree handle_user_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
102736 +{
102737 + *no_add_attrs = true;
102738 +
102739 + // check for types? for now accept everything linux has to offer
102740 + if (TREE_CODE(*node) != FIELD_DECL)
102741 + return NULL_TREE;
102742 +
102743 + *no_add_attrs = false;
102744 + return NULL_TREE;
102745 +}
102746 +
102747 +static struct attribute_spec user_attr = {
102748 + .name = "user",
102749 + .min_length = 0,
102750 + .max_length = 0,
102751 + .decl_required = false,
102752 + .type_required = false,
102753 + .function_type_required = false,
102754 + .handler = handle_user_attribute,
102755 +#if BUILDING_GCC_VERSION >= 4007
102756 + .affects_type_identity = true
102757 +#endif
102758 +};
102759 +
102760 +static void register_attributes(void *event_data, void *data)
102761 +{
102762 + register_attribute(&user_attr);
102763 +// register_attribute(&force_attr);
102764 +}
102765 +
102766 +static tree get_field_type(tree field)
102767 +{
102768 + return strip_array_types(TREE_TYPE(field));
102769 +}
102770 +
102771 +static bool is_userspace_type(tree type)
102772 +{
102773 + tree field;
102774 +
102775 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
102776 + tree fieldtype = get_field_type(field);
102777 + enum tree_code code = TREE_CODE(fieldtype);
102778 +
102779 + if (code == RECORD_TYPE || code == UNION_TYPE)
102780 + if (is_userspace_type(fieldtype))
102781 + return true;
102782 +
102783 + if (lookup_attribute("user", DECL_ATTRIBUTES(field)))
102784 + return true;
102785 + }
102786 + return false;
102787 +}
102788 +
102789 +static void finish_type(void *event_data, void *data)
102790 +{
102791 + tree type = (tree)event_data;
102792 +
102793 + if (TYPE_USERSPACE(type))
102794 + return;
102795 +
102796 + if (is_userspace_type(type))
102797 + TYPE_USERSPACE(type) = 1;
102798 +}
102799 +
102800 +static void initialize(tree var)
102801 +{
102802 + basic_block bb;
102803 + gimple_stmt_iterator gsi;
102804 + tree initializer;
102805 + gimple init_stmt;
102806 +
102807 + // this is the original entry bb before the forced split
102808 + // TODO: check further BBs in case more splits occured before us
102809 + bb = ENTRY_BLOCK_PTR->next_bb->next_bb;
102810 +
102811 + // first check if the variable is already initialized, warn otherwise
102812 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
102813 + gimple stmt = gsi_stmt(gsi);
102814 + tree rhs1;
102815 +
102816 + // we're looking for an assignment of a single rhs...
102817 + if (!gimple_assign_single_p(stmt))
102818 + continue;
102819 + rhs1 = gimple_assign_rhs1(stmt);
102820 +#if BUILDING_GCC_VERSION >= 4007
102821 + // ... of a non-clobbering expression...
102822 + if (TREE_CLOBBER_P(rhs1))
102823 + continue;
102824 +#endif
102825 + // ... to our variable...
102826 + if (gimple_get_lhs(stmt) != var)
102827 + continue;
102828 + // if it's an initializer then we're good
102829 + if (TREE_CODE(rhs1) == CONSTRUCTOR)
102830 + return;
102831 + }
102832 +
102833 + // these aren't the 0days you're looking for
102834 +// inform(DECL_SOURCE_LOCATION(var), "userspace variable will be forcibly initialized");
102835 +
102836 + // build the initializer expression
102837 + initializer = build_constructor(TREE_TYPE(var), NULL);
102838 +
102839 + // build the initializer stmt
102840 + init_stmt = gimple_build_assign(var, initializer);
102841 + gsi = gsi_start_bb(ENTRY_BLOCK_PTR->next_bb);
102842 + gsi_insert_before(&gsi, init_stmt, GSI_NEW_STMT);
102843 + update_stmt(init_stmt);
102844 +}
102845 +
102846 +static unsigned int handle_function(void)
102847 +{
102848 + basic_block bb;
102849 + unsigned int ret = 0;
102850 + tree var;
102851 +
102852 +#if BUILDING_GCC_VERSION == 4005
102853 + tree vars;
102854 +#else
102855 + unsigned int i;
102856 +#endif
102857 +
102858 + // split the first bb where we can put the forced initializers
102859 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
102860 + if (dom_info_available_p(CDI_DOMINATORS))
102861 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
102862 +
102863 + // enumarate all local variables and forcibly initialize our targets
102864 +#if BUILDING_GCC_VERSION == 4005
102865 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
102866 + var = TREE_VALUE(vars);
102867 +#else
102868 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
102869 +#endif
102870 + tree type = TREE_TYPE(var);
102871 +
102872 + gcc_assert(DECL_P(var));
102873 + if (!auto_var_in_fn_p(var, current_function_decl))
102874 + continue;
102875 +
102876 + // only care about structure types
102877 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
102878 + continue;
102879 +
102880 + // if the type is of interest, examine the variable
102881 + if (TYPE_USERSPACE(type))
102882 + initialize(var);
102883 + }
102884 +
102885 + return ret;
102886 +}
102887 +
102888 +static struct gimple_opt_pass structleak_pass = {
102889 + .pass = {
102890 + .type = GIMPLE_PASS,
102891 + .name = "structleak",
102892 +#if BUILDING_GCC_VERSION >= 4008
102893 + .optinfo_flags = OPTGROUP_NONE,
102894 +#endif
102895 + .gate = NULL,
102896 + .execute = handle_function,
102897 + .sub = NULL,
102898 + .next = NULL,
102899 + .static_pass_number = 0,
102900 + .tv_id = TV_NONE,
102901 + .properties_required = PROP_cfg,
102902 + .properties_provided = 0,
102903 + .properties_destroyed = 0,
102904 + .todo_flags_start = 0,
102905 + .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
102906 + }
102907 +};
102908 +
102909 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
102910 +{
102911 + int i;
102912 + const char * const plugin_name = plugin_info->base_name;
102913 + const int argc = plugin_info->argc;
102914 + const struct plugin_argument * const argv = plugin_info->argv;
102915 + bool enable = true;
102916 +
102917 + struct register_pass_info structleak_pass_info = {
102918 + .pass = &structleak_pass.pass,
102919 + .reference_pass_name = "ssa",
102920 + .ref_pass_instance_number = 1,
102921 + .pos_op = PASS_POS_INSERT_AFTER
102922 + };
102923 +
102924 + if (!plugin_default_version_check(version, &gcc_version)) {
102925 + error(G_("incompatible gcc/plugin versions"));
102926 + return 1;
102927 + }
102928 +
102929 + if (strcmp(lang_hooks.name, "GNU C")) {
102930 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
102931 + enable = false;
102932 + }
102933 +
102934 + for (i = 0; i < argc; ++i) {
102935 + if (!strcmp(argv[i].key, "disable")) {
102936 + enable = false;
102937 + continue;
102938 + }
102939 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
102940 + }
102941 +
102942 + register_callback(plugin_name, PLUGIN_INFO, NULL, &structleak_plugin_info);
102943 + if (enable) {
102944 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &structleak_pass_info);
102945 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
102946 + }
102947 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
102948 +
102949 + return 0;
102950 +}
102951 diff --git a/tools/perf/util/include/asm/alternative-asm.h b/tools/perf/util/include/asm/alternative-asm.h
102952 index 6789d78..4afd019e 100644
102953 --- a/tools/perf/util/include/asm/alternative-asm.h
102954 +++ b/tools/perf/util/include/asm/alternative-asm.h
102955 @@ -5,4 +5,7 @@
102956
102957 #define altinstruction_entry #
102958
102959 + .macro pax_force_retaddr rip=0, reload=0
102960 + .endm
102961 +
102962 #endif
102963 diff --git a/tools/perf/util/include/linux/compiler.h b/tools/perf/util/include/linux/compiler.h
102964 index 96b919d..c49bb74 100644
102965 --- a/tools/perf/util/include/linux/compiler.h
102966 +++ b/tools/perf/util/include/linux/compiler.h
102967 @@ -18,4 +18,12 @@
102968 #define __force
102969 #endif
102970
102971 +#ifndef __size_overflow
102972 +# define __size_overflow(...)
102973 +#endif
102974 +
102975 +#ifndef __intentional_overflow
102976 +# define __intentional_overflow(...)
102977 +#endif
102978 +
102979 #endif
102980 diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
102981 index f18013f..90421df 100644
102982 --- a/virt/kvm/kvm_main.c
102983 +++ b/virt/kvm/kvm_main.c
102984 @@ -75,12 +75,17 @@ LIST_HEAD(vm_list);
102985
102986 static cpumask_var_t cpus_hardware_enabled;
102987 static int kvm_usage_count = 0;
102988 -static atomic_t hardware_enable_failed;
102989 +static atomic_unchecked_t hardware_enable_failed;
102990
102991 struct kmem_cache *kvm_vcpu_cache;
102992 EXPORT_SYMBOL_GPL(kvm_vcpu_cache);
102993
102994 -static __read_mostly struct preempt_ops kvm_preempt_ops;
102995 +static void kvm_sched_in(struct preempt_notifier *pn, int cpu);
102996 +static void kvm_sched_out(struct preempt_notifier *pn, struct task_struct *next);
102997 +static struct preempt_ops kvm_preempt_ops = {
102998 + .sched_in = kvm_sched_in,
102999 + .sched_out = kvm_sched_out,
103000 +};
103001
103002 struct dentry *kvm_debugfs_dir;
103003
103004 @@ -769,7 +774,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
103005 /* We can read the guest memory with __xxx_user() later on. */
103006 if (user_alloc &&
103007 ((mem->userspace_addr & (PAGE_SIZE - 1)) ||
103008 - !access_ok(VERIFY_WRITE,
103009 + !__access_ok(VERIFY_WRITE,
103010 (void __user *)(unsigned long)mem->userspace_addr,
103011 mem->memory_size)))
103012 goto out;
103013 @@ -1881,7 +1886,7 @@ static int kvm_vcpu_release(struct inode *inode, struct file *filp)
103014 return 0;
103015 }
103016
103017 -static struct file_operations kvm_vcpu_fops = {
103018 +static file_operations_no_const kvm_vcpu_fops __read_only = {
103019 .release = kvm_vcpu_release,
103020 .unlocked_ioctl = kvm_vcpu_ioctl,
103021 #ifdef CONFIG_COMPAT
103022 @@ -2402,7 +2407,7 @@ static int kvm_vm_mmap(struct file *file, struct vm_area_struct *vma)
103023 return 0;
103024 }
103025
103026 -static struct file_operations kvm_vm_fops = {
103027 +static file_operations_no_const kvm_vm_fops __read_only = {
103028 .release = kvm_vm_release,
103029 .unlocked_ioctl = kvm_vm_ioctl,
103030 #ifdef CONFIG_COMPAT
103031 @@ -2500,7 +2505,7 @@ out:
103032 return r;
103033 }
103034
103035 -static struct file_operations kvm_chardev_ops = {
103036 +static file_operations_no_const kvm_chardev_ops __read_only = {
103037 .unlocked_ioctl = kvm_dev_ioctl,
103038 .compat_ioctl = kvm_dev_ioctl,
103039 .llseek = noop_llseek,
103040 @@ -2526,7 +2531,7 @@ static void hardware_enable_nolock(void *junk)
103041
103042 if (r) {
103043 cpumask_clear_cpu(cpu, cpus_hardware_enabled);
103044 - atomic_inc(&hardware_enable_failed);
103045 + atomic_inc_unchecked(&hardware_enable_failed);
103046 printk(KERN_INFO "kvm: enabling virtualization on "
103047 "CPU%d failed\n", cpu);
103048 }
103049 @@ -2580,10 +2585,10 @@ static int hardware_enable_all(void)
103050
103051 kvm_usage_count++;
103052 if (kvm_usage_count == 1) {
103053 - atomic_set(&hardware_enable_failed, 0);
103054 + atomic_set_unchecked(&hardware_enable_failed, 0);
103055 on_each_cpu(hardware_enable_nolock, NULL, 1);
103056
103057 - if (atomic_read(&hardware_enable_failed)) {
103058 + if (atomic_read_unchecked(&hardware_enable_failed)) {
103059 hardware_disable_all_nolock();
103060 r = -EBUSY;
103061 }
103062 @@ -2941,7 +2946,7 @@ static void kvm_sched_out(struct preempt_notifier *pn,
103063 kvm_arch_vcpu_put(vcpu);
103064 }
103065
103066 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
103067 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
103068 struct module *module)
103069 {
103070 int r;
103071 @@ -2977,7 +2982,7 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
103072 if (!vcpu_align)
103073 vcpu_align = __alignof__(struct kvm_vcpu);
103074 kvm_vcpu_cache = kmem_cache_create("kvm_vcpu", vcpu_size, vcpu_align,
103075 - 0, NULL);
103076 + SLAB_USERCOPY, NULL);
103077 if (!kvm_vcpu_cache) {
103078 r = -ENOMEM;
103079 goto out_free_3;
103080 @@ -2987,9 +2992,11 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
103081 if (r)
103082 goto out_free;
103083
103084 + pax_open_kernel();
103085 kvm_chardev_ops.owner = module;
103086 kvm_vm_fops.owner = module;
103087 kvm_vcpu_fops.owner = module;
103088 + pax_close_kernel();
103089
103090 r = misc_register(&kvm_dev);
103091 if (r) {
103092 @@ -2999,9 +3006,6 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
103093
103094 register_syscore_ops(&kvm_syscore_ops);
103095
103096 - kvm_preempt_ops.sched_in = kvm_sched_in;
103097 - kvm_preempt_ops.sched_out = kvm_sched_out;
103098 -
103099 r = kvm_init_debug();
103100 if (r) {
103101 printk(KERN_ERR "kvm: create debugfs files failed\n");